Пример #1
0
 @Override
 public Xid[] recover(int flag) throws XAException {
   NodeEngine nodeEngine = getNodeEngine();
   XAService xaService = getService();
   OperationService operationService = nodeEngine.getOperationService();
   ClusterService clusterService = nodeEngine.getClusterService();
   Collection<Member> memberList = clusterService.getMembers();
   List<InternalCompletableFuture<SerializableList>> futureList =
       new ArrayList<InternalCompletableFuture<SerializableList>>();
   for (Member member : memberList) {
     if (member.localMember()) {
       continue;
     }
     CollectRemoteTransactionsOperation op = new CollectRemoteTransactionsOperation();
     Address address = member.getAddress();
     InternalCompletableFuture<SerializableList> future =
         operationService.invokeOnTarget(SERVICE_NAME, op, address);
     futureList.add(future);
   }
   HashSet<SerializableXID> xids = new HashSet<SerializableXID>();
   xids.addAll(xaService.getPreparedXids());
   for (InternalCompletableFuture<SerializableList> future : futureList) {
     SerializableList xidSet = future.getSafely();
     for (Data xidData : xidSet) {
       SerializableXID xid = nodeEngine.toObject(xidData);
       xids.add(xid);
     }
   }
   return xids.toArray(new SerializableXID[xids.size()]);
 }
Пример #2
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());
            }
          }
        }
      }
    }
  }
  private Object handleAuthenticated() {
    if (isOwnerConnection()) {
      final String uuid = getUuid();
      final String localMemberUUID = clientEngine.getLocalMember().getUuid();

      principal = new ClientPrincipal(uuid, localMemberUUID);
      reAuthLocal();
      Collection<Member> members = nodeEngine.getClusterService().getMembers();
      for (Member member : members) {
        if (!member.localMember()) {
          ClientReAuthOperation op = new ClientReAuthOperation(uuid);
          op.setCallerUuid(localMemberUUID);
          nodeEngine.getOperationService().send(op, member.getAddress());
        }
      }
    }

    boolean isNotMember =
        clientEngine.getClusterService().getMember(principal.getOwnerUuid()) == null;
    if (isNotMember) {
      throw new AuthenticationException(
          "Invalid owner-uuid: " + principal.getOwnerUuid() + ", it's not member of this cluster!");
    }

    endpoint.authenticated(principal, credentials, isOwnerConnection());
    setConnectionType();
    endpointManager.registerEndpoint(endpoint);
    clientEngine.bind(endpoint);

    final Address thisAddress = clientEngine.getThisAddress();
    return encodeAuth(thisAddress, principal.getUuid(), principal.getOwnerUuid());
  }
 protected void destroyCacheOnAllMembers(String name, String callerUuid) {
   final OperationService operationService = nodeEngine.getOperationService();
   final Collection<Member> members = nodeEngine.getClusterService().getMembers();
   for (Member member : members) {
     if (!member.localMember() && !member.getUuid().equals(callerUuid)) {
       final CacheDestroyOperation op = new CacheDestroyOperation(name, true);
       operationService.invokeOnTarget(AbstractCacheService.SERVICE_NAME, op, member.getAddress());
     }
   }
 }
Пример #5
0
    private void callDisconnectionOperation(ClientEndpointImpl endpoint) {
      Collection<Member> memberList = nodeEngine.getClusterService().getMembers();
      OperationService operationService = nodeEngine.getOperationService();
      ClientDisconnectionOperation op = createClientDisconnectionOperation(endpoint.getUuid());
      operationService.runOperationOnCallingThread(op);

      for (Member member : memberList) {
        if (!member.localMember()) {
          op = createClientDisconnectionOperation(endpoint.getUuid());
          operationService.send(op, member.getAddress());
        }
      }
    }
Пример #6
0
 public void removeMapInterceptorInternal(String id) {
   NodeEngine nodeEngine = getNodeEngine();
   mapServiceContext.removeInterceptor(name, id);
   Collection<Member> members = nodeEngine.getClusterService().getMembers();
   for (Member member : members) {
     try {
       if (member.localMember()) {
         continue;
       }
       RemoveInterceptorOperation op = new RemoveInterceptorOperation(name, id);
       Future future = operationService.invokeOnTarget(SERVICE_NAME, op, member.getAddress());
       future.get();
     } catch (Throwable t) {
       throw rethrow(t);
     }
   }
 }
Пример #7
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);
  }