FileDocCategorySizeDatePackage
ORBMonitoring.javaAPI DocGlassfish v2 API9697Fri May 04 22:34:54 BST 2007com.sun.enterprise.iiop

ORBMonitoring

public class ORBMonitoring extends Object
This file provides for the registration of the ThreadPool and orb connection statistics capture.
author
Pramod Gopinath

Fields Summary
static Logger
_logger
private org.omg.CORBA.ORB
orb
private com.sun.enterprise.admin.monitor.registry.MonitoringRegistry
registry
Constructors Summary
public ORBMonitoring(org.omg.CORBA.ORB orb)


       
        this.orb = orb;
        registry = ApplicationServer.getServerContext().getMonitoringRegistry();
        registerOrbStatistics();
    
Methods Summary
private voidregisterORBConnectionStats()
This method is called to register the orb connection manager stats For each connection create an object that would be registerd with the admin framework.

        Iterator outboundConnectionListIterator;
        Iterator inboundConnectionListIterator;

        try {
	    com.sun.corba.ee.spi.orb.ORB internalORB = 
		(com.sun.corba.ee.spi.orb.ORB)orb ;
	    MonitoredObject orbRoot = 
		internalORB.getMonitoringManager().getRootMonitoredObject() ;

            MonitoredObject rootConnectionNode = 
                orbRoot.getChild( MonitoringConstants.CONNECTION_MONITORING_ROOT );
    
            MonitoredObject rootOutboundConnections =
                rootConnectionNode.getChild( 
                    MonitoringConstants.OUTBOUND_CONNECTION_MONITORING_ROOT );
            MonitoredObject rootInboundConnections =
                rootConnectionNode.getChild( 
                    MonitoringConstants.INBOUND_CONNECTION_MONITORING_ROOT );
             
            if( rootOutboundConnections != null ) {
                outboundConnectionListIterator = 
                    rootOutboundConnections.getChildren().iterator();

                while( outboundConnectionListIterator.hasNext() ) {
                    MonitoredObject outboundConnection = 
                        (MonitoredObject) outboundConnectionListIterator.next();

                    try {
                        OrbConnectionManagerStats connectionManagerStats = 
                            new OrbConnectionManagerStatsImpl( outboundConnection );

                        registry.registerOrbConnectionManagerStats( connectionManagerStats, 
			    orbRoot.getName() + 
                            "." + MonitoringConstants.CONNECTION_MONITORING_ROOT +
                            "." + MonitoringConstants.OUTBOUND_CONNECTION_MONITORING_ROOT +
                            "." + outboundConnection.getName(),
                            null );

                    } catch( MonitoringRegistrationException mex ) {
                        //TODO: localize these messages
                        _logger.log( Level.WARNING, 
                            "Unable to register Outbound ORB Connections - ", mex );
                    } catch( Exception ex ) {
                        //TODO: localize these messages
                        _logger.log( Level.WARNING, 
                            "Unexpected exception caught when registering Outbound ORB Connections", ex );
                    }
                } 
            } 

            if( rootInboundConnections != null ) {
                inboundConnectionListIterator = 
                    rootInboundConnections.getChildren().iterator();

                while( inboundConnectionListIterator.hasNext() ) {
                    MonitoredObject inboundConnection = 
                        (MonitoredObject) inboundConnectionListIterator.next();
        
                    try {
                        OrbConnectionManagerStats connectionManagerStats = 
                            new OrbConnectionManagerStatsImpl( inboundConnection );
        
                        registry.registerOrbConnectionManagerStats( connectionManagerStats, 
			    orbRoot.getName() + 
                            "." + MonitoringConstants.CONNECTION_MONITORING_ROOT +
                            "." + MonitoringConstants.INBOUND_CONNECTION_MONITORING_ROOT +
                            "." + inboundConnection.getName(),
                            null );
                    } catch( MonitoringRegistrationException mex ) {
                        //TODO: localize these messages
                        _logger.log( Level.WARNING, 
                            "Unable to register Inbound ORB Connections - ", mex );
                    } catch( Exception ex ) {
                        //TODO: localize these messages
                        _logger.log( Level.WARNING, 
                            "Unexpected exception caught when registering Inbound ORB Connections", ex );
                    }
                } //while()
            } //if()

        } catch( Exception ex ) {
            _logger.log( Level.WARNING, 
                "Unexpected exception caught when accessing ORB Connection Stats:", ex );
            return;
        } 


    
public voidregisterOrbStatistics()


        registerThreadPoolStats(); 
        registerORBConnectionStats(); 
    
private voidregisterThreadPoolStats()
This method is called to register the thread pool stats For each threadpool create an object that would be registerd with the admin framework.

        Iterator threadPoolsIterator;
	MonitoredObject threadPoolRoot = 
	    MonitoringFactories.getMonitoringManagerFactory().createMonitoringManager( 
		MonitoringConstants.DEFAULT_MONITORING_ROOT, null ).
		getRootMonitoredObject();

        try {
            MonitoredObject rootThreadPoolNode = threadPoolRoot.getChild(
                   MonitoringConstants.THREADPOOL_MONITORING_ROOT );

            threadPoolsIterator = rootThreadPoolNode.getChildren().iterator();
        } catch( Exception ex ) {
            _logger.log( Level.WARNING, 
                "Unexpected exception caught when accessing ThreadPool Stats:", ex );
            return;
        } 

        while( threadPoolsIterator.hasNext() ) {
            MonitoredObject threadPool = (MonitoredObject) threadPoolsIterator.next();

            try {
                ThreadPoolStats threadPoolStats = 
                    new ThreadPoolStatsImpl( threadPool );

                registry.registerThreadPoolStats( threadPoolStats, 
		    threadPoolRoot.getName() + 
                    "." + MonitoringConstants.THREADPOOL_MONITORING_ROOT +
                     "." + threadPool.getName(),
                    null );
            } catch( MonitoringRegistrationException mex ) {
                //TODO: localize these messages
                _logger.log( Level.WARNING, 
                    "Unable to register ThreadPoolStats due to following exception ", mex );
            } catch( Exception ex ) {
                //TODO: localize these messages
                _logger.log( Level.WARNING, 
                    "Unexpected exception caught when registring ThreadPoolStats", ex );
            }
        }