Skip to content

Commit

Permalink
Merge pull request hazelcast#14743 from metanet/cp-subsystem/master/e…
Browse files Browse the repository at this point in the history
…xception-rename

Rename LockAcquireLimitExceededException to LockAcquireLimitReachedException
  • Loading branch information
metanet committed Mar 22, 2019
2 parents 7e4af51 + a66c503 commit d57e51a
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
import com.hazelcast.cp.exception.StaleAppendRequestException;
import com.hazelcast.cp.internal.datastructures.exception.WaitKeyCancelledException;
import com.hazelcast.cp.internal.session.SessionExpiredException;
import com.hazelcast.cp.lock.exception.LockAcquireLimitExceededException;
import com.hazelcast.cp.lock.exception.LockAcquireLimitReachedException;
import com.hazelcast.cp.lock.exception.LockOwnershipLostException;
import com.hazelcast.crdt.MutationDisallowedException;
import com.hazelcast.crdt.TargetNotReplicaException;
Expand Down Expand Up @@ -108,7 +108,7 @@
import static com.hazelcast.client.impl.protocol.ClientProtocolErrorCodes.CANNOT_REPLICATE_EXCEPTION;
import static com.hazelcast.client.impl.protocol.ClientProtocolErrorCodes.CP_GROUP_DESTROYED_EXCEPTION;
import static com.hazelcast.client.impl.protocol.ClientProtocolErrorCodes.LEADER_DEMOTED_EXCEPTION;
import static com.hazelcast.client.impl.protocol.ClientProtocolErrorCodes.LOCK_ACQUIRE_LIMIT_EXCEEDED_EXCEPTION;
import static com.hazelcast.client.impl.protocol.ClientProtocolErrorCodes.LOCK_ACQUIRE_LIMIT_REACHED_EXCEPTION;
import static com.hazelcast.client.impl.protocol.ClientProtocolErrorCodes.LOCK_OWNERSHIP_LOST_EXCEPTION;
import static com.hazelcast.client.impl.protocol.ClientProtocolErrorCodes.NOT_LEADER_EXCEPTION;
import static com.hazelcast.client.impl.protocol.ClientProtocolErrorCodes.SESSION_EXPIRED_EXCEPTION;
Expand Down Expand Up @@ -695,10 +695,10 @@ public Throwable createException(String message, Throwable cause) {
return new WaitKeyCancelledException(message, cause);
}
});
register(LOCK_ACQUIRE_LIMIT_EXCEEDED_EXCEPTION, LockAcquireLimitExceededException.class, new ExceptionFactory() {
register(LOCK_ACQUIRE_LIMIT_REACHED_EXCEPTION, LockAcquireLimitReachedException.class, new ExceptionFactory() {
@Override
public Throwable createException(String message, Throwable cause) {
return new LockAcquireLimitExceededException(message);
return new LockAcquireLimitReachedException(message);
}
});
register(LOCK_OWNERSHIP_LOST_EXCEPTION, LockOwnershipLostException.class, new ExceptionFactory() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
import com.hazelcast.cp.exception.LeaderDemotedException;
import com.hazelcast.cp.exception.NotLeaderException;
import com.hazelcast.cp.exception.StaleAppendRequestException;
import com.hazelcast.cp.lock.exception.LockAcquireLimitExceededException;
import com.hazelcast.cp.lock.exception.LockAcquireLimitReachedException;
import com.hazelcast.cp.lock.exception.LockOwnershipLostException;
import com.hazelcast.cp.internal.datastructures.exception.WaitKeyCancelledException;
import com.hazelcast.cp.internal.session.SessionExpiredException;
Expand Down Expand Up @@ -209,7 +209,7 @@ public ClientExceptions(boolean jcacheAvailable) {
register(ClientProtocolErrorCodes.CONSISTENCY_LOST_EXCEPTION, ConsistencyLostException.class);
register(ClientProtocolErrorCodes.SESSION_EXPIRED_EXCEPTION, SessionExpiredException.class);
register(ClientProtocolErrorCodes.WAIT_KEY_CANCELLED_EXCEPTION, WaitKeyCancelledException.class);
register(ClientProtocolErrorCodes.LOCK_ACQUIRE_LIMIT_EXCEEDED_EXCEPTION, LockAcquireLimitExceededException.class);
register(ClientProtocolErrorCodes.LOCK_ACQUIRE_LIMIT_REACHED_EXCEPTION, LockAcquireLimitReachedException.class);
register(ClientProtocolErrorCodes.LOCK_OWNERSHIP_LOST_EXCEPTION, LockOwnershipLostException.class);
register(ClientProtocolErrorCodes.CP_GROUP_DESTROYED_EXCEPTION, CPGroupDestroyedException.class);
register(ClientProtocolErrorCodes.CANNOT_REPLICATE_EXCEPTION, CannotReplicateException.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public final class ClientProtocolErrorCodes {
public static final int CONSISTENCY_LOST_EXCEPTION = 88;
public static final int SESSION_EXPIRED_EXCEPTION = 89;
public static final int WAIT_KEY_CANCELLED_EXCEPTION = 90;
public static final int LOCK_ACQUIRE_LIMIT_EXCEEDED_EXCEPTION = 91;
public static final int LOCK_ACQUIRE_LIMIT_REACHED_EXCEPTION = 91;
public static final int LOCK_OWNERSHIP_LOST_EXCEPTION = 92;
public static final int CP_GROUP_DESTROYED_EXCEPTION = 93;
public static final int CANNOT_REPLICATE_EXCEPTION = 94;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import com.hazelcast.cp.internal.session.SessionAwareProxy;
import com.hazelcast.cp.internal.session.SessionExpiredException;
import com.hazelcast.cp.lock.FencedLock;
import com.hazelcast.cp.lock.exception.LockAcquireLimitExceededException;
import com.hazelcast.cp.lock.exception.LockAcquireLimitReachedException;
import com.hazelcast.cp.lock.exception.LockOwnershipLostException;
import com.hazelcast.spi.InternalCompletableFuture;
import com.hazelcast.util.Clock;
Expand Down Expand Up @@ -92,7 +92,7 @@ public void lockInterruptibly() throws InterruptedException {
return;
}

throw new LockAcquireLimitExceededException("Lock[" + proxyName + "] reentrant lock limit exceeded!");
throw new LockAcquireLimitReachedException("Lock[" + proxyName + "] reentrant lock limit is already reached!");
} catch (SessionExpiredException e) {
invalidateSession(sessionId);
verifyNoLockedSessionIdPresent(threadId);
Expand Down Expand Up @@ -125,7 +125,7 @@ public final long lockAndGetFence() {
return fence;
}

throw new LockAcquireLimitExceededException("Lock[" + proxyName + "] reentrant lock limit exceeded!");
throw new LockAcquireLimitReachedException("Lock[" + proxyName + "] reentrant lock limit is already reached!");
} catch (SessionExpiredException e) {
invalidateSession(sessionId);
verifyNoLockedSessionIdPresent(threadId);
Expand Down
35 changes: 19 additions & 16 deletions hazelcast/src/main/java/com/hazelcast/cp/lock/FencedLock.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import com.hazelcast.core.DistributedObject;
import com.hazelcast.cp.CPGroupId;
import com.hazelcast.cp.CPSubsystem;
import com.hazelcast.cp.lock.exception.LockAcquireLimitExceededException;
import com.hazelcast.cp.lock.exception.LockAcquireLimitReachedException;
import com.hazelcast.cp.lock.exception.LockOwnershipLostException;
import com.hazelcast.cp.session.CPSession;
import com.hazelcast.cp.session.CPSessionManagementService;
Expand All @@ -48,9 +48,9 @@
* in a linearizable manner. You can configure the reentrancy behaviour via
* {@link FencedLockConfig}. For instance, reentrancy can be disabled and
* {@link FencedLock} can work as a non-reentrant mutex. One can also set
* a custom reentrancy limit. When the reentrancy limit is exceeded,
* a custom reentrancy limit. When the reentrancy limit is reached,
* {@link FencedLock} does not block a lock call. Instead, it fails with
* {@link LockAcquireLimitExceededException} or a specified return value.
* {@link LockAcquireLimitReachedException} or a specified return value.
* Please check the locking methods to see details about the behaviour.
* <p>
* Distributed locks are unfortunately NOT EQUIVALENT to single-node mutexes
Expand Down Expand Up @@ -123,7 +123,7 @@
* @see CPSessionManagementService
* @see CPSession
* @see LockOwnershipLostException
* @see LockAcquireLimitExceededException
* @see LockAcquireLimitReachedException
*/
public interface FencedLock extends Lock, DistributedObject {

Expand All @@ -138,8 +138,9 @@ public interface FencedLock extends Lock, DistributedObject {
* <p>
* When the caller already holds the lock and the current lock() call is
* reentrant, the call can fail with
* {@link LockAcquireLimitExceededException} if the lock acquire limit is
* exceeded. Please see {@link FencedLockConfig} for more information.
* {@link LockAcquireLimitReachedException} if the lock acquire limit is
* already reached. Please see {@link FencedLockConfig} for more
* information.
* <p>
* If the lock is not available then the current thread becomes disabled
* for thread scheduling purposes and lies dormant until the lock has been
Expand Down Expand Up @@ -168,8 +169,8 @@ public interface FencedLock extends Lock, DistributedObject {
*
* @throws LockOwnershipLostException if the underlying CP session is
* closed while locking reentrantly
* @throws LockAcquireLimitExceededException if the lock call is reentrant
* and the configured lock acquire limit is exceeded.
* @throws LockAcquireLimitReachedException if the lock call is reentrant
* and the configured lock acquire limit is already reached.
*/
void lock();

Expand All @@ -179,8 +180,9 @@ public interface FencedLock extends Lock, DistributedObject {
* <p>
* When the caller already holds the lock and the current lock() call is
* reentrant, the call can fail with
* {@link LockAcquireLimitExceededException} if the lock acquire limit is
* exceeded. Please see {@link FencedLockConfig} for more information.
* {@link LockAcquireLimitReachedException} if the lock acquire limit is
* already reached. Please see {@link FencedLockConfig} for more
* information.
* <p>
* If the lock is not available then the current thread becomes disabled
* for thread scheduling purposes and lies dormant until the lock has been
Expand Down Expand Up @@ -220,17 +222,18 @@ public interface FencedLock extends Lock, DistributedObject {
*
* @throws LockOwnershipLostException if the underlying CP session is
* closed while locking reentrantly
* @throws LockAcquireLimitExceededException if the lock call is reentrant
* and the configured lock acquire limit is exceeded.
* @throws LockAcquireLimitReachedException if the lock call is reentrant
* and the configured lock acquire limit is already reached.
*/
void lockInterruptibly() throws InterruptedException;

/**
* Acquires the lock and returns the fencing token assigned to the current
* thread for this lock acquire. If the lock is acquired reentrantly,
* the same fencing token is returned, or the lock() call can fail with
* {@link LockAcquireLimitExceededException} if the lock acquire limit is
* exceeded. Please see {@link FencedLockConfig} for more information.
* {@link LockAcquireLimitReachedException} if the lock acquire limit is
* already reached. Please see {@link FencedLockConfig} for more
* information.
* <p>
* If the lock is not available then the current thread becomes disabled
* for thread scheduling purposes and lies dormant until the lock has been
Expand Down Expand Up @@ -293,8 +296,8 @@ public interface FencedLock extends Lock, DistributedObject {
*
* @throws LockOwnershipLostException if the underlying CP session is
* closed while locking reentrantly
* @throws LockAcquireLimitExceededException if the lock call is reentrant
* and the configured lock acquire limit is exceeded.
* @throws LockAcquireLimitReachedException if the lock call is reentrant
* and the configured lock acquire limit is already reached.
*/
long lockAndGetFence();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@
* @see FencedLockConfig
* @see FencedLock
*/
public class LockAcquireLimitExceededException extends HazelcastException {
public class LockAcquireLimitReachedException extends HazelcastException {

public LockAcquireLimitExceededException() {
public LockAcquireLimitReachedException() {
}

public LockAcquireLimitExceededException(String message) {
public LockAcquireLimitReachedException(String message) {
super(message);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import com.hazelcast.config.cp.FencedLockConfig;
import com.hazelcast.core.HazelcastInstance;
import com.hazelcast.cp.lock.FencedLock;
import com.hazelcast.cp.lock.exception.LockAcquireLimitExceededException;
import com.hazelcast.cp.lock.exception.LockAcquireLimitReachedException;
import com.hazelcast.cp.internal.HazelcastRaftTestSupport;
import com.hazelcast.test.HazelcastSerialClassRunner;
import com.hazelcast.test.annotation.ParallelTest;
Expand Down Expand Up @@ -156,7 +156,7 @@ public void testReentrantLockFails() {
lock.lock();
lock.lock();

expectedException.expect(LockAcquireLimitExceededException.class);
expectedException.expect(LockAcquireLimitReachedException.class);
lock.lock();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import com.hazelcast.config.cp.FencedLockConfig;
import com.hazelcast.core.HazelcastInstance;
import com.hazelcast.cp.lock.FencedLock;
import com.hazelcast.cp.lock.exception.LockAcquireLimitExceededException;
import com.hazelcast.cp.lock.exception.LockAcquireLimitReachedException;
import com.hazelcast.cp.internal.HazelcastRaftTestSupport;
import com.hazelcast.test.HazelcastSerialClassRunner;
import com.hazelcast.test.annotation.ParallelTest;
Expand Down Expand Up @@ -134,7 +134,7 @@ public void testTryLockTimeoutWhileLockedByAnotherEndpoint() {
public void testReentrantLockFails() {
lock.lock();

expectedException.expect(LockAcquireLimitExceededException.class);
expectedException.expect(LockAcquireLimitReachedException.class);
lock.lock();
}

Expand Down

0 comments on commit d57e51a

Please sign in to comment.