1 23 24 38 39 40 package com.sun.enterprise.admin.monitor.registry.spi; 41 42 import com.sun.enterprise.admin.monitor.registry.*; 43 import com.sun.enterprise.admin.monitor.stats.*; 44 import javax.management.*; 45 import javax.management.j2ee.statistics.*; 46 import java.util.*; 47 import java.util.logging.Logger ; 48 import com.sun.enterprise.admin.common.constant.AdminConstants; import com.sun.enterprise.util.i18n.StringManager; 50 import com.sun.enterprise.admin.event.AdminEventListenerRegistry; 52 import com.sun.enterprise.admin.monitor.jndi.JndiMBeanManager; 53 import com.sun.enterprise.admin.monitor.registry.spi.reconfig.MonitoringConfigurationHandler; 54 import com.sun.enterprise.admin.monitor.registry.spi.reconfig.DynamicReconfigurator; 55 import com.sun.enterprise.admin.monitor.registry.spi.reconfig.MonitoringConfigChangeListener; 56 import com.sun.enterprise.server.stats.JVMStatsImpl; 57 68 public class MonitoringRegistrationHelper implements MonitoringRegistry { 69 private static final Logger logger = Logger.getLogger(AdminConstants.kLoggerName); 70 private static final StringManager sm = StringManager.getManager(MonitoringRegistrationHelper.class); 71 private final MBeanServer mbeanserver; 72 Vector listeners = new Vector(); 73 private final ValueListMap objTypeListeners; 74 private static MonitoringRegistrationHelper mrh = new MonitoringRegistrationHelper(); 75 private final StatsHolder rootStatsHolder = 76 new StatsHolderImpl(MonitoredObjectType.ROOT.getTypeName(), MonitoredObjectType.ROOT); 77 78 private MonitoringRegistrationHelper(){ 79 mbeanserver = getMBeanServer(); 80 objTypeListeners = new ValueListMap(); 81 initialize(); AdminEventListenerRegistry.addMonitoringLevelChangeEventListener( 83 new MonitoringConfigChangeListener(new DynamicReconfigurator(objTypeListeners))); 84 } 85 86 90 public static MonitoringRegistrationHelper getInstance() { 91 return mrh; 92 } 93 94 private MBeanServer getMBeanServer() { 95 MBeanServer server=null; 96 ArrayList servers = MBeanServerFactory.findMBeanServer(null); 97 if(!servers.isEmpty()){ 98 server = (MBeanServer)servers.get(0); 99 } 100 else { 101 final String msg = sm.getString("gen.no_mbs"); 102 throw new NullPointerException (msg); 103 } 104 return server; 105 } 106 107 public void registerEJBCacheStats(EJBCacheStats cs, String ejb, 108 String module, String app, MonitoringLevelListener listener) 109 throws MonitoringRegistrationException { 110 StatsHolder currChild = null; 111 String dottedName = null; 112 final String name = MonitoredObjectType.BEAN_CACHE.getTypeName(); 113 114 if (cs == null || module == null || ejb == null) throw new IllegalArgumentException ("MRH:EjbCacheStats, module, ejb can't be null"); 116 addMonitoringLevelListener(listener); currChild = getEjb(app, module, ejb); 118 currChild = currChild.addChild(name, MonitoredObjectType.BEAN_CACHE); 119 currChild.setStats(cs); 120 currChild.setStatsClass(com.sun.enterprise.admin.monitor.stats.EJBCacheStats.class); 121 final ObjectName on = MonitoringObjectNames.getEjbCacheObjectName(ejb, module, app); 122 currChild.setObjectName(on); 123 currChild.setDottedName(DottedNameFactory.getEJBCacheDottedName(app, module,ejb)); 124 if (shouldRegisterMBean(MonitoredObjectType.BEAN_CACHE)) 125 currChild.registerMBean(); 126 } 127 128 public void unregisterEJBCacheStats(String ejb, String module, String app) 129 throws MonitoringRegistrationException { 130 131 StatsHolder currChild = null; 132 StatsHolder cacheNode = null; 133 final String name = MonitoredObjectType.BEAN_CACHE.getTypeName(); 134 currChild = getEjb(app, module, ejb); 135 assert (currChild != null) : "MRH:unregisterEJBCacheStats: method registerEJBCacheStats was never called"; 136 cacheNode = currChild.getChild(name); 137 cacheNode.unregisterMBean(); 138 currChild.removeChild(name); 139 } 140 141 142 public void registerEJBPoolStats(EJBPoolStats ps, String ejb, 143 String module, String app, MonitoringLevelListener listener) 144 throws MonitoringRegistrationException { 145 146 StatsHolder currChild = null; 147 String dottedName = null; 148 final String name = MonitoredObjectType.BEAN_POOL.getTypeName(); 149 150 if (ps == null || module == null || ejb == null) throw new IllegalArgumentException ("MRH:EjbPoolStats, module, ejb can't be null"); 152 153 addMonitoringLevelListener(listener); currChild = getEjb(app, module, ejb); 155 currChild = currChild.addChild(name, MonitoredObjectType.BEAN_POOL); 156 currChild.setStats(ps); 157 currChild.setStatsClass(com.sun.enterprise.admin.monitor.stats.EJBPoolStats.class); 158 final ObjectName on = MonitoringObjectNames.getEjbPoolObjectName(ejb, module, app); 159 currChild.setObjectName(on); 160 currChild.setDottedName(DottedNameFactory.getEJBPoolDottedName(app, module,ejb)); 161 if (shouldRegisterMBean(MonitoredObjectType.BEAN_POOL)) 162 currChild.registerMBean(); 163 } 164 165 public void unregisterEJBPoolStats(String ejb, String module, String app) 166 throws MonitoringRegistrationException { 167 168 StatsHolder currChild = null; 169 StatsHolder poolNode = null; 170 final String name = MonitoredObjectType.BEAN_POOL.getTypeName(); 171 currChild = getEjb(app, module, ejb); 172 assert (currChild != null) : "MRH:unregisterEJBPoolStats: method registerEJBPoolStats was never called"; 173 poolNode = currChild.getChild(name); 174 poolNode.unregisterMBean(); 175 currChild.removeChild(name); 176 } 177 178 public void registerEJBMethodStats(EJBMethodStats ms, String method, 179 String ejb, String module, String app, MonitoringLevelListener listener) 180 throws MonitoringRegistrationException { 181 182 StatsHolder currChild = null; 183 String dottedName = null; 184 185 if (ms == null || module == null || ejb == null) throw new IllegalArgumentException ("MRH:EjbMethodStats, module, ejb can't be null"); 187 188 addMonitoringLevelListener(listener); currChild = getEjbMethods(app, module, ejb); 190 currChild = currChild.addChild(method, MonitoredObjectType.BEAN_METHOD); 191 currChild.setStats(ms); 192 currChild.setStatsClass(com.sun.enterprise.admin.monitor.stats.EJBMethodStats.class); 193 final ObjectName on = MonitoringObjectNames.getEjbMethodObjectName(method, ejb, module, app); 194 currChild.setObjectName(on); 195 currChild.setDottedName(DottedNameFactory.getEJBMethodDottedName(app, module, ejb, method)); 196 if (shouldRegisterMBean(MonitoredObjectType.BEAN_METHOD)) 197 currChild.registerMBean(); 198 } 199 200 public void unregisterEJBMethodStats(String method, String ejb, 201 String module, String app) throws MonitoringRegistrationException { 202 203 if ( method == null || ejb == null || module == null) 204 throw new IllegalArgumentException ("MRH: unregister method called with null arguments"); 205 StatsHolder currChild = null; 206 StatsHolder methodNode = null; 207 currChild = getEjbMethods(app, module, ejb); 208 assert (currChild != null) : "Serious: EjbMethodsNode is not created at all"; 209 methodNode = currChild.getChild(method); 210 assert (methodNode != null) : "MRH:unregisterEJBMethodStats - methodNode null"; 211 methodNode.unregisterMBean(); 212 currChild.removeChild(method); 213 } 214 215 private void registerAnyEjbStats(EJBStats es, MonitoredObjectType ejbType, 216 String ejb, String module, String app, MonitoringLevelListener listener) 217 throws MonitoringRegistrationException { 218 StatsHolder currChild = null; 219 String dottedName = null; 220 221 if (es == null || module == null || ejb == null) throw new IllegalArgumentException ("MRH:registerEntityBeanStats, module, ejb can't be null"); 223 224 addMonitoringLevelListener(listener); currChild = getEjb(app, module, ejb); 226 assert (currChild != null) : "MRH:registerEntityBeanStats - Serious: EjbNode is null"; 227 currChild.setStats(es); 228 this.setEjbStatsClass(currChild, ejbType); 229 currChild.setType(ejbType); 231 final ObjectName on = MonitoringObjectNames.getEjbObjectName(ejb, module, app); 232 currChild.setObjectName(on); 233 currChild.setDottedName(DottedNameFactory.getEJBDottedName(app, module, ejb)); 234 if (shouldRegisterMBean(ejbType)) 235 currChild.registerMBean(); 236 } 237 private void setEjbStatsClass(StatsHolder s, MonitoredObjectType t) { 238 assert (t == MonitoredObjectType.ENTITY_BEAN || 239 t == MonitoredObjectType.STATEFUL_BEAN || 240 t == MonitoredObjectType.STATELESS_BEAN || 241 t == MonitoredObjectType.MESSAGE_DRIVEN_BEAN) : "Invalid Ejb Type: " + t.getTypeName(); 242 if (t == MonitoredObjectType.ENTITY_BEAN) 243 s.setStatsClass(javax.management.j2ee.statistics.EntityBeanStats .class); 244 else if (t == MonitoredObjectType.STATEFUL_BEAN) 245 s.setStatsClass(javax.management.j2ee.statistics.StatefulSessionBeanStats .class); 246 else if (t == MonitoredObjectType.STATELESS_BEAN) 247 s.setStatsClass(javax.management.j2ee.statistics.StatelessSessionBeanStats .class); 248 else 249 s.setStatsClass(javax.management.j2ee.statistics.MessageDrivenBeanStats .class); 250 } 251 252 private void unregisterAnyEjbStats(String ejb, String module, String app) 253 throws MonitoringRegistrationException { 254 if (module == null || ejb == null) throw new IllegalArgumentException ("MRH: UnregisterEntityBeanStats, method and ejb name should be non-null"); 256 final StatsHolder ejbRoot = getEjbRootNode(app, module); 257 assert (ejbRoot != null) : "MRH:unregisterEntityBeanStats: method registerEntityBeanStats was never called"; 258 final StatsHolder ejbNode = ejbRoot.getChild(ejb); 259 assert (ejbNode != null) : "MRH:unregisterEntityBeanStats: null node received for ejb: " + ejb; 260 ejbNode.removeAllChildren(); 261 ejbNode.unregisterMBean(); 262 ejbRoot.removeChild(ejb); 263 } 264 265 public void registerEntityBeanStats(EntityBeanStats es, String ejb, 266 String module, String app, MonitoringLevelListener listener) 267 throws MonitoringRegistrationException { 268 this.registerAnyEjbStats(es, MonitoredObjectType.ENTITY_BEAN, ejb, module, app, listener); 269 } 270 271 public void unregisterEntityBeanStats(String ejb, String module, 272 String app) throws MonitoringRegistrationException { 273 this.unregisterAnyEjbStats(ejb, module, app); 274 } 275 276 public void registerStatefulSessionBeanStats(StatefulSessionBeanStats ss, 277 String ejb, String module, String app, MonitoringLevelListener listener) 278 throws MonitoringRegistrationException { 279 this.registerAnyEjbStats(ss, MonitoredObjectType.STATEFUL_BEAN, ejb, module, app, listener); 280 } 281 282 public void unregisterStatefulSessionBeanStats(String ejb, String module, 283 String app) throws MonitoringRegistrationException { 284 this.unregisterAnyEjbStats(ejb, module, app); 285 } 286 287 public void registerStatelessSessionBeanStats(StatelessSessionBeanStats ss, 288 String ejb, String module, String app, MonitoringLevelListener listener) 289 throws MonitoringRegistrationException { 290 this.registerAnyEjbStats(ss, MonitoredObjectType.STATELESS_BEAN, ejb, module, app, listener); 291 } 292 293 public void unregisterStatelessSessionBeanStats(String ejb, String module, 294 String app) throws MonitoringRegistrationException { 295 this.unregisterAnyEjbStats(ejb, module, app); 296 } 297 298 public void registerMessageDrivenBeanStats(MessageDrivenBeanStats ms, 299 String ejb, String module, String app, MonitoringLevelListener listener) 300 throws MonitoringRegistrationException { 301 this.registerAnyEjbStats(ms, MonitoredObjectType.MESSAGE_DRIVEN_BEAN, ejb, module, app, listener); 302 } 303 304 public void unregisterMessageDrivenBeanStats(String ejb, String module, 305 String app) throws MonitoringRegistrationException { 306 this.unregisterAnyEjbStats(ejb, module, app); 307 } 308 309 private void registerConnectionPoolStats(ConnectionPoolStats ps, String name, 310 MonitoredObjectType type, MonitoringLevelListener listener) 311 throws MonitoringRegistrationException { 312 assert (type == MonitoredObjectType.JDBC_CONN_POOL || type == MonitoredObjectType.CONNECTOR_CONN_POOL) : "MRH:registerConnectionPool - type is invalid"; 313 if (name == null || ps == null) 314 throw new IllegalArgumentException ("MRH:registerConnectionPoolStats - null name"); 315 final StatsHolder resourcesNode = rootStatsHolder.getChild(MonitoredObjectType.RESOURCES.getTypeName()); 316 assert (resourcesNode != null) : "MRH: registerConnectionPoolStats - Resources top-level node not registered"; 317 final StatsHolder added = resourcesNode.addChild(name, type); 318 assert (added != null) : "Connection Pool Addtion Error: " + name; 319 added.setStats(ps); 320 if (type == MonitoredObjectType.JDBC_CONN_POOL) 321 added.setStatsClass(com.sun.enterprise.admin.monitor.stats.JDBCConnectionPoolStats.class); 322 else 323 added.setStatsClass(com.sun.enterprise.admin.monitor.stats.ConnectorConnectionPoolStats.class); 324 final ObjectName on = MonitoringObjectNames.getConnectionPoolObjectName(name, type); 325 added.setObjectName(on); 326 added.setDottedName(DottedNameFactory.getConnectionPoolDottedName(name, type.getTypeName())); 327 if (shouldRegisterMBean(type)) 328 added.registerMBean(); 329 } 330 private void unregisterConnectionPoolStats(String name) 331 throws MonitoringRegistrationException { 332 if (name == null) 333 throw new IllegalArgumentException ("MRH:unregisterConnectionPoolStats - null name"); 334 final StatsHolder resourcesNode = rootStatsHolder.getChild(MonitoredObjectType.RESOURCES.getTypeName()); 335 assert (resourcesNode != null) : "MRH: registerConnectionPoolStats - Resources top-level node not registered"; 336 final StatsHolder pool = resourcesNode.getChild(name); 337 assert (pool != null) : "MRH:unregisterConnectionPoolStats - null node - Serious"; 338 pool.unregisterMBean(); 339 resourcesNode.removeChild(name); 340 } 342 343 public void registerJDBCConnectionPoolStats(com.sun.enterprise.admin.monitor.stats.JDBCConnectionPoolStats ps, 344 String name, MonitoringLevelListener listener) throws MonitoringRegistrationException { 345 this.registerConnectionPoolStats(ps, name, MonitoredObjectType.JDBC_CONN_POOL, listener); 346 } 347 348 public void unregisterJDBCConnectionPoolStats(String name) 349 throws MonitoringRegistrationException { 350 this.unregisterConnectionPoolStats(name); 351 } 352 353 public void registerConnectorConnectionPoolStats(com.sun.enterprise.admin.monitor.stats.ConnectorConnectionPoolStats ps, String name, MonitoringLevelListener listener) throws MonitoringRegistrationException { 354 this.registerConnectionPoolStats(ps, name, MonitoredObjectType.CONNECTOR_CONN_POOL, listener); 355 } 356 357 public void unregisterConnectorConnectionPoolStats(String name) throws MonitoringRegistrationException { 358 this.unregisterConnectionPoolStats(name); 359 } 360 361 public void registerOrbConnectionManagerStats(OrbConnectionManagerStats cms, 362 String name, MonitoringLevelListener listener) 363 throws MonitoringRegistrationException { 364 if (cms == null || name == null) 365 throw new IllegalArgumentException ("MRH:registerOrbCMStats - null arguments"); 366 final StatsHolder orb = rootStatsHolder.getChild(MonitoredObjectType.ORB.getTypeName()); 367 final StatsHolder managers = orb.getChild(MonitoredObjectType.CONNECTION_MANAGERS.getTypeName()); 368 assert (managers != null) : "MRH:registerOrbConnectionManagerStats ORB Node not created yet"; 369 managers.setDottedName(DottedNameFactory.getConnectionManagersDottedName()); 370 final StatsHolder added = managers.addChild(name, MonitoredObjectType.CONNECTION_MANAGER); 371 assert (added != null) : "Addition of Connection Manager failed: " + name; 372 added.setStats(cms); 373 added.setStatsClass(com.sun.enterprise.admin.monitor.stats.OrbConnectionManagerStats.class); 374 final ObjectName on = MonitoringObjectNames.getOrbConnectionManagerObjectName(name); 375 added.setObjectName(on); 376 added.setDottedName(DottedNameFactory.getOrbConnectionManagerDottedName(name)); 377 if (shouldRegisterMBean(MonitoredObjectType.CONNECTION_MANAGER)) 378 added.registerMBean(); 379 } 380 381 public void unregisterOrbConnectionManagerStats(String name) 382 throws MonitoringRegistrationException { 383 final StatsHolder orb = rootStatsHolder.getChild(MonitoredObjectType.ORB.getTypeName()); 384 final StatsHolder managers = orb.getChild(MonitoredObjectType.CONNECTION_MANAGERS.getTypeName()); 385 assert (managers != null) : "MRH:registerOrbConnectionManagerStats ORB Node not created yet"; 386 final StatsHolder cm = managers.getChild(name); 387 assert ( cm != null) : "Connection Manager to be removed is null"; 388 cm.unregisterMBean(); 389 managers.removeChild(name); 390 } 391 392 public void registerThreadPoolStats(ThreadPoolStats tps, String name, 393 MonitoringLevelListener listener) throws MonitoringRegistrationException { 394 if (tps == null || name == null) 395 throw new IllegalArgumentException ("registerThreadPoolStats - null arguments"); 396 final StatsHolder pools = rootStatsHolder.getChild(MonitoredObjectType.THREAD_POOLS.getTypeName()); 397 assert (pools != null) : "ThreadPools Node not initialized"; 398 final StatsHolder added = pools.addChild(name, MonitoredObjectType.THREAD_POOL); 399 assert (added != null) : "No matching thread pool: " + name; 400 added.setStats(tps); 401 added.setStatsClass(com.sun.enterprise.admin.monitor.stats.ThreadPoolStats.class); 402 final ObjectName on = MonitoringObjectNames.getThreadPoolObjectName(name); 403 added.setObjectName(on); 404 added.setDottedName(DottedNameFactory.getThreadPoolDottedName(name)); 405 if (shouldRegisterMBean(MonitoredObjectType.THREAD_POOL)) 406 added.registerMBean(); 407 } 408 409 public void unregisterThreadPoolStats(String name) throws MonitoringRegistrationException { 410 final StatsHolder tps = rootStatsHolder.getChild(MonitoredObjectType.THREAD_POOLS.getTypeName()); 411 assert (tps != null) : "MRH:unregisterThreadPoolStats - null"; 412 final StatsHolder tp = tps.getChild(name); 413 assert ( tp != null) : "Thread Pool to be removed is null"; 414 tp.unregisterMBean(); 415 tps.removeChild(name); 416 } 417 418 public void registerJTAStats(com.sun.enterprise.admin.monitor.stats.JTAStats js, 419 MonitoringLevelListener listener) throws MonitoringRegistrationException { 420 if (js == null) 421 throw new IllegalArgumentException ("JTA - null stats provided"); 422 final StatsHolder tsNode = rootStatsHolder.getChild(MonitoredObjectType.TRANSACTION_SERVICE.getTypeName()); 423 assert (tsNode != null) : "MRH:registerJTAStats - Initialization failed"; 424 tsNode.setStats(js); 425 tsNode.setStatsClass(com.sun.enterprise.admin.monitor.stats.JTAStats.class); 426 if(listener != null) 427 registerMonitoringLevelListener(listener, MonitoredObjectType.TRANSACTION_SERVICE); 428 if (shouldRegisterMBean(MonitoredObjectType.TRANSACTION_SERVICE)) 429 tsNode.registerMBean(); 430 } 431 432 public void unregisterJTAStats() throws MonitoringRegistrationException { 433 final String name = MonitoredObjectType.TRANSACTION_SERVICE.getTypeName(); 434 final StatsHolder ts = rootStatsHolder.getChild(name); 435 assert (ts != null) : "Serious JTS is null"; 436 ts.unregisterMBean(); 437 rootStatsHolder.removeChild(name); 438 } 439 440 public void registerJVMStats(JVMStats js, MonitoringLevelListener listener) 441 throws MonitoringRegistrationException { 442 if (js == null) 443 throw new IllegalArgumentException ("JVM - null stats provided"); 444 final StatsHolder vmNode = rootStatsHolder.getChild(MonitoredObjectType.JVM.getTypeName()); 445 assert (vmNode != null) : "MRH:registerJVMStats - Initialization failed"; 446 vmNode.setStats(js); 447 vmNode.setStatsClass(javax.management.j2ee.statistics.JVMStats .class); 448 vmNode.registerMBean(); 449 } 450 451 public void unregisterJVMStats() throws MonitoringRegistrationException { 452 final String name = MonitoredObjectType.JVM.getTypeName(); 453 final StatsHolder js = rootStatsHolder.getChild(name); 454 assert (js != null) : "Serious JVM is null"; 455 js.unregisterMBean(); 456 rootStatsHolder.removeChild(name); 457 } 458 459 public void registerHttpListenerStats(HTTPListenerStats hs, String ls, 460 String vs, MonitoringLevelListener listener) throws MonitoringRegistrationException { 461 if (hs == null || ls == null || vs == null) 462 throw new IllegalArgumentException ("MRH:registerHttpListenerStats - Null argunments"); 463 StatsHolder added = getRootVs(vs); 464 added = added.addChild(ls, MonitoredObjectType.HTTP_LISTENER); 465 assert (added != null) : "MRH: Listener is null - " + ls; 466 added.setObjectName(MonitoringObjectNames.getHttpListenerObjectName(vs, ls)); 467 added.setDottedName(DottedNameFactory.getHttpListenerDottedName(ls, vs)); 468 added.setStats(hs); 469 added.setStatsClass(com.sun.enterprise.admin.monitor.stats.HTTPListenerStats.class); 470 if (shouldRegisterMBean(MonitoredObjectType.HTTP_LISTENER)) 471 added.registerMBean(); 472 } 473 474 public void unregisterHttpListenerStats(String name, String vs) 475 throws MonitoringRegistrationException { 476 if (name == null || vs == null) 477 throw new IllegalArgumentException ("Null args"); 478 final StatsHolder vsNode = getRootVs(vs); 479 final StatsHolder ls = vsNode.getChild(name); 480 assert (ls != null) : "Unexpected this http listener should be non null : vs = " + vs + " ls = " + name; 481 ls.unregisterMBean(); 482 vsNode.removeChild(name); 483 } 484 485 public void registerServletStats( 486 com.sun.enterprise.admin.monitor.stats.ServletStats ss, 487 String app, 488 String module, 489 String ctxRoot, 490 String vs, 491 String servlet, 492 MonitoringLevelListener listener) 493 throws MonitoringRegistrationException { 494 495 if ( ss == null || module == null || ctxRoot == null 496 || vs == null || servlet == null) { 497 throw new IllegalArgumentException ("Null arguments"); 498 } 499 500 final StatsHolder sRootNode = getServletRootNode(app, module, ctxRoot, vs); 501 final StatsHolder sNode = sRootNode.addChild(servlet, MonitoredObjectType.SERVLET); 502 assert (sNode != null) : "Added Servlet Node is not null"; 503 sNode.setStats(ss); 504 sNode.setStatsClass(com.sun.enterprise.admin.monitor.stats.ServletStats.class); 505 sNode.setObjectName(MonitoringObjectNames.getServletObjectName(app, ctxRoot, vs, servlet)); 506 sNode.setDottedName(DottedNameFactory.getServletDottedName(app, module, vs, servlet)); 507 508 if (shouldRegisterMBean(MonitoredObjectType.SERVLET)) { 509 sNode.registerMBean(); 510 } 511 } 512 513 public void unregisterServletStats(String app, 514 String module, 515 String ctxRoot, 516 String vs, 517 String servlet) 518 throws MonitoringRegistrationException { 519 520 final StatsHolder sRootNode = getServletRootNode(app, module, ctxRoot, vs); 521 final StatsHolder tmp = sRootNode.getChild(servlet); 522 assert (tmp != null) : "Registration of this servlet was not called before: " + servlet; 523 tmp.unregisterMBean(); 524 sRootNode.removeChild(servlet); 525 } 526 527 540 public void registerWebModuleStats( 541 com.sun.enterprise.admin.monitor.stats.WebModuleStats stats, 542 String appName, 543 String webModuleName, 544 String ctxRoot, 545 String vs, 546 MonitoringLevelListener listener) 547 throws MonitoringRegistrationException { 548 549 if (stats == null || webModuleName == null 550 || ctxRoot == null || vs == null) { 551 throw new IllegalArgumentException ("Null arguments"); 552 } 553 554 StatsHolder sNode = getServletRootNode(appName, webModuleName, 555 ctxRoot, vs); 556 sNode.setStats(stats); 557 Class beanMethods = 558 com.sun.enterprise.admin.monitor.stats.WebModuleStats.class; 559 Class [] interfaces = stats.getClass().getInterfaces(); 560 for (int i=0; interfaces != null && i<interfaces.length; i++) { 561 if (beanMethods.isAssignableFrom(interfaces[i])) { 562 beanMethods = interfaces[i]; 564 break; 565 } 566 } 567 sNode.setStatsClass(beanMethods); 568 569 if (shouldRegisterMBean(MonitoredObjectType.WEBMODULE)) { 570 sNode.registerMBean(); 571 } 572 } 573 574 587 public void unregisterWebModuleStats(String appName, 588 String webModuleName, 589 String ctxRoot, 590 String vs) 591 throws MonitoringRegistrationException { 592 593 final StatsHolder sNode = getServletRootNode(appName, webModuleName, 594 ctxRoot, vs); 595 sNode.unregisterMBean(); 596 final StatsHolder parent = (null == appName 597 ? rootStatsHolder.getChild(MonitoredObjectType.APPLICATIONS.getTypeName()) 598 : rootStatsHolder.getChild(MonitoredObjectType.APPLICATIONS.getTypeName()).getChild(appName)); 599 if (null != parent){ 600 final StatsHolder webModule = parent.getChild(webModuleName); 601 if (null != webModule){ 602 webModule.unregisterMBean(); 603 parent.removeChild(webModuleName); 604 } 605 } 606 } 607 608 609 610 611 628 public WebModuleStats getWebModuleStats(String appName, 629 String webModuleName, 630 String ctxRoot, 631 String vs) { 632 WebModuleStats stats = null; 633 634 StatsHolder sNode = getServletRootNode(appName, webModuleName, 635 ctxRoot, vs); 636 if (sNode != null) { 637 stats = (WebModuleStats) sNode.getStats(); 638 } 639 640 return stats; 641 642 } 643 644 662 private StatsHolder getServletRootNode( 663 String app, String module, String ctxRoot, String vs) { 664 665 StatsHolder tmp = rootStatsHolder.getChild(MonitoredObjectType.APPLICATIONS.getTypeName()); if (app != null) { 667 tmp = tmp.addChild(app, MonitoredObjectType.APPLICATION); 668 tmp.setObjectName(MonitoringObjectNames.getApplicationObjectName(app)); 669 tmp.setDottedName(DottedNameFactory.getAppDottedName(app)); 670 tmp.registerMBean(); 671 tmp = tmp.addChild(module, MonitoredObjectType.WEBMODULE); 672 tmp.setDottedName(DottedNameFactory.getAppModuleDottedName(app,module)); 673 logger.finest("Added - MRH:getWebRootNode for ejb-jar module in j2ee-app: " + app + ":" + module); 674 } else { 675 tmp = tmp.addChild(module, MonitoredObjectType.STANDALONE_WEBMODULE); 676 tmp.setDottedName(DottedNameFactory.getStandAloneWebModuleDottedName(module)); 677 logger.finest("Added MRH:getWebRootNode for standalone web module: " + module); 678 } 679 tmp.setObjectName(MonitoringObjectNames.getWebModuleObjectName(app, ctxRoot, vs)); 680 tmp.registerMBean(); 681 logger.finest("MRH:getWebRootNode: name = " + tmp.getName()); 682 tmp = tmp.addChild(vs, MonitoredObjectType.VIRTUAL_SERVER); 683 tmp.setObjectName(MonitoringObjectNames.getVirtualServerObjectName(app, ctxRoot, vs)); 684 tmp.setDottedName(DottedNameFactory.getWebAppsVirtualServerDottedName(app, module, vs)); 685 return ( tmp ); 686 } 687 688 private StatsHolder getEjbRootNode(String app, String module) { 689 StatsHolder tmp = rootStatsHolder.getChild(MonitoredObjectType.APPLICATIONS.getTypeName()); if (app != null) { 691 tmp = tmp.addChild(app, MonitoredObjectType.APPLICATION); 692 tmp.setObjectName(MonitoringObjectNames.getApplicationObjectName(app)); 693 tmp.setDottedName(DottedNameFactory.getAppDottedName(app)); 694 tmp.registerMBean(); 695 tmp = tmp.addChild(module, MonitoredObjectType.EJBMODULE); 696 tmp.setDottedName(DottedNameFactory.getAppModuleDottedName(app, module)); 697 logger.finest("Added - MRH:getEjbRootNode for ejb-jar module in j2ee-app: " + app + ":" + module); 698 } 699 else { 700 tmp = tmp.addChild(module, MonitoredObjectType.STANDALONE_EJBMODULE); 701 tmp.setDottedName(DottedNameFactory.getStandAloneEJBModuleDottedName(module)); 702 logger.finest("Added MRH:getEjbRootNode for standalone ejb-jar module: " + module); 703 } 704 tmp.setObjectName(MonitoringObjectNames.getEjbModuleObjectName(app, module)); 705 tmp.registerMBean(); 706 logger.finest("MRH:getEjbRootNode: name = " + tmp.getName()); 707 return ( tmp ); 708 } 709 710 private StatsHolder getWebServiceEndpointForWeb(String app, 711 String module, String ctxRoot, String vs, String endpoint) { 712 final StatsHolder sRoot = getServletRootNode(app, module, ctxRoot, vs); 713 assert (sRoot != null) : "MRH:getWebService, unexpectedly sRoot is null: " 714 + app + ":" + module; 715 final StatsHolder wsNode = sRoot.addChild(endpoint, 716 MonitoredObjectType.WEBSERVICE_ENDPOINT); assert (wsNode != null) : "Web Service node should not be null: " + 718 endpoint; 719 return ( wsNode ); 720 } 721 722 private StatsHolder getWebServiceEndpointForEjb(String app, String module, 723 String endpoint) { 724 final StatsHolder ejbRoot = getEjbRootNode(app, module); 725 assert (ejbRoot != null) : "MRH:getEjb, unexpectedly ejbRoot is null: " 726 + app + ":" + module; 727 final StatsHolder wsNode = ejbRoot.addChild(endpoint, 728 MonitoredObjectType.WEBSERVICE_ENDPOINT); assert (wsNode != null) : "Web Service node should not be null: " + 730 endpoint; 731 return ( wsNode ); 732 } 733 734 private StatsHolder getEjb(String app, String module, String ejb) { 735 final StatsHolder ejbRoot = getEjbRootNode(app, module); 736 assert (ejbRoot != null) : "MRH:getEjb, unexpectedly ejbRoot is null: " + app + ":" + module; 737 final StatsHolder ejbNode = ejbRoot.addChild(ejb, MonitoredObjectType.EJB); assert (ejbNode != null) : "Ejb node should not be null: " + ejb; 739 return ( ejbNode ); 740 } 741 742 private StatsHolder getEjbMethods(String app, String module, String ejb) { 743 final StatsHolder ejbNode = getEjb(app, module, ejb); 744 assert (ejbNode != null) : "MRH:getEjbMethods, unexpectedly ejb node is null: " + app + ":" + module + ":" + ejb; 745 final String methods = MonitoredObjectType.BEAN_METHODS.getTypeName(); 746 final StatsHolder added = ejbNode.addChild(methods, MonitoredObjectType.BEAN_METHODS); 747 added.setObjectName(MonitoringObjectNames.getEjbMethodsObjectName(app, module, ejb)); 748 added.setDottedName(DottedNameFactory.getEJBMethodsDottedName(app, module, ejb)); 749 added.registerMBean(); 750 return ( added ); 751 } 752 753 private StatsHolder getRootVs(String vs) { 754 final StatsHolder https = rootStatsHolder.getChild(MonitoredObjectType.HTTP_SERVICE.getTypeName()); 755 assert (https != null) : "MRH:registerHttpListener HTTP Service is not initialized - Serious"; 756 https.setDottedName(DottedNameFactory.getHttpServiceDottedName()); 757 StatsHolder added = https.addChild(vs, MonitoredObjectType.VIRTUAL_SERVER); 758 assert (added != null) : "MRH: VS is null: " + vs; 759 added.setObjectName(MonitoringObjectNames.getVirtualServerObjectName(vs)); 760 added.setDottedName(DottedNameFactory.getHttpSvcVirtualServerDottedName(vs)); 761 added.registerMBean(); 762 return ( added ); 763 } 764 765 771 772 public Collection getThreadPoolNodes() { 773 final StatsHolder tps = rootStatsHolder.getChild(MonitoredObjectType.THREAD_POOLS.getTypeName()); 774 return ( tps.getAllChildren() ); 775 } 776 public Collection getOrbNodes() { 777 StatsHolder tmp = rootStatsHolder.getChild(MonitoredObjectType.ORB.getTypeName()); 779 tmp = tmp.getChild(MonitoredObjectType.CONNECTION_MANAGERS.getTypeName()); return ( tmp.getAllChildren() ); 781 } 782 783 public Collection getHttpServiceNodes() { 784 final ArrayList all = new ArrayList(); 786 final Collection vss = getVsNodes(); 787 all.addAll(vss); 790 793 final Iterator it = vss.iterator(); 794 while (it.hasNext()) { 795 final StatsHolder vs = (StatsHolder) it.next(); 796 all.addAll(vs.getAllChildren()); 797 } 798 return ( all ); 799 } 800 private Collection getVsNodes() { 801 final StatsHolder https = rootStatsHolder.getChild(MonitoredObjectType.HTTP_SERVICE.getTypeName()); 802 return ( https.getAllChildren() ); 803 } 804 805 public Collection getTransactionServiceNodes() { 806 final ArrayList all = new ArrayList(); 808 all.add(rootStatsHolder.getChild(MonitoredObjectType.TRANSACTION_SERVICE.getTypeName())); 809 return ( all ); 810 } 811 812 public Collection getConnectionPoolNodes() { 813 final StatsHolder res = rootStatsHolder.getChild(MonitoredObjectType.RESOURCES.getTypeName()); 814 return ( res.getAllChildren() ); 815 } 816 817 818 public Collection getWebContainerNodes() { 819 final ArrayList all = new ArrayList(); 821 822 final StatsHolder appsNode = rootStatsHolder.getChild(MonitoredObjectType.APPLICATIONS.getTypeName()); 823 final Collection apps = appsNode.getAllChildren(); 824 final Iterator it = apps.iterator(); 825 while (it.hasNext()) { 826 final StatsHolder appOrStandaloneModule = (StatsHolder) it.next(); 827 if (appOrStandaloneModule.getType() == MonitoredObjectType.APPLICATION) { 828 final Collection modulesInApp = appOrStandaloneModule.getAllChildren(); 829 final Iterator ii = modulesInApp.iterator(); 830 while (ii.hasNext()) { 831 final StatsHolder embedded = (StatsHolder) ii.next(); 832 if (embedded.getType() == MonitoredObjectType.WEBMODULE) { 833 all.addAll(getWebModuleNodes(embedded)); 834 } 835 } 836 } 837 else if (appOrStandaloneModule.getType() == MonitoredObjectType.STANDALONE_WEBMODULE) { 838 final StatsHolder standaloneWebModule = appOrStandaloneModule; 839 all.addAll(getWebModuleNodes(standaloneWebModule)); 840 } 841 } 842 return ( all ); 843 } 844 845 private Collection getWebModuleNodes(StatsHolder node) { 846 final ArrayList nodes = new ArrayList(); 847 assert (node.getType() == MonitoredObjectType.WEBMODULE || 848 node.getType() == MonitoredObjectType.STANDALONE_WEBMODULE); 849 final Collection vss = node.getAllChildren(); 850 final Iterator it = vss.iterator(); 851 while (it.hasNext()) { 852 final StatsHolder vs = (StatsHolder) it.next(); 853 nodes.add(vs); 856 nodes.addAll(vs.getAllChildren()); 858 } 859 return ( nodes ); 860 } 861 862 public Collection getEjbContainerNodes(boolean includeMethods) { 863 final Collection all = new ArrayList(); 865 final StatsHolder appsNode = rootStatsHolder.getChild(MonitoredObjectType.APPLICATIONS.getTypeName()); 866 final Collection apps = appsNode.getAllChildren(); 867 final Iterator it = apps.iterator(); 868 while (it.hasNext()) { 869 final StatsHolder appOrStandaloneModule = (StatsHolder) it.next(); 870 if (appOrStandaloneModule.getType() == MonitoredObjectType.APPLICATION) { 871 final Collection modulesInApp = appOrStandaloneModule.getAllChildren(); 872 final Iterator ii = modulesInApp.iterator(); 873 while (ii.hasNext()) { 874 final StatsHolder embedded = (StatsHolder) ii.next(); 875 if (embedded.getType() == MonitoredObjectType.EJBMODULE) { 876 all.addAll(getEjbNodesInEjbModule(embedded, includeMethods)); 877 } 878 } 879 } 880 else if (appOrStandaloneModule.getType() == MonitoredObjectType.STANDALONE_EJBMODULE) { 881 final StatsHolder standaloneEjbModule = appOrStandaloneModule; 882 all.addAll(getEjbNodesInEjbModule(standaloneEjbModule, includeMethods)); 883 } 884 } 885 return ( all ); 886 } 887 888 private Collection getEjbNodesInEjbModule(StatsHolder node, boolean includeMethods) { 889 final ArrayList ejbNodes = new ArrayList(); 890 assert (node.getType() == MonitoredObjectType.EJBMODULE || 891 node.getType() == MonitoredObjectType.STANDALONE_EJBMODULE); 892 final Collection ejbs = node.getAllChildren(); 893 ejbNodes.addAll(ejbs); final Iterator it = ejbs.iterator(); 896 while (it.hasNext()) { 897 final StatsHolder ejb = (StatsHolder) it.next(); 898 ejbNodes.addAll(ejb.getAllChildren()); final StatsHolder methodsNode = ejb.getChild(MonitoredObjectType.BEAN_METHODS.getTypeName()); 900 if(includeMethods) { 901 if (methodsNode != null) ejbNodes.addAll(getEjbMethodNodes(methodsNode)); 903 } 904 else { 905 ejbNodes.remove(methodsNode); 906 } 907 } 908 return ( ejbNodes ); 909 } 910 911 private Collection getEjbMethodNodes(StatsHolder methodsNode) { 912 assert (methodsNode.getType() == MonitoredObjectType.BEAN_METHODS); 913 return ( methodsNode.getAllChildren() ); 914 } 915 916 public Collection getEjbMethodNodes() { 917 final ArrayList ejbNodes = new ArrayList(); 919 final ArrayList ejbMethodNodes = new ArrayList(); 920 ejbNodes.addAll(getEjbContainerNodes(true)); 921 final Iterator it = ejbNodes.iterator(); 922 while (it.hasNext()) { 923 StatsHolder ejbNode = (StatsHolder) it.next(); 924 if((ejbNode.getType() == MonitoredObjectType.BEAN_METHODS) || 925 (ejbNode.getType() == MonitoredObjectType.BEAN_METHOD)) 926 ejbMethodNodes.add(ejbNode); 927 } 928 return ejbMethodNodes; 929 } 930 931 937 private void addMonitoringLevelListener(MonitoringLevelListener listener){ 938 if(listener != null) 939 listeners.add(listener); 940 } 941 942 946 public void registerMonitoringLevelListener(MonitoringLevelListener listener, 947 MonitoredObjectType objType) { 948 if (listener != null && objType != null) { 949 objTypeListeners.put(objType, listener); 951 final MonitoringLevel level = MonitoringConfigurationHandler.getLevel(objType); 953 } 955 } 956 957 public void unregisterMonitoringLevelListener(MonitoringLevelListener listener) { 958 if (listener != null) { 959 objTypeListeners.remove(listener); 960 } 961 } 962 963 964 private void initialize() { 965 initializeRoot(); 966 initializeJvm(); 967 initializeApplications(); 968 initializeThreadPools(); 969 initializeOrb(); 970 initializeTransactionService(); 971 initializeHttpService(); 972 initializeResources(); 973 initializeConnectorService(); 974 initializeJmsService(); 975 initializeJndi(); 976 } 978 979 private void initializeRoot() { 980 rootStatsHolder.setObjectName(MonitoringObjectNames.getRootObjectName()); 981 rootStatsHolder.setDottedName(DottedNameFactory.getRootDottedName()); 982 rootStatsHolder.registerMBean(); 983 } 984 private void initializeJvm() { 985 final StatsHolder jvmNode = rootStatsHolder.addChild(MonitoredObjectType.JVM.getTypeName(), MonitoredObjectType.JVM); 986 assert (jvmNode != null) : "Initialization Error in jvmNodeCreation"; 987 jvmNode.setObjectName(MonitoringObjectNames.getJvmObjectName()); 988 jvmNode.setDottedName(DottedNameFactory.getJVMDottedName()); 989 try { 990 this.registerJVMStats(new JVMStatsImpl(), null); 991 logger.finest("Registering the JVM stats in RegistryHelper only"); 992 } 993 catch (Exception cause) { 994 throw new RuntimeException (cause); 995 } 996 997 initializeJvmMonitoring(rootStatsHolder); 998 } 999 private void initializeApplications() { 1000 final StatsHolder appsNode = rootStatsHolder.addChild(MonitoredObjectType.APPLICATIONS.getTypeName(), MonitoredObjectType.APPLICATIONS); 1001 assert (appsNode != null) : "Initialization Error in appsNodeCreation"; 1002 appsNode.setObjectName(MonitoringObjectNames.getApplicationsObjectName()); 1003 appsNode.setDottedName(DottedNameFactory.getApplicationsDottedName()); 1004 appsNode.registerMBean(); 1005 } 1006 private void initializeThreadPools() { 1007 final StatsHolder tpsNode = rootStatsHolder.addChild(MonitoredObjectType.THREAD_POOLS.getTypeName(), MonitoredObjectType.THREAD_POOLS); 1008 assert (tpsNode != null) : "Initialization Error in tpsNodeCreation"; 1009 tpsNode.setObjectName(MonitoringObjectNames.getThreadPoolsObjectName()); 1010 tpsNode.setDottedName(DottedNameFactory.getThreadPoolsDottedName()); 1011 tpsNode.registerMBean(); 1012 } 1013 private void initializeOrb() { 1014 final StatsHolder orbNode = rootStatsHolder.addChild(MonitoredObjectType.ORB.getTypeName(), MonitoredObjectType.ORB); 1015 assert (orbNode != null) : "Initialization Error in orbNodeCreation"; 1016 orbNode.setObjectName(MonitoringObjectNames.getOrbObjectName()); 1017 orbNode.setDottedName(DottedNameFactory.getOrbDottedName()); 1018 orbNode.registerMBean(); 1019 final StatsHolder cmsNode = orbNode.addChild(MonitoredObjectType.CONNECTION_MANAGERS.getTypeName(), MonitoredObjectType.CONNECTION_MANAGERS); 1020 assert (cmsNode != null) : "Initialization Error in Connection Managers Creation"; 1021 cmsNode.setObjectName(MonitoringObjectNames.getConnectionManagersObjectName()); 1022 cmsNode.setDottedName(DottedNameFactory.getConnectionManagersDottedName()); 1023 cmsNode.registerMBean(); 1024 } 1025 private void initializeTransactionService() { 1026 final StatsHolder tsNode = rootStatsHolder.addChild(MonitoredObjectType.TRANSACTION_SERVICE.getTypeName(), MonitoredObjectType.TRANSACTION_SERVICE); 1027 assert (tsNode != null) : "Initialization Error in Transaction Service"; 1028 tsNode.setObjectName(MonitoringObjectNames.getTransactionServiceObjectName()); 1029 tsNode.setDottedName(DottedNameFactory.getTransactionServiceDottedName()); 1030 } 1031 private void initializeHttpService() { 1032 final StatsHolder hsNode = rootStatsHolder.addChild(MonitoredObjectType.HTTP_SERVICE.getTypeName(), MonitoredObjectType.HTTP_SERVICE); 1033 assert (hsNode != null) : "Initialization Error in HttpServiceCreation"; 1034 hsNode.setObjectName(MonitoringObjectNames.getHttpServiceObjectName()); 1035 hsNode.setDottedName(DottedNameFactory.getHttpServiceDottedName()); 1036 hsNode.registerMBean(); 1037 } 1038 private void initializeResources() { 1039 final StatsHolder resNode = rootStatsHolder.addChild(MonitoredObjectType.RESOURCES.getTypeName(), MonitoredObjectType.RESOURCES); 1040 assert (resNode != null) : "Initialization Error in Resources"; 1041 resNode.setObjectName(MonitoringObjectNames.getResourcesObjectName()); 1042 resNode.setDottedName(DottedNameFactory.getResourcesDottedName()); 1043 resNode.registerMBean(); 1044 } 1045 1046 private void initializeJndi() { 1047 JndiMBeanManager mgr = new JndiMBeanManager(); 1049 mgr.registerMBean(MonitoringObjectNames.getJndiObjectName()); 1050 } 1052 1053 private void initializeJvmMonitoring(StatsHolder rootNode) { 1054 1055 final String JMM_CLASS = 1056 "com.sun.enterprise.admin.monitor.registry.spi.JVMMonitoringManager"; 1057 final String METHOD = "getInstance"; 1058 final String REG_METHOD = "registerStats"; 1059 try { 1060 final Class c = Class.forName(JMM_CLASS); 1061 final java.lang.reflect.Method m = c.getMethod(METHOD); 1062 final Object jmm = m.invoke(c); 1063 registerMonitoringLevelListener((MonitoringLevelListener)jmm, MonitoredObjectType.JVM); 1064 final java.lang.reflect.Method m1 = 1065 c.getMethod(REG_METHOD, new Class []{com.sun.enterprise.admin.monitor.registry.StatsHolder.class}); 1066 m1.invoke(jmm, new Object []{rootStatsHolder}); 1067 } 1069 catch(Throwable t) { 1070 logger.finest("Exception in the initialization of JVM 1.5 Monitoring"); 1071 throw new RuntimeException (t); 1072 } 1073 } 1074 1075 private boolean shouldRegisterMBean(MonitoredObjectType type) { 1076 return ( MonitoringConfigurationHandler.shouldRegisterMBean(type) ); 1077 } 1078 1079 1084 private void initializeConnectorService() { 1085 final StatsHolder adaptorsNode = rootStatsHolder.addChild( 1086 MonitoredObjectType.CONNECTOR_SERVICE.getTypeName(), 1087 MonitoredObjectType.CONNECTOR_SERVICE); 1088 assert (adaptorsNode != null) : "connector-service node not created"; 1089 adaptorsNode.setObjectName(MonitoringObjectNames.getConnectorServiceObjectName()); 1090 adaptorsNode.setDottedName(DottedNameFactory.getConnectorServiceDottedName()); 1091 adaptorsNode.registerMBean(); 1092 } 1093 1094 1098 1099 private void initializeJmsService() { 1100 final StatsHolder adaptorsNode = rootStatsHolder.addChild( 1101 MonitoredObjectType.JMS_SERVICE.getTypeName(), 1102 MonitoredObjectType.JMS_SERVICE); 1103 assert (adaptorsNode != null) : "jms-service node not created"; 1104 adaptorsNode.setObjectName(MonitoringObjectNames.getJmsServiceObjectName()); 1105 adaptorsNode.setDottedName(DottedNameFactory.getJmsServiceDottedName()); 1106 adaptorsNode.registerMBean(); 1107 } 1108 1109 1113 private StatsHolder getConnectorRootNode(String j2eeAppName, String moduleName) { 1114 1115 StatsHolder tmp = rootStatsHolder.getChild(MonitoredObjectType.CONNECTOR_SERVICE.getTypeName()); 1118 assert (tmp != null) : "connector-service node not created"; 1119 if (j2eeAppName != null) 1120 tmp = tmp.addChild(j2eeAppName +"#" + moduleName, MonitoredObjectType.CONNECTOR_MODULE); 1121 else 1122 tmp = tmp.addChild(moduleName, MonitoredObjectType.STANDALONE_CONNECTOR_MODULE); 1123 1124 logger.finest("Added - MRH:getConnectorRootNode for connector-module in j2ee-app: " + j2eeAppName + ":" + moduleName); 1125 tmp.setDottedName(DottedNameFactory.getConnectorModuleDottedName(j2eeAppName, moduleName)); 1126 tmp.setObjectName(MonitoringObjectNames.getConnectorModuleObjectName(j2eeAppName, moduleName)); 1127 tmp.registerMBean(); 1128 logger.finest("MRH:getConnectorRootNode: name = " + tmp.getName()); 1129 return ( tmp ); 1130 } 1131 1132 public void registerConnectorWorkMgmtStats( 1134 com.sun.enterprise.admin.monitor.stats.ConnectorWorkMgmtStats stats, 1135 String j2eeAppName, 1136 String moduleName, 1137 MonitoringLevelListener listener) 1138 throws MonitoringRegistrationException { 1139 1140 registerConnectorWorkMgmtStats(stats, j2eeAppName, moduleName, false, listener); 1141 1142 } 1143 1144 1145 public void registerConnectorWorkMgmtStats( 1146 com.sun.enterprise.admin.monitor.stats.ConnectorWorkMgmtStats stats, 1147 String j2eeAppName, 1148 String moduleName, 1149 boolean isJms, 1150 MonitoringLevelListener listener) throws MonitoringRegistrationException { 1151 1152 StatsHolder adapterNode = null; 1153 if(isJms) { 1156 if(stats == null) 1157 throw new IllegalArgumentException ("Invalid Arguments for ConnectorWorkManagementStats registration"); 1158 adapterNode = rootStatsHolder.getChild(MonitoredObjectType.JMS_SERVICE.getTypeName()); 1159 } 1160 else { 1161 if((stats == null)||(moduleName == null)||(moduleName.equals(""))) 1162 throw new IllegalArgumentException ("Invalid Arguments for ConnectorWorkManagementStats registration"); 1163 adapterNode = getConnectorRootNode(j2eeAppName, moduleName); 1164 } 1165 1166 assert(adapterNode != null):"connector node is null"; 1167 adapterNode = adapterNode.addChild(MonitoredObjectType.CONNECTOR_WORKMGMT.getTypeName(), 1168 MonitoredObjectType.CONNECTOR_WORKMGMT); 1169 adapterNode.setStats(stats); 1170 adapterNode.setStatsClass(com.sun.enterprise.admin.monitor.stats.ConnectorWorkMgmtStats.class); 1171 adapterNode.setDottedName(DottedNameFactory.getConnectorWorkMgmtDottedName(j2eeAppName, moduleName, isJms)); 1172 adapterNode.setObjectName(MonitoringObjectNames.getConnectorWorkMgmtObjectName(j2eeAppName, moduleName, isJms)); 1173 adapterNode.registerMBean(); 1174 if (shouldRegisterMBean(MonitoredObjectType.CONNECTOR_WORKMGMT)) 1175 adapterNode.registerMBean(); 1176 } 1177 1178 1180 public void unregisterConnectorWorkMgmtStats(String j2eeAppName, String moduleName) 1182 throws MonitoringRegistrationException { 1183 unregisterConnectorWorkMgmtStats(j2eeAppName, moduleName, false); 1184 } 1185 1186 public void unregisterConnectorWorkMgmtStats(String j2eeAppName, String moduleName, boolean isJms) 1187 throws MonitoringRegistrationException { 1188 1189 StatsHolder connectorNode = null; 1190 if(isJms) { 1191 connectorNode = rootStatsHolder.getChild(MonitoredObjectType.JMS_SERVICE.getTypeName()); 1192 } 1193 else { 1194 if((j2eeAppName == null) || (moduleName == null)||(j2eeAppName.equals(""))||(moduleName.equals(""))) 1195 throw new IllegalArgumentException ("Invalid Arguments for ConnectorWorkManagementStats unregistration"); 1196 connectorNode = getConnectorRootNode(j2eeAppName, moduleName); 1197 } 1198 assert(connectorNode != null): "connector node not initialized"; 1199 StatsHolder workmgmtNode = connectorNode.getChild(MonitoredObjectType.CONNECTOR_WORKMGMT.getTypeName()); 1200 assert(workmgmtNode != null): "Connector Work Management node not initialized"; 1201 workmgmtNode.unregisterMBean(); 1202 connectorNode.removeChild(MonitoredObjectType.CONNECTOR_WORKMGMT.getTypeName()); 1203 } 1204 1205 1206 public void registerConnectionFactoryStats(com.sun.enterprise.admin.monitor.stats.ConnectionFactoryStats stats, 1207 String factoryName, 1208 MonitoringLevelListener listener) 1209 throws MonitoringRegistrationException { 1210 1211 if((stats == null) || (factoryName == null)) 1212 throw new IllegalArgumentException ("Invalid arguments for registraion of ConnectionFactory Stats"); 1213 StatsHolder cfNode = getConnectionFactoriesNode(); 1214 assert(cfNode != null): "connection-factories node not initialized correctly"; 1215 cfNode = cfNode.addChild(factoryName, MonitoredObjectType.CONNECTION_FACTORY); 1216 cfNode.setStats(stats); 1217 cfNode.setStatsClass(com.sun.enterprise.admin.monitor.stats.ConnectionFactoryStats.class); 1218 cfNode.setDottedName(DottedNameFactory.getConnectionFactoryDottedName(factoryName)); 1219 cfNode.setObjectName(MonitoringObjectNames.getConnectionFactoryObjectName(factoryName)); 1220 if(shouldRegisterMBean(MonitoredObjectType.CONNECTION_FACTORY)) 1221 cfNode.registerMBean(); 1222 } 1223 1224 private StatsHolder getConnectionFactoriesNode() { 1225 1226 StatsHolder tmpNode = rootStatsHolder.getChild(MonitoredObjectType.JMS_SERVICE.getTypeName()); 1227 assert(tmpNode != null): "jms-service node initialized correctly"; 1228 tmpNode = tmpNode.addChild(MonitoredObjectType.CONNECTION_FACTORIES.getTypeName(), MonitoredObjectType.CONNECTION_FACTORIES); 1229 tmpNode.setDottedName(DottedNameFactory.getConnectionFactoriesDottedName()); 1230 tmpNode.setObjectName(MonitoringObjectNames.getConnectionFactoriesObjectName()); 1231 tmpNode.registerMBean(); 1232 return tmpNode; 1233 } 1234 1235 public void unregisterConnectionFactoryStats(String factoryName) throws MonitoringRegistrationException { 1236 1237 if(factoryName == null) 1238 throw new IllegalArgumentException ("Invalid arguments for the unregistration of ConnectionFactory Stats"); 1239 StatsHolder tmpNode = rootStatsHolder.getChild(MonitoredObjectType.JMS_SERVICE.getTypeName()); 1240 assert(tmpNode != null): "jms-service node not initialized correctly"; 1241 tmpNode = tmpNode.getChild(MonitoredObjectType.CONNECTION_FACTORIES.getTypeName()); 1242 assert(tmpNode != null): "connection-factories node not initialized correctly"; 1243 StatsHolder cfNode = tmpNode.getChild(factoryName); 1244 assert(cfNode != null): "connection-factory node not initialized correctly"; 1245 cfNode.unregisterMBean(); 1246 tmpNode.removeChild(factoryName); 1247 } 1248 1249 public void registerConnectorConnectionPoolStats(com.sun.enterprise.admin.monitor.stats.ConnectorConnectionPoolStats stats, 1250 String poolName, 1251 String j2eeAppName, 1252 String moduleName, 1253 MonitoringLevelListener listener) 1254 throws MonitoringRegistrationException { 1255 if((stats == null)||(j2eeAppName == null)||(moduleName == null)||(poolName == null)) 1256 throw new IllegalArgumentException ("Invalid arguments for the registration of connection-pool stats"); 1257 1258 StatsHolder poolsNode = getConnectionPoolsNode(j2eeAppName, moduleName); 1259 assert(poolsNode != null): "connection-pools node not initialized correctly"; 1260 StatsHolder poolNode = poolsNode.addChild(poolName, MonitoredObjectType.CONNECTOR_CONN_POOL); 1261 poolNode.setStats(stats); 1262 poolNode.setStatsClass(com.sun.enterprise.admin.monitor.stats.ConnectorConnectionPoolStats.class); 1263 poolNode.setDottedName(DottedNameFactory.getConnectionPoolDottedName(poolName, j2eeAppName, moduleName)); 1264 poolNode.setObjectName(MonitoringObjectNames.getConnectionPoolObjectName(poolName, j2eeAppName, moduleName)); 1265 if(shouldRegisterMBean(MonitoredObjectType.CONNECTOR_CONN_POOL)) 1266 poolNode.registerMBean(); 1267 } 1268 1269 private StatsHolder getConnectionPoolsNode(String j2eeAppName, String moduleName) { 1270 1271 StatsHolder connNode = getConnectorRootNode(j2eeAppName, moduleName); 1272 assert(connNode != null): "connector node initialized correctly"; 1273 connNode = connNode.addChild(MonitoredObjectType.CONNECTION_POOLS.getTypeName(), MonitoredObjectType.CONNECTION_POOLS); 1274 connNode.setDottedName(DottedNameFactory.getConnectionPoolsDottedName(j2eeAppName, moduleName)); 1275 connNode.setObjectName(MonitoringObjectNames.getConnectionPoolsObjectName(j2eeAppName, moduleName)); 1276 connNode.registerMBean(); 1277 return connNode; 1278 } 1279 1280 public void unregisterConnectorConnectionPoolStats(String poolName, 1281 String j2eeAppName, 1282 String moduleName) 1283 throws MonitoringRegistrationException { 1284 1285 StatsHolder poolsNode = getConnectionPoolsNode(j2eeAppName, moduleName); 1286 assert(poolsNode != null): "connection-pools node not initialized"; 1287 StatsHolder poolNode = poolsNode.getChild(poolName); 1288 assert(poolNode != null): "connection-pool node not initialized"; 1289 poolNode.unregisterMBean(); 1290 poolsNode.removeChild(poolName); 1291 } 1292 1293 1297 1298 public Collection getConnectorRelatedNodes() { 1299 Collection c = getConnectionPoolNodes(MonitoredObjectType.CONNECTOR_CONN_POOL); 1300 c.addAll(getConnectorServiceChildren()); 1301 c.addAll(getJmsServiceChildren()); 1302 return c; 1303 } 1304 1305 1309 private Collection getConnectorServiceChildren() { 1310 1311 StatsHolder connservNode = rootStatsHolder.getChild(MonitoredObjectType.CONNECTOR_SERVICE.getTypeName()); 1312 assert(connservNode != null): "connector-service node is null"; 1313 ArrayList c = new ArrayList(); 1315 Collection cNodes = connservNode.getAllChildren(); 1316 c.addAll(cNodes); 1317 Iterator iter = cNodes.iterator(); 1319 while(iter.hasNext()) { 1320 StatsHolder connectorNode = (StatsHolder) iter.next(); 1321 c.addAll(connectorNode.getAllChildren()); StatsHolder poolsNode = connectorNode.getChild(MonitoredObjectType.CONNECTION_POOLS.getTypeName()); 1323 c.addAll(poolsNode.getAllChildren()); 1324 } 1325 return c; 1326 } 1327 1328 private Collection getJmsServiceChildren() { 1329 1330 StatsHolder jmsservNode = rootStatsHolder.getChild(MonitoredObjectType.JMS_SERVICE.getTypeName()); 1331 assert(jmsservNode != null): "jms-service node is null"; 1332 ArrayList c = new ArrayList(); 1334 Collection jmsNodes = jmsservNode.getAllChildren(); 1335 c.addAll(jmsNodes); 1336 Iterator it = jmsNodes.iterator(); 1338 while(it.hasNext()) { 1339 StatsHolder childNode = (StatsHolder) it.next(); 1340 Collection c1 = childNode.getAllChildren(); 1341 if(c1 != null) 1342 c.addAll(c1); 1343 } 1344 return c; 1345 } 1346 1347 public Collection getConnectionPoolNodes(MonitoredObjectType t) { 1348 1349 StatsHolder resNode = rootStatsHolder.getChild(MonitoredObjectType.RESOURCES.getTypeName()); 1350 Collection c = resNode.getAllChildren(); 1351 Iterator iter = c.iterator(); 1352 ArrayList poolNodes = new ArrayList(); 1353 while(iter.hasNext()) { 1354 StatsHolder tmp = (StatsHolder)iter.next(); 1355 if(tmp.getType() == t) 1356 poolNodes.add(tmp); 1357 } 1358 return poolNodes; 1359 } 1360 1361 1363 1364 public void registerPWCConnectionQueueStats(com.sun.enterprise.admin.monitor.stats.PWCConnectionQueueStats stats, 1367 MonitoringLevelListener listener) throws MonitoringRegistrationException { 1368 1369 if(stats == null) 1370 throw new IllegalArgumentException ("PWCConnectionQueueStats is null"); 1371 StatsHolder httpsvcNode = rootStatsHolder.getChild(MonitoredObjectType.HTTP_SERVICE.getTypeName()); 1372 assert(httpsvcNode != null): "HttpService is not initialized correctly"; 1373 httpsvcNode = httpsvcNode.addChild(MonitoredObjectType.CONNECTION_QUEUE.getTypeName(), MonitoredObjectType.CONNECTION_QUEUE); 1374 httpsvcNode.setStats(stats); 1375 httpsvcNode.setStatsClass(com.sun.enterprise.admin.monitor.stats.PWCConnectionQueueStats.class); 1376 httpsvcNode.setDottedName(DottedNameFactory.getConnectionQueueDottedName()); 1377 httpsvcNode.setObjectName(MonitoringObjectNames.getConnectionQueueObjectName()); 1378 if(shouldRegisterMBean(MonitoredObjectType.CONNECTION_QUEUE)) 1379 httpsvcNode.registerMBean(); 1380 } 1381 1382 public void unregisterPWCConnectionQueueStats() throws MonitoringRegistrationException { 1384 1385 StatsHolder httpsvcNode = rootStatsHolder.getChild(MonitoredObjectType.HTTP_SERVICE.getTypeName()); 1386 assert(httpsvcNode != null): "http-service node is null"; 1387 StatsHolder targetNode = httpsvcNode.getChild(MonitoredObjectType.CONNECTION_QUEUE.getTypeName()); 1388 assert(targetNode != null): "connection-queue node is null"; 1389 targetNode.unregisterMBean(); 1390 } 1392 1393 public void registerPWCDnsStats( 1395 com.sun.enterprise.admin.monitor.stats.PWCDnsStats stats, 1396 MonitoringLevelListener listener) throws MonitoringRegistrationException { 1397 1398 if(stats == null) 1399 throw new IllegalArgumentException ("PWCDnsStats is null"); 1400 StatsHolder httpsvcNode = rootStatsHolder.getChild(MonitoredObjectType.HTTP_SERVICE.getTypeName()); 1401 assert(httpsvcNode != null): "HttpService is not initialized correctly"; 1402 httpsvcNode = httpsvcNode.addChild(MonitoredObjectType.DNS.getTypeName(), MonitoredObjectType.DNS); 1403 httpsvcNode.setStats(stats); 1404 httpsvcNode.setStatsClass(com.sun.enterprise.admin.monitor.stats.PWCDnsStats.class); 1405 httpsvcNode.setDottedName(DottedNameFactory.getDnsDottedName()); 1406 httpsvcNode.setObjectName(MonitoringObjectNames.getDnsObjectName()); 1407 if(shouldRegisterMBean(MonitoredObjectType.DNS)) 1408 httpsvcNode.registerMBean(); 1409 } 1410 1411 public void unregisterPWCDnsStats() throws MonitoringRegistrationException { 1413 1414 StatsHolder httpsvcNode = rootStatsHolder.getChild(MonitoredObjectType.HTTP_SERVICE.getTypeName()); 1415 assert(httpsvcNode != null): "http-service node is null"; 1416 StatsHolder dnsNode = httpsvcNode.getChild(MonitoredObjectType.DNS.getTypeName()); 1417 assert(dnsNode != null): "dns node is null"; 1418 dnsNode.unregisterMBean(); 1419 } 1421 1422 public void registerPWCFileCacheStats( 1424 com.sun.enterprise.admin.monitor.stats.PWCFileCacheStats stats, 1425 MonitoringLevelListener listener) throws MonitoringRegistrationException { 1426 1427 if(stats == null) 1428 throw new IllegalArgumentException ("PWCFileCacheStats is null"); 1429 StatsHolder httpsvcNode = rootStatsHolder.getChild(MonitoredObjectType.HTTP_SERVICE.getTypeName()); 1430 assert(httpsvcNode != null): "HttpService is not initialized correctly"; 1431 httpsvcNode = httpsvcNode.addChild(MonitoredObjectType.FILE_CACHE.getTypeName(), MonitoredObjectType.FILE_CACHE); 1432 httpsvcNode.setStats(stats); 1433 httpsvcNode.setStatsClass(com.sun.enterprise.admin.monitor.stats.PWCFileCacheStats.class); 1434 httpsvcNode.setDottedName(DottedNameFactory.getFileCacheDottedName()); 1435 httpsvcNode.setObjectName(MonitoringObjectNames.getFileCacheObjectName()); 1436 if(shouldRegisterMBean(MonitoredObjectType.FILE_CACHE)) 1437 httpsvcNode.registerMBean(); 1438 } 1439 1440 public void unregisterPWCFileCacheStats() throws MonitoringRegistrationException { 1442 1443 StatsHolder httpsvcNode = rootStatsHolder.getChild(MonitoredObjectType.HTTP_SERVICE.getTypeName()); 1444 assert(httpsvcNode != null): "http-service node is null"; 1445 StatsHolder fcNode = httpsvcNode.getChild(MonitoredObjectType.FILE_CACHE.getTypeName()); 1446 assert(fcNode != null): "file-cache node is null"; 1447 fcNode.unregisterMBean(); 1448 } 1450 1451 public void registerPWCHttpServiceStats( 1453 com.sun.enterprise.admin.monitor.stats.PWCHttpServiceStats stats, 1454 MonitoringLevelListener listener) throws MonitoringRegistrationException { 1455 1456 if(stats == null) 1457 throw new IllegalArgumentException ("PWCHttpServiceStats is null"); 1458 StatsHolder httpsvcNode = rootStatsHolder.getChild(MonitoredObjectType.HTTP_SERVICE.getTypeName()); 1463 assert(httpsvcNode != null): "HttpService is not initialized correctly"; 1464 httpsvcNode.setStats(stats); 1465 httpsvcNode.setStatsClass(com.sun.enterprise.admin.monitor.stats.PWCHttpServiceStats.class); 1466 if(shouldRegisterMBean(MonitoredObjectType.HTTP_SERVICE)) { 1467 httpsvcNode.unregisterMBean(); 1468 httpsvcNode.registerMBean(); 1469 } 1470 } 1471 1472 public void unregisterPWCHttpServiceStats() throws MonitoringRegistrationException { 1474 1475 StatsHolder httpsvcNode = rootStatsHolder.getChild(MonitoredObjectType.HTTP_SERVICE.getTypeName()); 1476 assert(httpsvcNode != null): "http-service node is null"; 1477 httpsvcNode.unregisterMBean(); 1478 httpsvcNode.setStats(null); 1479 httpsvcNode.setStatsClass(javax.management.j2ee.statistics.Stats .class); 1482 httpsvcNode.registerMBean(); 1483 } 1484 1485 public void registerPWCKeepAliveStats( 1487 com.sun.enterprise.admin.monitor.stats.PWCKeepAliveStats stats, 1488 MonitoringLevelListener listener) throws MonitoringRegistrationException { 1489 1490 if(stats == null) 1491 throw new IllegalArgumentException ("PWCHttpServiceStats is null"); 1492 StatsHolder httpsvcNode = rootStatsHolder.getChild(MonitoredObjectType.HTTP_SERVICE.getTypeName()); 1493 assert(httpsvcNode != null): "HttpService is not initialized correctly"; 1494 httpsvcNode = httpsvcNode.addChild(MonitoredObjectType.KEEP_ALIVE.getTypeName(), MonitoredObjectType.KEEP_ALIVE); 1495 httpsvcNode.setStats(stats); 1496 httpsvcNode.setStatsClass(com.sun.enterprise.admin.monitor.stats.PWCKeepAliveStats.class); 1497 httpsvcNode.setDottedName(DottedNameFactory.getKeepAliveDottedName()); 1498 httpsvcNode.setObjectName(MonitoringObjectNames.getKeepAliveObjectName()); 1499 if(shouldRegisterMBean(MonitoredObjectType.KEEP_ALIVE)) 1500 httpsvcNode.registerMBean(); 1501 } 1502 public void unregisterPWCKeepAliveStats() throws MonitoringRegistrationException { 1504 1505 StatsHolder httpsvcNode = rootStatsHolder.getChild(MonitoredObjectType.HTTP_SERVICE.getTypeName()); 1506 assert(httpsvcNode != null): "http-service node is null"; 1507 StatsHolder kaNode = httpsvcNode.getChild(MonitoredObjectType.KEEP_ALIVE.getTypeName()); 1508 assert(kaNode != null): "keep-alive node is null"; 1509 kaNode.unregisterMBean(); 1510 } 1512 1513 public void registerPWCRequestStats( 1515 com.sun.enterprise.admin.monitor.stats.PWCRequestStats stats, 1516 String vsId, 1517 MonitoringLevelListener listener) throws MonitoringRegistrationException { 1518 1519 if((stats == null) || (vsId == null) || (vsId.equals(""))) 1520 throw new IllegalArgumentException ("Invalid arguments for registration of request stats"); 1521 StatsHolder httpsvcNode = rootStatsHolder.getChild(MonitoredObjectType.HTTP_SERVICE.getTypeName()); 1522 assert(httpsvcNode != null): "http-service node is null"; 1523 StatsHolder vsNode = httpsvcNode.getChild(vsId); 1524 assert(vsNode != null): "virtual-server is not initialized correctly"; 1525 vsNode = vsNode.addChild(MonitoredObjectType.REQUEST.getTypeName(), MonitoredObjectType.REQUEST); 1526 vsNode.setStats(stats); 1527 vsNode.setStatsClass(com.sun.enterprise.admin.monitor.stats.PWCRequestStats.class); 1528 vsNode.setDottedName(DottedNameFactory.getRequestDottedName(vsId)); 1529 vsNode.setObjectName(MonitoringObjectNames.getRequestObjectName(vsId)); 1530 if(shouldRegisterMBean(MonitoredObjectType.REQUEST)) 1531 vsNode.registerMBean(); 1532 } 1533 1534 public void unregisterPWCRequestStats(String vsId) throws MonitoringRegistrationException { 1536 1537 StatsHolder httpsvcNode = rootStatsHolder.getChild(MonitoredObjectType.HTTP_SERVICE.getTypeName()); 1538 assert(httpsvcNode != null): "http-service node is null"; 1539 StatsHolder vsNode = httpsvcNode.getChild(vsId); 1540 assert(vsNode != null): "virtual-server node is null"; 1541 StatsHolder requestNode = vsNode.getChild(MonitoredObjectType.REQUEST.getTypeName()); 1542 assert(requestNode != null): "request node is null"; 1543 requestNode.unregisterMBean(); 1544 } 1546 1547 public void registerPWCThreadPoolStats( 1549 com.sun.enterprise.admin.monitor.stats.PWCThreadPoolStats stats, 1550 MonitoringLevelListener listener) throws MonitoringRegistrationException { 1551 1552 if(stats == null) 1553 throw new IllegalArgumentException ("PWCThreadPoolStats is null"); 1554 StatsHolder httpsvcNode = rootStatsHolder.getChild(MonitoredObjectType.HTTP_SERVICE.getTypeName()); 1555 assert(httpsvcNode != null): "HttpService is not initialized correctly"; 1556 httpsvcNode = httpsvcNode.addChild(MonitoredObjectType.PWC_THREAD_POOL.getTypeName(), MonitoredObjectType.PWC_THREAD_POOL); 1557 httpsvcNode.setStats(stats); 1558 httpsvcNode.setStatsClass(com.sun.enterprise.admin.monitor.stats.PWCThreadPoolStats.class); 1559 httpsvcNode.setDottedName(DottedNameFactory.getPWCThreadPoolDottedName()); 1560 httpsvcNode.setObjectName(MonitoringObjectNames.getPWCThreadPoolObjectName()); 1561 if(shouldRegisterMBean(MonitoredObjectType.PWC_THREAD_POOL)) 1562 httpsvcNode.registerMBean(); 1563 } 1564 1565 public void unregisterPWCThreadPoolStats() throws MonitoringRegistrationException { 1567 1568 StatsHolder httpsvcNode = rootStatsHolder.getChild(MonitoredObjectType.HTTP_SERVICE.getTypeName()); 1569 assert(httpsvcNode != null): "http-service node is null"; 1570 StatsHolder tpNode = httpsvcNode.getChild(MonitoredObjectType.PWC_THREAD_POOL.getTypeName()); 1571 assert(tpNode != null): "pwc-thread-pool node is null"; 1572 tpNode.unregisterMBean(); 1573 } 1575 1576 public void registerPWCVirtualServerStats( 1578 com.sun.enterprise.admin.monitor.stats.PWCVirtualServerStats stats, 1579 String vsId, 1580 MonitoringLevelListener listener) throws MonitoringRegistrationException { 1581 1582 if((stats == null) || (vsId == null) || (vsId.equals(""))) 1583 throw new IllegalArgumentException ("Invalid arguments for registration of vs stats"); 1584 StatsHolder httpsvcNode = rootStatsHolder.getChild(MonitoredObjectType.HTTP_SERVICE.getTypeName()); 1585 assert(httpsvcNode != null): "HttpService is not initialized correctly"; 1586 httpsvcNode = httpsvcNode.addChild(vsId, MonitoredObjectType.VIRTUAL_SERVER); 1587 httpsvcNode.setStats(stats); 1588 httpsvcNode.setStatsClass(com.sun.enterprise.admin.monitor.stats.PWCVirtualServerStats.class); 1589 httpsvcNode.setDottedName(DottedNameFactory.getHttpSvcVirtualServerDottedName(vsId)); 1590 httpsvcNode.setObjectName(MonitoringObjectNames.getVirtualServerObjectName(vsId)); 1591 if(shouldRegisterMBean(MonitoredObjectType.VIRTUAL_SERVER)) 1592 httpsvcNode.registerMBean(); 1593 } 1594 1595 public void unregisterPWCVirtualServerStats(String vsId) throws MonitoringRegistrationException { 1597 1598 StatsHolder httpsvcNode = rootStatsHolder.getChild(MonitoredObjectType.HTTP_SERVICE.getTypeName()); 1599 assert(httpsvcNode != null): "http-service node is null"; 1600 StatsHolder vsNode = httpsvcNode.getChild(vsId); 1601 assert(vsNode != null): "virtual-server node is null"; 1602 Collection c = vsNode.getAllChildren(); 1604 Iterator iter = c.iterator(); 1605 while(iter.hasNext()) { 1606 StatsHolder childNode = (StatsHolder)iter.next(); 1607 childNode.unregisterMBean(); 1608 } 1610 vsNode.unregisterMBean(); 1612 } 1614 1616 public void registerStatefulSessionStoreStats(StatefulSessionStoreStats stats, 1618 String ejbName, 1619 String moduleName, 1620 String j2eeAppName, 1621 MonitoringLevelListener listener) 1622 throws MonitoringRegistrationException { 1623 1624 if((stats == null) || (ejbName == null) || (moduleName == null)) 1625 throw new IllegalArgumentException ("Invalid arguments for registration of StatefulSessionStore stats"); 1626 1627 StatsHolder ejbNode = getEjb(j2eeAppName, moduleName, ejbName); 1628 assert(ejbNode != null): "EJB node is not initialized correctly"; 1629 ejbNode = ejbNode.addChild(MonitoredObjectType.SESSION_STORE.getTypeName(), MonitoredObjectType.SESSION_STORE); 1630 ejbNode.setStats(stats); 1631 if(stats instanceof com.sun.enterprise.admin.monitor.stats.HAStatefulSessionStoreStats) 1632 ejbNode.setStatsClass(com.sun.enterprise.admin.monitor.stats.HAStatefulSessionStoreStats.class); 1633 else 1634 ejbNode.setStatsClass(com.sun.enterprise.admin.monitor.stats.StatefulSessionStoreStats.class); 1635 ejbNode.setDottedName(DottedNameFactory.getStatefulSessionStoreDottedName(ejbName, moduleName, j2eeAppName)); 1636 ejbNode.setObjectName(MonitoringObjectNames.getStatefulSessionStoreObjectName(ejbName, moduleName, j2eeAppName)); 1637 addMonitoringLevelListener(listener); if(shouldRegisterMBean(MonitoredObjectType.SESSION_STORE)) 1639 ejbNode.registerMBean(); 1640 } 1641 1642 public void unregisterStatefulSessionStoreStats(String ejbName, 1643 String moduleName, 1644 String j2eeAppName) 1645 throws MonitoringRegistrationException { 1646 1647 if((ejbName == null)|| (moduleName == null)) 1648 throw new IllegalArgumentException ("Invalid arguments for the unregistration of StatefulSessionStore stats"); 1649 1650 StatsHolder ejbNode = getEjb(j2eeAppName, moduleName, ejbName); 1651 assert(ejbNode != null): "EJB node is not initialized correctly"; 1652 StatsHolder storeNode = ejbNode.getChild(MonitoredObjectType.SESSION_STORE.getTypeName()); 1653 assert(storeNode != null): "SessionStore node is not initialized correctly"; 1654 storeNode.unregisterMBean(); 1655 ejbNode.removeChild(MonitoredObjectType.SESSION_STORE.getTypeName()); 1656 } 1657 1659 public void registerTimerStats(TimerServiceStats stats, 1661 String ejbName, 1662 String moduleName, 1663 String j2eeAppName, 1664 MonitoringLevelListener listener) 1665 throws MonitoringRegistrationException { 1666 1667 if((stats == null) || (ejbName == null) || (moduleName == null)) 1668 throw new IllegalArgumentException ("Invalid arguments for registration of Timer stats"); 1669 1670 StatsHolder ejbNode = getEjb(j2eeAppName, moduleName, ejbName); 1671 assert(ejbNode != null): "EJB node is not initialized correctly"; 1672 ejbNode = ejbNode.addChild(MonitoredObjectType.TIMERS.getTypeName(), MonitoredObjectType.TIMERS); 1673 ejbNode.setStats(stats); 1674 ejbNode.setStatsClass(com.sun.enterprise.admin.monitor.stats.TimerServiceStats.class); 1675 ejbNode.setDottedName(DottedNameFactory.getTimerDottedName(ejbName, moduleName, j2eeAppName)); 1676 ejbNode.setObjectName(MonitoringObjectNames.getTimerObjectName(ejbName, moduleName, j2eeAppName)); 1677 addMonitoringLevelListener(listener); if(shouldRegisterMBean(MonitoredObjectType.TIMERS)) 1679 ejbNode.registerMBean(); 1680 } 1681 1682 public void unregisterTimerStats(String ejbName, 1683 String moduleName, 1684 String j2eeAppName) 1685 throws MonitoringRegistrationException { 1686 1687 if((ejbName == null)|| (moduleName == null)) 1688 throw new IllegalArgumentException ("Invalid arguments for the unregistration of Timer stats"); 1689 1690 StatsHolder ejbNode = getEjb(j2eeAppName, moduleName, ejbName); 1691 assert(ejbNode != null): "EJB node is not initialized correctly"; 1692 StatsHolder timerNode = ejbNode.getChild(MonitoredObjectType.TIMERS.getTypeName()); 1693 assert(timerNode != null): "Timer node is not initialized correctly"; 1694 timerNode.unregisterMBean(); 1695 ejbNode.removeChild(MonitoredObjectType.TIMERS.getTypeName()); 1696 } 1697 1698 1700 1702 public void registerWSAggregateStatsForWeb(Stats stats, 1703 String endpointName, 1704 String moduleName, 1705 String ctxRoot, 1706 String j2eeAppName, 1707 String vs, 1708 MonitoringLevelListener listener) 1709 throws MonitoringRegistrationException { 1710 1711 if((stats == null) || (endpointName == null) || (moduleName == null)) 1712 throw new IllegalArgumentException ( 1713 "Invalid arguments for registration of WS aggregate stats"); 1714 1715 StatsHolder wsNode = getWebServiceEndpointForWeb(j2eeAppName, 1716 moduleName, ctxRoot, vs, endpointName); 1717 assert(wsNode != null): "Web Service node is not initialized correctly"; 1718 wsNode = wsNode.addChild(MonitoredObjectType.WEBSERVICE_ENDPOINT. 1719 getTypeName(), MonitoredObjectType.WEBSERVICE_ENDPOINT); 1720 wsNode.setStats(stats); 1721 wsNode.setStatsClassName("com.sun.appserv.management.monitor.statistics.WebServiceEndpointAggregateStats"); 1722 wsNode.setDottedName( DottedNameFactory. 1723 getWebServiceAggregateStatsInWebDottedName( 1724 endpointName, moduleName, j2eeAppName)); 1725 wsNode.setObjectName( 1726 MonitoringObjectNames.getWebServiceObjectNameForWeb( 1727 endpointName, j2eeAppName, ctxRoot, vs )); 1728 addMonitoringLevelListener(listener); if(shouldRegisterMBean(MonitoredObjectType.WEBSERVICE_ENDPOINT)) 1730 wsNode.registerMBean(); 1731 } 1732 1733 public void unregisterWSAggregateStatsForWeb(String endpointName, 1734 String moduleName, 1735 String ctxRoot, 1736 String j2eeAppName, 1737 String vs) 1738 throws MonitoringRegistrationException { 1739 1740 if((endpointName == null)|| (moduleName == null)) 1741 throw new IllegalArgumentException ( 1742 "Invalid arguments for the unregistration of Web Service stats"); 1743 1744 StatsHolder wsNode = getWebServiceEndpointForWeb(j2eeAppName, 1745 moduleName, ctxRoot, vs, endpointName); 1746 assert(wsNode != null): "Web Service node is not initialized correctly"; 1747 StatsHolder endpointNode = 1748 wsNode.getChild(MonitoredObjectType.WEBSERVICE_ENDPOINT.getTypeName()); 1749 assert(endpointNode != null): 1750 "Endpoint node is not initialized correctly"; 1751 endpointNode.unregisterMBean(); 1752 wsNode.removeChild(MonitoredObjectType.WEBSERVICE_ENDPOINT. 1753 getTypeName()); 1754 } 1755 1756 public void registerWSAggregateStatsForEjb(Stats stats, 1757 String endpointName, 1758 String moduleName, 1759 String j2eeAppName, 1760 MonitoringLevelListener listener) 1761 throws MonitoringRegistrationException { 1762 1763 if((stats == null) || (endpointName == null) || (moduleName == null)) 1764 throw new IllegalArgumentException ( 1765 "Invalid arguments for registration of WS aggregate stats"); 1766 1767 StatsHolder wsNode = getWebServiceEndpointForEjb(j2eeAppName,moduleName, 1768 endpointName); 1769 assert(wsNode != null): "Web Service node is not initialized correctly"; 1770 wsNode = wsNode.addChild(MonitoredObjectType.WEBSERVICE_ENDPOINT. 1771 getTypeName(), MonitoredObjectType.WEBSERVICE_ENDPOINT); 1772 wsNode.setStats(stats); 1773 wsNode.setStatsClassName("com.sun.appserv.management.monitor.statistics.WebServiceEndpointAggregateStats"); 1774 wsNode.setDottedName( DottedNameFactory. 1775 getWebServiceAggregateStatsInEjbDottedName( 1776 endpointName, moduleName, j2eeAppName)); 1777 wsNode.setObjectName( 1778 MonitoringObjectNames.getWebServiceObjectNameForEjb( 1779 endpointName, moduleName, j2eeAppName)); 1780 addMonitoringLevelListener(listener); if(shouldRegisterMBean(MonitoredObjectType.WEBSERVICE_ENDPOINT)) 1782 wsNode.registerMBean(); 1783 } 1784 1785 public void unregisterWSAggregateStatsForEjb(String endpointName, 1786 String moduleName, 1787 String j2eeAppName) 1788 throws MonitoringRegistrationException { 1789 1790 if((endpointName == null)|| (moduleName == null)) 1791 throw new IllegalArgumentException ( 1792 "Invalid arguments for the unregistration of Web Service stats"); 1793 1794 StatsHolder wsNode = getWebServiceEndpointForEjb(j2eeAppName,moduleName, endpointName); 1795 1796 assert(wsNode != null): "Web Service node is not initialized correctly"; 1797 StatsHolder endpointNode = 1798 wsNode.getChild(MonitoredObjectType.WEBSERVICE_ENDPOINT.getTypeName()); 1799 assert(endpointNode != null): 1800 "Endpoint node is not initialized correctly"; 1801 endpointNode.unregisterMBean(); 1802 wsNode.removeChild(MonitoredObjectType.WEBSERVICE_ENDPOINT. 1803 getTypeName()); 1804 } 1805 1806 1808 public Collection getJvmNodes(boolean threadInfo) { 1810 1811 final Collection all = new ArrayList(); 1812 final StatsHolder jvmNode = rootStatsHolder.getChild(MonitoredObjectType.JVM.getTypeName()); 1813 final Collection systemNodes = jvmNode.getAllChildren(); 1814 if(systemNodes != null) { 1815 final Iterator it = systemNodes.iterator(); 1816 while (it.hasNext()) { 1817 StatsHolder childNode = (StatsHolder)it.next(); 1818 all.add(childNode); 1819 if(childNode.getType() == MonitoredObjectType.JVM_GCS) 1821 all.addAll(childNode.getAllChildren()); 1822 if((childNode.getType() == MonitoredObjectType.JVM_THREAD) && threadInfo) 1824 all.addAll(childNode.getAllChildren()); 1825 } 1826 } 1827 return all; 1828 } 1829 1830 public Collection getJvmThreadInfoNodes() { 1831 1832 final Collection all = new ArrayList(); 1833 final StatsHolder jvmNode = rootStatsHolder.getChild(MonitoredObjectType.JVM.getTypeName()); 1834 final StatsHolder threadNode = jvmNode.getChild(MonitoredObjectType.JVM_THREAD.getTypeName()); 1835 if(threadNode != null) 1836 all.addAll(threadNode.getAllChildren()); 1837 1838 return all; 1839 } 1840 1841 public StatsHolder getRootStatsHolder() { 1842 return rootStatsHolder; 1843 } 1844} 1845 | Popular Tags |