protected void startJGroupsChannelIfNeeded() {
    if (startChannel) {
      String clusterName = configuration.getClusterName();
      try {
        channel.connect(clusterName);
      } catch (Exception e) {
        throw new CacheException("Unable to start JGroups Channel", e);
      }

      try {
        // Normally this would be done by CacheManagerJmxRegistration but
        // the channel is not started when the cache manager starts but
        // when first cache starts, so it's safer to do it here.
        globalStatsEnabled = configuration.isExposeGlobalJmxStatistics();
        if (globalStatsEnabled) {
          String groupName =
              String.format("type=channel,cluster=%s", ObjectName.quote(clusterName));
          mbeanServer = JmxUtil.lookupMBeanServer(configuration);
          domain = JmxUtil.buildJmxDomain(configuration, mbeanServer, groupName);
          JmxConfigurator.registerChannel(
              (JChannel) channel, mbeanServer, domain, clusterName, true);
        }
      } catch (Exception e) {
        throw new CacheException("Channel connected, but unable to register MBeans", e);
      }
    }
    address = fromJGroupsAddress(channel.getAddress());
    if (!startChannel) {
      // the channel was already started externally, we need to initialize our member list
      viewAccepted(channel.getView());
    }
    if (log.isInfoEnabled()) log.localAndPhysicalAddress(getAddress(), getPhysicalAddresses());
  }
Esempio n. 2
0
 private void unregisterProtobufMetadataManagerMBean(GlobalComponentRegistry gcr) {
   try {
     ObjectName objName = gcr.getComponent(ProtobufMetadataManager.class).getObjectName();
     MBeanServer mBeanServer = JmxUtil.lookupMBeanServer(gcr.getGlobalConfiguration());
     JmxUtil.unregisterMBean(objName, mBeanServer);
   } catch (Exception e) {
     throw new CacheException("Unable to unregister ProtobufMetadataManager MBean", e);
   }
 }
 /** Performs the MBean registration. */
 public void registerMBeans() throws CacheException {
   try {
     List<ResourceDMBean> resourceDMBeans = getResourceDMBeansFromComponents();
     for (ResourceDMBean resource : resourceDMBeans)
       JmxUtil.registerMBean(resource, getObjectName(resource), mBeanServer);
   } catch (Exception e) {
     throw new CacheException("Failure while registering mbeans", e);
   }
 }
 /** Unregisters all the MBeans registered through {@link #registerMBeans()}. */
 public void unregisterMBeans() throws CacheException {
   log.trace("Unregistering jmx resources..");
   try {
     List<ResourceDMBean> resourceDMBeans = getResourceDMBeansFromComponents();
     for (ResourceDMBean resource : resourceDMBeans) {
       JmxUtil.unregisterMBean(getObjectName(resource), mBeanServer);
     }
   } catch (Exception e) {
     throw new CacheException("Failure while unregistering mbeans", e);
   }
 }
Esempio n. 5
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);
    }
  }
Esempio n. 6
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);
    }
  }
Esempio n. 7
0
  @Override
  public void cacheStopping(ComponentRegistry cr, String cacheName) {
    // TODO move this to cacheStopped event (won't work right now as the ComponentRegistry is half
    // empty at that point: ISPN-1006)
    Object searchFactoryIntegrator = cr.getComponent(SearchFactoryIntegrator.class);
    if (searchFactoryIntegrator != null && searchFactoryIntegrator != REMOVED_REGISTRY_COMPONENT) {
      searchFactoriesToShutdown.put(cacheName, (SearchFactoryIntegrator) searchFactoryIntegrator);
      // free some memory by de-registering the SearchFactory
      cr.registerComponent(REMOVED_REGISTRY_COMPONENT, SearchFactoryIntegrator.class);
    }

    // Unregister MBeans
    if (mbeanServer != null) {
      String queryMBeanFilter = jmxDomain + ":" + getQueryGroupName(cacheName) + ",*";
      JmxUtil.unregisterMBeans(queryMBeanFilter, mbeanServer);
    }
  }