예제 #1
0
    // ClusterListener
    @Override
    public void nodeUP(TopologyMember member, boolean last) {
      ClientSessionInternal sessionToUse = session;
      RemotingConnection connectionToUse =
          sessionToUse != null ? sessionToUse.getConnection() : null;

      if (member != null
          && BridgeImpl.this.targetNodeID != null
          && BridgeImpl.this.targetNodeID.equals(member.getNodeId())) {
        // this could be an update of the topology say after a backup started
        BridgeImpl.this.targetNode = member;
      } else {
        // we don't need synchronization here, but we need to make sure we won't get a NPE on races
        if (connectionToUse != null && member.isMember(connectionToUse)) {
          BridgeImpl.this.targetNode = member;
          BridgeImpl.this.targetNodeID = member.getNodeId();
        }
      }
    }
예제 #2
0
  private ClientSessionFactoryInternal reconnectOnOriginalNode() throws Exception {
    String targetNodeIdUse = targetNodeID;
    TopologyMember nodeUse = targetNode;
    if (targetNodeIdUse != null && nodeUse != null) {
      TransportConfiguration[] configs = new TransportConfiguration[2]; // live and backup
      int numberOfConfigs = 0;

      if (nodeUse.getLive() != null) {
        configs[numberOfConfigs++] = nodeUse.getLive();
      }
      if (nodeUse.getBackup() != null) {
        configs[numberOfConfigs++] = nodeUse.getBackup();
      }

      if (numberOfConfigs > 0) {
        // It will bounce between all the available configs
        int nodeTry = (retryCount - 1) % numberOfConfigs;

        return (ClientSessionFactoryInternal) serverLocator.createSessionFactory(configs[nodeTry]);
      }
    }

    return null;
  }
예제 #3
0
 @Override
 public void nodeUP(TopologyMember topologyMember, boolean last) {
   if (topologyMember.getLive() != null
       && !liveNode.contains(topologyMember.getLive().getName())) {
     liveNode.add(topologyMember.getLive().getName());
     latch.countDown();
   }
   if (topologyMember.getBackup() != null
       && !backupNode.contains(topologyMember.getBackup().getName())) {
     backupNode.add(topologyMember.getBackup().getName());
     latch.countDown();
   }
 }