Author: pferraro
Date: 2008-10-23 01:16:30 -0400 (Thu, 23 Oct 2008)
New Revision: 1989
Added:
trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/SelfSourcedLoadMetric.java
trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/SourcedLoadMetric.java
Removed:
trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/AbstractLoadMetricSource.java
trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/SingleLoadMetricSource.java
Modified:
trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/impl/DynamicLoadBalanceFactorProvider.java
trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/LoadMetric.java
trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/LoadMetricSource.java
trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/AbstractLoadMetric.java
trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/ActiveSessionsLoadMetric.java
trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/AverageSystemLoadMetric.java
trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/BusyConnectorsLoadMetric.java
trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/ConnectionPoolLoadMetricSource.java
trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/ConnectionPoolUsageLoadMetric.java
trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/HeapMemoryUsageLoadMetric.java
trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/MBeanAttributeLoadMetric.java
trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/MBeanAttributeRatioLoadMetric.java
trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/MBeanLoadMetricSource.java
trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/MBeanQueryLoadMetricSource.java
trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/OperatingSystemLoadMetricSource.java
trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/ReceiveTrafficLoadMetric.java
trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/RequestCountLoadMetric.java
trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/RequestProcessorLoadMetricSource.java
trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/SendTrafficLoadMetric.java
trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/SessionLoadMetricSource.java
trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/SystemMemoryUsageLoadMetric.java
trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/ThreadCountLoadMetric.java
trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/ThreadPoolLoadMetricSource.java
trunk/mod_cluster/src/main/resources/mod-cluster-jboss-beans.xml
trunk/mod_cluster/src/test/java/org/jboss/modcluster/load/DynamicLoadBalanceFactorProviderTestCase.java
trunk/mod_cluster/src/test/java/org/jboss/modcluster/load/metric/ActiveSessionsLoadMetricTestCase.java
trunk/mod_cluster/src/test/java/org/jboss/modcluster/load/metric/AverageSystemLoadMetricTestCase.java
trunk/mod_cluster/src/test/java/org/jboss/modcluster/load/metric/BusyConnectorsLoadMetricTestCase.java
trunk/mod_cluster/src/test/java/org/jboss/modcluster/load/metric/ConnectionPoolLoadMetricSourceTestCase.java
trunk/mod_cluster/src/test/java/org/jboss/modcluster/load/metric/ConnectionPoolUsageLoadMetricTestCase.java
trunk/mod_cluster/src/test/java/org/jboss/modcluster/load/metric/MBeanAttributeLoadMetricTestCase.java
trunk/mod_cluster/src/test/java/org/jboss/modcluster/load/metric/MBeanAttributeRatioLoadMetricTestCase.java
trunk/mod_cluster/src/test/java/org/jboss/modcluster/load/metric/MBeanLoadMetricSourceTestCase.java
trunk/mod_cluster/src/test/java/org/jboss/modcluster/load/metric/MBeanQueryLoadMetricSourceTestCase.java
trunk/mod_cluster/src/test/java/org/jboss/modcluster/load/metric/OperatingSystemLoadMetricSourceTestCase.java
trunk/mod_cluster/src/test/java/org/jboss/modcluster/load/metric/ReceiveTrafficLoadMetricTestCase.java
trunk/mod_cluster/src/test/java/org/jboss/modcluster/load/metric/RequestCountLoadMetricTestCase.java
trunk/mod_cluster/src/test/java/org/jboss/modcluster/load/metric/RequestProcessorLoadMetricSourceTestCase.java
trunk/mod_cluster/src/test/java/org/jboss/modcluster/load/metric/SendTrafficLoadMetricTestCase.java
trunk/mod_cluster/src/test/java/org/jboss/modcluster/load/metric/SessionLoadMetricSourceTestCase.java
trunk/mod_cluster/src/test/java/org/jboss/modcluster/load/metric/SystemMemoryUsageLoadMetricTestCase.java
trunk/mod_cluster/src/test/java/org/jboss/modcluster/load/metric/ThreadPoolLoadMetricSourceTestCase.java
Log:
Revert metric -> source relationship.
LoadBalanceFactorProvider now defines explicit load metrics - instead of sources.
Added convenience default constructors to load metrics that will create necessary source
instances, instead of injecting.
Modified:
trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/impl/DynamicLoadBalanceFactorProvider.java
===================================================================
---
trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/impl/DynamicLoadBalanceFactorProvider.java 2008-10-22
21:44:32 UTC (rev 1988)
+++
trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/impl/DynamicLoadBalanceFactorProvider.java 2008-10-23
05:16:30 UTC (rev 1989)
@@ -24,8 +24,10 @@
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
+import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
+import java.util.Set;
import org.apache.catalina.util.StringManager;
import org.jboss.logging.Logger;
@@ -45,15 +47,27 @@
private final Logger log = Logger.getLogger(this.getClass());
private final StringManager sm = StringManager.getManager(Constants.Package);
- private final Collection<LoadMetricSource<LoadContext>> sources;
+ private final Map<LoadMetricSource<LoadContext>,
Collection<LoadMetric<LoadContext>>> metrics = new
LinkedHashMap<LoadMetricSource<LoadContext>,
Collection<LoadMetric<LoadContext>>>();
private final Map<LoadMetric<LoadContext>, List<Double>> loadHistory
= new HashMap<LoadMetric<LoadContext>, List<Double>>();
private volatile int decayFactor = 2;
private volatile int history = 10;
- public
DynamicLoadBalanceFactorProvider(Collection<LoadMetricSource<LoadContext>>
sources)
+ public DynamicLoadBalanceFactorProvider(Set<LoadMetric<LoadContext>>
metrics)
{
- this.sources = sources;
+ for (LoadMetric<LoadContext> metric: metrics)
+ {
+ LoadMetricSource<LoadContext> source = metric.getSource();
+ Collection<LoadMetric<LoadContext>> sourceMetrics =
this.metrics.get(source);
+
+ if (sourceMetrics == null)
+ {
+ sourceMetrics = new ArrayList<LoadMetric<LoadContext>>();
+ this.metrics.put(source, sourceMetrics);
+ }
+
+ sourceMetrics.add(metric);
+ }
}
/**
@@ -65,43 +79,44 @@
int totalWeight = 0;
double totalWeightedLoad = 0;
- for (LoadMetricSource<LoadContext> source: this.sources)
+ for (Map.Entry<LoadMetricSource<LoadContext>,
Collection<LoadMetric<LoadContext>>> entry: this.metrics.entrySet())
{
- Collection<LoadMetric<LoadContext>> metrics = source.getMetrics();
+ LoadMetricSource<LoadContext> source = entry.getKey();
+ Collection<LoadMetric<LoadContext>> metrics = entry.getValue();
- List<LoadMetric<LoadContext>> metricList = new
ArrayList<LoadMetric<LoadContext>>(metrics.size());
+ boolean skip = true;
- // Prune 0 weights since they will not contribute anything
+ // Skip this source if all weights are 0
for (LoadMetric<LoadContext> metric: metrics)
{
- if (metric.getWeight() != 0)
- {
- metricList.add(metric);
- }
+ skip = skip && (metric.getWeight() <= 0);
}
- if (!metricList.isEmpty())
+ if (!skip)
{
LoadContext context = source.createContext();
try
{
- for (LoadMetric<LoadContext> metric: metricList)
+ for (LoadMetric<LoadContext> metric: metrics)
{
- try
+ int weight = metric.getWeight();
+
+ if (weight > 0)
{
- // Normalize load with respect to capacity
- List<Double> queue = this.recordLoad(metric,
metric.getLoad(context) / metric.getCapacity());
-
- int weight = metric.getWeight();
-
- totalWeight += weight;
- totalWeightedLoad += this.average(queue) * weight;
+ try
+ {
+ // Normalize load with respect to capacity
+ List<Double> queue = this.recordLoad(metric,
metric.getLoad(context) / metric.getCapacity());
+
+ totalWeight += weight;
+ totalWeightedLoad += this.average(queue) * weight;
+ }
+ catch (Exception e)
+ {
+ this.log.error(e.getMessage(), e);
+ }
}
- catch (Exception e)
- {
- this.log.error(e.getMessage(), e);
- }
}
}
finally
Modified:
trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/LoadMetric.java
===================================================================
---
trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/LoadMetric.java 2008-10-22
21:44:32 UTC (rev 1988)
+++
trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/LoadMetric.java 2008-10-23
05:16:30 UTC (rev 1989)
@@ -47,4 +47,6 @@
* @throws Exception if there was an error fetching this metric.
*/
double getLoad(C context) throws Exception;
+
+ LoadMetricSource<C> getSource();
}
Modified:
trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/LoadMetricSource.java
===================================================================
---
trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/LoadMetricSource.java 2008-10-22
21:44:32 UTC (rev 1988)
+++
trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/LoadMetricSource.java 2008-10-23
05:16:30 UTC (rev 1989)
@@ -21,7 +21,6 @@
*/
package org.jboss.modcluster.load.metric;
-import java.util.Collection;
/**
* A source for obtaining load metrics.
@@ -30,12 +29,6 @@
public interface LoadMetricSource<C extends LoadContext>
{
/**
- * Returns the collection of metrics registered with this source.
- * @return the metrics from this source
- */
- Collection<LoadMetric<C>> getMetrics();
-
- /**
* Prepare any resources required to collect load metrics
*/
C createContext();
Modified:
trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/AbstractLoadMetric.java
===================================================================
---
trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/AbstractLoadMetric.java 2008-10-22
21:44:32 UTC (rev 1988)
+++
trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/AbstractLoadMetric.java 2008-10-23
05:16:30 UTC (rev 1989)
@@ -34,7 +34,7 @@
{
private volatile int weight = 1;
private volatile double capacity = 1;
-
+
/**
* @{inheritDoc}
* @see org.jboss.modcluster.load.metric.LoadMetric#getWeight()
Deleted:
trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/AbstractLoadMetricSource.java
===================================================================
---
trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/AbstractLoadMetricSource.java 2008-10-22
21:44:32 UTC (rev 1988)
+++
trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/AbstractLoadMetricSource.java 2008-10-23
05:16:30 UTC (rev 1989)
@@ -1,52 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-package org.jboss.modcluster.load.metric.impl;
-
-import java.util.Collection;
-
-import org.jboss.modcluster.load.metric.LoadContext;
-import org.jboss.modcluster.load.metric.LoadMetric;
-import org.jboss.modcluster.load.metric.LoadMetricSource;
-
-/**
- * Abstract {@link LoadMetricSource} that allows a {@link LoadMetric} to register with
it.
- *
- * @author Paul Ferraro
- */
-public abstract class AbstractLoadMetricSource<C extends LoadContext> implements
LoadMetricSource<C>
-{
- private final Collection<LoadMetric<C>> metrics;
-
- protected AbstractLoadMetricSource(Collection<LoadMetric<C>> metrics)
- {
- this.metrics = metrics;
- }
-
- /**
- * @{inheritDoc}
- * @see org.jboss.modcluster.load.metric.LoadMetricSource#getMetrics()
- */
- public Collection<LoadMetric<C>> getMetrics()
- {
- return this.metrics;
- }
-}
Modified:
trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/ActiveSessionsLoadMetric.java
===================================================================
---
trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/ActiveSessionsLoadMetric.java 2008-10-22
21:44:32 UTC (rev 1988)
+++
trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/ActiveSessionsLoadMetric.java 2008-10-23
05:16:30 UTC (rev 1989)
@@ -21,6 +21,8 @@
*/
package org.jboss.modcluster.load.metric.impl;
+import javax.management.MalformedObjectNameException;
+
import org.jboss.modcluster.load.metric.LoadMetric;
/**
@@ -32,13 +34,18 @@
{
public static final String DEFAULT_ATTRIBUTE = "activeSessions";
- public ActiveSessionsLoadMetric()
+ public ActiveSessionsLoadMetric() throws MalformedObjectNameException
{
- this(DEFAULT_ATTRIBUTE);
+ this(new SessionLoadMetricSource());
}
- public ActiveSessionsLoadMetric(String attribute)
+ public ActiveSessionsLoadMetric(SessionLoadMetricSource source)
{
- super(attribute);
+ super(source, DEFAULT_ATTRIBUTE);
}
+
+ public ActiveSessionsLoadMetric(SessionLoadMetricSource source, String attribute)
+ {
+ super(source, attribute);
+ }
}
Modified:
trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/AverageSystemLoadMetric.java
===================================================================
---
trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/AverageSystemLoadMetric.java 2008-10-22
21:44:32 UTC (rev 1988)
+++
trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/AverageSystemLoadMetric.java 2008-10-23
05:16:30 UTC (rev 1989)
@@ -25,6 +25,7 @@
import javax.management.AttributeNotFoundException;
import javax.management.JMException;
+import javax.management.MalformedObjectNameException;
import org.jboss.logging.Logger;
@@ -34,12 +35,22 @@
*
* @author Paul Ferraro
*/
-public class AverageSystemLoadMetric extends AbstractLoadMetric<MBeanLoadContext>
+public class AverageSystemLoadMetric extends SourcedLoadMetric<MBeanLoadContext>
{
public static final String SYSTEM_LOAD_AVERAGE = "SystemLoadAverage";
private Logger logger = Logger.getLogger(this.getClass());
+ public AverageSystemLoadMetric() throws MalformedObjectNameException
+ {
+ super(new OperatingSystemLoadMetricSource());
+ }
+
+ public AverageSystemLoadMetric(OperatingSystemLoadMetricSource source)
+ {
+ super(source);
+ }
+
/**
* @{inheritDoc}
* @see org.jboss.modcluster.load.metric.LoadMetric#getLoad()
Modified:
trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/BusyConnectorsLoadMetric.java
===================================================================
---
trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/BusyConnectorsLoadMetric.java 2008-10-22
21:44:32 UTC (rev 1988)
+++
trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/BusyConnectorsLoadMetric.java 2008-10-23
05:16:30 UTC (rev 1989)
@@ -21,6 +21,8 @@
*/
package org.jboss.modcluster.load.metric.impl;
+import javax.management.MalformedObjectNameException;
+
import org.jboss.modcluster.load.metric.LoadMetric;
/**
@@ -33,13 +35,18 @@
public static final String DEFAULT_DIVIDEND_ATTRIBUTE =
"currentThreadsBusy";
public static final String DEFAULT_DIVISOR_ATTRIBUTE = "maxThreads";
- public BusyConnectorsLoadMetric()
+ public BusyConnectorsLoadMetric() throws MalformedObjectNameException
{
- super(DEFAULT_DIVIDEND_ATTRIBUTE, DEFAULT_DIVISOR_ATTRIBUTE);
+ this(new ThreadPoolLoadMetricSource());
}
- public BusyConnectorsLoadMetric(String currentThreadsBusy, String maxThreads)
+ public BusyConnectorsLoadMetric(ThreadPoolLoadMetricSource source)
{
- super(currentThreadsBusy, maxThreads);
+ super(source, DEFAULT_DIVIDEND_ATTRIBUTE, DEFAULT_DIVISOR_ATTRIBUTE);
}
+
+ public BusyConnectorsLoadMetric(ThreadPoolLoadMetricSource source, String
currentThreadsBusy, String maxThreads)
+ {
+ super(source, currentThreadsBusy, maxThreads);
+ }
}
Modified:
trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/ConnectionPoolLoadMetricSource.java
===================================================================
---
trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/ConnectionPoolLoadMetricSource.java 2008-10-22
21:44:32 UTC (rev 1988)
+++
trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/ConnectionPoolLoadMetricSource.java 2008-10-23
05:16:30 UTC (rev 1989)
@@ -21,12 +21,9 @@
*/
package org.jboss.modcluster.load.metric.impl;
-import java.util.Collection;
-
import javax.management.MBeanServer;
import javax.management.MalformedObjectNameException;
-import org.jboss.modcluster.load.metric.LoadMetric;
import org.jboss.modcluster.load.metric.LoadMetricSource;
/**
@@ -44,9 +41,9 @@
* @param server
* @throws MalformedObjectNameException
*/
- public
ConnectionPoolLoadMetricSource(Collection<LoadMetric<MBeanQueryLoadContext>>
metrics, MBeanServer server) throws MalformedObjectNameException
+ public ConnectionPoolLoadMetricSource(MBeanServer server) throws
MalformedObjectNameException
{
- super(metrics, DEFAULT_PATTERN, server);
+ super(DEFAULT_PATTERN, server);
}
/**
@@ -57,9 +54,9 @@
* @param server
* @throws MalformedObjectNameException
*/
- public
ConnectionPoolLoadMetricSource(Collection<LoadMetric<MBeanQueryLoadContext>>
metrics, String pattern, MBeanServer server) throws MalformedObjectNameException
+ public ConnectionPoolLoadMetricSource(String pattern, MBeanServer server) throws
MalformedObjectNameException
{
- super(metrics, pattern, server);
+ super(pattern, server);
}
/**
@@ -68,9 +65,9 @@
* @param registration
* @throws MalformedObjectNameException
*/
- public
ConnectionPoolLoadMetricSource(Collection<LoadMetric<MBeanQueryLoadContext>>
metrics) throws MalformedObjectNameException
+ public ConnectionPoolLoadMetricSource() throws MalformedObjectNameException
{
- super(metrics, DEFAULT_PATTERN);
+ super(DEFAULT_PATTERN);
}
/**
@@ -80,8 +77,8 @@
* @param pattern
* @throws MalformedObjectNameException
*/
- public
ConnectionPoolLoadMetricSource(Collection<LoadMetric<MBeanQueryLoadContext>>
metrics, String pattern) throws MalformedObjectNameException
+ public ConnectionPoolLoadMetricSource(String pattern) throws
MalformedObjectNameException
{
- super(metrics, pattern);
+ super(pattern);
}
}
Modified:
trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/ConnectionPoolUsageLoadMetric.java
===================================================================
---
trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/ConnectionPoolUsageLoadMetric.java 2008-10-22
21:44:32 UTC (rev 1988)
+++
trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/ConnectionPoolUsageLoadMetric.java 2008-10-23
05:16:30 UTC (rev 1989)
@@ -21,6 +21,8 @@
*/
package org.jboss.modcluster.load.metric.impl;
+import javax.management.MalformedObjectNameException;
+
import org.jboss.modcluster.load.metric.LoadMetric;
/**
@@ -33,13 +35,18 @@
public static final String DEFAULT_DIVIDEND_ATTRIBUTE =
"InUseConnectionCount";
public static final String DEFAULT_DIVISOR_ATTRIBUTE = "MaxSize";
- public ConnectionPoolUsageLoadMetric()
+ public ConnectionPoolUsageLoadMetric() throws MalformedObjectNameException
{
- super(DEFAULT_DIVIDEND_ATTRIBUTE, DEFAULT_DIVISOR_ATTRIBUTE);
+ this(new ConnectionPoolLoadMetricSource());
}
- public ConnectionPoolUsageLoadMetric(String usedAttribute, String maxAttribute)
+ public ConnectionPoolUsageLoadMetric(ConnectionPoolLoadMetricSource source)
{
- super(usedAttribute, maxAttribute);
+ super(source, DEFAULT_DIVIDEND_ATTRIBUTE, DEFAULT_DIVISOR_ATTRIBUTE);
}
+
+ public ConnectionPoolUsageLoadMetric(ConnectionPoolLoadMetricSource source, String
usedAttribute, String maxAttribute)
+ {
+ super(source, usedAttribute, maxAttribute);
+ }
}
Modified:
trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/HeapMemoryUsageLoadMetric.java
===================================================================
---
trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/HeapMemoryUsageLoadMetric.java 2008-10-22
21:44:32 UTC (rev 1988)
+++
trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/HeapMemoryUsageLoadMetric.java 2008-10-23
05:16:30 UTC (rev 1989)
@@ -33,7 +33,7 @@
*
* @author Paul Ferraro
*/
-public class HeapMemoryUsageLoadMetric extends SingleLoadMetricSource
+public class HeapMemoryUsageLoadMetric extends SelfSourcedLoadMetric
{
private final MemoryMXBean bean;
Modified:
trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/MBeanAttributeLoadMetric.java
===================================================================
---
trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/MBeanAttributeLoadMetric.java 2008-10-22
21:44:32 UTC (rev 1988)
+++
trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/MBeanAttributeLoadMetric.java 2008-10-23
05:16:30 UTC (rev 1989)
@@ -29,12 +29,14 @@
* Generic {@link LoadMetric} whose load is the aggregated value of an mbean attribute.
* @author Paul Ferraro
*/
-public class MBeanAttributeLoadMetric extends
AbstractLoadMetric<MBeanQueryLoadContext>
+public class MBeanAttributeLoadMetric extends
SourcedLoadMetric<MBeanQueryLoadContext>
{
private final String attribute;
- public MBeanAttributeLoadMetric(String attribute)
+ public MBeanAttributeLoadMetric(MBeanQueryLoadMetricSource source, String attribute)
{
+ super(source);
+
this.attribute = attribute;
}
Modified:
trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/MBeanAttributeRatioLoadMetric.java
===================================================================
---
trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/MBeanAttributeRatioLoadMetric.java 2008-10-22
21:44:32 UTC (rev 1988)
+++
trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/MBeanAttributeRatioLoadMetric.java 2008-10-23
05:16:30 UTC (rev 1989)
@@ -31,13 +31,15 @@
* Generic {@link LoadMetric} whose load is the ratio of 2 aggregated mbean attributes.
* @author Paul Ferraro
*/
-public class MBeanAttributeRatioLoadMetric extends
AbstractLoadMetric<MBeanQueryLoadContext>
+public class MBeanAttributeRatioLoadMetric extends
SourcedLoadMetric<MBeanQueryLoadContext>
{
private final String dividendAttribute;
private final String divisorAttribute;
- public MBeanAttributeRatioLoadMetric(String currentAttribute, String maxAttribute)
+ public MBeanAttributeRatioLoadMetric(MBeanQueryLoadMetricSource source, String
currentAttribute, String maxAttribute)
{
+ super(source);
+
this.dividendAttribute = currentAttribute;
this.divisorAttribute = maxAttribute;
}
Modified:
trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/MBeanLoadMetricSource.java
===================================================================
---
trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/MBeanLoadMetricSource.java 2008-10-22
21:44:32 UTC (rev 1988)
+++
trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/MBeanLoadMetricSource.java 2008-10-23
05:16:30 UTC (rev 1989)
@@ -22,31 +22,28 @@
package org.jboss.modcluster.load.metric.impl;
import java.lang.management.ManagementFactory;
-import java.util.Collection;
import javax.management.MBeanServer;
import javax.management.MalformedObjectNameException;
import javax.management.ObjectName;
-import org.jboss.modcluster.load.metric.LoadMetric;
+import org.jboss.modcluster.load.metric.LoadMetricSource;
/**
* @author Paul Ferraro
*
*/
-public class MBeanLoadMetricSource extends
AbstractLoadMetricSource<MBeanLoadContext>
+public class MBeanLoadMetricSource implements LoadMetricSource<MBeanLoadContext>
{
private final MBeanLoadContext context;
- public MBeanLoadMetricSource(Collection<LoadMetric<MBeanLoadContext>>
metrics, String name) throws MalformedObjectNameException
+ public MBeanLoadMetricSource(String name) throws MalformedObjectNameException
{
- this(metrics, name, ManagementFactory.getPlatformMBeanServer());
+ this(name, ManagementFactory.getPlatformMBeanServer());
}
- public MBeanLoadMetricSource(Collection<LoadMetric<MBeanLoadContext>>
metrics, String name, MBeanServer server) throws MalformedObjectNameException
+ public MBeanLoadMetricSource(String name, MBeanServer server) throws
MalformedObjectNameException
{
- super(metrics);
-
this.context = new MBeanLoadContext(server, ObjectName.getInstance(name));
}
Modified:
trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/MBeanQueryLoadMetricSource.java
===================================================================
---
trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/MBeanQueryLoadMetricSource.java 2008-10-22
21:44:32 UTC (rev 1988)
+++
trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/MBeanQueryLoadMetricSource.java 2008-10-23
05:16:30 UTC (rev 1989)
@@ -22,7 +22,6 @@
package org.jboss.modcluster.load.metric.impl;
import java.lang.management.ManagementFactory;
-import java.util.Collection;
import javax.management.MBeanServer;
import javax.management.MalformedObjectNameException;
@@ -36,20 +35,18 @@
*
* @author Paul Ferraro
*/
-public class MBeanQueryLoadMetricSource extends
AbstractLoadMetricSource<MBeanQueryLoadContext>
+public class MBeanQueryLoadMetricSource implements
LoadMetricSource<MBeanQueryLoadContext>
{
private final MBeanServer server;
private final ObjectName name;
- public
MBeanQueryLoadMetricSource(Collection<LoadMetric<MBeanQueryLoadContext>>
metrics, String pattern) throws MalformedObjectNameException
+ public MBeanQueryLoadMetricSource(String pattern) throws MalformedObjectNameException
{
- this(metrics, pattern, ManagementFactory.getPlatformMBeanServer());
+ this(pattern, ManagementFactory.getPlatformMBeanServer());
}
- public
MBeanQueryLoadMetricSource(Collection<LoadMetric<MBeanQueryLoadContext>>
metrics, String pattern, MBeanServer server) throws MalformedObjectNameException
+ public MBeanQueryLoadMetricSource(String pattern, MBeanServer server) throws
MalformedObjectNameException
{
- super(metrics);
-
this.server = server;
this.name = ObjectName.getInstance(pattern);
}
Modified:
trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/OperatingSystemLoadMetricSource.java
===================================================================
---
trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/OperatingSystemLoadMetricSource.java 2008-10-22
21:44:32 UTC (rev 1988)
+++
trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/OperatingSystemLoadMetricSource.java 2008-10-23
05:16:30 UTC (rev 1989)
@@ -22,12 +22,10 @@
package org.jboss.modcluster.load.metric.impl;
import java.lang.management.ManagementFactory;
-import java.util.Collection;
import javax.management.MBeanServer;
import javax.management.MalformedObjectNameException;
-import org.jboss.modcluster.load.metric.LoadMetric;
import org.jboss.modcluster.load.metric.LoadMetricSource;
/**
@@ -43,9 +41,9 @@
* @param registration
* @throws MalformedObjectNameException
*/
- public
OperatingSystemLoadMetricSource(Collection<LoadMetric<MBeanLoadContext>>
metrics) throws MalformedObjectNameException
+ public OperatingSystemLoadMetricSource() throws MalformedObjectNameException
{
- super(metrics, ManagementFactory.OPERATING_SYSTEM_MXBEAN_NAME);
+ super(ManagementFactory.OPERATING_SYSTEM_MXBEAN_NAME);
}
/**
@@ -54,8 +52,8 @@
* @param registration
* @throws MalformedObjectNameException
*/
- public
OperatingSystemLoadMetricSource(Collection<LoadMetric<MBeanLoadContext>>
metrics, MBeanServer server) throws MalformedObjectNameException
+ public OperatingSystemLoadMetricSource(MBeanServer server) throws
MalformedObjectNameException
{
- super(metrics, ManagementFactory.OPERATING_SYSTEM_MXBEAN_NAME, server);
+ super(ManagementFactory.OPERATING_SYSTEM_MXBEAN_NAME, server);
}
}
Modified:
trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/ReceiveTrafficLoadMetric.java
===================================================================
---
trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/ReceiveTrafficLoadMetric.java 2008-10-22
21:44:32 UTC (rev 1988)
+++
trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/ReceiveTrafficLoadMetric.java 2008-10-23
05:16:30 UTC (rev 1989)
@@ -22,6 +22,7 @@
package org.jboss.modcluster.load.metric.impl;
import javax.management.JMException;
+import javax.management.MalformedObjectNameException;
import org.jboss.modcluster.load.metric.LoadMetric;
@@ -35,16 +36,21 @@
private final DeterministicLoadState state = new DeterministicLoadState();
- public ReceiveTrafficLoadMetric()
+ public ReceiveTrafficLoadMetric() throws MalformedObjectNameException
{
- super(DEFAULT_ATTRIBUTE);
+ this(new RequestProcessorLoadMetricSource());
}
- public ReceiveTrafficLoadMetric(String attribute)
+ public ReceiveTrafficLoadMetric(RequestProcessorLoadMetricSource source)
{
- super(attribute);
+ super(source, DEFAULT_ATTRIBUTE);
}
+ public ReceiveTrafficLoadMetric(RequestProcessorLoadMetricSource source, String
attribute)
+ {
+ super(source, attribute);
+ }
+
/**
* @{inheritDoc}
* @see
org.jboss.modcluster.load.metric.impl.MBeanAttributeLoadMetric#getLoad(org.jboss.modcluster.load.metric.impl.MBeanQueryLoadContext)
Modified:
trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/RequestCountLoadMetric.java
===================================================================
---
trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/RequestCountLoadMetric.java 2008-10-22
21:44:32 UTC (rev 1988)
+++
trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/RequestCountLoadMetric.java 2008-10-23
05:16:30 UTC (rev 1989)
@@ -22,6 +22,7 @@
package org.jboss.modcluster.load.metric.impl;
import javax.management.JMException;
+import javax.management.MalformedObjectNameException;
import org.jboss.modcluster.load.metric.LoadMetric;
@@ -36,16 +37,21 @@
private final DeterministicLoadState state = new DeterministicLoadState();
- public RequestCountLoadMetric()
+ public RequestCountLoadMetric() throws MalformedObjectNameException
{
- super(DEFAULT_ATTRIBUTE);
+ this(new RequestProcessorLoadMetricSource());
}
- public RequestCountLoadMetric(String attribute)
+ public RequestCountLoadMetric(RequestProcessorLoadMetricSource source)
{
- super(attribute);
+ super(source, DEFAULT_ATTRIBUTE);
}
+ public RequestCountLoadMetric(RequestProcessorLoadMetricSource source, String
attribute)
+ {
+ super(source, attribute);
+ }
+
/**
* @{inheritDoc}
* @see
org.jboss.modcluster.load.metric.impl.MBeanAttributeLoadMetric#getLoad(org.jboss.modcluster.load.metric.impl.MBeanQueryLoadContext)
Modified:
trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/RequestProcessorLoadMetricSource.java
===================================================================
---
trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/RequestProcessorLoadMetricSource.java 2008-10-22
21:44:32 UTC (rev 1988)
+++
trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/RequestProcessorLoadMetricSource.java 2008-10-23
05:16:30 UTC (rev 1989)
@@ -21,12 +21,9 @@
*/
package org.jboss.modcluster.load.metric.impl;
-import java.util.Collection;
-
import javax.management.MBeanServer;
import javax.management.MalformedObjectNameException;
-import org.jboss.modcluster.load.metric.LoadMetric;
import org.jboss.modcluster.load.metric.LoadMetricSource;
/**
@@ -45,9 +42,9 @@
* @param registration
* @throws MalformedObjectNameException
*/
- public
RequestProcessorLoadMetricSource(Collection<LoadMetric<MBeanQueryLoadContext>>
metrics) throws MalformedObjectNameException
+ public RequestProcessorLoadMetricSource() throws MalformedObjectNameException
{
- super(metrics, DEFAULT_PATTERN);
+ super(DEFAULT_PATTERN);
}
/**
@@ -57,9 +54,9 @@
* @param pattern
* @throws MalformedObjectNameException
*/
- public
RequestProcessorLoadMetricSource(Collection<LoadMetric<MBeanQueryLoadContext>>
metrics, String pattern) throws MalformedObjectNameException
+ public RequestProcessorLoadMetricSource(String pattern) throws
MalformedObjectNameException
{
- super(metrics, pattern);
+ super(pattern);
}
/**
@@ -69,9 +66,9 @@
* @param server
* @throws MalformedObjectNameException
*/
- public
RequestProcessorLoadMetricSource(Collection<LoadMetric<MBeanQueryLoadContext>>
metrics, MBeanServer server) throws MalformedObjectNameException
+ public RequestProcessorLoadMetricSource(MBeanServer server) throws
MalformedObjectNameException
{
- super(metrics, DEFAULT_PATTERN, server);
+ super(DEFAULT_PATTERN, server);
}
/**
@@ -82,8 +79,8 @@
* @param server
* @throws MalformedObjectNameException
*/
- public
RequestProcessorLoadMetricSource(Collection<LoadMetric<MBeanQueryLoadContext>>
metrics, String pattern, MBeanServer server) throws MalformedObjectNameException
+ public RequestProcessorLoadMetricSource(String pattern, MBeanServer server) throws
MalformedObjectNameException
{
- super(metrics, pattern, server);
+ super(pattern, server);
}
}
Copied:
trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/SelfSourcedLoadMetric.java
(from rev 1988,
trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/SingleLoadMetricSource.java)
===================================================================
---
trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/SelfSourcedLoadMetric.java
(rev 0)
+++
trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/SelfSourcedLoadMetric.java 2008-10-23
05:16:30 UTC (rev 1989)
@@ -0,0 +1,61 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.modcluster.load.metric.impl;
+
+import org.jboss.modcluster.load.metric.LoadContext;
+import org.jboss.modcluster.load.metric.LoadMetric;
+import org.jboss.modcluster.load.metric.LoadMetricSource;
+
+/**
+ * Abstract {@link LoadMetricSource} + {@link LoadMetric} implementation that returns a
single metric.
+ *
+ * @author Paul Ferraro
+ */
+public abstract class SelfSourcedLoadMetric extends AbstractLoadMetric<LoadContext>
implements LoadMetricSource<LoadContext>
+{
+ // We don't need to use a load context since there's only one metric in this
source
+ private final LoadContext context = new LoadContext()
+ {
+ public void close()
+ {
+ // nothing to close
+ }
+ };
+
+ /**
+ * @{inheritDoc}
+ * @see org.jboss.modcluster.load.metric.LoadMetricSource#createContext()
+ */
+ public LoadContext createContext()
+ {
+ return this.context;
+ }
+
+ /**
+ * @{inheritDoc}
+ * @see org.jboss.modcluster.load.metric.LoadMetric#getSource()
+ */
+ public LoadMetricSource<LoadContext> getSource()
+ {
+ return this;
+ }
+}
Property changes on:
trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/SelfSourcedLoadMetric.java
___________________________________________________________________
Name: svn:mergeinfo
+
Modified:
trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/SendTrafficLoadMetric.java
===================================================================
---
trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/SendTrafficLoadMetric.java 2008-10-22
21:44:32 UTC (rev 1988)
+++
trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/SendTrafficLoadMetric.java 2008-10-23
05:16:30 UTC (rev 1989)
@@ -22,6 +22,7 @@
package org.jboss.modcluster.load.metric.impl;
import javax.management.JMException;
+import javax.management.MalformedObjectNameException;
import org.jboss.modcluster.load.metric.LoadMetric;
@@ -36,16 +37,21 @@
private final DeterministicLoadState state = new DeterministicLoadState();
- public SendTrafficLoadMetric()
+ public SendTrafficLoadMetric() throws MalformedObjectNameException
{
- this(DEFAULT_ATTRIBUTE);
+ this(new RequestProcessorLoadMetricSource());
}
- public SendTrafficLoadMetric(String attribute)
+ public SendTrafficLoadMetric(RequestProcessorLoadMetricSource source)
{
- super(attribute);
+ this(source, DEFAULT_ATTRIBUTE);
}
+ public SendTrafficLoadMetric(RequestProcessorLoadMetricSource source, String
attribute)
+ {
+ super(source, attribute);
+ }
+
/**
* @{inheritDoc}
* @see org.jboss.modcluster.load.metric.impl.MBeanAttributeLoadMetric#getLoad()
Modified:
trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/SessionLoadMetricSource.java
===================================================================
---
trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/SessionLoadMetricSource.java 2008-10-22
21:44:32 UTC (rev 1988)
+++
trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/SessionLoadMetricSource.java 2008-10-23
05:16:30 UTC (rev 1989)
@@ -21,12 +21,9 @@
*/
package org.jboss.modcluster.load.metric.impl;
-import java.util.Collection;
-
import javax.management.MBeanServer;
import javax.management.MalformedObjectNameException;
-import org.jboss.modcluster.load.metric.LoadMetric;
import org.jboss.modcluster.load.metric.LoadMetricSource;
/**
@@ -45,9 +42,9 @@
* @param registration
* @throws MalformedObjectNameException
*/
- public
SessionLoadMetricSource(Collection<LoadMetric<MBeanQueryLoadContext>> metrics)
throws MalformedObjectNameException
+ public SessionLoadMetricSource() throws MalformedObjectNameException
{
- super(metrics, DEFAULT_PATTERN);
+ super(DEFAULT_PATTERN);
}
/**
@@ -57,9 +54,9 @@
* @param pattern
* @throws MalformedObjectNameException
*/
- public
SessionLoadMetricSource(Collection<LoadMetric<MBeanQueryLoadContext>> metrics,
String pattern) throws MalformedObjectNameException
+ public SessionLoadMetricSource(String pattern) throws MalformedObjectNameException
{
- super(metrics, pattern);
+ super(pattern);
}
/**
@@ -69,9 +66,9 @@
* @param server
* @throws MalformedObjectNameException
*/
- public
SessionLoadMetricSource(Collection<LoadMetric<MBeanQueryLoadContext>> metrics,
MBeanServer server) throws MalformedObjectNameException
+ public SessionLoadMetricSource(MBeanServer server) throws
MalformedObjectNameException
{
- super(metrics, DEFAULT_PATTERN, server);
+ super(DEFAULT_PATTERN, server);
}
/**
@@ -82,8 +79,8 @@
* @param server
* @throws MalformedObjectNameException
*/
- public
SessionLoadMetricSource(Collection<LoadMetric<MBeanQueryLoadContext>> metrics,
String pattern, MBeanServer server) throws MalformedObjectNameException
+ public SessionLoadMetricSource(String pattern, MBeanServer server) throws
MalformedObjectNameException
{
- super(metrics, pattern, server);
+ super(pattern, server);
}
}
Deleted:
trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/SingleLoadMetricSource.java
===================================================================
---
trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/SingleLoadMetricSource.java 2008-10-22
21:44:32 UTC (rev 1988)
+++
trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/SingleLoadMetricSource.java 2008-10-23
05:16:30 UTC (rev 1989)
@@ -1,65 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-package org.jboss.modcluster.load.metric.impl;
-
-import java.util.Collection;
-import java.util.Collections;
-
-import org.jboss.modcluster.load.metric.LoadContext;
-import org.jboss.modcluster.load.metric.LoadMetric;
-import org.jboss.modcluster.load.metric.LoadMetricSource;
-
-/**
- * Abstract {@link LoadMetricSource} + {@link LoadMetric} implementation that returns a
single metric.
- *
- * @author Paul Ferraro
- */
-public abstract class SingleLoadMetricSource extends
AbstractLoadMetric<LoadContext> implements LoadMetricSource<LoadContext>
-{
- // We don't need to use a load context since there's only one metric in this
source
- private final LoadContext context = new LoadContext()
- {
- public void close()
- {
- // nothing to close
- }
- };
-
- /**
- * @{inheritDoc}
- * @see org.jboss.modcluster.load.metric.LoadMetricSource#createContext()
- */
- public LoadContext createContext()
- {
- return this.context;
- }
-
- /**
- * @{inheritDoc}
- * @see org.jboss.modcluster.load.metric.LoadMetricSource#getMetrics()
- */
- public Collection<LoadMetric<LoadContext>> getMetrics()
- {
- // Silly that we need to down cast to prevent a compiler error, no?
- return Collections.singleton((LoadMetric<LoadContext>) this);
- }
-}
Added:
trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/SourcedLoadMetric.java
===================================================================
---
trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/SourcedLoadMetric.java
(rev 0)
+++
trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/SourcedLoadMetric.java 2008-10-23
05:16:30 UTC (rev 1989)
@@ -0,0 +1,48 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.modcluster.load.metric.impl;
+
+import org.jboss.modcluster.load.metric.LoadContext;
+import org.jboss.modcluster.load.metric.LoadMetricSource;
+
+/**
+ * @author Paul Ferraro
+ *
+ */
+public abstract class SourcedLoadMetric<C extends LoadContext> extends
AbstractLoadMetric<C>
+{
+ private final LoadMetricSource<C> source;
+
+ protected SourcedLoadMetric(LoadMetricSource<C> source)
+ {
+ this.source = source;
+ }
+
+ /**
+ * @{inheritDoc}
+ * @see org.jboss.modcluster.load.metric.LoadMetric#getSource()
+ */
+ public LoadMetricSource<C> getSource()
+ {
+ return this.source;
+ }
+}
Modified:
trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/SystemMemoryUsageLoadMetric.java
===================================================================
---
trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/SystemMemoryUsageLoadMetric.java 2008-10-22
21:44:32 UTC (rev 1988)
+++
trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/SystemMemoryUsageLoadMetric.java 2008-10-23
05:16:30 UTC (rev 1989)
@@ -23,6 +23,7 @@
import javax.management.AttributeNotFoundException;
import javax.management.JMException;
+import javax.management.MalformedObjectNameException;
import org.jboss.logging.Logger;
import org.jboss.modcluster.load.metric.LoadMetric;
@@ -33,13 +34,23 @@
*
* @author Paul Ferraro
*/
-public class SystemMemoryUsageLoadMetric extends
AbstractLoadMetric<MBeanLoadContext>
+public class SystemMemoryUsageLoadMetric extends
SourcedLoadMetric<MBeanLoadContext>
{
public static final String FREE_MEMORY = "FreePhysicalMemorySize";
public static final String TOTAL_MEMORY = "TotalPhysicalMemorySize";
private Logger logger = Logger.getLogger(this.getClass());
+ public SystemMemoryUsageLoadMetric() throws MalformedObjectNameException
+ {
+ super(new OperatingSystemLoadMetricSource());
+ }
+
+ public SystemMemoryUsageLoadMetric(OperatingSystemLoadMetricSource source)
+ {
+ super(source);
+ }
+
/**
* @{inheritDoc}
* @see org.jboss.modcluster.load.metric.LoadMetric#getLoad()
Modified:
trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/ThreadCountLoadMetric.java
===================================================================
---
trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/ThreadCountLoadMetric.java 2008-10-22
21:44:32 UTC (rev 1988)
+++
trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/ThreadCountLoadMetric.java 2008-10-23
05:16:30 UTC (rev 1989)
@@ -30,7 +30,7 @@
* @author Paul Ferraro
*
*/
-public class ThreadCountLoadMetric extends SingleLoadMetricSource
+public class ThreadCountLoadMetric extends SelfSourcedLoadMetric
{
private final ThreadMXBean bean;
Modified:
trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/ThreadPoolLoadMetricSource.java
===================================================================
---
trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/ThreadPoolLoadMetricSource.java 2008-10-22
21:44:32 UTC (rev 1988)
+++
trunk/mod_cluster/src/main/java/org/jboss/modcluster/load/metric/impl/ThreadPoolLoadMetricSource.java 2008-10-23
05:16:30 UTC (rev 1989)
@@ -21,12 +21,9 @@
*/
package org.jboss.modcluster.load.metric.impl;
-import java.util.Collection;
-
import javax.management.MBeanServer;
import javax.management.MalformedObjectNameException;
-import org.jboss.modcluster.load.metric.LoadMetric;
import org.jboss.modcluster.load.metric.LoadMetricSource;
/**
@@ -45,9 +42,9 @@
* @param registration
* @throws MalformedObjectNameException
*/
- public
ThreadPoolLoadMetricSource(Collection<LoadMetric<MBeanQueryLoadContext>>
metrics) throws MalformedObjectNameException
+ public ThreadPoolLoadMetricSource() throws MalformedObjectNameException
{
- super(metrics, DEFAULT_PATTERN);
+ super(DEFAULT_PATTERN);
}
/**
@@ -57,9 +54,9 @@
* @param patterh
* @throws MalformedObjectNameException
*/
- public
ThreadPoolLoadMetricSource(Collection<LoadMetric<MBeanQueryLoadContext>>
metrics, String pattern) throws MalformedObjectNameException
+ public ThreadPoolLoadMetricSource(String pattern) throws MalformedObjectNameException
{
- super(metrics, pattern);
+ super(pattern);
}
/**
@@ -69,9 +66,9 @@
* @param server
* @throws MalformedObjectNameException
*/
- public
ThreadPoolLoadMetricSource(Collection<LoadMetric<MBeanQueryLoadContext>>
metrics, MBeanServer server) throws MalformedObjectNameException
+ public ThreadPoolLoadMetricSource(MBeanServer server) throws
MalformedObjectNameException
{
- super(metrics, DEFAULT_PATTERN, server);
+ super(DEFAULT_PATTERN, server);
}
/**
@@ -82,8 +79,8 @@
* @param server
* @throws MalformedObjectNameException
*/
- public
ThreadPoolLoadMetricSource(Collection<LoadMetric<MBeanQueryLoadContext>>
metrics, String pattern, MBeanServer server) throws MalformedObjectNameException
+ public ThreadPoolLoadMetricSource(String pattern, MBeanServer server) throws
MalformedObjectNameException
{
- super(metrics, pattern, server);
+ super(pattern, server);
}
}
Modified: trunk/mod_cluster/src/main/resources/mod-cluster-jboss-beans.xml
===================================================================
--- trunk/mod_cluster/src/main/resources/mod-cluster-jboss-beans.xml 2008-10-22 21:44:32
UTC (rev 1988)
+++ trunk/mod_cluster/src/main/resources/mod-cluster-jboss-beans.xml 2008-10-23 05:16:30
UTC (rev 1989)
@@ -11,7 +11,7 @@
<!-- Comma separated list of address:port listing the httpd servers
where mod_cluster is running. -->
<!--property name="proxyList"></property-->
- <!-- URL prefix to send with commands to mod_cluster. Default is no prefix.
+ <!-- URL prefix to send with commands to mod_cluster. Default is no prefix.
-->
<!--property name="proxyURL"></property-->
<!-- mod_advertise is a small httpd module that advertises the
@@ -51,11 +51,11 @@
<annotation>@org.jboss.aop.microcontainer.aspects.jmx.JMX(name="jboss.web:service=LoadBalanceFactorProvider",exposedInterface=org.jboss.modcluster.load.impl.DynamicLoadBalanceFactorProviderMBean.class)</annotation>
<constructor>
<parameter>
- <!-- Define the load metric sources to use in your load balance factor
calculation here -->
- <collection
elementClass="org.jboss.modcluster.load.metric.LoadMetricSource">
- <value><inject
bean="ThreadPoolLoadMetricSource"/></value>
- <value><inject
bean="HeapMemoryUsageLoadMetric"/></value>
- </collection>
+ <!-- Define the load metrics to use in your load balance factor calculation
here -->
+ <set
elementClass="org.jboss.modcluster.load.metric.LoadMetricSource">
+ <inject bean="BusyConnectorsLoadMetric"/>
+ <inject bean="HeapMemoryUsageLoadMetric"/>
+ </set>
</parameter>
</constructor>
<!-- The number of historical load values used to determine load factor -->
@@ -65,28 +65,25 @@
</bean>
<!-- Default load metrics/sources -->
- <!-- Queries all JBossWeb ThreadPool mbeans -->
- <bean name="ThreadPoolLoadMetricSource"
class="org.jboss.modcluster.load.metric.impl.ThreadPoolLoadMetricSource"
mode="On Demand">
- <constructor>
- <parameter>
- <!-- Define the load metrics for this source -->
- <collection
elementClass="org.jboss.modcluster.load.metric.LoadMetric">
- <value><inject
bean="BusyConnectorsLoadMetric"/></value>
- </collection>
- </parameter>
- <parameter class="javax.management.MBeanServer"><inject
bean="JMXKernel" property="mbeanServer"/></parameter>
- <!-- Object name pattern for connector thread pools -->
- <!--parameter>jboss.web:type=ThreadPool,*</parameter-->
- </constructor>
- </bean>
<!-- The JBossWeb connector thread pool usage as a ratio of busy threads to max
thread pool size -->
<!-- Analogous to method=B in mod_jk -->
<bean name="BusyConnectorsLoadMetric"
class="org.jboss.modcluster.load.metric.impl.BusyConnectorsLoadMetric"
mode="On Demand">
<annotation>@org.jboss.aop.microcontainer.aspects.jmx.JMX(name="jboss.web:service=BusyConnectorsLoadMetric",exposedInterface=org.jboss.modcluster.load.metric.LoadMetricMBean.class)</annotation>
+ <constructor>
+ <parameter><inject
bean="ThreadPoolLoadMetricSource"/></parameter>
+ </constructor>
<!-- The weight determines the significance of this metric with respect
to others in the overall load balance factor calculation -->
<property name="weight">2</property>
</bean>
+ <!-- Queries all JBossWeb ThreadPool mbeans -->
+ <bean name="ThreadPoolLoadMetricSource"
class="org.jboss.modcluster.load.metric.impl.ThreadPoolLoadMetricSource"
mode="On Demand">
+ <constructor>
+ <parameter class="javax.management.MBeanServer"><inject
bean="JMXKernel" property="mbeanServer"/></parameter>
+ <!-- Object name pattern for connector thread pools -->
+ <!--parameter>jboss.web:type=ThreadPool,*</parameter-->
+ </constructor>
+ </bean>
<!-- The heap memory usage as a ratio of used heap to max heap size -->
<!-- N.B. This load metric is its own source -->
@@ -126,23 +123,15 @@
<!-- Alternative load metrics, grouped by source -->
- <!-- Uses the platform's OperatingSystemMXBean -->
- <bean name="OperatingSystemLoadMetricSource"
class="org.jboss.modcluster.load.metric.impl.OperatingSystemLoadMetricSource"
mode="On Demand">
- <constructor>
- <parameter>
- <collection
elementClass="org.jboss.modcluster.load.metric.LoadMetric">
- <value><inject
bean="AverageSystemLoadMetric"/></value>
- <value><inject
bean="SystemMemoryUsageLoadMetric"/></value>
- </collection>
- </parameter>
- </constructor>
- </bean>
<!-- CPU usage -->
<!-- Perhaps the best metric for determining system load - but only available on
Java 1.6 or later -->
<bean name="AverageSystemLoadMetric"
class="org.jboss.modcluster.load.metric.impl.AverageSystemLoadMetric"
mode="On Demand">
<annotation>@org.jboss.aop.microcontainer.aspects.jmx.JMX(name="jboss.web:service=AverageSystemLoadMetric",exposedInterface=org.jboss.modcluster.load.metric.LoadMetricMBean.class)</annotation>
+ <constructor>
+ <parameter><inject
bean="OperatingSystemLoadMetricSource"/></parameter>
+ </constructor>
</bean>
<!-- The system memory usage as ratio of used memory to total memory size -->
<!-- Requires com.sun.management.OperatingSystemMXBean -->
@@ -150,31 +139,23 @@
class="org.jboss.modcluster.load.metric.impl.SystemMemoryUsageLoadMetric"
mode="On Demand">
<annotation>@org.jboss.aop.microcontainer.aspects.jmx.JMX(name="jboss.web:service=SystemMemoryUsageLoadMetric",exposedInterface=org.jboss.modcluster.load.metric.LoadMetricMBean.class)</annotation>
- </bean>
-
-
- <!-- Queries all JBossWeb GlobalRequestProcessor mbeans -->
- <bean name="RequestProcessorLoadMetricSource"
class="org.jboss.modcluster.load.metric.impl.RequestProcessorLoadMetricSource"
mode="On Demand">
<constructor>
- <parameter>
- <collection
elementClass="org.jboss.modcluster.load.metric.LoadMetric">
- <value><inject
bean="RequestCountLoadMetric"/></value>
- <value><inject
bean="ReceiveTrafficLoadMetric"/></value>
- <value><inject
bean="SendTrafficLoadMetric"/></value>
- </collection>
- </parameter>
- <parameter class="javax.management.MBeanServer"><inject
bean="JMXKernel" property="mbeanServer"/></parameter>
- <!-- Object name pattern for request processors -->
- <!--parameter>jboss.web:type=GlobalRequestProcessor,*</parameter-->
+ <parameter><inject
bean="OperatingSystemLoadMetricSource"/></parameter>
</constructor>
</bean>
+ <!-- Uses the platform's OperatingSystemMXBean -->
+ <bean name="OperatingSystemLoadMetricSource"
class="org.jboss.modcluster.load.metric.impl.OperatingSystemLoadMetricSource"
mode="On Demand">
+ </bean>
+
+
<!-- The number of requests/sec processed by the JBossWeb connectors, with respect
to the defined capacity -->
<!-- Analogous to method=R in mod_jk -->
<bean name="RequestCountLoadMetric"
class="org.jboss.modcluster.load.metric.impl.RequestCountLoadMetric"
mode="On Demand">
<annotation>@org.jboss.aop.microcontainer.aspects.jmx.JMX(name="jboss.web:service=RequestCountLoadMetric",exposedInterface=org.jboss.modcluster.load.metric.LoadMetricMBean.class)</annotation>
- <!--constructor>
- <parameter>requestCount</parameter>
- </constructor-->
+ <constructor>
+ <parameter><inject
bean="RequestProcessorLoadMetricSource"/></parameter>
+ <!--parameter>requestCount</parameter-->
+ </constructor>
<!-- This metric requires an explicit capacity, e.g. maximum capacity of 1000
requests/sec -->
<property name="capacity">1000</property>
</bean>
@@ -182,90 +163,80 @@
<!-- Analogous to method=T in mod_jk -->
<bean name="ReceiveTrafficLoadMetric"
class="org.jboss.modcluster.load.metric.impl.ReceiveTrafficLoadMetric"
mode="On Demand">
<annotation>@org.jboss.aop.microcontainer.aspects.jmx.JMX(name="jboss.web:service=ReceiveTrafficLoadMetric",exposedInterface=org.jboss.modcluster.load.metric.LoadMetricMBean.class)</annotation>
- <!--constructor>
- <parameter>bytesReceived</parameter>
- </constructor-->
+ <constructor>
+ <parameter><inject
bean="RequestProcessorLoadMetricSource"/></parameter>
+ <!--parameter>bytesReceived</parameter-->
+ </constructor>
<!-- This metric requires an explicit capacity, e.g. max capacity of 1024 KB/s
-->
<property name="capacity">1024</property>
</bean>
<!-- The outgoing traffic sent by JBossWeb connectors in KB/sec, with respect to the
defined capacity -->
<bean name="SendTrafficLoadMetric"
class="org.jboss.modcluster.load.metric.impl.SendTrafficLoadMetric"
mode="On Demand">
<annotation>@org.jboss.aop.microcontainer.aspects.jmx.JMX(name="jboss.web:service=SendTrafficLoadMetric",exposedInterface=org.jboss.modcluster.load.metric.LoadMetricMBean.class)</annotation>
- <!--constructor>
- <parameter>bytesSent</parameter>
- </constructor-->
+ <constructor>
+ <parameter><inject
bean="RequestProcessorLoadMetricSource"/></parameter>
+ <!--parameter>bytesSent</parameter-->
+ </constructor>
<!-- This metric requires an explicit capacity, e.g. max capacity of 512 KB/s
-->
<property name="capacity">512</property>
</bean>
-
-
- <!-- Queries all JBossWeb session manager mbeans -->
- <bean name="SessionLoadMetricSource"
class="org.jboss.modcluster.load.metric.impl.SessionLoadMetricSource"
mode="On Demand">
+ <!-- Queries all JBossWeb GlobalRequestProcessor mbeans -->
+ <bean name="RequestProcessorLoadMetricSource"
class="org.jboss.modcluster.load.metric.impl.RequestProcessorLoadMetricSource"
mode="On Demand">
<constructor>
- <parameter>
- <collection
elementClass="org.jboss.modcluster.load.metric.LoadMetric">
- <value><inject
bean="ActiveSessionsLoadMetric"/></value>
- </collection>
- </parameter>
<parameter class="javax.management.MBeanServer"><inject
bean="JMXKernel" property="mbeanServer"/></parameter>
- <!-- Object name pattern for session managers -->
- <!--parameter>jboss.web:type=Manager,*</parameter-->
+ <!-- Object name pattern for request processors -->
+ <!--parameter>jboss.web:type=GlobalRequestProcessor,*</parameter-->
</constructor>
</bean>
+
+
<!-- The number of active sessions, with respect to the defined capacity -->
<!-- Analogous to method=S in mod_jk -->
<bean name="ActiveSessionsLoadMetric"
class="org.jboss.modcluster.load.metric.impl.ActiveSessionsLoadMetric"
mode="On Demand">
<annotation>@org.jboss.aop.microcontainer.aspects.jmx.JMX(name="jboss.web:service=ActiveSessionsLoadMetric",exposedInterface=org.jboss.modcluster.load.metric.LoadMetricMBean.class)</annotation>
- <!--constructor>
- <parameter>activeSessions</parameter>
- </constructor-->
+ <constructor>
+ <parameter><inject
bean="SessionLoadMetricSource"/></parameter>
+ <!--parameter>activeSessions</parameter-->
+ </constructor>
<!-- This metric requires an explicit capacity, e.g. max capacity of 1000 active
sessions -->
<property name="capacity">1000</property>
</bean>
+ <!-- Queries all JBossWeb session manager mbeans -->
+ <bean name="SessionLoadMetricSource"
class="org.jboss.modcluster.load.metric.impl.SessionLoadMetricSource"
mode="On Demand">
+ <constructor>
+ <parameter class="javax.management.MBeanServer"><inject
bean="JMXKernel" property="mbeanServer"/></parameter>
+ <!-- Object name pattern for session managers -->
+ <!--parameter>jboss.web:type=Manager,*</parameter-->
+ </constructor>
+ </bean>
+ <!-- Returns the connection pool usage as a ratio of used to max pool size -->
+ <bean name="ConnectionPoolUsageMetric"
class="org.jboss.modcluster.load.metric.impl.ConnectionPoolUsageLoadMetric"
mode="On Demand">
+
<annotation>@org.jboss.aop.microcontainer.aspects.jmx.JMX(name="jboss.web:service=ConnectionPoolUsageLoadMetric",exposedInterface=org.jboss.modcluster.load.metric.LoadMetricMBean.class)</annotation>
+ <constructor>
+ <parameter><inject
bean="ConnectionPoolLoadMetricSource"/></parameter>
+ <!--parameter>InUseConnectionCount</parameter-->
+ <!--parameter>MaxSize</parameter-->
+ </constructor>
+ </bean>
<!-- Queries all JCA connection pools -->
<bean name="ConnectionPoolLoadMetricSource"
class="org.jboss.modcluster.load.metric.impl.ConnectionPoolLoadMetricSource"
mode="On Demand">
<constructor>
- <parameter>
- <collection
elementClass="org.jboss.modcluster.load.metric.LoadMetric">
- <value><inject
bean="ConnectionPoolUsageMetric"/></value>
- </collection>
- </parameter>
<parameter class="javax.management.MBeanServer"><inject
bean="JMXKernel" property="mbeanServer"/></parameter>
<!-- Object name pattern for connector thread pools -->
<!--parameter>jboss.jca:service=ManagedConnectionPool,*</parameter-->
</constructor>
</bean>
- <!-- Returns the connection pool usage as a ratio of used to max pool size -->
- <bean name="ConnectionPoolUsageMetric"
class="org.jboss.modcluster.load.metric.impl.ConnectionPoolUsageLoadMetric"
mode="On Demand">
-
<annotation>@org.jboss.aop.microcontainer.aspects.jmx.JMX(name="jboss.web:service=ConnectionPoolUsageLoadMetric",exposedInterface=org.jboss.modcluster.load.metric.LoadMetricMBean.class)</annotation>
- <!--constructor>
- <parameter>InUseConnectionCount</parameter>
- <parameter>MaxSize</parameter>
- </constructor-->
- </bean>
<!-- Generic load metrics/sources -->
- <!-- Queries for mbeans matching the specified pattern -->
- <bean name="MBeanQueryLoadMetricSource"
class="org.jboss.modcluster.load.metric.impl.MBeanQueryLoadMetricSource"
mode="On Demand">
- <constructor>
- <parameter>
- <collection
elementClass="org.jboss.modcluster.load.metric.LoadMetric">
- <value><bean
inject="MBeanAttributeLoadMetric"/></value>
- <value><bean
inject="MBeanAttributeRatioLoadMetric"/></value>
- </collection>
- </parameter>
- <parameter><!-- ObjectName pattern --></parameter>
- <parameter><inject bean="JMXKernel"
property="mbeanServer"/></parameter>
- </constructor>
- </bean>
<!-- Uses the sum of the values of the specified attribute for each
mbean matching the query, with respect to a defined capacity. -->
<bean name="MBeanAttributeLoadMetric"
class="org.jboss.modcluster.load.metric.impl.MBeanAttributeLoadMetric"
mode="On Demand">
<annotation>@org.jboss.aop.microcontainer.aspects.jmx.JMX(name="jboss.web:service=MBeanAttributeLoadMetric",exposedInterface=org.jboss.modcluster.load.metric.LoadMetricMBean.class)</annotation>
<constructor>
+ <parameter><inject
bean="MBeanQueryLoadMetricSource"/></parameter>
<parameter><!-- mbean attribute --></parameter>
</constructor>
<property name="capacity">1</property>
@@ -276,9 +247,17 @@
<bean name="MBeanAttributeRatioLoadMetric"
class="org.jboss.modcluster.load.metric.impl.MBeanAttributeLoadMetric"
mode="On Demand">
<annotation>@org.jboss.aop.microcontainer.aspects.jmx.JMX(name="jboss.web:service=MBeanAttributeLoadMetric",exposedInterface=org.jboss.modcluster.load.metric.LoadMetricMBean.class)</annotation>
<constructor>
+ <parameter><inject
bean="MBeanQueryLoadMetricSource"/></parameter>
<parameter><!-- dividend attribute --></parameter>
<parameter><!-- divisor attribute --></parameter>
</constructor>
</bean>
-
+ <!-- Queries for mbeans matching the specified pattern -->
+ <bean name="MBeanQueryLoadMetricSource"
class="org.jboss.modcluster.load.metric.impl.MBeanQueryLoadMetricSource"
mode="On Demand">
+ <constructor>
+ <parameter><!-- ObjectName pattern --></parameter>
+ <parameter><inject bean="JMXKernel"
property="mbeanServer"/></parameter>
+ </constructor>
+ </bean>
+
</deployment>
\ No newline at end of file
Modified:
trunk/mod_cluster/src/test/java/org/jboss/modcluster/load/DynamicLoadBalanceFactorProviderTestCase.java
===================================================================
---
trunk/mod_cluster/src/test/java/org/jboss/modcluster/load/DynamicLoadBalanceFactorProviderTestCase.java 2008-10-22
21:44:32 UTC (rev 1988)
+++
trunk/mod_cluster/src/test/java/org/jboss/modcluster/load/DynamicLoadBalanceFactorProviderTestCase.java 2008-10-23
05:16:30 UTC (rev 1989)
@@ -22,7 +22,7 @@
package org.jboss.modcluster.load;
import java.util.Arrays;
-import java.util.Collections;
+import java.util.LinkedHashSet;
import org.easymock.EasyMock;
import org.jboss.modcluster.load.impl.DynamicLoadBalanceFactorProvider;
@@ -40,14 +40,29 @@
@SuppressWarnings({ "unchecked", "boxing" })
public class DynamicLoadBalanceFactorProviderTestCase
{
+ LoadMetric<LoadContext> metric1 = EasyMock.createStrictMock(LoadMetric.class);
+ LoadMetric<LoadContext> metric2 = EasyMock.createStrictMock(LoadMetric.class);
+ LoadMetric<LoadContext> metric3 = EasyMock.createStrictMock(LoadMetric.class);
private final LoadMetricSource<LoadContext> source1 =
EasyMock.createStrictMock(LoadMetricSource.class);
private final LoadMetricSource<LoadContext> source2 =
EasyMock.createStrictMock(LoadMetricSource.class);
- private final DynamicLoadBalanceFactorProvider provider = new
DynamicLoadBalanceFactorProvider(Arrays.asList(this.source1, this.source2));
+ private DynamicLoadBalanceFactorProvider provider;
+
@Before
public void init() throws Exception
{
+ EasyMock.expect(this.metric1.getSource()).andReturn(this.source1);
+ EasyMock.expect(this.metric2.getSource()).andReturn(this.source1);
+ EasyMock.expect(this.metric3.getSource()).andReturn(this.source2);
+
+ EasyMock.replay(this.metric1, this.metric2, this.metric3);
+
+ this.provider = new DynamicLoadBalanceFactorProvider(new
LinkedHashSet<LoadMetric<LoadContext>>(Arrays.asList(this.metric1,
this.metric2, this.metric3)));
+
+ EasyMock.verify(this.metric1, this.metric2, this.metric3);
+ EasyMock.reset(this.metric1, this.metric2, this.metric3);
+
this.provider.setHistory(2);
}
@@ -55,103 +70,85 @@
public void getLoadBalanceFactor() throws Exception
{
LoadContext context1 = EasyMock.createStrictMock(LoadContext.class);
- LoadMetric<LoadContext> metric1 =
EasyMock.createStrictMock(LoadMetric.class);
- LoadMetric<LoadContext> metric2 =
EasyMock.createStrictMock(LoadMetric.class);
- LoadMetric<LoadContext> metric3 =
EasyMock.createStrictMock(LoadMetric.class);
- EasyMock.expect(this.source1.getMetrics()).andReturn(Arrays.asList(metric1,
metric2));
+ EasyMock.expect(this.metric1.getWeight()).andReturn(1);
- EasyMock.expect(metric1.getWeight()).andReturn(1);
- EasyMock.expect(metric2.getWeight()).andReturn(2);
-
EasyMock.expect(this.source1.createContext()).andReturn(context1);
- EasyMock.expect(metric1.getLoad(context1)).andReturn(0.2);
- EasyMock.expect(metric1.getCapacity()).andReturn(1d);
- EasyMock.expect(metric1.getWeight()).andReturn(1);
+ EasyMock.expect(this.metric1.getWeight()).andReturn(1);
+ EasyMock.expect(this.metric1.getLoad(context1)).andReturn(0.2);
+ EasyMock.expect(this.metric1.getCapacity()).andReturn(1d);
- EasyMock.expect(metric2.getLoad(context1)).andReturn(400d);
- EasyMock.expect(metric2.getCapacity()).andReturn(1000d);
- EasyMock.expect(metric2.getWeight()).andReturn(2);
+ EasyMock.expect(this.metric2.getWeight()).andReturn(2);
+ EasyMock.expect(this.metric2.getLoad(context1)).andReturn(400d);
+ EasyMock.expect(this.metric2.getCapacity()).andReturn(1000d);
context1.close();
-
EasyMock.expect(this.source2.getMetrics()).andReturn(Collections.singleton(metric3));
+ EasyMock.expect(this.metric3.getWeight()).andReturn(0);
- EasyMock.expect(metric3.getWeight()).andReturn(0);
+ EasyMock.replay(this.source1, this.source2, context1, this.metric1, this.metric2,
this.metric3);
- EasyMock.replay(this.source1, this.source2, context1, metric1, metric2, metric3);
-
int loadBalanceFactor = this.provider.getLoadBalanceFactor();
- EasyMock.verify(this.source1, this.source2, context1, metric1, metric2, metric3);
+ EasyMock.verify(this.source1, this.source2, context1, this.metric1, this.metric2,
this.metric3);
Assert.assertEquals(67, loadBalanceFactor);
- EasyMock.reset(this.source1, this.source2, context1, metric1, metric2, metric3);
+ EasyMock.reset(this.source1, this.source2, context1, this.metric1, this.metric2,
this.metric3);
// Test time-decay function
- EasyMock.expect(this.source1.getMetrics()).andReturn(Arrays.asList(metric1,
metric2));
+ EasyMock.expect(this.metric1.getWeight()).andReturn(1);
- EasyMock.expect(metric1.getWeight()).andReturn(1);
- EasyMock.expect(metric2.getWeight()).andReturn(2);
-
EasyMock.expect(this.source1.createContext()).andReturn(context1);
- EasyMock.expect(metric1.getLoad(context1)).andReturn(0.4);
- EasyMock.expect(metric1.getCapacity()).andReturn(1d);
- EasyMock.expect(metric1.getWeight()).andReturn(1);
+ EasyMock.expect(this.metric1.getWeight()).andReturn(1);
+ EasyMock.expect(this.metric1.getLoad(context1)).andReturn(0.4);
+ EasyMock.expect(this.metric1.getCapacity()).andReturn(1d);
- EasyMock.expect(metric2.getLoad(context1)).andReturn(600d);
- EasyMock.expect(metric2.getCapacity()).andReturn(1000d);
- EasyMock.expect(metric2.getWeight()).andReturn(2);
+ EasyMock.expect(this.metric2.getWeight()).andReturn(2);
+ EasyMock.expect(this.metric2.getLoad(context1)).andReturn(600d);
+ EasyMock.expect(this.metric2.getCapacity()).andReturn(1000d);
context1.close();
-
EasyMock.expect(this.source2.getMetrics()).andReturn(Collections.singleton(metric3));
+ EasyMock.expect(this.metric3.getWeight()).andReturn(0);
- EasyMock.expect(metric3.getWeight()).andReturn(0);
+ EasyMock.replay(this.source1, this.source2, context1, this.metric1, this.metric2,
this.metric3);
- EasyMock.replay(this.source1, this.source2, context1, metric1, metric2, metric3);
-
loadBalanceFactor = this.provider.getLoadBalanceFactor();
- EasyMock.verify(this.source1, this.source2, context1, metric1, metric2, metric3);
+ EasyMock.verify(this.source1, this.source2, context1, this.metric1, this.metric2,
this.metric3);
Assert.assertEquals(53, loadBalanceFactor);
- EasyMock.reset(this.source1, this.source2, context1, metric1, metric2, metric3);
+ EasyMock.reset(this.source1, this.source2, context1, this.metric1, this.metric2,
this.metric3);
//Test decay queue overflow
- EasyMock.expect(this.source1.getMetrics()).andReturn(Arrays.asList(metric1,
metric2));
+ EasyMock.expect(this.metric1.getWeight()).andReturn(1);
- EasyMock.expect(metric1.getWeight()).andReturn(1);
- EasyMock.expect(metric2.getWeight()).andReturn(2);
-
EasyMock.expect(this.source1.createContext()).andReturn(context1);
- EasyMock.expect(metric1.getLoad(context1)).andReturn(0.3);
- EasyMock.expect(metric1.getCapacity()).andReturn(1d);
- EasyMock.expect(metric1.getWeight()).andReturn(1);
+ EasyMock.expect(this.metric1.getWeight()).andReturn(1);
+ EasyMock.expect(this.metric1.getLoad(context1)).andReturn(0.3);
+ EasyMock.expect(this.metric1.getCapacity()).andReturn(1d);
- EasyMock.expect(metric2.getLoad(context1)).andReturn(300d);
- EasyMock.expect(metric2.getCapacity()).andReturn(1000d);
- EasyMock.expect(metric2.getWeight()).andReturn(2);
+ EasyMock.expect(this.metric2.getWeight()).andReturn(2);
+ EasyMock.expect(this.metric2.getLoad(context1)).andReturn(300d);
+ EasyMock.expect(this.metric2.getCapacity()).andReturn(1000d);
context1.close();
-
EasyMock.expect(this.source2.getMetrics()).andReturn(Collections.singleton(metric3));
+ EasyMock.expect(this.metric3.getWeight()).andReturn(0);
- EasyMock.expect(metric3.getWeight()).andReturn(0);
+ EasyMock.replay(this.source1, this.source2, context1, this.metric1, this.metric2,
this.metric3);
- EasyMock.replay(this.source1, this.source2, context1, metric1, metric2, metric3);
-
loadBalanceFactor = this.provider.getLoadBalanceFactor();
- EasyMock.verify(this.source1, this.source2, context1, metric1, metric2, metric3);
+ EasyMock.verify(this.source1, this.source2, context1, this.metric1, this.metric2,
this.metric3);
Assert.assertEquals(62, loadBalanceFactor);
- EasyMock.reset(this.source1, this.source2, context1, metric1, metric2, metric3);
+ EasyMock.reset(this.source1, this.source2, context1, this.metric1, this.metric2,
this.metric3);
}
}
Modified:
trunk/mod_cluster/src/test/java/org/jboss/modcluster/load/metric/ActiveSessionsLoadMetricTestCase.java
===================================================================
---
trunk/mod_cluster/src/test/java/org/jboss/modcluster/load/metric/ActiveSessionsLoadMetricTestCase.java 2008-10-22
21:44:32 UTC (rev 1988)
+++
trunk/mod_cluster/src/test/java/org/jboss/modcluster/load/metric/ActiveSessionsLoadMetricTestCase.java 2008-10-23
05:16:30 UTC (rev 1989)
@@ -21,6 +21,8 @@
*/
package org.jboss.modcluster.load.metric;
+import javax.management.MalformedObjectNameException;
+
import org.jboss.modcluster.load.metric.impl.ActiveSessionsLoadMetric;
/**
@@ -29,7 +31,7 @@
*/
public class ActiveSessionsLoadMetricTestCase extends MBeanAttributeLoadMetricTestCase
{
- public ActiveSessionsLoadMetricTestCase()
+ public ActiveSessionsLoadMetricTestCase() throws MalformedObjectNameException
{
super(new ActiveSessionsLoadMetric(), ActiveSessionsLoadMetric.DEFAULT_ATTRIBUTE);
}
Modified:
trunk/mod_cluster/src/test/java/org/jboss/modcluster/load/metric/AverageSystemLoadMetricTestCase.java
===================================================================
---
trunk/mod_cluster/src/test/java/org/jboss/modcluster/load/metric/AverageSystemLoadMetricTestCase.java 2008-10-22
21:44:32 UTC (rev 1988)
+++
trunk/mod_cluster/src/test/java/org/jboss/modcluster/load/metric/AverageSystemLoadMetricTestCase.java 2008-10-23
05:16:30 UTC (rev 1989)
@@ -44,7 +44,7 @@
{
private final MBeanServer server = EasyMock.createStrictMock(MBeanServer.class);
- private LoadMetric<MBeanLoadContext> metric = new AverageSystemLoadMetric();
+ private LoadMetric<MBeanLoadContext> metric;
private ObjectName name;
private MBeanLoadContext context;
@@ -52,6 +52,7 @@
@Before
public void prepare() throws MalformedObjectNameException
{
+ this.metric = new AverageSystemLoadMetric();
this.name =
ObjectName.getInstance(ManagementFactory.OPERATING_SYSTEM_MXBEAN_NAME);
this.context = new MBeanLoadContext(this.server, this.name);
}
Modified:
trunk/mod_cluster/src/test/java/org/jboss/modcluster/load/metric/BusyConnectorsLoadMetricTestCase.java
===================================================================
---
trunk/mod_cluster/src/test/java/org/jboss/modcluster/load/metric/BusyConnectorsLoadMetricTestCase.java 2008-10-22
21:44:32 UTC (rev 1988)
+++
trunk/mod_cluster/src/test/java/org/jboss/modcluster/load/metric/BusyConnectorsLoadMetricTestCase.java 2008-10-23
05:16:30 UTC (rev 1989)
@@ -21,6 +21,8 @@
*/
package org.jboss.modcluster.load.metric;
+import javax.management.MalformedObjectNameException;
+
import org.jboss.modcluster.load.metric.impl.BusyConnectorsLoadMetric;
/**
@@ -29,7 +31,7 @@
*/
public class BusyConnectorsLoadMetricTestCase extends
MBeanAttributeRatioLoadMetricTestCase
{
- public BusyConnectorsLoadMetricTestCase()
+ public BusyConnectorsLoadMetricTestCase() throws MalformedObjectNameException
{
super(new BusyConnectorsLoadMetric(),
BusyConnectorsLoadMetric.DEFAULT_DIVIDEND_ATTRIBUTE,
BusyConnectorsLoadMetric.DEFAULT_DIVISOR_ATTRIBUTE);
}
Modified:
trunk/mod_cluster/src/test/java/org/jboss/modcluster/load/metric/ConnectionPoolLoadMetricSourceTestCase.java
===================================================================
---
trunk/mod_cluster/src/test/java/org/jboss/modcluster/load/metric/ConnectionPoolLoadMetricSourceTestCase.java 2008-10-22
21:44:32 UTC (rev 1988)
+++
trunk/mod_cluster/src/test/java/org/jboss/modcluster/load/metric/ConnectionPoolLoadMetricSourceTestCase.java 2008-10-23
05:16:30 UTC (rev 1989)
@@ -21,14 +21,11 @@
*/
package org.jboss.modcluster.load.metric;
-import java.util.Collection;
-
import javax.management.MBeanServer;
import javax.management.MalformedObjectNameException;
+import org.easymock.EasyMock;
import org.jboss.modcluster.load.metric.impl.ConnectionPoolLoadMetricSource;
-import org.jboss.modcluster.load.metric.impl.MBeanQueryLoadContext;
-import org.jboss.modcluster.load.metric.impl.MBeanQueryLoadMetricSource;
/**
* @author Paul Ferraro
@@ -38,12 +35,11 @@
{
public ConnectionPoolLoadMetricSourceTestCase() throws MalformedObjectNameException
{
- super(ConnectionPoolLoadMetricSource.DEFAULT_PATTERN);
+ this(EasyMock.createStrictMock(MBeanServer.class));
}
- @Override
- protected MBeanQueryLoadMetricSource
createSource(Collection<LoadMetric<MBeanQueryLoadContext>> metrics,
MBeanServer server) throws MalformedObjectNameException
+ private ConnectionPoolLoadMetricSourceTestCase(MBeanServer server) throws
MalformedObjectNameException
{
- return new ConnectionPoolLoadMetricSource(metrics, server);
+ super(new ConnectionPoolLoadMetricSource(server),
ConnectionPoolLoadMetricSource.DEFAULT_PATTERN, server);
}
}
Modified:
trunk/mod_cluster/src/test/java/org/jboss/modcluster/load/metric/ConnectionPoolUsageLoadMetricTestCase.java
===================================================================
---
trunk/mod_cluster/src/test/java/org/jboss/modcluster/load/metric/ConnectionPoolUsageLoadMetricTestCase.java 2008-10-22
21:44:32 UTC (rev 1988)
+++
trunk/mod_cluster/src/test/java/org/jboss/modcluster/load/metric/ConnectionPoolUsageLoadMetricTestCase.java 2008-10-23
05:16:30 UTC (rev 1989)
@@ -21,6 +21,8 @@
*/
package org.jboss.modcluster.load.metric;
+import javax.management.MalformedObjectNameException;
+
import org.jboss.modcluster.load.metric.impl.ConnectionPoolUsageLoadMetric;
@@ -30,7 +32,7 @@
*/
public class ConnectionPoolUsageLoadMetricTestCase extends
MBeanAttributeRatioLoadMetricTestCase
{
- public ConnectionPoolUsageLoadMetricTestCase()
+ public ConnectionPoolUsageLoadMetricTestCase() throws MalformedObjectNameException
{
super(new ConnectionPoolUsageLoadMetric(),
ConnectionPoolUsageLoadMetric.DEFAULT_DIVIDEND_ATTRIBUTE,
ConnectionPoolUsageLoadMetric.DEFAULT_DIVISOR_ATTRIBUTE);
}
Modified:
trunk/mod_cluster/src/test/java/org/jboss/modcluster/load/metric/MBeanAttributeLoadMetricTestCase.java
===================================================================
---
trunk/mod_cluster/src/test/java/org/jboss/modcluster/load/metric/MBeanAttributeLoadMetricTestCase.java 2008-10-22
21:44:32 UTC (rev 1988)
+++
trunk/mod_cluster/src/test/java/org/jboss/modcluster/load/metric/MBeanAttributeLoadMetricTestCase.java 2008-10-23
05:16:30 UTC (rev 1989)
@@ -31,6 +31,7 @@
import org.easymock.EasyMock;
import org.jboss.modcluster.load.metric.impl.MBeanAttributeLoadMetric;
import org.jboss.modcluster.load.metric.impl.MBeanQueryLoadContext;
+import org.jboss.modcluster.load.metric.impl.MBeanQueryLoadMetricSource;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
@@ -50,14 +51,14 @@
private String attribute;
LoadMetric<MBeanQueryLoadContext> metric;
- public MBeanAttributeLoadMetricTestCase()
+ public MBeanAttributeLoadMetricTestCase() throws MalformedObjectNameException
{
this("attribute");
}
- private MBeanAttributeLoadMetricTestCase(String attribute)
+ private MBeanAttributeLoadMetricTestCase(String attribute) throws
MalformedObjectNameException
{
- this(new MBeanAttributeLoadMetric(attribute), attribute);
+ this(new MBeanAttributeLoadMetric(new
MBeanQueryLoadMetricSource("domain:*"), attribute), attribute);
}
protected MBeanAttributeLoadMetricTestCase(LoadMetric<MBeanQueryLoadContext>
metric, String attribute)
Modified:
trunk/mod_cluster/src/test/java/org/jboss/modcluster/load/metric/MBeanAttributeRatioLoadMetricTestCase.java
===================================================================
---
trunk/mod_cluster/src/test/java/org/jboss/modcluster/load/metric/MBeanAttributeRatioLoadMetricTestCase.java 2008-10-22
21:44:32 UTC (rev 1988)
+++
trunk/mod_cluster/src/test/java/org/jboss/modcluster/load/metric/MBeanAttributeRatioLoadMetricTestCase.java 2008-10-23
05:16:30 UTC (rev 1989)
@@ -31,6 +31,7 @@
import org.easymock.EasyMock;
import org.jboss.modcluster.load.metric.impl.MBeanAttributeRatioLoadMetric;
import org.jboss.modcluster.load.metric.impl.MBeanQueryLoadContext;
+import org.jboss.modcluster.load.metric.impl.MBeanQueryLoadMetricSource;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
@@ -51,14 +52,14 @@
private String divisor;
private LoadMetric<MBeanQueryLoadContext> metric;
- public MBeanAttributeRatioLoadMetricTestCase()
+ public MBeanAttributeRatioLoadMetricTestCase() throws MalformedObjectNameException
{
this("dividend", "divisor");
}
- private MBeanAttributeRatioLoadMetricTestCase(String dividend, String divisor)
+ private MBeanAttributeRatioLoadMetricTestCase(String dividend, String divisor) throws
MalformedObjectNameException
{
- this(new MBeanAttributeRatioLoadMetric(dividend, divisor), dividend, divisor);
+ this(new MBeanAttributeRatioLoadMetric(new
MBeanQueryLoadMetricSource("domain:*"), dividend, divisor), dividend, divisor);
}
protected
MBeanAttributeRatioLoadMetricTestCase(LoadMetric<MBeanQueryLoadContext> metric,
String dividend, String divisor)
Modified:
trunk/mod_cluster/src/test/java/org/jboss/modcluster/load/metric/MBeanLoadMetricSourceTestCase.java
===================================================================
---
trunk/mod_cluster/src/test/java/org/jboss/modcluster/load/metric/MBeanLoadMetricSourceTestCase.java 2008-10-22
21:44:32 UTC (rev 1988)
+++
trunk/mod_cluster/src/test/java/org/jboss/modcluster/load/metric/MBeanLoadMetricSourceTestCase.java 2008-10-23
05:16:30 UTC (rev 1989)
@@ -21,10 +21,6 @@
*/
package org.jboss.modcluster.load.metric;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Iterator;
-
import javax.management.MBeanServer;
import javax.management.MalformedObjectNameException;
@@ -39,30 +35,25 @@
* @author Paul Ferraro
*
*/
-@SuppressWarnings("unchecked")
public class MBeanLoadMetricSourceTestCase
{
- private MBeanServer server = EasyMock.createStrictMock(MBeanServer.class);
- private LoadMetric<MBeanLoadContext> metric1 =
EasyMock.createStrictMock(LoadMetric.class);
- private LoadMetric<MBeanLoadContext> metric2 =
EasyMock.createStrictMock(LoadMetric.class);
-
- private String name;
+ private MBeanServer server;
private LoadMetricSource<MBeanLoadContext> source;
public MBeanLoadMetricSourceTestCase() throws MalformedObjectNameException
{
- this("domain:name=test");
+ this("domain:name=test", EasyMock.createStrictMock(MBeanServer.class));
}
- protected MBeanLoadMetricSourceTestCase(String name) throws
MalformedObjectNameException
+ private MBeanLoadMetricSourceTestCase(String name, MBeanServer server) throws
MalformedObjectNameException
{
- this.name = name;
- this.source = this.createSource(Arrays.asList(this.metric1, this.metric2),
this.server);
+ this(new MBeanLoadMetricSource(name, server), server);
}
- protected MBeanLoadMetricSource
createSource(Collection<LoadMetric<MBeanLoadContext>> metrics, MBeanServer
server) throws MalformedObjectNameException
+ protected MBeanLoadMetricSourceTestCase(MBeanLoadMetricSource source, MBeanServer
server)
{
- return new MBeanLoadMetricSource(metrics, this.name, server);
+ this.source = source;
+ this.server = server;
}
@Test
@@ -78,17 +69,4 @@
EasyMock.reset(this.server);
}
-
- @Test
- public void getMetrics()
- {
- Collection<LoadMetric<MBeanLoadContext>> metrics =
this.source.getMetrics();
-
- Assert.assertEquals(2, metrics.size());
-
- Iterator<LoadMetric<MBeanLoadContext>> iterator = metrics.iterator();
-
- Assert.assertSame(this.metric1, iterator.next());
- Assert.assertSame(this.metric2, iterator.next());
- }
}
Modified:
trunk/mod_cluster/src/test/java/org/jboss/modcluster/load/metric/MBeanQueryLoadMetricSourceTestCase.java
===================================================================
---
trunk/mod_cluster/src/test/java/org/jboss/modcluster/load/metric/MBeanQueryLoadMetricSourceTestCase.java 2008-10-22
21:44:32 UTC (rev 1988)
+++
trunk/mod_cluster/src/test/java/org/jboss/modcluster/load/metric/MBeanQueryLoadMetricSourceTestCase.java 2008-10-23
05:16:30 UTC (rev 1989)
@@ -21,10 +21,7 @@
*/
package org.jboss.modcluster.load.metric;
-import java.util.Arrays;
-import java.util.Collection;
import java.util.Collections;
-import java.util.Iterator;
import javax.management.MBeanServer;
import javax.management.MalformedObjectNameException;
@@ -43,30 +40,27 @@
* @author Paul Ferraro
*
*/
-@SuppressWarnings("unchecked")
public class MBeanQueryLoadMetricSourceTestCase
{
- private MBeanServer server = EasyMock.createStrictMock(MBeanServer.class);
- private LoadMetric<MBeanQueryLoadContext> metric1 =
EasyMock.createStrictMock(LoadMetric.class);
- private LoadMetric<MBeanQueryLoadContext> metric2 =
EasyMock.createStrictMock(LoadMetric.class);
-
+ private MBeanServer server;
private String pattern;
private LoadMetricSource<MBeanQueryLoadContext> source;
public MBeanQueryLoadMetricSourceTestCase() throws MalformedObjectNameException
{
- this("domain:*");
+ this("domain:*", EasyMock.createStrictMock(MBeanServer.class));
}
- protected MBeanQueryLoadMetricSourceTestCase(String pattern) throws
MalformedObjectNameException
+ private MBeanQueryLoadMetricSourceTestCase(String pattern, MBeanServer server) throws
MalformedObjectNameException
{
- this.pattern = pattern;
- this.source = this.createSource(Arrays.asList(this.metric1, this.metric2),
this.server);
+ this(new MBeanQueryLoadMetricSource(pattern, server), pattern, server);
}
- protected MBeanQueryLoadMetricSource
createSource(Collection<LoadMetric<MBeanQueryLoadContext>> metrics,
MBeanServer server) throws MalformedObjectNameException
+ protected MBeanQueryLoadMetricSourceTestCase(MBeanQueryLoadMetricSource source, String
pattern, MBeanServer server)
{
- return new MBeanQueryLoadMetricSource(metrics, this.pattern, server);
+ this.source = source;
+ this.pattern = pattern;
+ this.server = server;
}
@Test
@@ -88,17 +82,4 @@
EasyMock.reset(this.server);
}
-
- @Test
- public void getMetrics()
- {
- Collection<LoadMetric<MBeanQueryLoadContext>> metrics =
this.source.getMetrics();
-
- Assert.assertEquals(2, metrics.size());
-
- Iterator<LoadMetric<MBeanQueryLoadContext>> iterator =
metrics.iterator();
-
- Assert.assertSame(this.metric1, iterator.next());
- Assert.assertSame(this.metric2, iterator.next());
- }
}
Modified:
trunk/mod_cluster/src/test/java/org/jboss/modcluster/load/metric/OperatingSystemLoadMetricSourceTestCase.java
===================================================================
---
trunk/mod_cluster/src/test/java/org/jboss/modcluster/load/metric/OperatingSystemLoadMetricSourceTestCase.java 2008-10-22
21:44:32 UTC (rev 1988)
+++
trunk/mod_cluster/src/test/java/org/jboss/modcluster/load/metric/OperatingSystemLoadMetricSourceTestCase.java 2008-10-23
05:16:30 UTC (rev 1989)
@@ -21,14 +21,10 @@
*/
package org.jboss.modcluster.load.metric;
-import java.lang.management.ManagementFactory;
-import java.util.Collection;
-
import javax.management.MBeanServer;
import javax.management.MalformedObjectNameException;
-import org.jboss.modcluster.load.metric.impl.MBeanLoadContext;
-import org.jboss.modcluster.load.metric.impl.MBeanLoadMetricSource;
+import org.easymock.EasyMock;
import org.jboss.modcluster.load.metric.impl.OperatingSystemLoadMetricSource;
/**
@@ -39,16 +35,11 @@
{
public OperatingSystemLoadMetricSourceTestCase() throws MalformedObjectNameException
{
- super(ManagementFactory.OPERATING_SYSTEM_MXBEAN_NAME);
+ this(EasyMock.createStrictMock(MBeanServer.class));
}
- /**
- * @{inheritDoc}
- * @see
org.jboss.modcluster.load.metric.MBeanLoadMetricSourceTestCase#createSource(java.util.Collection,
javax.management.MBeanServer)
- */
- @Override
- protected MBeanLoadMetricSource
createSource(Collection<LoadMetric<MBeanLoadContext>> metrics, MBeanServer
server) throws MalformedObjectNameException
+ private OperatingSystemLoadMetricSourceTestCase(MBeanServer server) throws
MalformedObjectNameException
{
- return new OperatingSystemLoadMetricSource(metrics, server);
+ super(new OperatingSystemLoadMetricSource(server), server);
}
}
Modified:
trunk/mod_cluster/src/test/java/org/jboss/modcluster/load/metric/ReceiveTrafficLoadMetricTestCase.java
===================================================================
---
trunk/mod_cluster/src/test/java/org/jboss/modcluster/load/metric/ReceiveTrafficLoadMetricTestCase.java 2008-10-22
21:44:32 UTC (rev 1988)
+++
trunk/mod_cluster/src/test/java/org/jboss/modcluster/load/metric/ReceiveTrafficLoadMetricTestCase.java 2008-10-23
05:16:30 UTC (rev 1989)
@@ -21,6 +21,8 @@
*/
package org.jboss.modcluster.load.metric;
+import javax.management.MalformedObjectNameException;
+
import org.easymock.EasyMock;
import org.jboss.modcluster.load.metric.impl.ReceiveTrafficLoadMetric;
import org.junit.Assert;
@@ -33,7 +35,7 @@
@SuppressWarnings("boxing")
public class ReceiveTrafficLoadMetricTestCase extends MBeanAttributeLoadMetricTestCase
{
- public ReceiveTrafficLoadMetricTestCase()
+ public ReceiveTrafficLoadMetricTestCase() throws MalformedObjectNameException
{
super(new ReceiveTrafficLoadMetric(), ReceiveTrafficLoadMetric.DEFAULT_ATTRIBUTE);
}
Modified:
trunk/mod_cluster/src/test/java/org/jboss/modcluster/load/metric/RequestCountLoadMetricTestCase.java
===================================================================
---
trunk/mod_cluster/src/test/java/org/jboss/modcluster/load/metric/RequestCountLoadMetricTestCase.java 2008-10-22
21:44:32 UTC (rev 1988)
+++
trunk/mod_cluster/src/test/java/org/jboss/modcluster/load/metric/RequestCountLoadMetricTestCase.java 2008-10-23
05:16:30 UTC (rev 1989)
@@ -21,6 +21,8 @@
*/
package org.jboss.modcluster.load.metric;
+import javax.management.MalformedObjectNameException;
+
import org.easymock.EasyMock;
import org.jboss.modcluster.load.metric.impl.RequestCountLoadMetric;
import org.junit.Assert;
@@ -33,7 +35,7 @@
@SuppressWarnings("boxing")
public class RequestCountLoadMetricTestCase extends MBeanAttributeLoadMetricTestCase
{
- public RequestCountLoadMetricTestCase()
+ public RequestCountLoadMetricTestCase() throws MalformedObjectNameException
{
super(new RequestCountLoadMetric(), RequestCountLoadMetric.DEFAULT_ATTRIBUTE);
}
Modified:
trunk/mod_cluster/src/test/java/org/jboss/modcluster/load/metric/RequestProcessorLoadMetricSourceTestCase.java
===================================================================
---
trunk/mod_cluster/src/test/java/org/jboss/modcluster/load/metric/RequestProcessorLoadMetricSourceTestCase.java 2008-10-22
21:44:32 UTC (rev 1988)
+++
trunk/mod_cluster/src/test/java/org/jboss/modcluster/load/metric/RequestProcessorLoadMetricSourceTestCase.java 2008-10-23
05:16:30 UTC (rev 1989)
@@ -21,13 +21,10 @@
*/
package org.jboss.modcluster.load.metric;
-import java.util.Collection;
-
import javax.management.MBeanServer;
import javax.management.MalformedObjectNameException;
-import org.jboss.modcluster.load.metric.impl.MBeanQueryLoadContext;
-import org.jboss.modcluster.load.metric.impl.MBeanQueryLoadMetricSource;
+import org.easymock.EasyMock;
import org.jboss.modcluster.load.metric.impl.RequestProcessorLoadMetricSource;
/**
@@ -38,12 +35,11 @@
{
public RequestProcessorLoadMetricSourceTestCase() throws MalformedObjectNameException
{
- super(RequestProcessorLoadMetricSource.DEFAULT_PATTERN);
+ this(EasyMock.createStrictMock(MBeanServer.class));
}
- @Override
- protected MBeanQueryLoadMetricSource
createSource(Collection<LoadMetric<MBeanQueryLoadContext>> metrics,
MBeanServer server) throws MalformedObjectNameException
+ private RequestProcessorLoadMetricSourceTestCase(MBeanServer server) throws
MalformedObjectNameException
{
- return new RequestProcessorLoadMetricSource(metrics, server);
+ super(new RequestProcessorLoadMetricSource(server),
RequestProcessorLoadMetricSource.DEFAULT_PATTERN, server);
}
}
Modified:
trunk/mod_cluster/src/test/java/org/jboss/modcluster/load/metric/SendTrafficLoadMetricTestCase.java
===================================================================
---
trunk/mod_cluster/src/test/java/org/jboss/modcluster/load/metric/SendTrafficLoadMetricTestCase.java 2008-10-22
21:44:32 UTC (rev 1988)
+++
trunk/mod_cluster/src/test/java/org/jboss/modcluster/load/metric/SendTrafficLoadMetricTestCase.java 2008-10-23
05:16:30 UTC (rev 1989)
@@ -21,6 +21,8 @@
*/
package org.jboss.modcluster.load.metric;
+import javax.management.MalformedObjectNameException;
+
import org.easymock.EasyMock;
import org.jboss.modcluster.load.metric.impl.SendTrafficLoadMetric;
import org.junit.Assert;
@@ -33,7 +35,7 @@
@SuppressWarnings("boxing")
public class SendTrafficLoadMetricTestCase extends MBeanAttributeLoadMetricTestCase
{
- public SendTrafficLoadMetricTestCase()
+ public SendTrafficLoadMetricTestCase() throws MalformedObjectNameException
{
super(new SendTrafficLoadMetric(), SendTrafficLoadMetric.DEFAULT_ATTRIBUTE);
}
Modified:
trunk/mod_cluster/src/test/java/org/jboss/modcluster/load/metric/SessionLoadMetricSourceTestCase.java
===================================================================
---
trunk/mod_cluster/src/test/java/org/jboss/modcluster/load/metric/SessionLoadMetricSourceTestCase.java 2008-10-22
21:44:32 UTC (rev 1988)
+++
trunk/mod_cluster/src/test/java/org/jboss/modcluster/load/metric/SessionLoadMetricSourceTestCase.java 2008-10-23
05:16:30 UTC (rev 1989)
@@ -21,13 +21,10 @@
*/
package org.jboss.modcluster.load.metric;
-import java.util.Collection;
-
import javax.management.MBeanServer;
import javax.management.MalformedObjectNameException;
-import org.jboss.modcluster.load.metric.impl.MBeanQueryLoadContext;
-import org.jboss.modcluster.load.metric.impl.MBeanQueryLoadMetricSource;
+import org.easymock.EasyMock;
import org.jboss.modcluster.load.metric.impl.SessionLoadMetricSource;
/**
@@ -38,12 +35,11 @@
{
public SessionLoadMetricSourceTestCase() throws MalformedObjectNameException
{
- super(SessionLoadMetricSource.DEFAULT_PATTERN);
+ this(EasyMock.createStrictMock(MBeanServer.class));
}
- @Override
- protected MBeanQueryLoadMetricSource
createSource(Collection<LoadMetric<MBeanQueryLoadContext>> metrics,
MBeanServer server) throws MalformedObjectNameException
+ private SessionLoadMetricSourceTestCase(MBeanServer server) throws
MalformedObjectNameException
{
- return new SessionLoadMetricSource(metrics, server);
+ super(new SessionLoadMetricSource(server), SessionLoadMetricSource.DEFAULT_PATTERN,
server);
}
}
Modified:
trunk/mod_cluster/src/test/java/org/jboss/modcluster/load/metric/SystemMemoryUsageLoadMetricTestCase.java
===================================================================
---
trunk/mod_cluster/src/test/java/org/jboss/modcluster/load/metric/SystemMemoryUsageLoadMetricTestCase.java 2008-10-22
21:44:32 UTC (rev 1988)
+++
trunk/mod_cluster/src/test/java/org/jboss/modcluster/load/metric/SystemMemoryUsageLoadMetricTestCase.java 2008-10-23
05:16:30 UTC (rev 1989)
@@ -43,7 +43,7 @@
{
private final MBeanServer server = EasyMock.createStrictMock(MBeanServer.class);
- private LoadMetric<MBeanLoadContext> metric = new
SystemMemoryUsageLoadMetric();
+ private LoadMetric<MBeanLoadContext> metric;
private ObjectName name;
private MBeanLoadContext context;
@@ -51,6 +51,7 @@
@Before
public void prepare() throws MalformedObjectNameException
{
+ this.metric = new SystemMemoryUsageLoadMetric();
this.name =
ObjectName.getInstance(ManagementFactory.OPERATING_SYSTEM_MXBEAN_NAME);
this.context = new MBeanLoadContext(this.server, this.name);
}
Modified:
trunk/mod_cluster/src/test/java/org/jboss/modcluster/load/metric/ThreadPoolLoadMetricSourceTestCase.java
===================================================================
---
trunk/mod_cluster/src/test/java/org/jboss/modcluster/load/metric/ThreadPoolLoadMetricSourceTestCase.java 2008-10-22
21:44:32 UTC (rev 1988)
+++
trunk/mod_cluster/src/test/java/org/jboss/modcluster/load/metric/ThreadPoolLoadMetricSourceTestCase.java 2008-10-23
05:16:30 UTC (rev 1989)
@@ -21,13 +21,10 @@
*/
package org.jboss.modcluster.load.metric;
-import java.util.Collection;
-
import javax.management.MBeanServer;
import javax.management.MalformedObjectNameException;
-import org.jboss.modcluster.load.metric.impl.MBeanQueryLoadContext;
-import org.jboss.modcluster.load.metric.impl.MBeanQueryLoadMetricSource;
+import org.easymock.EasyMock;
import org.jboss.modcluster.load.metric.impl.ThreadPoolLoadMetricSource;
/**
@@ -38,12 +35,11 @@
{
public ThreadPoolLoadMetricSourceTestCase() throws MalformedObjectNameException
{
- super(ThreadPoolLoadMetricSource.DEFAULT_PATTERN);
+ this(EasyMock.createStrictMock(MBeanServer.class));
}
- @Override
- protected MBeanQueryLoadMetricSource
createSource(Collection<LoadMetric<MBeanQueryLoadContext>> metrics,
MBeanServer server) throws MalformedObjectNameException
+ private ThreadPoolLoadMetricSourceTestCase(MBeanServer server) throws
MalformedObjectNameException
{
- return new ThreadPoolLoadMetricSource(metrics, server);
+ super(new ThreadPoolLoadMetricSource(server),
ThreadPoolLoadMetricSource.DEFAULT_PATTERN, server);
}
}