Skip to content
Permalink
Browse files

Apply multiple fixes

* Major renaming in the public API
* Delete RaftLockProxy which implements the old ILock interface
* Fix snapshotting mechanism of blocking services
  • Loading branch information...
metanet authored and mdogan committed Dec 19, 2018
1 parent 6258250 commit aa9d156bfc724e6b8aa0fbbe9458bfe5ad4ce107
Showing with 1,433 additions and 2,545 deletions.
  1. +91 −7 ...lient/src/main/java/com/hazelcast/client/cp/internal/datastructures/lock/RaftFencedLockProxy.java
  2. +0 −344 ...cast-client/src/main/java/com/hazelcast/client/cp/internal/datastructures/lock/RaftLockProxy.java
  3. +11 −11 ...ava/com/hazelcast/client/cp/internal/datastructures/semaphore/RaftSessionAwareSemaphoreProxy.java
  4. +20 −53 ...java/com/hazelcast/client/cp/internal/datastructures/semaphore/RaftSessionlessSemaphoreProxy.java
  5. +31 −7 ...hazelcast/client/cp/internal/session/{ClientSessionManager.java → ClientProxySessionManager.java}
  6. +6 −6 hazelcast-client/src/main/java/com/hazelcast/client/cp/internal/session/SessionManagerProvider.java
  7. +3 −3 ...test/java/com/hazelcast/client/cp/internal/datastructures/lock/RaftFencedLockClientBasicTest.java
  8. +0 −75 ...t/src/test/java/com/hazelcast/client/cp/internal/datastructures/lock/RaftLockClientBasicTest.java
  9. +2 −2 ...zelcast/client/cp/internal/datastructures/semaphore/RaftSessionAwareSemaphoreClientBasicTest.java
  10. +18 −1 ...azelcast/client/cp/internal/datastructures/semaphore/RaftSessionlessSemaphoreClientBasicTest.java
  11. +7 −7 ...lcast-client/src/test/java/com/hazelcast/client/cp/internal/session/ClientSessionManagerTest.java
  12. +4 −0 hazelcast/src/main/java/com/hazelcast/client/impl/protocol/ClientExceptions.java
  13. +2 −0 hazelcast/src/main/java/com/hazelcast/client/impl/protocol/ClientProtocolErrorCodes.java
  14. +12 −12 hazelcast/src/main/java/com/hazelcast/config/Config.java
  15. +4 −4 ...n/java/com/hazelcast/config/{raft/AbstractRaftObjectConfig.java → cp/AbstractCPObjectConfig.java}
  16. +12 −12 ...st/src/main/java/com/hazelcast/config/{raft/RaftSemaphoreConfig.java → cp/CPSemaphoreConfig.java}
  17. +41 −35 hazelcast/src/main/java/com/hazelcast/config/{raft/RaftConfig.java → cp/CPSubsystemConfig.java}
  18. +1 −1 hazelcast/src/main/java/com/hazelcast/config/{raft → cp}/RaftAlgorithmConfig.java
  19. +1 −1 hazelcast/src/main/java/com/hazelcast/config/{raft → cp}/package-info.java
  20. +2 −1 hazelcast/src/main/java/com/hazelcast/core/IndeterminateOperationStateException.java
  21. +15 −0 hazelcast/src/main/java/com/hazelcast/cp/CpSubsystem.java
  22. +14 −13 ...t/src/main/java/com/hazelcast/cp/{RaftManagementService.java → CpSubsystemManagementService.java}
  23. +2 −2 hazelcast/src/main/java/com/hazelcast/cp/{SessionInfo.java → Session.java}
  24. +6 −6 ...rc/main/java/com/hazelcast/cp/{RaftSessionManagementService.java → SessionManagementService.java}
  25. +2 −2 hazelcast/src/main/java/com/hazelcast/cp/internal/IndeterminateOperationStateAware.java
  26. +10 −10 hazelcast/src/main/java/com/hazelcast/cp/internal/MetadataRaftGroupManager.java
  27. +24 −23 hazelcast/src/main/java/com/hazelcast/cp/internal/RaftService.java
  28. +3 −3 hazelcast/src/main/java/com/hazelcast/cp/internal/RaftServiceDescriptorProvider.java
  29. +3 −3 ...ast/src/main/java/com/hazelcast/cp/internal/datastructures/RaftDataServiceDescriptorProvider.java
  30. +9 −8 ...ternal/datastructures/countdownlatch/{CountDownLatchInvocationKey.java → AwaitInvocationKey.java}
  31. +18 −6 ...ast/src/main/java/com/hazelcast/cp/internal/datastructures/countdownlatch/RaftCountDownLatch.java
  32. +4 −4 ...com/hazelcast/cp/internal/datastructures/countdownlatch/RaftCountDownLatchDataSerializerHook.java
  33. +23 −9 ...nal/datastructures/countdownlatch/{CountDownLatchRegistry.java → RaftCountDownLatchRegistry.java}
  34. +6 −6 .../main/java/com/hazelcast/cp/internal/datastructures/countdownlatch/RaftCountDownLatchService.java
  35. +0 −4 ...t/src/main/java/com/hazelcast/cp/internal/datastructures/exception/WaitKeyCancelledException.java
  36. +2 −2 hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/lock/LockEndpoint.java
  37. +12 −0 hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/lock/RaftLock.java
  38. +5 −5 ...lcast/src/main/java/com/hazelcast/cp/internal/datastructures/lock/RaftLockDataSerializerHook.java
  39. +3 −3 hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/lock/RaftLockOwnershipState.java
  40. +31 −15 ...in/java/com/hazelcast/cp/internal/datastructures/lock/{LockRegistry.java → RaftLockRegistry.java}
  41. +17 −15 hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/lock/RaftLockService.java
  42. +5 −10 ...rc/main/java/com/hazelcast/cp/internal/datastructures/lock/proxy/AbstractRaftFencedLockProxy.java
  43. +2 −2 hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/lock/proxy/RaftFencedLockProxy.java
  44. +0 −209 hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/lock/proxy/RaftLockProxy.java
  45. +5 −5 ...st/cp/internal/datastructures/semaphore/{SemaphoreInvocationKey.java → AcquireInvocationKey.java}
  46. +58 −41 hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/semaphore/RaftSemaphore.java
  47. +10 −6 ...main/java/com/hazelcast/cp/internal/datastructures/semaphore/RaftSemaphoreDataSerializerHook.java
  48. +67 −18 ...elcast/cp/internal/datastructures/semaphore/{SemaphoreRegistry.java → RaftSemaphoreRegistry.java}
  49. +21 −17 hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/semaphore/RaftSemaphoreService.java
  50. +110 −0 ...n/java/com/hazelcast/cp/internal/datastructures/semaphore/client/GenerateThreadIdMessageTask.java
  51. +8 −0 ...om/hazelcast/cp/internal/datastructures/semaphore/client/SemaphoreMessageTaskFactoryProvider.java
  52. +8 −7 .../src/main/java/com/hazelcast/cp/internal/datastructures/semaphore/operation/AcquirePermitsOp.java
  53. +5 −4 ...t/src/main/java/com/hazelcast/cp/internal/datastructures/semaphore/operation/ChangePermitsOp.java
  54. +3 −2 ...st/src/main/java/com/hazelcast/cp/internal/datastructures/semaphore/operation/DrainPermitsOp.java
  55. +86 −0 ...rc/main/java/com/hazelcast/cp/internal/datastructures/semaphore/operation/GenerateThreadIdOp.java
  56. +5 −4 .../src/main/java/com/hazelcast/cp/internal/datastructures/semaphore/operation/ReleasePermitsOp.java
  57. +0 −63 ...ain/java/com/hazelcast/cp/internal/datastructures/semaphore/proxy/GloballyUniqueThreadIdUtil.java
  58. +10 −10 ...java/com/hazelcast/cp/internal/datastructures/semaphore/proxy/RaftSessionAwareSemaphoreProxy.java
  59. +20 −38 .../java/com/hazelcast/cp/internal/datastructures/semaphore/proxy/RaftSessionlessSemaphoreProxy.java
  60. +9 −8 .../src/main/java/com/hazelcast/cp/internal/datastructures/spi/blocking/AbstractBlockingService.java
  61. +6 −4 hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/spi/blocking/ResourceRegistry.java
  62. +2 −2 hazelcast/src/main/java/com/hazelcast/cp/internal/datastructures/spi/blocking/WaitKey.java
  63. +5 −5 ...ast/cp/internal/exception/{CannotRemoveMemberException.java → CannotRemoveCPMemberException.java}
  64. +3 −0 hazelcast/src/main/java/com/hazelcast/cp/internal/raft/SnapshotAwareService.java
  65. +1 −1 hazelcast/src/main/java/com/hazelcast/cp/internal/raft/exception/CannotReplicateException.java
  66. +1 −1 hazelcast/src/main/java/com/hazelcast/cp/internal/raft/impl/RaftNodeImpl.java
  67. +1 −1 hazelcast/src/main/java/com/hazelcast/cp/internal/raftop/metadata/TriggerRemoveRaftMemberOp.java
  68. +24 −1 ...om/hazelcast/cp/internal/session/{AbstractSessionManager.java → AbstractProxySessionManager.java}
  69. +13 −4 .../com/hazelcast/cp/internal/session/{SessionManagerService.java → ProxySessionManagerService.java}
  70. +11 −11 hazelcast/src/main/java/com/hazelcast/cp/internal/session/{Session.java → RaftSession.java}
  71. +69 −28 ...src/main/java/com/hazelcast/cp/internal/session/{SessionRegistry.java → RaftSessionRegistry.java}
  72. +38 −38 ...t/src/main/java/com/hazelcast/cp/internal/session/{SessionService.java → RaftSessionService.java}
  73. +18 −19 hazelcast/src/main/java/com/hazelcast/cp/internal/session/RaftSessionServiceDataSerializerHook.java
  74. +1 −1 hazelcast/src/main/java/com/hazelcast/cp/internal/session/SessionAccessor.java
  75. +7 −3 hazelcast/src/main/java/com/hazelcast/cp/internal/session/SessionAwareProxy.java
  76. +0 −4 hazelcast/src/main/java/com/hazelcast/cp/internal/session/SessionExpiredException.java
  77. +0 −95 hazelcast/src/main/java/com/hazelcast/cp/internal/session/SessionRegistrySnapshot.java
  78. +6 −6 hazelcast/src/main/java/com/hazelcast/cp/internal/session/operation/CloseInactiveSessionsOp.java
  79. +4 −4 hazelcast/src/main/java/com/hazelcast/cp/internal/session/operation/CloseSessionOp.java
  80. +4 −4 hazelcast/src/main/java/com/hazelcast/cp/internal/session/operation/CreateSessionOp.java
  81. +6 −6 hazelcast/src/main/java/com/hazelcast/cp/internal/session/operation/ExpireSessionsOp.java
  82. +6 −6 hazelcast/src/main/java/com/hazelcast/cp/internal/session/operation/GetSessionsOp.java
  83. +4 −4 hazelcast/src/main/java/com/hazelcast/cp/internal/session/operation/HeartbeatSessionOp.java
  84. +14 −13 hazelcast/src/main/java/com/hazelcast/internal/dynamicconfig/DynamicConfigurationAwareConfig.java
  85. +4 −4 hazelcast/src/test/java/com/hazelcast/cp/internal/HazelcastRaftTestSupport.java
  86. +2 −2 hazelcast/src/test/java/com/hazelcast/cp/internal/MetadataRaftGroupTest.java
  87. +21 −21 hazelcast/src/test/java/com/hazelcast/cp/internal/RaftMemberAddRemoveTest.java
  88. +2 −2 hazelcast/src/test/java/com/hazelcast/cp/internal/RaftMemberAutoRemoveTest.java
  89. +2 −2 ...st/src/test/java/com/hazelcast/cp/internal/datastructures/atomiclong/RaftAtomicLongBasicTest.java
  90. +2 −2 ...cast/src/test/java/com/hazelcast/cp/internal/datastructures/atomicref/RaftAtomicRefBasicTest.java
  91. +8 −8 .../java/com/hazelcast/cp/internal/datastructures/countdownlatch/RaftCountDownLatchAdvancedTest.java
  92. +23 −22 ...lcast/src/test/java/com/hazelcast/cp/internal/datastructures/lock/RaftFencedLockAdvancedTest.java
  93. +16 −15 hazelcast/src/test/java/com/hazelcast/cp/internal/datastructures/lock/RaftFencedLockBasicTest.java
  94. +17 −17 hazelcast/src/test/java/com/hazelcast/cp/internal/datastructures/lock/RaftFencedLockFailureTest.java
  95. +0 −496 hazelcast/src/test/java/com/hazelcast/cp/internal/datastructures/lock/RaftLockBasicTest.java
  96. +0 −348 hazelcast/src/test/java/com/hazelcast/cp/internal/datastructures/lock/RaftLockFailureTest.java
  97. +28 −28 ...t/src/test/java/com/hazelcast/cp/internal/datastructures/semaphore/RaftSemaphoreAdvancedTest.java
  98. +47 −30 ...st/src/test/java/com/hazelcast/cp/internal/datastructures/semaphore/RaftSemaphoreFailureTest.java
  99. +10 −10 ...t/java/com/hazelcast/cp/internal/datastructures/semaphore/RaftSessionAwareSemaphoreBasicTest.java
  100. +7 −7 ...java/com/hazelcast/cp/internal/datastructures/semaphore/RaftSessionAwareSemaphoreFailureTest.java
  101. +6 −6 ...st/java/com/hazelcast/cp/internal/datastructures/semaphore/RaftSessionlessSemaphoreBasicTest.java
  102. +3 −20 .../java/com/hazelcast/cp/internal/datastructures/semaphore/RaftSessionlessSemaphoreFailureTest.java
  103. +1 −1 hazelcast/src/test/java/com/hazelcast/cp/internal/raft/impl/DestroyRaftGroupTest.java
  104. +1 −1 hazelcast/src/test/java/com/hazelcast/cp/internal/raft/impl/LocalQueryTest.java
  105. +1 −1 hazelcast/src/test/java/com/hazelcast/cp/internal/raft/impl/LocalRaftTest.java
  106. +1 −1 hazelcast/src/test/java/com/hazelcast/cp/internal/raft/impl/MembershipChangeTest.java
  107. +1 −1 hazelcast/src/test/java/com/hazelcast/cp/internal/raft/impl/RaftUtil.java
  108. +1 −1 hazelcast/src/test/java/com/hazelcast/cp/internal/raft/impl/SnapshotTest.java
  109. +1 −1 hazelcast/src/test/java/com/hazelcast/cp/internal/raft/impl/testing/LocalRaftGroup.java
  110. +22 −21 ...cast/cp/internal/session/{AbstractSessionManagerTest.java → AbstractProxySessionManagerTest.java}
  111. +47 −45 hazelcast/src/test/java/com/hazelcast/cp/internal/session/RaftSessionServiceTest.java
  112. +3 −3 hazelcast/src/test/java/com/hazelcast/cp/internal/session/SessionManagerServiceTest.java
  113. +3 −3 hazelcast/src/test/java/com/hazelcast/spi/impl/operationservice/impl/RaftInvocationFailureTest.java
@@ -16,6 +16,7 @@

package com.hazelcast.client.cp.internal.datastructures.lock;

import com.hazelcast.client.cp.internal.session.SessionManagerProvider;
import com.hazelcast.client.impl.clientside.ClientMessageDecoder;
import com.hazelcast.client.impl.clientside.HazelcastClientInstanceImpl;
import com.hazelcast.client.impl.protocol.ClientMessage;
@@ -27,32 +28,31 @@
import com.hazelcast.cp.internal.RaftGroupIdImpl;
import com.hazelcast.cp.internal.datastructures.lock.RaftLockOwnershipState;
import com.hazelcast.cp.internal.datastructures.lock.proxy.AbstractRaftFencedLockProxy;
import com.hazelcast.client.cp.internal.session.SessionManagerProvider;
import com.hazelcast.cp.internal.datastructures.spi.client.RaftGroupTaskFactoryProvider;
import com.hazelcast.nio.Bits;
import com.hazelcast.spi.InternalCompletableFuture;

import java.util.UUID;

import static com.hazelcast.client.cp.internal.ClientAccessor.getClient;
import static com.hazelcast.client.impl.protocol.util.ParameterUtil.calculateDataSize;
import static com.hazelcast.cp.internal.RaftGroupIdImpl.dataSize;
import static com.hazelcast.cp.internal.RaftService.getObjectNameForProxy;
import static com.hazelcast.cp.internal.datastructures.lock.client.LockMessageTaskFactoryProvider.DESTROY_TYPE;
import static com.hazelcast.cp.internal.datastructures.lock.client.LockMessageTaskFactoryProvider.FORCE_UNLOCK_TYPE;
import static com.hazelcast.cp.internal.datastructures.lock.client.LockMessageTaskFactoryProvider.LOCK_OWNERSHIP_STATE;
import static com.hazelcast.cp.internal.datastructures.lock.client.LockMessageTaskFactoryProvider.LOCK_TYPE;
import static com.hazelcast.cp.internal.datastructures.lock.client.LockMessageTaskFactoryProvider.TRY_LOCK_TYPE;
import static com.hazelcast.cp.internal.datastructures.lock.client.LockMessageTaskFactoryProvider.UNLOCK_TYPE;
import static com.hazelcast.client.cp.internal.datastructures.lock.RaftLockProxy.BOOLEAN_RESPONSE_DECODER;
import static com.hazelcast.client.cp.internal.datastructures.lock.RaftLockProxy.LOCK_OWNERSHIP_STATE_RESPONSE_DECODER;
import static com.hazelcast.client.cp.internal.datastructures.lock.RaftLockProxy.encodeRequest;
import static com.hazelcast.client.cp.internal.datastructures.lock.RaftLockProxy.invoke;
import static com.hazelcast.client.cp.internal.datastructures.lock.RaftLockProxy.prepareClientMessage;
import static com.hazelcast.client.cp.internal.ClientAccessor.getClient;

/**
* TODO: Javadoc Pending...
*/
public class RaftFencedLockProxy extends AbstractRaftFencedLockProxy {

static final ClientMessageDecoder BOOLEAN_RESPONSE_DECODER = new BooleanResponseDecoder();
static final ClientMessageDecoder LOCK_OWNERSHIP_STATE_RESPONSE_DECODER = new RaftLockOwnershipStateResponseDecoder();

public static AbstractRaftFencedLockProxy create(HazelcastInstance instance, String name) {
int dataSize = ClientMessage.HEADER_SIZE + calculateDataSize(name);
ClientMessage msg = ClientMessage.createForEncode(dataSize);
@@ -132,4 +132,88 @@ public void destroy() {
invoke(client, name, msg, BOOLEAN_RESPONSE_DECODER).join();
}

static <T> InternalCompletableFuture<T> invoke(HazelcastClientInstanceImpl client, String name, ClientMessage msg,
ClientMessageDecoder decoder) {
ClientInvocationFuture future = new ClientInvocation(client, msg, name).invoke();
return new ClientDelegatingFuture<T>(future, client.getSerializationService(), decoder);
}

static ClientMessage encodeRequest(int messageTypeId, RaftGroupId groupId, String name, long sessionId,
long threadId, UUID invUid) {
int dataSize = ClientMessage.HEADER_SIZE
+ dataSize(groupId) + calculateDataSize(name) + Bits.LONG_SIZE_IN_BYTES * 4;
ClientMessage msg = prepareClientMessage(groupId, name, dataSize, messageTypeId);
setRequestParams(msg, sessionId, threadId, invUid);
msg.updateFrameLength();
return msg;
}

static ClientMessage encodeRequest(int messageTypeId, RaftGroupId groupId, String name, long sessionId,
long threadId, UUID invUid, int val) {
int dataSize = ClientMessage.HEADER_SIZE
+ dataSize(groupId) + calculateDataSize(name) + Bits.LONG_SIZE_IN_BYTES * 4 + Bits.INT_SIZE_IN_BYTES;
ClientMessage msg = prepareClientMessage(groupId, name, dataSize, messageTypeId);
setRequestParams(msg, sessionId, threadId, invUid);
msg.set(val);
msg.updateFrameLength();
return msg;
}

static ClientMessage encodeRequest(int messageTypeId, RaftGroupId groupId, String name, long sessionId,
long threadId, UUID invUid, long val) {

int dataSize = ClientMessage.HEADER_SIZE
+ dataSize(groupId) + calculateDataSize(name) + Bits.LONG_SIZE_IN_BYTES * 5;
ClientMessage msg = prepareClientMessage(groupId, name, dataSize, messageTypeId);
setRequestParams(msg, sessionId, threadId, invUid);
msg.set(val);
msg.updateFrameLength();
return msg;
}

private static void setRequestParams(ClientMessage msg, long sessionId, long threadId, UUID invUid) {
msg.set(sessionId);
msg.set(threadId);
msg.set(invUid.getLeastSignificantBits());
msg.set(invUid.getMostSignificantBits());
}

static ClientMessage encodeRequest(int messageTypeId, RaftGroupId groupId, String name, long sessionId, long threadId) {
int dataSize = ClientMessage.HEADER_SIZE
+ dataSize(groupId) + calculateDataSize(name) + Bits.LONG_SIZE_IN_BYTES * 2;
ClientMessage msg = prepareClientMessage(groupId, name, dataSize, messageTypeId);
msg.set(sessionId);
msg.set(threadId);
msg.updateFrameLength();
return msg;
}

static ClientMessage prepareClientMessage(RaftGroupId groupId, String name, int dataSize, int messageTypeId) {
ClientMessage msg = ClientMessage.createForEncode(dataSize);
msg.setMessageType(messageTypeId);
msg.setRetryable(false);
msg.setOperationName("");
RaftGroupIdImpl.writeTo(groupId, msg);
msg.set(name);
return msg;
}

private static class BooleanResponseDecoder implements ClientMessageDecoder {
@Override
public Boolean decodeClientMessage(ClientMessage msg) {
return msg.getBoolean();
}
}

private static class RaftLockOwnershipStateResponseDecoder implements ClientMessageDecoder {
@Override
public RaftLockOwnershipState decodeClientMessage(ClientMessage msg) {
long fence = msg.getLong();
int lockCount = msg.getInt();
long sessionId = msg.getLong();
long threadId = msg.getLong();
return new RaftLockOwnershipState(fence, lockCount, sessionId, threadId);
}
}

}

0 comments on commit aa9d156

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