aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMohammad Salehe <salehe@cs.toronto.edu>2019-02-08 11:34:41 -0500
committerMohammad Salehe <salehe@cs.toronto.edu>2019-02-24 22:23:39 -0500
commit6a3fb42a95b61ac862ffb8c5dad1777265935516 (patch)
tree780eec2501376cf59e277a9edd2bafdc16949704
parent017a7bbadc5464bb49a481c0a903bc879e441ccf (diff)
Implement voluntaryReleaseLock retry logic
Add retry logic for voluntaryReleaseLock inside atomicPut Change-Id: Iedb474c673541f3f79d4ae4ee76e15f14a387ed7 Issue-ID: MUSIC-148 Signed-off-by: Mohammad Salehe <salehe@cs.toronto.edu>
-rw-r--r--src/main/java/org/onap/music/service/impl/MusicCassaCore.java18
1 files changed, 17 insertions, 1 deletions
diff --git a/src/main/java/org/onap/music/service/impl/MusicCassaCore.java b/src/main/java/org/onap/music/service/impl/MusicCassaCore.java
index 7eebf65a..e3347486 100644
--- a/src/main/java/org/onap/music/service/impl/MusicCassaCore.java
+++ b/src/main/java/org/onap/music/service/impl/MusicCassaCore.java
@@ -668,7 +668,23 @@ public class MusicCassaCore implements MusicCoreService {
ReturnType criticalPutResult = criticalPut(keyspaceName, tableName, primaryKey,
queryObject, lockReference, conditionInfo);
long criticalPutTime = System.currentTimeMillis();
- voluntaryReleaseLock(fullyQualifiedKey, lockReference);
+
+ int releaseTries = 0;
+ while (true) {
+ MusicLockState rs = voluntaryReleaseLock(fullyQualifiedKey, lockReference);
+ releaseTries++;
+ if (rs.getLockStatus() != MusicLockState.LockStatus.UNLOCKED) {
+ try {
+ Thread.sleep(Integer.min(100, (int) Math.pow(2, releaseTries - 1)));
+ } catch (InterruptedException e) {
+ }
+ } else
+ break;
+ }
+ if (releaseTries > 1) {
+ System.out.print((char) (Integer.min(releaseTries, 9) + 78));
+ }
+
long lockDeleteTime = System.currentTimeMillis();
String timingInfo = "|lock creation time:" + (lockCreationTime - start)
+ "|lock accquire time:" + (lockAcqTime - lockCreationTime)