1 23 package com.sun.enterprise.iiop; 24 25 import java.util.Iterator ; 26 import java.util.logging.*; 27 28 import org.omg.CORBA.ORB ; 29 30 import com.sun.enterprise.server.ApplicationServer; 31 import com.sun.enterprise.server.ServerContext; 32 33 import com.sun.enterprise.admin.monitor.registry.MonitoringRegistry; 34 import com.sun.enterprise.admin.monitor.registry.MonitoringRegistrationException; 35 36 import com.sun.enterprise.admin.monitor.stats.OrbConnectionManagerStats; 37 import com.sun.enterprise.admin.monitor.stats.ThreadPoolStats; 38 39 import com.sun.corba.ee.spi.monitoring.MonitoringConstants; 40 import com.sun.corba.ee.spi.monitoring.MonitoringFactories; 41 import com.sun.corba.ee.spi.monitoring.MonitoringManager; 42 import com.sun.corba.ee.spi.monitoring.MonitoredObject; 43 44 import com.sun.logging.*; 45 46 47 53 54 55 public class ORBMonitoring { 56 static Logger _logger=LogDomains.getLogger(LogDomains.UTIL_LOGGER); 57 58 private ORB orb; 59 private MonitoringRegistry registry; 60 61 public ORBMonitoring(ORB orb) { 62 this.orb = orb; 63 registry = ApplicationServer.getServerContext().getMonitoringRegistry(); 64 registerOrbStatistics(); 65 } 66 67 public void registerOrbStatistics() { 68 69 registerThreadPoolStats(); 70 registerORBConnectionStats(); 71 } 72 73 79 private void registerThreadPoolStats() { 80 Iterator threadPoolsIterator; 81 MonitoredObject threadPoolRoot = 82 MonitoringFactories.getMonitoringManagerFactory().createMonitoringManager( 83 MonitoringConstants.DEFAULT_MONITORING_ROOT, null ). 84 getRootMonitoredObject(); 85 86 try { 87 MonitoredObject rootThreadPoolNode = threadPoolRoot.getChild( 88 MonitoringConstants.THREADPOOL_MONITORING_ROOT ); 89 90 threadPoolsIterator = rootThreadPoolNode.getChildren().iterator(); 91 } catch( Exception ex ) { 92 _logger.log( Level.WARNING, 93 "Unexpected exception caught when accessing ThreadPool Stats:", ex ); 94 return; 95 } 96 97 while( threadPoolsIterator.hasNext() ) { 98 MonitoredObject threadPool = (MonitoredObject) threadPoolsIterator.next(); 99 100 try { 101 ThreadPoolStats threadPoolStats = 102 new ThreadPoolStatsImpl( threadPool ); 103 104 registry.registerThreadPoolStats( threadPoolStats, 105 threadPoolRoot.getName() + 106 "." + MonitoringConstants.THREADPOOL_MONITORING_ROOT + 107 "." + threadPool.getName(), 108 null ); 109 } catch( MonitoringRegistrationException mex ) { 110 _logger.log( Level.WARNING, 112 "Unable to register ThreadPoolStats due to following exception ", mex ); 113 } catch( Exception ex ) { 114 _logger.log( Level.WARNING, 116 "Unexpected exception caught when registring ThreadPoolStats", ex ); 117 } 118 } 119 } 121 122 128 private void registerORBConnectionStats() { 129 Iterator outboundConnectionListIterator; 130 Iterator inboundConnectionListIterator; 131 132 try { 133 com.sun.corba.ee.spi.orb.ORB internalORB = 134 (com.sun.corba.ee.spi.orb.ORB)orb ; 135 MonitoredObject orbRoot = 136 internalORB.getMonitoringManager().getRootMonitoredObject() ; 137 138 MonitoredObject rootConnectionNode = 139 orbRoot.getChild( MonitoringConstants.CONNECTION_MONITORING_ROOT ); 140 141 MonitoredObject rootOutboundConnections = 142 rootConnectionNode.getChild( 143 MonitoringConstants.OUTBOUND_CONNECTION_MONITORING_ROOT ); 144 MonitoredObject rootInboundConnections = 145 rootConnectionNode.getChild( 146 MonitoringConstants.INBOUND_CONNECTION_MONITORING_ROOT ); 147 148 if( rootOutboundConnections != null ) { 149 outboundConnectionListIterator = 150 rootOutboundConnections.getChildren().iterator(); 151 152 while( outboundConnectionListIterator.hasNext() ) { 153 MonitoredObject outboundConnection = 154 (MonitoredObject) outboundConnectionListIterator.next(); 155 156 try { 157 OrbConnectionManagerStats connectionManagerStats = 158 new OrbConnectionManagerStatsImpl( outboundConnection ); 159 160 registry.registerOrbConnectionManagerStats( connectionManagerStats, 161 orbRoot.getName() + 162 "." + MonitoringConstants.CONNECTION_MONITORING_ROOT + 163 "." + MonitoringConstants.OUTBOUND_CONNECTION_MONITORING_ROOT + 164 "." + outboundConnection.getName(), 165 null ); 166 167 } catch( MonitoringRegistrationException mex ) { 168 _logger.log( Level.WARNING, 170 "Unable to register Outbound ORB Connections - ", mex ); 171 } catch( Exception ex ) { 172 _logger.log( Level.WARNING, 174 "Unexpected exception caught when registering Outbound ORB Connections", ex ); 175 } 176 } 177 } 178 179 if( rootInboundConnections != null ) { 180 inboundConnectionListIterator = 181 rootInboundConnections.getChildren().iterator(); 182 183 while( inboundConnectionListIterator.hasNext() ) { 184 MonitoredObject inboundConnection = 185 (MonitoredObject) inboundConnectionListIterator.next(); 186 187 try { 188 OrbConnectionManagerStats connectionManagerStats = 189 new OrbConnectionManagerStatsImpl( inboundConnection ); 190 191 registry.registerOrbConnectionManagerStats( connectionManagerStats, 192 orbRoot.getName() + 193 "." + MonitoringConstants.CONNECTION_MONITORING_ROOT + 194 "." + MonitoringConstants.INBOUND_CONNECTION_MONITORING_ROOT + 195 "." + inboundConnection.getName(), 196 null ); 197 } catch( MonitoringRegistrationException mex ) { 198 _logger.log( Level.WARNING, 200 "Unable to register Inbound ORB Connections - ", mex ); 201 } catch( Exception ex ) { 202 _logger.log( Level.WARNING, 204 "Unexpected exception caught when registering Inbound ORB Connections", ex ); 205 } 206 } } 209 } catch( Exception ex ) { 210 _logger.log( Level.WARNING, 211 "Unexpected exception caught when accessing ORB Connection Stats:", ex ); 212 return; 213 } 214 215 216 } 218 } | Popular Tags |