コード例 #1
0
 public void register(StatsProviderInfo spInfo) {
   try {
     tryToRegister(spInfo);
   } catch (RuntimeException rte) {
     logger.log(
         Level.WARNING,
         ListenerRegistrationFailed,
         new Object[] {spInfo.getStatsProvider().getClass().getName()});
     if (logger.isLoggable(Level.FINE))
       logger.log(Level.FINE, "Listener registration failed", rte);
     FutureStatsProviders.add(spInfo);
   }
 }
コード例 #2
0
  /* throws RuntimeException maybe
   * note the default visibility so that MonitoringBootstrap can call it.
   */
  void tryToRegister(StatsProviderInfo spInfo) {
    final String configElement = spInfo.getConfigElement();
    Object statsProvider = spInfo.getStatsProvider();
    // register the statsProvider
    if (logger.isLoggable(Level.FINE)) logger.fine("registering a statsProvider");
    StatsProviderRegistryElement spre;
    // If configElement is null, create it
    if (monitoringService != null
        && monitoringService.getContainerMonitoring(configElement) == null
        && monitoringService.getMonitoringLevel(configElement) == null) {
      createConfigElement(configElement);
    }

    // First check if the configElement associated for statsProvider is 'ON'
    if (getMonitoringEnabled() && getEnabledValue(configElement)) {
      if (logger.isLoggable(Level.FINE)) logger.fine(" enabled is true ");
      spre = statsProviderRegistry.getStatsProviderRegistryElement(statsProvider);

      if (spre == null) {
        statsProviderRegistry.registerStatsProvider(spInfo);
        spre = statsProviderRegistry.getStatsProviderRegistryElement(statsProvider);
      }
      // Enable the StatsProvider if the enable is allowed
      if (spre.isEnableAllowed(getMonitoringLevel(configElement))) {
        enableStatsProvider(spre);
      }

    } else {
      if (logger.isLoggable(Level.FINE)) logger.fine(" enabled is false ");
      // Register with null values so to know that we need to register them individually and config
      // is on
      statsProviderRegistry.registerStatsProvider(spInfo);
      spre = statsProviderRegistry.getStatsProviderRegistryElement(statsProvider);
    }

    if (logger.isLoggable(Level.FINE)) {
      logger.fine(spre.toString());
      logger.fine("=========================================================");
    }
  }