Search in sources :

Example 76 with OperationService

use of com.hazelcast.spi.impl.operationservice.OperationService in project hazelcast by hazelcast.

the class RaftInvocationManager method triggerRaftNodeCreation.

void triggerRaftNodeCreation(CPGroupSummary group) {
    for (CPMember groupMember : group.members()) {
        if (groupMember.equals(raftService.getLocalCPMember())) {
            ExecutionService executionService = nodeEngine.getExecutionService();
            executionService.execute(CP_SUBSYSTEM_EXECUTOR, () -> raftService.createRaftNode(group.id(), group.initialMembers()));
        } else {
            Operation op = new CreateRaftNodeOp(group.id(), group.initialMembers());
            OperationService operationService = nodeEngine.getOperationService();
            operationService.send(op, groupMember.getAddress());
        }
    }
}
Also used : CreateRaftNodeOp(com.hazelcast.cp.internal.raftop.metadata.CreateRaftNodeOp) Operation(com.hazelcast.spi.impl.operationservice.Operation) OperationService(com.hazelcast.spi.impl.operationservice.OperationService) ExecutionService(com.hazelcast.spi.impl.executionservice.ExecutionService) CPMember(com.hazelcast.cp.CPMember)

Example 77 with OperationService

use of com.hazelcast.spi.impl.operationservice.OperationService in project hazelcast by hazelcast.

the class MetadataRaftGroupManager method broadcastActiveCPMembers.

void broadcastActiveCPMembers() {
    if (!(isDiscoveryCompleted() && isMetadataGroupLeader())) {
        return;
    }
    RaftGroupId metadataGroupId = getMetadataGroupId();
    long commitIndex = this.activeMembersCommitIndex;
    Collection<CPMemberInfo> cpMembers = this.activeMembers;
    if (cpMembers.isEmpty()) {
        return;
    }
    Set<Member> clusterMembers = nodeEngine.getClusterService().getMembers();
    OperationService operationService = nodeEngine.getOperationService();
    Operation op = new PublishActiveCPMembersOp(metadataGroupId, commitIndex, cpMembers);
    for (Member member : clusterMembers) {
        if (member.localMember()) {
            continue;
        }
        operationService.send(op, member.getAddress());
    }
}
Also used : PublishActiveCPMembersOp(com.hazelcast.cp.internal.raftop.metadata.PublishActiveCPMembersOp) OperationService(com.hazelcast.spi.impl.operationservice.OperationService) Operation(com.hazelcast.spi.impl.operationservice.Operation) Member(com.hazelcast.cluster.Member)

Example 78 with OperationService

use of com.hazelcast.spi.impl.operationservice.OperationService in project hazelcast by hazelcast.

the class MetadataRaftGroupManager method sendTerminateRaftNodeOpsForDestroyedGroup.

private void sendTerminateRaftNodeOpsForDestroyedGroup(CPGroupInfo group) {
    Map<UUID, CPMemberInfo> activeMembersMap = getActiveMembersMap();
    CPMemberInfo localCPMember = getLocalCPMember();
    if (localCPMember == null) {
        return;
    }
    RaftEndpoint localEndpoint = localCPMember.toRaftEndpoint();
    OperationService operationService = nodeEngine.getOperationService();
    for (RaftEndpoint endpoint : group.members()) {
        if (endpoint.equals(localEndpoint)) {
            terminateRaftNodeAsync(group.id());
        } else {
            Operation op = new TerminateRaftNodesOp(Collections.singleton(group.id()));
            CPMemberInfo cpMember = activeMembersMap.get(endpoint.getUuid());
            operationService.invokeOnTarget(SERVICE_NAME, op, cpMember.getAddress());
        }
    }
}
Also used : RaftEndpoint(com.hazelcast.cp.internal.raft.impl.RaftEndpoint) OperationService(com.hazelcast.spi.impl.operationservice.OperationService) Operation(com.hazelcast.spi.impl.operationservice.Operation) UUID(java.util.UUID) TerminateRaftNodesOp(com.hazelcast.cp.internal.raftop.metadata.TerminateRaftNodesOp)

