[jboss-cvs] JBossAS SVN: r77040 - 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
Wed Aug 13 17:20:09 EDT 2008
Author: pferraro
Date: 2008-08-13 17:20:09 -0400 (Wed, 13 Aug 2008)
New Revision: 77040
Added:
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/SessionLoadMetricSource.java
Log:
[JBAS-5667] LoadMetricSource impl for gathering JBossWeb session metrics
Added: 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 (rev 0)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/load/metric/impl/ActiveSessionsLoadMetric.java 2008-08-13 21:20:09 UTC (rev 77040)
@@ -0,0 +1,62 @@
+/*
+ * 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.JMException;
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+
+/**
+ * @author Paul Ferraro
+ *
+ */
+public class ActiveSessionsLoadMetric extends AbstractLoadMetric
+{
+ private static final String ACTIVE_SESSIONS = "activeSessions";
+
+ private final SessionLoadMetricSource source;
+
+ public ActiveSessionsLoadMetric(SessionLoadMetricSource source)
+ {
+ this.source = source;
+
+ source.add(this);
+ }
+
+ /**
+ * @{inheritDoc}
+ * @see org.jboss.web.tomcat.service.modcluster.load.metric.LoadMetric#getMetric()
+ */
+ public double getMetric() throws JMException
+ {
+ int active = 0;
+
+ MBeanServer server = this.source.getServer();
+
+ for (ObjectName name: this.source.getObjectNames())
+ {
+ active += ((Integer) server.getAttribute(name, ACTIVE_SESSIONS)).intValue();
+ }
+
+ return active;
+ }
+}
Added: 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 (rev 0)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/service/modcluster/load/metric/impl/SessionLoadMetricSource.java 2008-08-13 21:20:09 UTC (rev 77040)
@@ -0,0 +1,51 @@
+/*
+ * 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 org.jboss.web.tomcat.service.modcluster.load.metric.LoadMetricSourceRegistration;
+
+/**
+ * @author Paul Ferraro
+ *
+ */
+public class SessionLoadMetricSource extends ObjectNamePatternLoadMetricSource
+{
+ /**
+ * Create a new SessionLoadMetricSource.
+ *
+ * @param registration
+ */
+ public SessionLoadMetricSource(LoadMetricSourceRegistration registration)
+ {
+ super(registration);
+ }
+
+ /**
+ * @{inheritDoc}
+ * @see org.jboss.web.tomcat.service.modcluster.load.metric.impl.ObjectNamePatternLoadMetricSource#defaultObjectNamePattern()
+ */
+ @Override
+ protected String defaultObjectNamePattern()
+ {
+ return "Catalina:type=Manager,path=*,host=*";
+ }
+}
More information about the jboss-cvs-commits
mailing list