[jboss-cvs] JBossAS SVN: r77463 - trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/load/metric/impl.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Mon Aug 25 19:09:16 EDT 2008
Author: pferraro
Date: 2008-08-25 19:09:16 -0400 (Mon, 25 Aug 2008)
New Revision: 77463
Modified:
trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/load/metric/impl/ActiveSessionsLoadMetric.java
trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/load/metric/impl/BusyConnectorsLoadMetric.java
trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/load/metric/impl/ConnectionPoolLoadMetricSource.java
trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/load/metric/impl/ConnectionPoolUsageLoadMetric.java
trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/load/metric/impl/ReceiveTrafficLoadMetric.java
trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/load/metric/impl/RequestCountLoadMetric.java
trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/load/metric/impl/RequestProcessorLoadMetricSource.java
trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/load/metric/impl/SendTrafficLoadMetric.java
trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/load/metric/impl/SessionLoadMetricSource.java
trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/load/metric/impl/ThreadPoolLoadMetricSource.java
Log:
Refactored mbean attribute aggregation into base class.
Use stateful helper object to convert deterministic load into a meaningful delta.
Modified: trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/load/metric/impl/ActiveSessionsLoadMetric.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/load/metric/impl/ActiveSessionsLoadMetric.java 2008-08-25 23:07:18 UTC (rev 77462)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/load/metric/impl/ActiveSessionsLoadMetric.java 2008-08-25 23:09:16 UTC (rev 77463)
@@ -21,10 +21,6 @@
*/
package org.jboss.web.tomcat.service.modcluster.load.metric.impl;
-import java.util.List;
-
-import javax.management.JMException;
-
import org.jboss.web.tomcat.service.modcluster.load.metric.LoadMetric;
/**
@@ -32,13 +28,10 @@
*
* @author Paul Ferraro
*/
-public class ActiveSessionsLoadMetric extends AbstractLoadMetric
+public class ActiveSessionsLoadMetric extends MBeanAttributeLoadMetric
{
private static final String DEFAULT_ATTRIBUTE = "LocalActiveSessions";
- private final SessionLoadMetricSource source;
- private final String attribute;
-
public ActiveSessionsLoadMetric(SessionLoadMetricSource source)
{
this(source, DEFAULT_ATTRIBUTE);
@@ -46,28 +39,6 @@
public ActiveSessionsLoadMetric(SessionLoadMetricSource source, String attribute)
{
- this.source = source;
-
- source.add(this);
-
- this.attribute = attribute;
+ super(source, attribute);
}
-
- /**
- * @{inheritDoc}
- * @see org.jboss.web.tomcat.service.modcluster.load.metric.LoadMetric#getLoad()
- */
- public double getLoad() throws JMException
- {
- long count = 0;
-
- List<Number> results = this.source.getAttributes(this.attribute, Number.class);
-
- for (Number result: results)
- {
- count += result.longValue();
- }
-
- return count;
- }
}
Modified: trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/load/metric/impl/BusyConnectorsLoadMetric.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/load/metric/impl/BusyConnectorsLoadMetric.java 2008-08-25 23:07:18 UTC (rev 77462)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/load/metric/impl/BusyConnectorsLoadMetric.java 2008-08-25 23:09:16 UTC (rev 77463)
@@ -21,10 +21,6 @@
*/
package org.jboss.web.tomcat.service.modcluster.load.metric.impl;
-import java.util.List;
-
-import javax.management.JMException;
-
import org.jboss.web.tomcat.service.modcluster.load.metric.LoadMetric;
/**
@@ -32,44 +28,13 @@
*
* @author Paul Ferraro
*/
-public class BusyConnectorsLoadMetric extends AbstractLoadMetric
+public class BusyConnectorsLoadMetric extends MBeanAttributeRatioLoadMetric
{
private static final String CURRENT_THREADS_BUSY = "currentThreadsBusy";
private static final String MAX_THREADS = "maxThreads";
- private final ThreadPoolLoadMetricSource source;
-
public BusyConnectorsLoadMetric(ThreadPoolLoadMetricSource source)
{
- this.source = source;
-
- source.add(this);
+ super(source, CURRENT_THREADS_BUSY, MAX_THREADS);
}
-
- /**
- * @{inheritDoc}
- * @see org.jboss.web.tomcat.service.modcluster.load.metric.LoadMetric#getLoad()
- */
- public double getLoad() throws JMException
- {
- double busy = 0;
-
- List<Integer> results = this.source.getAttributes(CURRENT_THREADS_BUSY, Integer.class);
-
- for (Integer result: results)
- {
- busy += result.intValue();
- }
-
- double max = 0;
-
- results = this.source.getAttributes(MAX_THREADS, Integer.class);
-
- for (Integer result: results)
- {
- max += result.intValue();
- }
-
- return busy / max;
- }
}
Modified: trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/load/metric/impl/ConnectionPoolLoadMetricSource.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/load/metric/impl/ConnectionPoolLoadMetricSource.java 2008-08-25 23:07:18 UTC (rev 77462)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/load/metric/impl/ConnectionPoolLoadMetricSource.java 2008-08-25 23:09:16 UTC (rev 77463)
@@ -30,7 +30,7 @@
* {@link LoadMetricSource} implementation that simplifies generic mbean access to
* a set of JBoss JCA connection pools.
*/
-public class ConnectionPoolLoadMetricSource extends ObjectNamePatternLoadMetricSource
+public class ConnectionPoolLoadMetricSource extends MBeanQueryLoadMetricSource
{
private static final String DEFAULT_PATTERN = "jboss.jca:service=ManagedConnectionPool,*";
Modified: trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/load/metric/impl/ConnectionPoolUsageLoadMetric.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/load/metric/impl/ConnectionPoolUsageLoadMetric.java 2008-08-25 23:07:18 UTC (rev 77462)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/load/metric/impl/ConnectionPoolUsageLoadMetric.java 2008-08-25 23:09:16 UTC (rev 77463)
@@ -21,22 +21,18 @@
*/
package org.jboss.web.tomcat.service.modcluster.load.metric.impl;
-import java.util.List;
+import org.jboss.web.tomcat.service.modcluster.load.metric.LoadMetric;
/**
* {@link LoadMetric} implementation that returns the usage ratio of a connection pool.
*
* @author Paul Ferraro
*/
-public class ConnectionPoolUsageLoadMetric extends AbstractLoadMetric
+public class ConnectionPoolUsageLoadMetric extends MBeanAttributeRatioLoadMetric
{
private static final String DEFAULT_USED_ATTRIBUTE = "InUseConnectionCount";
private static final String DEFAULT_MAX_ATTRIBUTE = "MaxSize";
- private final ConnectionPoolLoadMetricSource source;
- private final String usedAttribute;
- private final String maxAttribute;
-
public ConnectionPoolUsageLoadMetric(ConnectionPoolLoadMetricSource source)
{
this(source, DEFAULT_USED_ATTRIBUTE, DEFAULT_MAX_ATTRIBUTE);
@@ -44,38 +40,6 @@
public ConnectionPoolUsageLoadMetric(ConnectionPoolLoadMetricSource source, String usedAttribute, String maxAttribute)
{
- this.source = source;
-
- source.add(this);
-
- this.usedAttribute = usedAttribute;
- this.maxAttribute = maxAttribute;
+ super(source, usedAttribute, maxAttribute);
}
-
- /**
- * @{inheritDoc}
- * @see org.jboss.web.tomcat.service.modcluster.load.metric.LoadMetric#getLoad()
- */
- public double getLoad() throws Exception
- {
- double used = 0;
-
- List<Number> results = this.source.getAttributes(this.usedAttribute, Number.class);
-
- for (Number result: results)
- {
- used += result.longValue();
- }
-
- double max = 0;
-
- results = this.source.getAttributes(this.maxAttribute, Number.class);
-
- for (Number result: results)
- {
- max += result.longValue();
- }
-
- return used / max;
- }
}
Modified: trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/load/metric/impl/ReceiveTrafficLoadMetric.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/load/metric/impl/ReceiveTrafficLoadMetric.java 2008-08-25 23:07:18 UTC (rev 77462)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/load/metric/impl/ReceiveTrafficLoadMetric.java 2008-08-25 23:09:16 UTC (rev 77463)
@@ -21,8 +21,6 @@
*/
package org.jboss.web.tomcat.service.modcluster.load.metric.impl;
-import java.util.List;
-
import javax.management.JMException;
import org.jboss.web.tomcat.service.modcluster.load.metric.LoadMetric;
@@ -31,32 +29,25 @@
* {@link LoadMetric} implementation that returns the incoming bandwidth in KB.
* @author Paul Ferraro
*/
-public class ReceiveTrafficLoadMetric extends DeterministicLoadMetric
+public class ReceiveTrafficLoadMetric extends MBeanAttributeLoadMetric
{
private static final String RECEIVE_COUNT = "bytesReceived";
+
+ private final DeterministicLoadState state = new DeterministicLoadState();
- private final RequestProcessorLoadMetricSource source;
-
public ReceiveTrafficLoadMetric(RequestProcessorLoadMetricSource source)
{
- this.source = source;
+ super(source, RECEIVE_COUNT);
}
/**
* @{inheritDoc}
- * @see org.jboss.web.tomcat.service.modcluster.load.metric.impl.DeterministicLoadMetric#getDeterministicMetric()
+ * @see org.jboss.web.tomcat.service.modcluster.load.metric.impl.MBeanAttributeLoadMetric#getLoad()
*/
- protected double getDeterministicMetric() throws JMException
+ @Override
+ public double getLoad() throws JMException
{
- long bytes = 0;
-
- List<Long> results = this.source.getAttributes(RECEIVE_COUNT, Long.class);
-
- for (Long result: results)
- {
- bytes += result.longValue();
- }
-
- return bytes * 1000;
+ // Convert to KB/sec
+ return this.state.delta(super.getLoad() * 1000);
}
}
Modified: trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/load/metric/impl/RequestCountLoadMetric.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/load/metric/impl/RequestCountLoadMetric.java 2008-08-25 23:07:18 UTC (rev 77462)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/load/metric/impl/RequestCountLoadMetric.java 2008-08-25 23:09:16 UTC (rev 77463)
@@ -21,8 +21,6 @@
*/
package org.jboss.web.tomcat.service.modcluster.load.metric.impl;
-import java.util.List;
-
import javax.management.JMException;
import org.jboss.web.tomcat.service.modcluster.load.metric.LoadMetric;
@@ -32,32 +30,24 @@
*
* @author Paul Ferraro
*/
-public class RequestCountLoadMetric extends DeterministicLoadMetric
+public class RequestCountLoadMetric extends MBeanAttributeLoadMetric
{
private static final String REQUEST_COUNT = "requestCount";
- private final RequestProcessorLoadMetricSource source;
+ private final DeterministicLoadState state = new DeterministicLoadState();
public RequestCountLoadMetric(RequestProcessorLoadMetricSource source)
{
- this.source = source;
+ super(source, REQUEST_COUNT);
}
/**
* @{inheritDoc}
- * @see org.jboss.web.tomcat.service.modcluster.load.metric.impl.DeterministicLoadMetric#getDeterministicMetric()
+ * @see org.jboss.web.tomcat.service.modcluster.load.metric.impl.MBeanAttributeLoadMetric#getLoad()
*/
- protected double getDeterministicMetric() throws JMException
+ @Override
+ public double getLoad() throws JMException
{
- int count = 0;
-
- List<Integer> results = this.source.getAttributes(REQUEST_COUNT, Integer.class);
-
- for (Integer result: results)
- {
- count += result.intValue();
- }
-
- return count;
+ return this.state.delta(super.getLoad());
}
}
Modified: trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/load/metric/impl/RequestProcessorLoadMetricSource.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/load/metric/impl/RequestProcessorLoadMetricSource.java 2008-08-25 23:07:18 UTC (rev 77462)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/load/metric/impl/RequestProcessorLoadMetricSource.java 2008-08-25 23:09:16 UTC (rev 77463)
@@ -32,7 +32,7 @@
*
* @author Paul Ferraro
*/
-public class RequestProcessorLoadMetricSource extends ObjectNamePatternLoadMetricSource
+public class RequestProcessorLoadMetricSource extends MBeanQueryLoadMetricSource
{
private static final String DEFAULT_PATTERN = "jboss.web:type=GlobalRequestProcessor,*";
@@ -46,6 +46,7 @@
{
super(registration, DEFAULT_PATTERN);
}
+
/**
* Create a new GlobalRequestProcessorLoadMetricSource.
*
Modified: trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/load/metric/impl/SendTrafficLoadMetric.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/load/metric/impl/SendTrafficLoadMetric.java 2008-08-25 23:07:18 UTC (rev 77462)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/load/metric/impl/SendTrafficLoadMetric.java 2008-08-25 23:09:16 UTC (rev 77463)
@@ -21,8 +21,6 @@
*/
package org.jboss.web.tomcat.service.modcluster.load.metric.impl;
-import java.util.List;
-
import javax.management.JMException;
import org.jboss.web.tomcat.service.modcluster.load.metric.LoadMetric;
@@ -32,32 +30,25 @@
*
* @author Paul Ferraro
*/
-public class SendTrafficLoadMetric extends DeterministicLoadMetric
+public class SendTrafficLoadMetric extends MBeanAttributeLoadMetric
{
private static final String SEND_COUNT = "bytesSent";
- private final RequestProcessorLoadMetricSource source;
+ private final DeterministicLoadState state = new DeterministicLoadState();
public SendTrafficLoadMetric(RequestProcessorLoadMetricSource source)
{
- this.source = source;
+ super(source, SEND_COUNT);
}
/**
* @{inheritDoc}
- * @see org.jboss.web.tomcat.service.modcluster.load.metric.impl.DeterministicLoadMetric#getDeterministicMetric()
+ * @see org.jboss.web.tomcat.service.modcluster.load.metric.impl.MBeanAttributeLoadMetric#getLoad()
*/
- protected double getDeterministicMetric() throws JMException
+ @Override
+ public double getLoad() throws JMException
{
- long bytes = 0;
-
- List<Long> results = this.source.getAttributes(SEND_COUNT, Long.class);
-
- for (Long result: results)
- {
- bytes += result.longValue();
- }
-
- return bytes;
+ // Convert to KB/sec
+ return this.state.delta(super.getLoad() * 1000);
}
}
Modified: trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/load/metric/impl/SessionLoadMetricSource.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/load/metric/impl/SessionLoadMetricSource.java 2008-08-25 23:07:18 UTC (rev 77462)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/load/metric/impl/SessionLoadMetricSource.java 2008-08-25 23:09:16 UTC (rev 77463)
@@ -32,7 +32,7 @@
*
* @author Paul Ferraro
*/
-public class SessionLoadMetricSource extends ObjectNamePatternLoadMetricSource
+public class SessionLoadMetricSource extends MBeanQueryLoadMetricSource
{
private static final String DEFAULT_PATTERN = "jboss.web:type=Manager,*";
Modified: trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/load/metric/impl/ThreadPoolLoadMetricSource.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/load/metric/impl/ThreadPoolLoadMetricSource.java 2008-08-25 23:07:18 UTC (rev 77462)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/load/metric/impl/ThreadPoolLoadMetricSource.java 2008-08-25 23:09:16 UTC (rev 77463)
@@ -32,7 +32,7 @@
*
* @author Paul Ferraro
*/
-public class ThreadPoolLoadMetricSource extends ObjectNamePatternLoadMetricSource
+public class ThreadPoolLoadMetricSource extends MBeanQueryLoadMetricSource
{
private static final String DEFAULT_PATTERN = "jboss.web:type=ThreadPool,*";
More information about the jboss-cvs-commits
mailing list