[jboss-cvs] JBossAS SVN: r77397 - 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 00:05:19 EDT 2008
Author: pferraro
Date: 2008-08-25 00:05:18 -0400 (Mon, 25 Aug 2008)
New Revision: 77397
Added:
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
Log:
Added load metric for connection pool usage.
Added: 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 (rev 0)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/load/metric/impl/ConnectionPoolLoadMetricSource.java 2008-08-25 04:05:18 UTC (rev 77397)
@@ -0,0 +1,84 @@
+/*
+ * 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.web.tomcat.service.modcluster.load.metric.impl;
+
+import javax.management.MBeanServer;
+import javax.management.MalformedObjectNameException;
+
+import org.jboss.web.tomcat.service.modcluster.load.metric.LoadMetricSourceRegistration;
+
+/**
+ * {@link LoadMetricSource} implementation that simplifies generic mbean access to
+ * a set of JBoss JCA connection pools.
+ */
+public class ConnectionPoolLoadMetricSource extends ObjectNamePatternLoadMetricSource
+{
+ private static final String DEFAULT_PATTERN = "jboss.jca:service=ManagedConnectionPool,*";
+
+ /**
+ * Create a new ConnectionPoolLoadMetricSource.
+ *
+ * @param registration
+ * @param server
+ * @throws MalformedObjectNameException
+ */
+ public ConnectionPoolLoadMetricSource(LoadMetricSourceRegistration registration, MBeanServer server) throws MalformedObjectNameException
+ {
+ super(registration, DEFAULT_PATTERN, server);
+ }
+
+ /**
+ * Create a new ConnectionPoolLoadMetricSource.
+ *
+ * @param registration
+ * @param pattern
+ * @param server
+ * @throws MalformedObjectNameException
+ */
+ public ConnectionPoolLoadMetricSource(LoadMetricSourceRegistration registration, String pattern, MBeanServer server) throws MalformedObjectNameException
+ {
+ super(registration, pattern, server);
+ }
+
+ /**
+ * Create a new ConnectionPoolLoadMetricSource.
+ *
+ * @param registration
+ * @throws MalformedObjectNameException
+ */
+ public ConnectionPoolLoadMetricSource(LoadMetricSourceRegistration registration) throws MalformedObjectNameException
+ {
+ super(registration, DEFAULT_PATTERN);
+ }
+
+ /**
+ * Create a new ConnectionPoolLoadMetricSource.
+ *
+ * @param registration
+ * @param pattern
+ * @throws MalformedObjectNameException
+ */
+ public ConnectionPoolLoadMetricSource(LoadMetricSourceRegistration registration, String pattern) throws MalformedObjectNameException
+ {
+ super(registration, pattern);
+ }
+}
Added: 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 (rev 0)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/load/metric/impl/ConnectionPoolUsageLoadMetric.java 2008-08-25 04:05:18 UTC (rev 77397)
@@ -0,0 +1,81 @@
+/*
+ * 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.web.tomcat.service.modcluster.load.metric.impl;
+
+import java.util.List;
+
+/**
+ * {@link LoadMetric} implementation that returns the usage ratio of a connection pool.
+ *
+ * @author Paul Ferraro
+ */
+public class ConnectionPoolUsageLoadMetric extends AbstractLoadMetric
+{
+ 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);
+ }
+
+ public ConnectionPoolUsageLoadMetric(ConnectionPoolLoadMetricSource source, String usedAttribute, String maxAttribute)
+ {
+ this.source = source;
+
+ source.add(this);
+
+ this.usedAttribute = usedAttribute;
+ this.maxAttribute = 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;
+ }
+}
More information about the jboss-cvs-commits
mailing list