コード例 #1
0
  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());
  }
コード例 #2
0
 @Override
 public int getViewId() {
   if (channel == null)
     throw new CacheException("The cache has been stopped and invocations are not allowed!");
   View view = channel.getView();
   if (view == null) return -1;
   return (int) view.getVid().getId();
 }
コード例 #3
0
  public void start() {
    if (corr == null)
      corr =
          createRequestCorrelator(prot_adapter, this, local_addr)
              .asyncDispatching(async_dispatching);
    correlatorStarted();
    corr.start();

    if (channel != null) {
      List<Address> tmp_mbrs = channel.getView() != null ? channel.getView().getMembers() : null;
      setMembers(tmp_mbrs);
      if (channel instanceof JChannel) {
        TP transport = channel.getProtocolStack().getTransport();
        corr.registerProbeHandler(transport);
      }
      TP transport = channel.getProtocolStack().getTransport();
      hardware_multicast_supported = transport.supportsMulticasting();
      transport.registerProbeHandler(probe_handler);
    }
  }
コード例 #4
0
 @Override
 public void channelConnected(Channel channel) {
   // Validate view
   String localName = channel.getName();
   Address localAddress = channel.getAddress();
   for (Address address : channel.getView()) {
     String name = channel.getName(address);
     if ((name != null) && name.equals(localName) && !address.equals(localAddress)) {
       channel.close();
       throw JGroupsLogger.ROOT_LOGGER.duplicateNodeName(
           this.factory.getValue().getProtocolStackConfiguration().getEnvironment().getNodeName());
     }
   }
 }