Example 79 with OperationService

use of com.hazelcast.spi.impl.operationservice.OperationService in project hazelcast by hazelcast.

the class ExecutorServiceProxy method submitToPartitionOwner.

private <T> void submitToPartitionOwner(@Nonnull Callable<T> task, @Nullable ExecutionCallback<T> callback, int partitionId) {
    checkNotShutdown();
    checkNotNull(task, "task must not be null");
    NodeEngine nodeEngine = getNodeEngine();
    Data taskData = nodeEngine.toData(task);
    CallableTaskOperation op = new CallableTaskOperation(name, null, taskData);
    OperationService operationService = nodeEngine.getOperationService();
    InvocationFuture<T> future = operationService.createInvocationBuilder(DistributedExecutorService.SERVICE_NAME, op, partitionId).invoke();
    if (callback != null) {
        future.whenCompleteAsync(new ExecutionCallbackAdapter<>(callback)).whenCompleteAsync((v, t) -> {
            if (t instanceof RejectedExecutionException) {
                callback.onFailure(t);
            }
        });
    }
}
Also used : NodeEngine(com.hazelcast.spi.impl.NodeEngine) Data(com.hazelcast.internal.serialization.Data) OperationService(com.hazelcast.spi.impl.operationservice.OperationService) RejectedExecutionException(java.util.concurrent.RejectedExecutionException) CallableTaskOperation(com.hazelcast.executor.impl.operations.CallableTaskOperation) MemberCallableTaskOperation(com.hazelcast.executor.impl.operations.MemberCallableTaskOperation)

Example 80 with OperationService

use of com.hazelcast.spi.impl.operationservice.OperationService in project hazelcast by hazelcast.

the class ExecutorServiceProxy method shutdown.

@Override
public void shutdown() {
    NodeEngine nodeEngine = getNodeEngine();
    Collection<Member> members = nodeEngine.getClusterService().getMembers();
    OperationService operationService = nodeEngine.getOperationService();
    Collection<Future> calls = new LinkedList<>();
    for (Member member : members) {
        Future f = submitShutdownOperation(operationService, member);
        calls.add(f);
    }
    waitWithDeadline(calls, 3, TimeUnit.SECONDS, shutdownExceptionHandler);
}
Also used : NodeEngine(com.hazelcast.spi.impl.NodeEngine) InvocationFuture(com.hazelcast.spi.impl.operationservice.impl.InvocationFuture) InternalCompletableFuture(com.hazelcast.spi.impl.InternalCompletableFuture) Future(java.util.concurrent.Future) OperationService(com.hazelcast.spi.impl.operationservice.OperationService) Member(com.hazelcast.cluster.Member) LinkedList(java.util.LinkedList)

Aggregations

OperationService (com.hazelcast.spi.impl.operationservice.OperationService)140 Operation (com.hazelcast.spi.impl.operationservice.Operation)55 Test (org.junit.Test)54 HazelcastInstance (com.hazelcast.core.HazelcastInstance)46 QuickTest (com.hazelcast.test.annotation.QuickTest)41 Accessors.getOperationService (com.hazelcast.test.Accessors.getOperationService)40 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)40 Address (com.hazelcast.cluster.Address)31 NodeEngine (com.hazelcast.spi.impl.NodeEngine)31 InternalCompletableFuture (com.hazelcast.spi.impl.InternalCompletableFuture)24 Future (java.util.concurrent.Future)24 TestHazelcastInstanceFactory (com.hazelcast.test.TestHazelcastInstanceFactory)23 Config (com.hazelcast.config.Config)22 Member (com.hazelcast.cluster.Member)21 Data (com.hazelcast.internal.serialization.Data)12 SlowTest (com.hazelcast.test.annotation.SlowTest)12 ClusterService (com.hazelcast.internal.cluster.ClusterService)9 ILogger (com.hazelcast.logging.ILogger)7 ArrayList (java.util.ArrayList)7 IPartitionService (com.hazelcast.internal.partition.IPartitionService)6