Created
April 13, 2016 16:36
-
-
Save mpilone/194242200e509be8d1acb0365e3b2078 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
final static String KEY_PREFIX = "gatekeeper"; | |
ConcurrentMap definitionMap = hazelcast.getMap(KEY_PREFIX + ".semaphoreDefinitions"); | |
ConcurrentMap permitMap = hazelcast.getMap(KEY_PREFIX + ".semaphorePermits"); | |
// Logic: | |
// - Lookup the definition | |
// - Check the group and acquirer pattern | |
// - Check for an available permit | |
// - Issue the permit | |
if (!permitMap.replace(semaphoreName, origPermits, updatedPermits)) { | |
throw new OptimisticLockingFailureException("Conflict " | |
+ "while updating semaphore permits."); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment