Skip to content
Permalink
Browse files

Generalize handling of indeterminate operation state in the Raft module

  • Loading branch information...
metanet authored and mdogan committed Nov 14, 2018
1 parent ae26dde commit 066364821848efaba115a1a07af5d469d3a13998
Showing with 386 additions and 187 deletions.
  1. +3 −3 ...-raft-dataservices/src/main/java/com/hazelcast/raft/service/atomiclong/operation/AddAndGetOp.java
  2. +3 −3 ...-raft-dataservices/src/main/java/com/hazelcast/raft/service/atomiclong/operation/GetAndAddOp.java
  3. +3 −3 ...t-raft-dataservices/src/main/java/com/hazelcast/raft/service/atomiclong/operation/LocalGetOp.java
  4. +3 −3 ...st-raft-dataservices/src/main/java/com/hazelcast/raft/service/atomicref/operation/ContainsOp.java
  5. +3 −3 hazelcast-raft-dataservices/src/main/java/com/hazelcast/raft/service/atomicref/operation/GetOp.java
  6. +3 −3 ...-raft-dataservices/src/main/java/com/hazelcast/raft/service/countdownlatch/operation/AwaitOp.java
  7. +3 −3 ...t-dataservices/src/main/java/com/hazelcast/raft/service/countdownlatch/operation/CountDownOp.java
  8. +3 −3 ...rvices/src/main/java/com/hazelcast/raft/service/countdownlatch/operation/GetRemainingCountOp.java
  9. +3 −3 ...ft-dataservices/src/main/java/com/hazelcast/raft/service/countdownlatch/operation/GetRoundOp.java
  10. +3 −3 ...cast-raft-dataservices/src/main/java/com/hazelcast/raft/service/lock/operation/ForceUnlockOp.java
  11. +3 −3 ...dataservices/src/main/java/com/hazelcast/raft/service/lock/operation/GetLockOwnershipStateOp.java
  12. +3 −3 hazelcast-raft-dataservices/src/main/java/com/hazelcast/raft/service/lock/operation/LockOp.java
  13. +3 −3 hazelcast-raft-dataservices/src/main/java/com/hazelcast/raft/service/lock/operation/TryLockOp.java
  14. +3 −3 hazelcast-raft-dataservices/src/main/java/com/hazelcast/raft/service/lock/operation/UnlockOp.java
  15. +3 −3 ...t-dataservices/src/main/java/com/hazelcast/raft/service/semaphore/operation/AcquirePermitsOp.java
  16. +3 −3 ...dataservices/src/main/java/com/hazelcast/raft/service/semaphore/operation/AvailablePermitsOp.java
  17. +3 −3 ...ft-dataservices/src/main/java/com/hazelcast/raft/service/semaphore/operation/ChangePermitsOp.java
  18. +3 −3 ...aft-dataservices/src/main/java/com/hazelcast/raft/service/semaphore/operation/DrainPermitsOp.java
  19. +3 −3 ...ft-dataservices/src/main/java/com/hazelcast/raft/service/semaphore/operation/InitSemaphoreOp.java
  20. +3 −3 ...t-dataservices/src/main/java/com/hazelcast/raft/service/semaphore/operation/ReleasePermitsOp.java
  21. +5 −5 ...com/hazelcast/raft/impl/{InvocationTargetLeaveAware.java → IndeterminateOperationStateAware.java}
  22. +3 −3 ...raft-server/src/main/java/com/hazelcast/raft/impl/service/operation/metadata/AddRaftMemberOp.java
  23. +3 −3 ...src/main/java/com/hazelcast/raft/impl/service/operation/metadata/CompleteDestroyRaftGroupsOp.java
  24. +3 −3 ...java/com/hazelcast/raft/impl/service/operation/metadata/CompleteRaftGroupMembershipChangesOp.java
  25. +3 −3 ...r/src/main/java/com/hazelcast/raft/impl/service/operation/metadata/CreateMetadataRaftGroupOp.java
  26. +3 −3 ...ft-server/src/main/java/com/hazelcast/raft/impl/service/operation/metadata/CreateRaftGroupOp.java
  27. +3 −3 ...ver/src/main/java/com/hazelcast/raft/impl/service/operation/metadata/ForceDestroyRaftGroupOp.java
  28. +3 −3 ...rver/src/main/java/com/hazelcast/raft/impl/service/operation/metadata/GetActiveRaftMembersOp.java
  29. +3 −3 ...src/main/java/com/hazelcast/raft/impl/service/operation/metadata/GetDestroyingRaftGroupIdsOp.java
  30. +4 −3 ...elcast/raft/impl/service/operation/metadata/GetInitialRaftGroupMembersIfCurrentGroupMemberOp.java
  31. +3 −3 ...rc/main/java/com/hazelcast/raft/impl/service/operation/metadata/GetMembershipChangeContextOp.java
  32. +3 −3 ...-raft-server/src/main/java/com/hazelcast/raft/impl/service/operation/metadata/GetRaftGroupOp.java
  33. +3 −3 ...r/src/main/java/com/hazelcast/raft/impl/service/operation/metadata/TriggerDestroyRaftGroupOp.java
  34. +3 −3 ...r/src/main/java/com/hazelcast/raft/impl/service/operation/metadata/TriggerExpandRaftGroupsOp.java
  35. +3 −3 ...rc/main/java/com/hazelcast/raft/impl/service/operation/metadata/TriggerRebalanceRaftGroupsOp.java
  36. +3 −3 ...r/src/main/java/com/hazelcast/raft/impl/service/operation/metadata/TriggerRemoveRaftMemberOp.java
  37. +3 −3 ...-raft-server/src/main/java/com/hazelcast/raft/impl/service/proxy/ChangeRaftGroupMembershipOp.java
  38. +5 −5 ...lcast-raft-server/src/main/java/com/hazelcast/raft/impl/service/proxy/DefaultRaftReplicateOp.java
  39. +3 −3 hazelcast-raft-server/src/main/java/com/hazelcast/raft/impl/service/proxy/DestroyRaftGroupOp.java
  40. +4 −4 hazelcast-raft-server/src/main/java/com/hazelcast/raft/impl/service/proxy/RaftQueryOp.java
  41. +3 −3 ...-raft-server/src/main/java/com/hazelcast/raft/impl/session/operation/CloseInactiveSessionsOp.java
  42. +3 −3 hazelcast-raft-server/src/main/java/com/hazelcast/raft/impl/session/operation/CloseSessionOp.java
  43. +3 −3 hazelcast-raft-server/src/main/java/com/hazelcast/raft/impl/session/operation/CreateSessionOp.java
  44. +3 −3 hazelcast-raft-server/src/main/java/com/hazelcast/raft/impl/session/operation/ExpireSessionsOp.java
  45. +3 −3 hazelcast-raft-server/src/main/java/com/hazelcast/raft/impl/session/operation/GetSessionsOp.java
  46. +3 −3 ...lcast-raft-server/src/main/java/com/hazelcast/raft/impl/session/operation/HeartbeatSessionOp.java
  47. +25 −16 hazelcast-raft-server/src/main/java/com/hazelcast/spi/impl/operationservice/impl/RaftInvocation.java
  48. +15 −0 hazelcast-raft-server/src/test/java/com/hazelcast/raft/impl/service/HazelcastRaftTestSupport.java
  49. +5 −8 hazelcast-raft-server/src/test/java/com/hazelcast/raft/impl/service/RaftMemberAddRemoveTest.java
  50. +159 −10 ...-server/src/test/java/com/hazelcast/spi/impl/operationservice/impl/RaftInvocationFailureTest.java
  51. +2 −1 hazelcast-raft/src/main/java/com/hazelcast/raft/exception/StaleAppendRequestException.java
  52. +23 −0 hazelcast/src/main/java/com/hazelcast/core/IndeterminateOperationState.java
  53. +9 −4 hazelcast/src/main/java/com/hazelcast/core/IndeterminateOperationStateException.java
  54. +1 −1 hazelcast/src/main/java/com/hazelcast/core/MemberLeftException.java
  55. +3 −4 hazelcast/src/main/java/com/hazelcast/spi/impl/operationservice/impl/InvocationFuture.java
@@ -20,7 +20,7 @@
import com.hazelcast.nio.ObjectDataInput;
import com.hazelcast.nio.ObjectDataOutput;
import com.hazelcast.raft.RaftGroupId;
import com.hazelcast.raft.impl.InvocationTargetLeaveAware;
import com.hazelcast.raft.impl.IndeterminateOperationStateAware;
import com.hazelcast.raft.service.atomiclong.RaftAtomicLongDataSerializerHook;
import com.hazelcast.raft.service.atomiclong.RaftAtomicLong;

@@ -29,7 +29,7 @@
/**
* Operation for {@link IAtomicLong#addAndGet(long)}
*/
public class AddAndGetOp extends AbstractAtomicLongOp implements InvocationTargetLeaveAware {
public class AddAndGetOp extends AbstractAtomicLongOp implements IndeterminateOperationStateAware {

private long delta;

@@ -48,7 +48,7 @@ public Object run(RaftGroupId groupId, long commitIndex) {
}

@Override
public boolean isRetryableOnTargetLeave() {
public boolean isRetryableOnIndeterminateOperationState() {
return delta == 0;
}

@@ -20,7 +20,7 @@
import com.hazelcast.nio.ObjectDataInput;
import com.hazelcast.nio.ObjectDataOutput;
import com.hazelcast.raft.RaftGroupId;
import com.hazelcast.raft.impl.InvocationTargetLeaveAware;
import com.hazelcast.raft.impl.IndeterminateOperationStateAware;
import com.hazelcast.raft.service.atomiclong.RaftAtomicLongDataSerializerHook;
import com.hazelcast.raft.service.atomiclong.RaftAtomicLong;

@@ -29,7 +29,7 @@
/**
* Operation for {@link IAtomicLong#getAndAdd(long)} (long, long)} and {@link IAtomicLong#get()}
*/
public class GetAndAddOp extends AbstractAtomicLongOp implements InvocationTargetLeaveAware {
public class GetAndAddOp extends AbstractAtomicLongOp implements IndeterminateOperationStateAware {

private long delta;

@@ -48,7 +48,7 @@ public Object run(RaftGroupId groupId, long commitIndex) {
}

@Override
public boolean isRetryableOnTargetLeave() {
public boolean isRetryableOnIndeterminateOperationState() {
return delta == 0;
}

@@ -18,14 +18,14 @@

import com.hazelcast.raft.QueryPolicy;
import com.hazelcast.raft.RaftGroupId;
import com.hazelcast.raft.impl.InvocationTargetLeaveAware;
import com.hazelcast.raft.impl.IndeterminateOperationStateAware;
import com.hazelcast.raft.service.atomiclong.RaftAtomicLongDataSerializerHook;
import com.hazelcast.raft.service.atomiclong.proxy.RaftAtomicLongProxy;

/**
* Operation for {@link RaftAtomicLongProxy#localGet(QueryPolicy)}
*/
public class LocalGetOp extends AbstractAtomicLongOp implements InvocationTargetLeaveAware {
public class LocalGetOp extends AbstractAtomicLongOp implements IndeterminateOperationStateAware {

public LocalGetOp() {
super();
@@ -41,7 +41,7 @@ public Object run(RaftGroupId groupId, long commitIndex) {
}

@Override
public boolean isRetryableOnTargetLeave() {
public boolean isRetryableOnIndeterminateOperationState() {
return true;
}

@@ -22,7 +22,7 @@
import com.hazelcast.nio.serialization.Data;
import com.hazelcast.nio.serialization.IdentifiedDataSerializable;
import com.hazelcast.raft.RaftGroupId;
import com.hazelcast.raft.impl.InvocationTargetLeaveAware;
import com.hazelcast.raft.impl.IndeterminateOperationStateAware;
import com.hazelcast.raft.service.atomicref.RaftAtomicRef;
import com.hazelcast.raft.service.atomicref.RaftAtomicReferenceDataSerializerHook;

@@ -31,7 +31,7 @@
/**
* Operation for {@link IAtomicReference#contains(Object)}
*/
public class ContainsOp extends AbstractAtomicRefOp implements InvocationTargetLeaveAware, IdentifiedDataSerializable {
public class ContainsOp extends AbstractAtomicRefOp implements IndeterminateOperationStateAware, IdentifiedDataSerializable {

private Data value;

@@ -50,7 +50,7 @@ public Object run(RaftGroupId groupId, long commitIndex) {
}

@Override
public boolean isRetryableOnTargetLeave() {
public boolean isRetryableOnIndeterminateOperationState() {
return true;
}

@@ -19,13 +19,13 @@
import com.hazelcast.core.IAtomicReference;
import com.hazelcast.nio.serialization.IdentifiedDataSerializable;
import com.hazelcast.raft.RaftGroupId;
import com.hazelcast.raft.impl.InvocationTargetLeaveAware;
import com.hazelcast.raft.impl.IndeterminateOperationStateAware;
import com.hazelcast.raft.service.atomicref.RaftAtomicReferenceDataSerializerHook;

/**
* Operation for {@link IAtomicReference#get()}
*/
public class GetOp extends AbstractAtomicRefOp implements InvocationTargetLeaveAware, IdentifiedDataSerializable {
public class GetOp extends AbstractAtomicRefOp implements IndeterminateOperationStateAware, IdentifiedDataSerializable {

public GetOp() {
}
@@ -39,7 +39,7 @@ public Object run(RaftGroupId groupId, long commitIndex) {
return getAtomicRef(groupId).get();
}

public boolean isRetryableOnTargetLeave() {
public boolean isRetryableOnIndeterminateOperationState() {
return true;
}

@@ -19,7 +19,7 @@
import com.hazelcast.nio.ObjectDataInput;
import com.hazelcast.nio.ObjectDataOutput;
import com.hazelcast.raft.RaftGroupId;
import com.hazelcast.raft.impl.InvocationTargetLeaveAware;
import com.hazelcast.raft.impl.IndeterminateOperationStateAware;
import com.hazelcast.raft.impl.util.PostponedResponse;
import com.hazelcast.raft.service.countdownlatch.RaftCountDownLatchDataSerializerHook;
import com.hazelcast.raft.service.countdownlatch.RaftCountDownLatchService;
@@ -30,7 +30,7 @@
/**
* Operation for {@link com.hazelcast.core.ICountDownLatch#await(long, TimeUnit)}
*/
public class AwaitOp extends AbstractCountDownLatchOp implements InvocationTargetLeaveAware {
public class AwaitOp extends AbstractCountDownLatchOp implements IndeterminateOperationStateAware {

private long timeoutMillis;

@@ -53,7 +53,7 @@ public Object run(RaftGroupId groupId, long commitIndex) {
}

@Override
public boolean isRetryableOnTargetLeave() {
public boolean isRetryableOnIndeterminateOperationState() {
return true;
}

@@ -20,7 +20,7 @@
import com.hazelcast.nio.ObjectDataInput;
import com.hazelcast.nio.ObjectDataOutput;
import com.hazelcast.raft.RaftGroupId;
import com.hazelcast.raft.impl.InvocationTargetLeaveAware;
import com.hazelcast.raft.impl.IndeterminateOperationStateAware;
import com.hazelcast.raft.service.countdownlatch.RaftCountDownLatchDataSerializerHook;
import com.hazelcast.raft.service.countdownlatch.RaftCountDownLatchService;

@@ -30,7 +30,7 @@
/**
* Operation for {@link ICountDownLatch#countDown()}
*/
public class CountDownOp extends AbstractCountDownLatchOp implements InvocationTargetLeaveAware {
public class CountDownOp extends AbstractCountDownLatchOp implements IndeterminateOperationStateAware {

private int expectedRound;
private UUID invocationUid;
@@ -51,7 +51,7 @@ public Object run(RaftGroupId groupId, long commitIndex) {
}

@Override
public boolean isRetryableOnTargetLeave() {
public boolean isRetryableOnIndeterminateOperationState() {
return true;
}

@@ -18,14 +18,14 @@

import com.hazelcast.core.ICountDownLatch;
import com.hazelcast.raft.RaftGroupId;
import com.hazelcast.raft.impl.InvocationTargetLeaveAware;
import com.hazelcast.raft.impl.IndeterminateOperationStateAware;
import com.hazelcast.raft.service.countdownlatch.RaftCountDownLatchDataSerializerHook;
import com.hazelcast.raft.service.countdownlatch.RaftCountDownLatchService;

/**
* Operation for {@link ICountDownLatch#getCount()}
*/
public class GetRemainingCountOp extends AbstractCountDownLatchOp implements InvocationTargetLeaveAware {
public class GetRemainingCountOp extends AbstractCountDownLatchOp implements IndeterminateOperationStateAware {

public GetRemainingCountOp() {
}
@@ -41,7 +41,7 @@ public Object run(RaftGroupId groupId, long commitIndex) {
}

@Override
public boolean isRetryableOnTargetLeave() {
public boolean isRetryableOnIndeterminateOperationState() {
return true;
}

@@ -18,14 +18,14 @@

import com.hazelcast.core.ICountDownLatch;
import com.hazelcast.raft.RaftGroupId;
import com.hazelcast.raft.impl.InvocationTargetLeaveAware;
import com.hazelcast.raft.impl.IndeterminateOperationStateAware;
import com.hazelcast.raft.service.countdownlatch.RaftCountDownLatchDataSerializerHook;
import com.hazelcast.raft.service.countdownlatch.RaftCountDownLatchService;

/**
* Operation used by {@link ICountDownLatch#countDown()}
*/
public class GetRoundOp extends AbstractCountDownLatchOp implements InvocationTargetLeaveAware {
public class GetRoundOp extends AbstractCountDownLatchOp implements IndeterminateOperationStateAware {

public GetRoundOp() {
}
@@ -41,7 +41,7 @@ public Object run(RaftGroupId groupId, long commitIndex) {
}

@Override
public boolean isRetryableOnTargetLeave() {
public boolean isRetryableOnIndeterminateOperationState() {
return true;
}

@@ -21,7 +21,7 @@
import com.hazelcast.nio.serialization.IdentifiedDataSerializable;
import com.hazelcast.raft.RaftGroupId;
import com.hazelcast.raft.impl.RaftOp;
import com.hazelcast.raft.impl.InvocationTargetLeaveAware;
import com.hazelcast.raft.impl.IndeterminateOperationStateAware;
import com.hazelcast.raft.service.lock.FencedLock;
import com.hazelcast.raft.service.lock.RaftLockDataSerializerHook;
import com.hazelcast.raft.service.lock.RaftLockService;
@@ -34,7 +34,7 @@
*
* @see com.hazelcast.raft.service.lock.RaftLock#forceRelease(long, UUID)
*/
public class ForceUnlockOp extends RaftOp implements InvocationTargetLeaveAware, IdentifiedDataSerializable {
public class ForceUnlockOp extends RaftOp implements IndeterminateOperationStateAware, IdentifiedDataSerializable {

private String name;
private long expectedFence;
@@ -57,7 +57,7 @@ public Object run(RaftGroupId groupId, long commitIndex) {
}

@Override
public boolean isRetryableOnTargetLeave() {
public boolean isRetryableOnIndeterminateOperationState() {
return true;
}

@@ -20,7 +20,7 @@
import com.hazelcast.nio.ObjectDataOutput;
import com.hazelcast.nio.serialization.IdentifiedDataSerializable;
import com.hazelcast.raft.RaftGroupId;
import com.hazelcast.raft.impl.InvocationTargetLeaveAware;
import com.hazelcast.raft.impl.IndeterminateOperationStateAware;
import com.hazelcast.raft.impl.RaftOp;
import com.hazelcast.raft.service.lock.RaftLockDataSerializerHook;
import com.hazelcast.raft.service.lock.RaftLockService;
@@ -30,7 +30,7 @@
/**
* @see com.hazelcast.raft.service.lock.RaftLock#lockOwnershipState()
*/
public class GetLockOwnershipStateOp extends RaftOp implements InvocationTargetLeaveAware, IdentifiedDataSerializable {
public class GetLockOwnershipStateOp extends RaftOp implements IndeterminateOperationStateAware, IdentifiedDataSerializable {

private String name;

@@ -48,7 +48,7 @@ public Object run(RaftGroupId groupId, long commitIndex) {
}

@Override
public boolean isRetryableOnTargetLeave() {
public boolean isRetryableOnIndeterminateOperationState() {
return true;
}

@@ -17,7 +17,7 @@
package com.hazelcast.raft.service.lock.operation;

import com.hazelcast.raft.RaftGroupId;
import com.hazelcast.raft.impl.InvocationTargetLeaveAware;
import com.hazelcast.raft.impl.IndeterminateOperationStateAware;
import com.hazelcast.raft.impl.util.PostponedResponse;
import com.hazelcast.raft.service.lock.FencedLock;
import com.hazelcast.raft.service.lock.LockEndpoint;
@@ -32,7 +32,7 @@
*
* @see com.hazelcast.raft.service.lock.RaftLock#acquire(LockEndpoint, long, UUID, boolean)
*/
public class LockOp extends AbstractLockOp implements InvocationTargetLeaveAware {
public class LockOp extends AbstractLockOp implements IndeterminateOperationStateAware {

public LockOp() {
}
@@ -50,7 +50,7 @@ public Object run(RaftGroupId groupId, long commitIndex) {
}

@Override
public boolean isRetryableOnTargetLeave() {
public boolean isRetryableOnIndeterminateOperationState() {
return true;
}

@@ -19,7 +19,7 @@
import com.hazelcast.nio.ObjectDataInput;
import com.hazelcast.nio.ObjectDataOutput;
import com.hazelcast.raft.RaftGroupId;
import com.hazelcast.raft.impl.InvocationTargetLeaveAware;
import com.hazelcast.raft.impl.IndeterminateOperationStateAware;
import com.hazelcast.raft.impl.util.PostponedResponse;
import com.hazelcast.raft.service.lock.FencedLock;
import com.hazelcast.raft.service.lock.LockEndpoint;
@@ -35,7 +35,7 @@
*
* @see com.hazelcast.raft.service.lock.RaftLock#acquire(LockEndpoint, long, UUID, boolean)
*/
public class TryLockOp extends AbstractLockOp implements InvocationTargetLeaveAware {
public class TryLockOp extends AbstractLockOp implements IndeterminateOperationStateAware {

private long timeoutMs;

@@ -62,7 +62,7 @@ public Object run(RaftGroupId groupId, long commitIndex) {
}

@Override
public boolean isRetryableOnTargetLeave() {
public boolean isRetryableOnIndeterminateOperationState() {
return true;
}

@@ -19,7 +19,7 @@
import com.hazelcast.nio.ObjectDataInput;
import com.hazelcast.nio.ObjectDataOutput;
import com.hazelcast.raft.RaftGroupId;
import com.hazelcast.raft.impl.InvocationTargetLeaveAware;
import com.hazelcast.raft.impl.IndeterminateOperationStateAware;
import com.hazelcast.raft.service.lock.FencedLock;
import com.hazelcast.raft.service.lock.LockEndpoint;
import com.hazelcast.raft.service.lock.RaftLockDataSerializerHook;
@@ -33,7 +33,7 @@
*
* @see com.hazelcast.raft.service.lock.RaftLock#release(LockEndpoint, UUID, int)
*/
public class UnlockOp extends AbstractLockOp implements InvocationTargetLeaveAware {
public class UnlockOp extends AbstractLockOp implements IndeterminateOperationStateAware {

private int lockCount;

@@ -53,7 +53,7 @@ public Object run(RaftGroupId groupId, long commitIndex) {
}

@Override
public boolean isRetryableOnTargetLeave() {
public boolean isRetryableOnIndeterminateOperationState() {
return true;
}

@@ -20,7 +20,7 @@
import com.hazelcast.nio.ObjectDataInput;
import com.hazelcast.nio.ObjectDataOutput;
import com.hazelcast.raft.RaftGroupId;
import com.hazelcast.raft.impl.InvocationTargetLeaveAware;
import com.hazelcast.raft.impl.IndeterminateOperationStateAware;
import com.hazelcast.raft.impl.util.PostponedResponse;
import com.hazelcast.raft.service.semaphore.RaftSemaphore;
import com.hazelcast.raft.service.semaphore.RaftSemaphoreDataSerializerHook;
@@ -37,7 +37,7 @@
*
* @see RaftSemaphore#acquire(SemaphoreInvocationKey, boolean)
*/
public class AcquirePermitsOp extends AbstractSemaphoreOp implements InvocationTargetLeaveAware {
public class AcquirePermitsOp extends AbstractSemaphoreOp implements IndeterminateOperationStateAware {

private int permits;
private long timeoutMs;
@@ -63,7 +63,7 @@ public Object run(RaftGroupId groupId, long commitIndex) {
}

@Override
public boolean isRetryableOnTargetLeave() {
public boolean isRetryableOnIndeterminateOperationState() {
return sessionId != NO_SESSION_ID;
}

0 comments on commit 0663648

Please sign in to comment.
You can’t perform that action at this time.