Search in sources :

Example 91 with Operation

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

the class RaftService method commitMigration.

@Override
public void commitMigration(PartitionMigrationEvent event) {
    if (cpSubsystemEnabled) {
        return;
    }
    if (event.getMigrationEndpoint() == MigrationEndpoint.SOURCE) {
        UnsafeModePartitionState state = unsafeModeStates[event.getPartitionId()];
        if (event.getCurrentReplicaIndex() == 0) {
            // Waiting operations are registered only on primary.
            Object ex = new PartitionMigratingException("Partition " + event.getPartitionId() + " is migrating!");
            for (Operation op : state.getWaitingOps()) {
                op.sendResponse(ex);
            }
        }
        int thresholdReplicaIndex = event.getNewReplicaIndex();
        if (thresholdReplicaIndex == -1 || thresholdReplicaIndex > getBackupCount()) {
            state.reset();
        }
    }
}
Also used : Operation(com.hazelcast.spi.impl.operationservice.Operation) MigrationEndpoint(com.hazelcast.internal.partition.MigrationEndpoint) RaftEndpoint(com.hazelcast.cp.internal.raft.impl.RaftEndpoint) PartitionMigratingException(com.hazelcast.spi.exception.PartitionMigratingException)

Example 92 with Operation

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

the class RaftInvocationManager method invoke.

public <T> InternalCompletableFuture<T> invoke(CPGroupId groupId, RaftOp raftOp, boolean deserializeResponse) {
    if (cpSubsystemEnabled) {
        Operation operation = new DefaultRaftReplicateOp(groupId, raftOp);
        Invocation invocation = new RaftInvocation(operationService.getInvocationContext(), raftInvocationContext, groupId, operation, invocationMaxRetryCount, invocationRetryPauseMillis, operationCallTimeout, deserializeResponse);
        return invocation.invoke();
    }
    return invokeOnPartition(new UnsafeRaftReplicateOp(groupId, raftOp), deserializeResponse);
}
Also used : RaftInvocation(com.hazelcast.spi.impl.operationservice.impl.RaftInvocation) Invocation(com.hazelcast.spi.impl.operationservice.impl.Invocation) RaftInvocation(com.hazelcast.spi.impl.operationservice.impl.RaftInvocation) Operation(com.hazelcast.spi.impl.operationservice.Operation) DefaultRaftReplicateOp(com.hazelcast.cp.internal.operation.DefaultRaftReplicateOp) UnsafeRaftReplicateOp(com.hazelcast.cp.internal.operation.unsafe.UnsafeRaftReplicateOp)

Example 93 with Operation

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

the class RaftInvocationManager method destroy.

public InternalCompletableFuture<Object> destroy(CPGroupId groupId) {
    InternalCompletableFuture<Object> completedFuture = completeExceptionallyIfCPSubsystemNotAvailable();
    if (completedFuture != null) {
        return completedFuture;
    }
    Operation operation = new DestroyRaftGroupOp(groupId);
    Invocation invocation = new RaftInvocation(operationService.getInvocationContext(), raftInvocationContext, groupId, operation, invocationMaxRetryCount, invocationRetryPauseMillis, operationCallTimeout);
    return invocation.invoke();
}
Also used : DestroyRaftGroupOp(com.hazelcast.cp.internal.operation.DestroyRaftGroupOp) RaftInvocation(com.hazelcast.spi.impl.operationservice.impl.RaftInvocation) Invocation(com.hazelcast.spi.impl.operationservice.impl.Invocation) RaftInvocation(com.hazelcast.spi.impl.operationservice.impl.RaftInvocation) Operation(com.hazelcast.spi.impl.operationservice.Operation)

Example 94 with Operation

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

the class RaftInvocationManager method changeMembership.

<T> InternalCompletableFuture<T> changeMembership(CPGroupId groupId, long membersCommitIndex, RaftEndpoint member, MembershipChangeMode membershipChangeMode) {
    InternalCompletableFuture<T> completedFuture = completeExceptionallyIfCPSubsystemNotAvailable();
    if (completedFuture != null) {
        return completedFuture;
    }
    Operation operation = new ChangeRaftGroupMembershipOp(groupId, membersCommitIndex, member, membershipChangeMode);
    Invocation invocation = new RaftInvocation(operationService.getInvocationContext(), raftInvocationContext, groupId, operation, invocationMaxRetryCount, invocationRetryPauseMillis, operationCallTimeout);
    return invocation.invoke();
}
Also used : RaftInvocation(com.hazelcast.spi.impl.operationservice.impl.RaftInvocation) ChangeRaftGroupMembershipOp(com.hazelcast.cp.internal.operation.ChangeRaftGroupMembershipOp) DEFAULT_DESERIALIZE_RESULT(com.hazelcast.spi.impl.operationservice.InvocationBuilder.DEFAULT_DESERIALIZE_RESULT) Invocation(com.hazelcast.spi.impl.operationservice.impl.Invocation) RaftInvocation(com.hazelcast.spi.impl.operationservice.impl.RaftInvocation) Operation(com.hazelcast.spi.impl.operationservice.Operation)

Example 95 with Operation

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

the class RaftInvocationManager method queryLocally.

public <T> InternalCompletableFuture<T> queryLocally(CPGroupId groupId, RaftOp raftOp, QueryPolicy queryPolicy) {
    Operation operation;
    if (cpSubsystemEnabled) {
        operation = new RaftQueryOp(groupId, raftOp, queryPolicy);
    } else {
        operation = new UnsafeRaftQueryOp(groupId, raftOp);
    }
    operation.setPartitionId(raftService.getCPGroupPartitionId(groupId));
    return nodeEngine.getOperationService().invokeOnTarget(RaftService.SERVICE_NAME, operation, nodeEngine.getThisAddress());
}
Also used : UnsafeRaftQueryOp(com.hazelcast.cp.internal.operation.unsafe.UnsafeRaftQueryOp) RaftQueryOp(com.hazelcast.cp.internal.operation.RaftQueryOp) UnsafeRaftQueryOp(com.hazelcast.cp.internal.operation.unsafe.UnsafeRaftQueryOp) Operation(com.hazelcast.spi.impl.operationservice.Operation)

Aggregations

Operation (com.hazelcast.spi.impl.operationservice.Operation)271 Test (org.junit.Test)80 QuickTest (com.hazelcast.test.annotation.QuickTest)79 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)59 OperationService (com.hazelcast.spi.impl.operationservice.OperationService)56 Address (com.hazelcast.cluster.Address)31 HazelcastInstance (com.hazelcast.core.HazelcastInstance)25 Data (com.hazelcast.internal.serialization.Data)24 Future (java.util.concurrent.Future)24 Member (com.hazelcast.cluster.Member)22 ArrayList (java.util.ArrayList)21 NodeEngine (com.hazelcast.spi.impl.NodeEngine)18 NodeEngineImpl (com.hazelcast.spi.impl.NodeEngineImpl)17 TestHazelcastInstanceFactory (com.hazelcast.test.TestHazelcastInstanceFactory)17 AssertTask (com.hazelcast.test.AssertTask)15 ILogger (com.hazelcast.logging.ILogger)14 UrgentSystemOperation (com.hazelcast.spi.impl.operationservice.UrgentSystemOperation)13 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)13 Config (com.hazelcast.config.Config)12 CompletableFuture (java.util.concurrent.CompletableFuture)12