Exemplo n.º 1
0
  private void ensureConnectionToAllMembers() {
    boolean allConnected = false;
    if (node.joined()) {
      logger.finest("Waiting for all connections");
      int connectAllWaitSeconds =
          node.groupProperties.getSeconds(GroupProperty.CONNECT_ALL_WAIT_SECONDS);
      int checkCount = 0;
      while (checkCount++ < connectAllWaitSeconds && !allConnected) {
        try {
          //noinspection BusyWait
          TimeUnit.SECONDS.sleep(1);
        } catch (InterruptedException ignored) {
          EmptyStatement.ignore(ignored);
        }

        allConnected = true;
        Collection<Member> members = clusterService.getMembers();
        for (Member member : members) {
          if (!member.localMember()
              && node.connectionManager.getOrConnect(member.getAddress()) == null) {
            allConnected = false;
            if (logger.isFinestEnabled()) {
              logger.finest("Not-connected to " + member.getAddress());
            }
          }
        }
      }
    }
  }
Exemplo n.º 2
0
  protected void startClusterMerge(final Address targetAddress) {
    ClusterServiceImpl clusterService = node.clusterService;

    if (!prepareClusterState(clusterService)) {
      return;
    }

    OperationService operationService = node.nodeEngine.getOperationService();
    Collection<Member> memberList = clusterService.getMembers();
    for (Member member : memberList) {
      if (!member.localMember()) {
        Operation op = new MergeClustersOperation(targetAddress);
        operationService.invokeOnTarget(ClusterServiceImpl.SERVICE_NAME, op, member.getAddress());
      }
    }

    Operation mergeClustersOperation = new MergeClustersOperation(targetAddress);
    mergeClustersOperation
        .setNodeEngine(node.nodeEngine)
        .setService(clusterService)
        .setOperationResponseHandler(createEmptyResponseHandler());
    operationService.runOperationOnCallingThread(mergeClustersOperation);
  }