コード例 #1
0
  private void registerProtobufMetadataManagerMBean(
      ProtobufMetadataManager protobufMetadataManager,
      GlobalComponentRegistry gcr,
      String cacheManagerName) {
    GlobalConfiguration globalCfg = gcr.getGlobalConfiguration();
    MBeanServer mBeanServer = JmxUtil.lookupMBeanServer(globalCfg);

    String groupName = "type=RemoteQuery,name=" + ObjectName.quote(cacheManagerName);
    String jmxDomain = JmxUtil.buildJmxDomain(globalCfg, mBeanServer, groupName);
    ComponentMetadataRepo metadataRepo = gcr.getComponentMetadataRepo();
    ManageableComponentMetadata metadata =
        metadataRepo
            .findComponentMetadata(ProtobufMetadataManagerImpl.class)
            .toManageableComponentMetadata();
    try {
      ResourceDMBean mBean = new ResourceDMBean(protobufMetadataManager, metadata);
      ObjectName objName =
          new ObjectName(jmxDomain + ":" + groupName + ",component=" + metadata.getJmxObjectName());
      protobufMetadataManager.setObjectName(objName);
      JmxUtil.registerMBean(mBean, objName, mBeanServer);
    } catch (Exception e) {
      throw new CacheException("Unable to register ProtobufMetadataManager MBean", e);
    }
  }
コード例 #2
0
  private void registerQueryMBeans(AdvancedCache cache, ComponentRegistry cr, String cacheName) {
    Configuration cfg = cache.getCacheConfiguration();
    SearchFactoryIntegrator sf = getSearchFactory(cfg.indexing().properties(), cr);

    // Resolve MBean server instance
    GlobalConfiguration globalCfg = cr.getGlobalComponentRegistry().getGlobalConfiguration();
    mbeanServer = JmxUtil.lookupMBeanServer(globalCfg);

    // Resolve jmx domain to use for query mbeans
    String queryGroupName = getQueryGroupName(cacheName);
    jmxDomain = JmxUtil.buildJmxDomain(globalCfg, mbeanServer, queryGroupName);

    // Register statistics MBean, but only enable if Infinispan config says so
    Statistics stats = sf.getStatistics();
    stats.setStatisticsEnabled(cfg.jmxStatistics().enabled());
    try {
      ObjectName statsObjName =
          new ObjectName(jmxDomain + ":" + queryGroupName + ",component=Statistics");
      JmxUtil.registerMBean(new StatisticsInfo(stats), statsObjName, mbeanServer);
    } catch (Exception e) {
      throw new CacheException("Unable to register query module statistics mbean", e);
    }

    // Register mass indexer MBean, picking metadata from repo
    ManageableComponentMetadata metadata =
        metadataRepo.findComponentMetadata(MassIndexer.class).toManageableComponentMetadata();
    try {
      // TODO: MassIndexer should be some kind of query cache component?
      MapReduceMassIndexer maxIndexer = new MapReduceMassIndexer(cache, sf);
      ResourceDMBean mbean = new ResourceDMBean(maxIndexer, metadata);
      ObjectName massIndexerObjName =
          new ObjectName(
              jmxDomain + ":" + queryGroupName + ",component=" + metadata.getJmxObjectName());
      JmxUtil.registerMBean(mbean, massIndexerObjName, mbeanServer);
    } catch (Exception e) {
      throw new CacheException("Unable to create ", e);
    }
  }