Search in sources :

Example 21 with RaftService

use of com.hazelcast.cp.internal.RaftService in project hazelcast by hazelcast.

the class AbstractUnsafeRaftOp method call.

@Override
public final CallStatus call() throws Exception {
    RaftService service = getService();
    if (service.isCpSubsystemEnabled()) {
        throw new IllegalStateException("CP subsystem is enabled on this member, " + "but received an UNSAFE operation! This could be due to a misconfiguration on the caller side. " + "CP subsystem configuration must be the same on all members.");
    }
    NodeEngine nodeEngine = getNodeEngine();
    if (op instanceof CallerAware) {
        ((CallerAware) op).setCaller(getCallerAddress(), getCallId());
    }
    long commitIndex = service.nextUnsafeModeCommitIndex(groupId);
    response = op.setNodeEngine(nodeEngine).run(groupId, commitIndex);
    return handleResponse(commitIndex, response);
}
Also used : NodeEngine(com.hazelcast.spi.impl.NodeEngine) RaftService(com.hazelcast.cp.internal.RaftService) CallerAware(com.hazelcast.cp.internal.CallerAware)

Example 22 with RaftService

use of com.hazelcast.cp.internal.RaftService in project hazelcast by hazelcast.

the class UnsafeStateReplicationOp method run.

@Override
public void run() throws Exception {
    RaftService service = getService();
    service.applyUnsafeModeState(getPartitionId(), state);
}
Also used : RaftService(com.hazelcast.cp.internal.RaftService)

Example 23 with RaftService

use of com.hazelcast.cp.internal.RaftService in project hazelcast by hazelcast.

the class RaftServicePreJoinOp method run.

@Override
public void run() {
    RaftService service = getService();
    MetadataRaftGroupManager metadataGroupManager = service.getMetadataGroupManager();
    metadataGroupManager.handleMetadataGroupId(metadataGroupId);
    if (discoveryCompleted) {
        metadataGroupManager.disableDiscovery();
    }
}
Also used : MetadataRaftGroupManager(com.hazelcast.cp.internal.MetadataRaftGroupManager) RaftService(com.hazelcast.cp.internal.RaftService)

Example 24 with RaftService

use of com.hazelcast.cp.internal.RaftService in project hazelcast by hazelcast.

the class CreateRaftNodeOp method run.

@Override
public void run() {
    RaftService service = getService();
    service.createRaftNode(groupId, initialMembers);
}
Also used : RaftService(com.hazelcast.cp.internal.RaftService)

Example 25 with RaftService

use of com.hazelcast.cp.internal.RaftService in project hazelcast by hazelcast.

the class AbstractFencedLockFailureTest method testRetriedTryLockWithTimeoutDoesNotCancelPendingLockRequest.

@Test(timeout = 300_000)
public void testRetriedTryLockWithTimeoutDoesNotCancelPendingLockRequest() {
    lockByOtherThread();
    // there is a session id now
    RaftGroupId groupId = lock.getGroupId();
    long sessionId = getSessionManager().getSession(groupId);
    RaftInvocationManager invocationManager = getRaftInvocationManager();
    UUID invUid = newUnsecureUUID();
    invocationManager.invoke(groupId, new TryLockOp(objectName, sessionId, getThreadId(), invUid, MINUTES.toMillis(5)));
    NodeEngineImpl nodeEngine = getNodeEngineImpl(primaryInstance);
    LockService service = nodeEngine.getService(LockService.SERVICE_NAME);
    assertTrueEventually(() -> {
        LockRegistry registry = service.getRegistryOrNull(groupId);
        assertNotNull(registry);
        assertNotNull(registry.getResourceOrNull(objectName));
        assertEquals(1, registry.getWaitTimeouts().size());
    });
    invocationManager.invoke(groupId, new TryLockOp(objectName, sessionId, getThreadId(), invUid, MINUTES.toMillis(5)));
    assertTrueEventually(() -> {
        RaftService raftService = getNodeEngineImpl(primaryInstance).getService(RaftService.SERVICE_NAME);
        int partitionId = raftService.getCPGroupPartitionId(groupId);
        LockRegistry registry = service.getRegistryOrNull(groupId);
        boolean[] verified = new boolean[1];
        CountDownLatch latch = new CountDownLatch(1);
        OperationServiceImpl operationService = nodeEngine.getOperationService();
        operationService.execute(new PartitionSpecificRunnable() {

            @Override
            public int getPartitionId() {
                return partitionId;
            }

            @Override
            public void run() {
                Lock lock = registry.getResourceOrNull(objectName);
                Map<Object, WaitKeyContainer<LockInvocationKey>> waitKeys = lock.getInternalWaitKeysMap();
                verified[0] = (waitKeys.size() == 1 && waitKeys.values().iterator().next().retryCount() == 1);
                latch.countDown();
            }
        });
        latch.await(60, SECONDS);
        assertTrue(verified[0]);
    });
}
Also used : TryLockOp(com.hazelcast.cp.internal.datastructures.lock.operation.TryLockOp) NodeEngineImpl(com.hazelcast.spi.impl.NodeEngineImpl) Accessors.getNodeEngineImpl(com.hazelcast.test.Accessors.getNodeEngineImpl) RaftInvocationManager(com.hazelcast.cp.internal.RaftInvocationManager) RaftService(com.hazelcast.cp.internal.RaftService) RaftGroupId(com.hazelcast.cp.internal.RaftGroupId) CountDownLatch(java.util.concurrent.CountDownLatch) PartitionSpecificRunnable(com.hazelcast.spi.impl.PartitionSpecificRunnable) UuidUtil.newUnsecureUUID(com.hazelcast.internal.util.UuidUtil.newUnsecureUUID) UUID(java.util.UUID) Map(java.util.Map) OperationServiceImpl(com.hazelcast.spi.impl.operationservice.impl.OperationServiceImpl) Test(org.junit.Test)

Aggregations

RaftService (com.hazelcast.cp.internal.RaftService)27 RaftGroupId (com.hazelcast.cp.internal.RaftGroupId)4 UuidUtil.newUnsecureUUID (com.hazelcast.internal.util.UuidUtil.newUnsecureUUID)3 NodeEngineImpl (com.hazelcast.spi.impl.NodeEngineImpl)3 PartitionSpecificRunnable (com.hazelcast.spi.impl.PartitionSpecificRunnable)3 OperationServiceImpl (com.hazelcast.spi.impl.operationservice.impl.OperationServiceImpl)3 Accessors.getNodeEngineImpl (com.hazelcast.test.Accessors.getNodeEngineImpl)3 Map (java.util.Map)3 UUID (java.util.UUID)3 CountDownLatch (java.util.concurrent.CountDownLatch)3 Test (org.junit.Test)3 CPGroupDestroyedException (com.hazelcast.cp.exception.CPGroupDestroyedException)2 NotLeaderException (com.hazelcast.cp.exception.NotLeaderException)2 MetadataRaftGroupManager (com.hazelcast.cp.internal.MetadataRaftGroupManager)2 RaftInvocationManager (com.hazelcast.cp.internal.RaftInvocationManager)2 RaftOp (com.hazelcast.cp.internal.RaftOp)2 TryLockOp (com.hazelcast.cp.internal.datastructures.lock.operation.TryLockOp)2 ExpireWaitKeysOp (com.hazelcast.cp.internal.datastructures.spi.blocking.operation.ExpireWaitKeysOp)2 RaftNode (com.hazelcast.cp.internal.raft.impl.RaftNode)2 BiTuple (com.hazelcast.internal.util.BiTuple)2