Пример #1
0
  // Setup monitoring for this threadpool
  private void initializeMonitoring() {
    // Get root monitored object
    MonitoredObject root =
        MonitoringFactories.getMonitoringManagerFactory()
            .createMonitoringManager(MonitoringConstants.DEFAULT_MONITORING_ROOT, null)
            .getRootMonitoredObject();

    // Create the threadpool monitoring root
    MonitoredObject threadPoolMonitoringObjectRoot =
        root.getChild(MonitoringConstants.THREADPOOL_MONITORING_ROOT);
    if (threadPoolMonitoringObjectRoot == null) {
      threadPoolMonitoringObjectRoot =
          MonitoringFactories.getMonitoredObjectFactory()
              .createMonitoredObject(
                  MonitoringConstants.THREADPOOL_MONITORING_ROOT,
                  MonitoringConstants.THREADPOOL_MONITORING_ROOT_DESCRIPTION);
      root.addChild(threadPoolMonitoringObjectRoot);
    }
    threadpoolMonitoredObject =
        MonitoringFactories.getMonitoredObjectFactory()
            .createMonitoredObject(name, MonitoringConstants.THREADPOOL_MONITORING_DESCRIPTION);

    threadPoolMonitoringObjectRoot.addChild(threadpoolMonitoredObject);

    LongMonitoredAttributeBase b1 =
        new LongMonitoredAttributeBase(
            MonitoringConstants.THREADPOOL_CURRENT_NUMBER_OF_THREADS,
            MonitoringConstants.THREADPOOL_CURRENT_NUMBER_OF_THREADS_DESCRIPTION) {
          public Object getValue() {
            return new Long(ThreadPoolImpl.this.currentNumberOfThreads());
          }
        };
    threadpoolMonitoredObject.addAttribute(b1);
    LongMonitoredAttributeBase b2 =
        new LongMonitoredAttributeBase(
            MonitoringConstants.THREADPOOL_NUMBER_OF_AVAILABLE_THREADS,
            MonitoringConstants.THREADPOOL_CURRENT_NUMBER_OF_THREADS_DESCRIPTION) {
          public Object getValue() {
            return new Long(ThreadPoolImpl.this.numberOfAvailableThreads());
          }
        };
    threadpoolMonitoredObject.addAttribute(b2);
    LongMonitoredAttributeBase b3 =
        new LongMonitoredAttributeBase(
            MonitoringConstants.THREADPOOL_NUMBER_OF_BUSY_THREADS,
            MonitoringConstants.THREADPOOL_NUMBER_OF_BUSY_THREADS_DESCRIPTION) {
          public Object getValue() {
            return new Long(ThreadPoolImpl.this.numberOfBusyThreads());
          }
        };
    threadpoolMonitoredObject.addAttribute(b3);
    LongMonitoredAttributeBase b4 =
        new LongMonitoredAttributeBase(
            MonitoringConstants.THREADPOOL_AVERAGE_WORK_COMPLETION_TIME,
            MonitoringConstants.THREADPOOL_AVERAGE_WORK_COMPLETION_TIME_DESCRIPTION) {
          public Object getValue() {
            return new Long(ThreadPoolImpl.this.averageWorkCompletionTime());
          }
        };
    threadpoolMonitoredObject.addAttribute(b4);
    LongMonitoredAttributeBase b5 =
        new LongMonitoredAttributeBase(
            MonitoringConstants.THREADPOOL_CURRENT_PROCESSED_COUNT,
            MonitoringConstants.THREADPOOL_CURRENT_PROCESSED_COUNT_DESCRIPTION) {
          public Object getValue() {
            return new Long(ThreadPoolImpl.this.currentProcessedCount());
          }
        };
    threadpoolMonitoredObject.addAttribute(b5);

    // Add the monitored object for the WorkQueue

    threadpoolMonitoredObject.addChild(((WorkQueueImpl) workQueue).getMonitoredObject());
  }
Пример #2
0
  protected void registerWithMonitoring() {
    // ORB
    MonitoredObject orbMO = orb.getMonitoringManager().getRootMonitoredObject();

    // CONNECTION
    MonitoredObject connectionMO = orbMO.getChild(MonitoringConstants.CONNECTION_MONITORING_ROOT);
    if (connectionMO == null) {
      connectionMO =
          MonitoringFactories.getMonitoredObjectFactory()
              .createMonitoredObject(
                  MonitoringConstants.CONNECTION_MONITORING_ROOT,
                  MonitoringConstants.CONNECTION_MONITORING_ROOT_DESCRIPTION);
      orbMO.addChild(connectionMO);
    }

    // OUTBOUND CONNECTION
    MonitoredObject outboundConnectionMO =
        connectionMO.getChild(MonitoringConstants.OUTBOUND_CONNECTION_MONITORING_ROOT);
    if (outboundConnectionMO == null) {
      outboundConnectionMO =
          MonitoringFactories.getMonitoredObjectFactory()
              .createMonitoredObject(
                  MonitoringConstants.OUTBOUND_CONNECTION_MONITORING_ROOT,
                  MonitoringConstants.OUTBOUND_CONNECTION_MONITORING_ROOT_DESCRIPTION);
      connectionMO.addChild(outboundConnectionMO);
    }

    // NODE FOR THIS CACHE
    MonitoredObject thisMO = outboundConnectionMO.getChild(getMonitoringName());
    if (thisMO == null) {
      thisMO =
          MonitoringFactories.getMonitoredObjectFactory()
              .createMonitoredObject(
                  getMonitoringName(), MonitoringConstants.CONNECTION_MONITORING_DESCRIPTION);
      outboundConnectionMO.addChild(thisMO);
    }

    LongMonitoredAttributeBase attribute;

    // ATTRIBUTE
    attribute =
        new LongMonitoredAttributeBase(
            MonitoringConstants.CONNECTION_TOTAL_NUMBER_OF_CONNECTIONS,
            MonitoringConstants.CONNECTION_TOTAL_NUMBER_OF_CONNECTIONS_DESCRIPTION) {
          public Object getValue() {
            return new Long(CorbaOutboundConnectionCacheImpl.this.numberOfConnections());
          }
        };
    thisMO.addAttribute(attribute);

    // ATTRIBUTE
    attribute =
        new LongMonitoredAttributeBase(
            MonitoringConstants.CONNECTION_NUMBER_OF_IDLE_CONNECTIONS,
            MonitoringConstants.CONNECTION_NUMBER_OF_IDLE_CONNECTIONS_DESCRIPTION) {
          public Object getValue() {
            return new Long(CorbaOutboundConnectionCacheImpl.this.numberOfIdleConnections());
          }
        };
    thisMO.addAttribute(attribute);

    // ATTRIBUTE
    attribute =
        new LongMonitoredAttributeBase(
            MonitoringConstants.CONNECTION_NUMBER_OF_BUSY_CONNECTIONS,
            MonitoringConstants.CONNECTION_NUMBER_OF_BUSY_CONNECTIONS_DESCRIPTION) {
          public Object getValue() {
            return new Long(CorbaOutboundConnectionCacheImpl.this.numberOfBusyConnections());
          }
        };
    thisMO.addAttribute(attribute);
  }