User: schaefera
Date: 01/07/20 13:07:16
Modified: src/main/org/jboss/management DataCollector.java
EJBDataCollector.java JDBCDataCollector.java
JNDIDataCollector.java MailDataCollector.java
NodeDataCollector.java ServerDataCollector.java
ServerDataCollectorMBean.java
Log:
Added Statistics Gathering for Entity Beans according to the JBoss
Management. The main idea is to add StatisticsProvider Interface to
all components delivering this data.
Revision Changes Path
1.3 +26 -7 jboss/src/main/org/jboss/management/DataCollector.java
Index: DataCollector.java
===================================================================
RCS file: /cvsroot/jboss/jboss/src/main/org/jboss/management/DataCollector.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- DataCollector.java 2001/06/18 20:01:27 1.2
+++ DataCollector.java 2001/07/20 20:07:16 1.3
@@ -11,6 +11,8 @@
import javax.management.MBeanServer;
import management.J2EEManagedObject;
+import management.StatisticsProvider;
+import management.Stats;
/**
* Collector Interface which must be implemented by
@@ -18,7 +20,7 @@
*
* @author <a href="mailto:[EMAIL PROTECTED]">Marc Fleury</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Andreas Schaefer</a>
- * @version $Revision: 1.2 $
+ * @version $Revision: 1.3 $
**/
public interface DataCollector {
@@ -27,12 +29,29 @@
// -------------------------------------------------------------------------
/**
- * Is called when the data must be refreshed
- *
- * @param pServer MBean Server is used to get the information about the server
- *
- * @return Collection of elements found (must be of type J2EEManagedObject)
- **/
+ * Is called when the data must be refreshed
+ *
+ * @param pServer MBean Server is used to get the information about the server
+ *
+ * @return Collection of elements found (must be of type J2EEManagedObject)
+ **/
public Collection refresh( MBeanServer pServer );
+
+ /**
+ * Returns the statistics for the given Statistics Provider
+ *
+ * @param pProvider Provider of the statistics
+ * @param pServer MBean Server is used to get the information about the server
+ * @return Information about the JVM this application server is running on
+ */
+ public Stats getStatistics( StatisticsProvider pProvider, MBeanServer pServer );
+
+ /**
+ * Resets the statiscs provider
+ *
+ * @param pProvider Statistics Provider to be reset
+ * @param pServer MBean Server is used to get the information about the server
+ **/
+ public void resetStatistics( StatisticsProvider pProvider, MBeanServer pServer );
}
1.3 +78 -7 jboss/src/main/org/jboss/management/EJBDataCollector.java
Index: EJBDataCollector.java
===================================================================
RCS file: /cvsroot/jboss/jboss/src/main/org/jboss/management/EJBDataCollector.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- EJBDataCollector.java 2001/06/18 20:01:27 1.2
+++ EJBDataCollector.java 2001/07/20 20:07:16 1.3
@@ -10,12 +10,15 @@
import java.util.Collection;
import java.util.Hashtable;
import java.util.Iterator;
+import java.util.Map;
import javax.management.MBeanServer;
import javax.management.ObjectName;
import org.jboss.ejb.Container;
+import org.jboss.ejb.EntityContainer;
import org.jboss.ejb.StatefulSessionContainer;
+import org.jboss.monitor.StatisticsProvider;
import org.jboss.management.JBossEjbModule;
import org.jboss.management.JBossEntityBean;
@@ -24,18 +27,31 @@
import org.jboss.management.JBossStatefulSessionBean;
import org.jboss.management.JBossStatelessSessionBean;
+import management.CountStatistic;
import management.EjbModule;
import management.EJB;
+import management.EntityBean;
+import management.EntityBeanStats;
import management.J2EEApplication;
import management.J2EEModule;
+import management.Statistic;
+import management.Stats;
+import management.TimeStatistic;
/**
- * JDBC Data Collector
- *
- * @author <a href="mailto:[EMAIL PROTECTED]">Marc Fleury</a>
- * @author <a href="mailto:[EMAIL PROTECTED]">Andreas Schaefer</a>
- * @version $Revision: 1.2 $
- **/
+* EJB Data Collector collects the management data about EJBs.
+*
+* @author <a href="mailto:[EMAIL PROTECTED]">Marc Fleury</a>
+* @author <a href="mailto:[EMAIL PROTECTED]">Andreas Schaefer</a>
+* @version $Revision: 1.3 $
+*
+* <p><b>Revisions:</b>
+* <p><b>20010718 andreas schaefer:</b>
+* <ul>
+* <li>- Create the data collector
+* <li>- Added Statistics Gathering
+* </ul>
+**/
public class EJBDataCollector
implements DataCollector
{
@@ -63,6 +79,7 @@
// -------------------------------------------------------------------------
public Collection refresh( MBeanServer pServer ) {
+ System.err.println( "EJBDataCollector.refresh(), start <<<<================"
);
Collection lReturn = new ArrayList();
try {
// Look up all the registered Containers for the EJB Module and loop
through
@@ -70,7 +87,8 @@
Iterator i = pServer.queryNames( new ObjectName( "Management:*" ), null
).iterator();
while( i.hasNext() ) {
ObjectName lName = (ObjectName) i.next();
- if( lName.getKeyProperty( "container" ) == null ) {
+ System.err.println( "===>>> Got Object Name: " + lName );
+ if( lName.getKeyProperty( "jndiName" ) == null ) {
continue;
}
Container lContainer = (Container) pServer.getAttribute( lName,
"Container" );
@@ -99,6 +117,14 @@
if( lContainer.getBeanMetaData().isMessageDriven() ) {
lBeans.add( new JBossMessageDrivenBean(
lContainer.getBeanMetaData().getEjbName() ) );
}
+ System.out.println( "==>> Tries to get statistics" );
+ // Only to test the Statistics Gathering
+ if( lContainer instanceof EntityContainer ) {
+ Map lStatistics = ( (EntityContainer) lContainer
).retrieveStatistic();
+ if( lStatistics != null ) {
+ System.out.println( "==>> Statistics: " + lStatistics );
+ }
+ }
}
i = lApplications.keySet().iterator();
while( i.hasNext() ) {
@@ -122,4 +148,49 @@
}
return lReturn;
}
+
+ public Stats getStatistics( management.StatisticsProvider pProvider, MBeanServer
pServer )
+ {
+ try {
+ if( pProvider instanceof EJB )
+ {
+ if( pProvider instanceof EntityBean ) {
+ EntityBean lBean = (EntityBean) pProvider;
+ Iterator i = pServer.queryNames( new ObjectName( "Management:container" +
lBean.getName() ), null ).iterator();
+ if( i.hasNext() )
+ {
+ ObjectName lName = (ObjectName) i.next();
+ StatisticsProvider lContainer = (StatisticsProvider)
pServer.getAttribute(
+ lName,
+ "Container"
+ );
+ Map lStatistics = lContainer.retrieveStatistic();
+ return new EntityBeanStats(
+ (CountStatistic) lStatistics.get( "ReadyBeanCount" ),
+ (CountStatistic) lStatistics.get( "BeanPoolSize" ),
+ (CountStatistic) lStatistics.get( "InstatiationCount" ),
+ (CountStatistic) lStatistics.get( "DestroyCount" ),
+ (CountStatistic) lStatistics.get( "CreateCount" ),
+ (CountStatistic) lStatistics.get( "RemoveCount" ),
+ (TimeStatistic[]) lStatistics.get( "MethodStatistics" ),
+ (TimeStatistic) lStatistics.get( "LoadTime" ),
+ (TimeStatistic) lStatistics.get( "StoreTime" ),
+ (CountStatistic) lStatistics.get( "ActiveBeanCount" ),
+ (TimeStatistic) lStatistics.get( "ActivationTime" ),
+ (TimeStatistic) lStatistics.get( "PassivationTime" )
+ );
+ }
+ }
+ }
+ }
+ catch( Exception e )
+ {
+ e.printStackTrace();
+ }
+ return null;
+ }
+
+ public void resetStatistics( management.StatisticsProvider pProvider, MBeanServer
pServer )
+ {
+ }
}
1.3 +11 -1 jboss/src/main/org/jboss/management/JDBCDataCollector.java
Index: JDBCDataCollector.java
===================================================================
RCS file: /cvsroot/jboss/jboss/src/main/org/jboss/management/JDBCDataCollector.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- JDBCDataCollector.java 2001/06/18 20:01:27 1.2
+++ JDBCDataCollector.java 2001/07/20 20:07:16 1.3
@@ -21,13 +21,15 @@
import management.JDBC;
import management.JDBCConnectionPool;
import management.JDBCDriver;
+import management.StatisticsProvider;
+import management.Stats;
/**
* JDBC Data Collector
*
* @author <a href="mailto:[EMAIL PROTECTED]">Marc Fleury</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Andreas Schaefer</a>
- * @version $Revision: 1.2 $
+ * @version $Revision: 1.3 $
**/
public class JDBCDataCollector
implements DataCollector
@@ -90,4 +92,12 @@
return lReturn;
}
+ public Stats getStatistics( StatisticsProvider pProvider, MBeanServer pServer )
+ {
+ return null;
+ }
+
+ public void resetStatistics( StatisticsProvider pProvider, MBeanServer pServer )
+ {
+ }
}
1.3 +11 -1 jboss/src/main/org/jboss/management/JNDIDataCollector.java
Index: JNDIDataCollector.java
===================================================================
RCS file: /cvsroot/jboss/jboss/src/main/org/jboss/management/JNDIDataCollector.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- JNDIDataCollector.java 2001/06/18 20:01:27 1.2
+++ JNDIDataCollector.java 2001/07/20 20:07:16 1.3
@@ -18,13 +18,15 @@
import org.jboss.management.JBossJNDI;
import management.JNDI;
+import management.StatisticsProvider;
+import management.Stats;
/**
* JNDI Data Collector
*
* @author <a href="mailto:[EMAIL PROTECTED]">Marc Fleury</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Andreas Schaefer</a>
- * @version $Revision: 1.2 $
+ * @version $Revision: 1.3 $
**/
public class JNDIDataCollector
implements DataCollector
@@ -79,4 +81,12 @@
return lReturn;
}
+ public Stats getStatistics( StatisticsProvider pProvider, MBeanServer pServer )
+ {
+ return null;
+ }
+
+ public void resetStatistics( StatisticsProvider pProvider, MBeanServer pServer )
+ {
+ }
}
1.3 +11 -1 jboss/src/main/org/jboss/management/MailDataCollector.java
Index: MailDataCollector.java
===================================================================
RCS file: /cvsroot/jboss/jboss/src/main/org/jboss/management/MailDataCollector.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- MailDataCollector.java 2001/06/18 20:01:27 1.2
+++ MailDataCollector.java 2001/07/20 20:07:16 1.3
@@ -18,13 +18,15 @@
import org.jboss.management.JBossJavaMail;
import management.JavaMail;
+import management.StatisticsProvider;
+import management.Stats;
/**
* Mail Data Collector
*
* @author <a href="mailto:[EMAIL PROTECTED]">Marc Fleury</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Andreas Schaefer</a>
- * @version $Revision: 1.2 $
+ * @version $Revision: 1.3 $
**/
public class MailDataCollector
implements DataCollector
@@ -77,4 +79,12 @@
return lReturn;
}
+ public Stats getStatistics( StatisticsProvider pProvider, MBeanServer pServer )
+ {
+ return null;
+ }
+
+ public void resetStatistics( StatisticsProvider pProvider, MBeanServer pServer )
+ {
+ }
}
1.3 +11 -1 jboss/src/main/org/jboss/management/NodeDataCollector.java
Index: NodeDataCollector.java
===================================================================
RCS file: /cvsroot/jboss/jboss/src/main/org/jboss/management/NodeDataCollector.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- NodeDataCollector.java 2001/06/18 20:01:27 1.2
+++ NodeDataCollector.java 2001/07/20 20:07:16 1.3
@@ -24,13 +24,15 @@
import management.JVM;
import management.Node;
import management.Port;
+import management.StatisticsProvider;
+import management.Stats;
/**
* Node Data Collector
*
* @author <a href="mailto:[EMAIL PROTECTED]">Marc Fleury</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Andreas Schaefer</a>
- * @version $Revision: 1.2 $
+ * @version $Revision: 1.3 $
**/
public class NodeDataCollector
implements DataCollector
@@ -111,4 +113,12 @@
return lReturn;
}
+ public Stats getStatistics( StatisticsProvider pProvider, MBeanServer pServer )
+ {
+ return null;
+ }
+
+ public void resetStatistics( StatisticsProvider pProvider, MBeanServer pServer )
+ {
+ }
}
1.3 +33 -7 jboss/src/main/org/jboss/management/ServerDataCollector.java
Index: ServerDataCollector.java
===================================================================
RCS file:
/cvsroot/jboss/jboss/src/main/org/jboss/management/ServerDataCollector.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- ServerDataCollector.java 2001/06/18 20:01:27 1.2
+++ ServerDataCollector.java 2001/07/20 20:07:16 1.3
@@ -6,13 +6,18 @@
*/
package org.jboss.management;
+import java.beans.PropertyEditor;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.Map;
+import javax.management.Attribute;
+import javax.management.AttributeList;
import javax.management.MalformedObjectNameException;
+import javax.management.MBeanAttributeInfo;
+import javax.management.MBeanInfo;
import javax.management.MBeanServer;
import javax.management.ObjectName;
import javax.naming.Context;
@@ -27,14 +32,17 @@
import org.jboss.naming.NonSerializableFactory;
import org.jboss.util.ServiceMBeanSupport;
+import management.EJB;
import management.J2EEApplication;
+import management.StatisticsProvider;
+import management.Stats;
/**
* JBoss Management MBean Wrapper
*
* @author <a href="mailto:[EMAIL PROTECTED]">Marc Fleury</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Andreas Schaefer</a>
- * @version $Revision: 1.2 $
+ * @version $Revision: 1.3 $
**/
public class ServerDataCollector
extends ServiceMBeanSupport
@@ -58,6 +66,8 @@
private RefreshWorker mWorker;
private int mRefreshSleep = 2000;
+ private Map mCollectors = new Hashtable();
+
private Map mApplications = new Hashtable();
private Collection mResources = new ArrayList();
private Collection mNodes = new ArrayList();
@@ -73,7 +83,7 @@
**/
public ServerDataCollector()
{
- mName = null;
+ this( null );
}
/**
@@ -84,6 +94,12 @@
public ServerDataCollector( String pName )
{
mName = pName;
+ //AS Later on load this dynamically
+ mCollectors.put( "EJB", new EJBDataCollector() );
+ mCollectors.put( "JDBC", new JDBCDataCollector() );
+ mCollectors.put( "JNDI", new JNDIDataCollector() );
+ mCollectors.put( "Mail", new MailDataCollector() );
+ mCollectors.put( "Node", new NodeDataCollector() );
}
// -------------------------------------------------------------------------
@@ -196,6 +212,16 @@
}
}
*/
+ public Stats getStatistics( StatisticsProvider pProvider ) {
+ if( pProvider instanceof EJB ) {
+ return ( (DataCollector) mCollectors.get( "EJB" ) ).getStatistics( pProvider,
getServer() );
+ }
+ return null;
+ }
+
+ public void resetStatistics( StatisticsProvider pProvider ) {
+ ( (DataCollector) mCollectors.get( "EJB" ) ).resetStatistics( pProvider,
getServer() );
+ }
// -------------------------------------------------------------------------
// ServiceMBean - Methods
@@ -306,7 +332,7 @@
private void doRefresh() {
try {
mApplications = new Hashtable();
- Collection lApplications = new EJBDataCollector().refresh( mServer );
+ Collection lApplications = ( (DataCollector) mCollectors.get( "EJB" )
).refresh( mServer );
Iterator i = lApplications.iterator();
while( i.hasNext() ) {
J2EEApplication lApplication = (J2EEApplication) i.next();
@@ -322,28 +348,28 @@
mResources = new ArrayList();
try {
// Get the info about JDBCs
- mResources.addAll( new JDBCDataCollector().refresh( mServer ) );
+ mResources.addAll( ( (DataCollector) mCollectors.get( "JDBC" )
).refresh( mServer ) );
}
catch( Exception e ) {
e.printStackTrace();
}
try {
// Get the info about Mail
- mResources.addAll( new MailDataCollector().refresh( mServer ) );
+ mResources.addAll( ( (DataCollector) mCollectors.get( "Mail" )
).refresh( mServer ) );
}
catch( Exception e ) {
e.printStackTrace();
}
try {
// Get the info about JNDI
- mResources.addAll( new JNDIDataCollector().refresh( mServer ) );
+ mResources.addAll( ( (DataCollector) mCollectors.get( "JNDI" )
).refresh( mServer ) );
}
catch( Exception e ) {
e.printStackTrace();
}
try {
// Get the info about current nodes
- mNodes = new NodeDataCollector().refresh( mServer );
+ mNodes = ( (DataCollector) mCollectors.get( "Node" ) ).refresh( mServer
);
}
catch( Exception e ) {
e.printStackTrace();
1.3 +99 -71
jboss/src/main/org/jboss/management/ServerDataCollectorMBean.java
Index: ServerDataCollectorMBean.java
===================================================================
RCS file:
/cvsroot/jboss/jboss/src/main/org/jboss/management/ServerDataCollectorMBean.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- ServerDataCollectorMBean.java 2001/06/18 20:01:27 1.2
+++ ServerDataCollectorMBean.java 2001/07/20 20:07:16 1.3
@@ -1,9 +1,9 @@
/*
- * JBoss, the OpenSource EJB server
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
+* JBoss, the OpenSource EJB server
+*
+* Distributable under LGPL license.
+* See terms of license at gnu.org.
+*/
package org.jboss.management;
import java.util.Collection;
@@ -11,83 +11,96 @@
import org.jboss.util.ServiceMBean;
import management.J2EEApplication;
+import management.StatisticsProvider;
+import management.Stats;
/**
* This interface defines the manageable interface for the JBoss Server
* management object to be used as a JMX MBean.
*
- * @author <a href="mailto:[EMAIL PROTECTED]">Marc Fleury</a>
- * @author <a href="mailto:[EMAIL PROTECTED]">Andreas Schaefer</a>
- * @version $Revision: 1.2 $
- **/
+ * @author <a href="mailto:[EMAIL PROTECTED]"> Marc Fleury </a>
+ * @author <a href="mailto:[EMAIL PROTECTED]"> Andreas Schaefer </a>
+ * @created July 1, 2001
+ * @version $Revision: 1.3 $
+ */
public interface ServerDataCollectorMBean
- extends ServiceMBean
-{
- // -------------------------------------------------------------------------
- // Constants
- // -------------------------------------------------------------------------
-
- public static final String OBJECT_NAME = "J2EEManagement:service=J2EEServer";
-
- // -------------------------------------------------------------------------
- // Methods
- // -------------------------------------------------------------------------
+ extends ServiceMBean {
+ // -------------------------------------------------------------------------
+ // Constants
+ // -------------------------------------------------------------------------
+
+ public final static String OBJECT_NAME = "J2EEManagement:service=J2EEServer";
+
+ // -------------------------------------------------------------------------
+ // Methods
+ // -------------------------------------------------------------------------
+
+ /**
+ * @return Sleep period in milliseconds between to refresh cycles
+ */
+ public int getRefreshSleep();
+
+
+ /**
+ * Sets the Sleep time (in milliseconds) between two refresh cycles
+ *
+ * @param pSleep Sleep period in milliseconds
+ */
+ public void setRefreshSleep( int pSleep );
+
+
+ /**
+ * Informs this intance the environment changes and he should update its
+ * data
+ */
+ public void refresh();
+
+
+ /**
+ * Informs this intance the environment changes and he should update its
+ * data right NOW
+ */
+ public void refreshNow();
+
+
+ /**
+ * Returns an application if found with the given key.
+ *
+ * @param pApplicationId Id of the application to be retrieved
+ * @return Application if found or null if not
+ */
+ public J2EEApplication getApplication(
+ String pApplicationId
+ );
- /** @return Sleep period in milliseconds between to refresh cycles **/
- public int getRefreshSleep();
- /**
- * Sets the Sleep time (in milliseconds) between two refresh cycles
- *
- * @param pSleep Sleep period in milliseconds
- **/
- public void setRefreshSleep( int pSleep );
-
- /**
- * Informs this intance the environment changes and he should update its
- * data
- **/
- public void refresh();
- /**
- * Informs this intance the environment changes and he should update its
- * data right NOW
- **/
- public void refreshNow();
+ /**
+ * @return All the registered applications where the element is of type
+ * {@link org.jboss.mpg.Application Application}.
+ */
+ public Collection getApplications();
- /**
- * Returns an application if found with the given key.
- *
- * @param pApplicationId Id of the application to be retrieved
- *
- * @return Application if found or null if not
- **/
- public J2EEApplication getApplication(
- String pApplicationId
- );
- /**
- * @return All the registered applications where the element is of type
- * {@link org.jboss.mpg.Application Application}.
- **/
- public Collection getApplications();
-
- /**
- * @return All the registered resources of this server. All are of type
- * {@link management.J2EEResource J2EEResource}.
- **/
- public Collection getResources();
-
- /**
- * @return All the nodes of this server running. All are of type
- * {@link management.Node Node}.
- **/
- public Collection getNodes();
-
- /**
- * @return Information about the JVM this application server is running on
- **/
-// public void getJVM();
+ /**
+ * @return All the registered resources of this server. All are of type
+ * {@link management.J2EEResource J2EEResource}.
+ */
+ public Collection getResources();
+
+ /**
+ * @return All the nodes of this server running. All are of type
+ * {@link management.Node Node}.
+ */
+ public Collection getNodes();
+
+
+ /**
+ * @param pProvider Description of Parameter
+ * @return Information about the JVM this application server is running on
+ */
+// public void getJVM();
+
/* AS Is not used anymore
/**
* Saves the given application either by registering as new application
@@ -134,4 +147,19 @@
int pModuleId
);
*/
+ /**
+ * Returns the statistics for the given Statistics Provider
+ *
+ * @param pProvider Provider of the statistics
+ * @return Information about the JVM this application server is running on
+ */
+ public Stats getStatistics( StatisticsProvider pProvider );
+
+ /**
+ * Resets the statiscs provider
+ *
+ * @param pProvider Statistics Provider to be reset
+ **/
+ public void resetStatistics( StatisticsProvider pProvider );
}
+
_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/jboss-development