aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMohammad Salehe <salehe@cs.toronto.edu>2019-02-08 11:29:08 -0500
committerMohammad Salehe <salehe@cs.toronto.edu>2019-02-24 22:23:39 -0500
commit764787d0e3a4682ac8345f925d83d002dc577386 (patch)
treeb1e6ba2e8555a6aa92f1b2ed871b75efa6fe169f
parent8014ef7e259a46b3c2128f3b9628a48b758be9cb (diff)
Return correct value on lockref dequeue exception
If we can not dequeue the lock reference, we should not return same result, so the caller can try again Change-Id: I10c2923849b837253e3ef86da077b221f9607e13 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.java31
1 files changed, 9 insertions, 22 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 343ba1f1..824dc0c4 100644
--- a/src/main/java/org/onap/music/service/impl/MusicCassaCore.java
+++ b/src/main/java/org/onap/music/service/impl/MusicCassaCore.java
@@ -401,12 +401,14 @@ public class MusicCassaCore implements MusicCoreService {
String primaryKeyValue = splitString[2];
try {
getLockingServiceHandle().deQueueLockRef(keyspace, table, primaryKeyValue, lockReference);
- } catch (MusicLockingException | MusicServiceException | MusicQueryException e) {
- logger.error(EELFLoggerDelegate.errorLogger, e.getMessage(), AppMessages.DESTROYLOCK + lockReference, ErrorSeverity.CRITICAL, ErrorTypes.LOCKINGERROR);
+ } catch (MusicServiceException | MusicQueryException | MusicLockingException e) {
+ logger.error(EELFLoggerDelegate.errorLogger, e.getMessage(), AppMessages.DESTROYLOCK + " " + primaryKeyValue + " " + lockReference, ErrorSeverity.CRITICAL, ErrorTypes.LOCKINGERROR);
+ logger.info(EELFLoggerDelegate.applicationLogger, "Lock not destroyed " + primaryKeyValue + " " + lockReference + " " + " :" + e.getMessage());
+ return new MusicLockState(MusicLockState.LockStatus.LOCKED, "");
}
long end = System.currentTimeMillis();
- logger.info(EELFLoggerDelegate.applicationLogger, "Time taken to destroy lock reference:" + (end - start) + " ms");
- return getMusicLockState(fullyQualifiedKey);
+ logger.info(EELFLoggerDelegate.applicationLogger, "Time taken to destroy lock reference " + primaryKeyValue + " " + lockReference + " " + " :" + (end - start) + " ms");
+ return new MusicLockState(MusicLockState.LockStatus.UNLOCKED, "");
}
finally {
TimeMeasureInstance.instance().exit();
@@ -624,7 +626,7 @@ public class MusicCassaCore implements MusicCoreService {
try {
Thread.sleep(Integer.min(100, (int) Math.pow(2, createLockReferenceTries - 1)));
} catch (InterruptedException e) {
- e.printStackTrace();
+ logger.error(EELFLoggerDelegate.errorLogger, e.getMessage());
}
} else
break;
@@ -644,7 +646,7 @@ public class MusicCassaCore implements MusicCoreService {
try {
Thread.sleep(Integer.min(100, (int) Math.pow(2, acquireLockTries - 1)));
} catch (InterruptedException e) {
- e.printStackTrace();
+ logger.error(EELFLoggerDelegate.errorLogger, e.getMessage());
}
} else
break;
@@ -679,9 +681,6 @@ public class MusicCassaCore implements MusicCoreService {
TimeMeasureInstance.instance().exit();
}
}
-
-
-
/**
* This method performs DDL operation on cassasndra, when the lock for the resource is acquired.
@@ -713,13 +712,10 @@ public class MusicCassaCore implements MusicCoreService {
return null;
}
}
-
-
+
public static MusicLockState getMusicLockState(String fullyQualifiedKey) {
return null;
}
-
-
/**
* @param lockName
@@ -738,15 +734,6 @@ public class MusicCassaCore implements MusicCoreService {
resultMap.put("keyspace",keyspace);
return resultMap;
}
-
-
- public static void main(String[] args) {
- String x = "axe top";
- x = x.replaceFirst("top", "sword");
- System.out.print(x); //returns sword pickaxe
- }
-
-
@Override
public ReturnType atomicPutWithDeleteLock(String keyspaceName, String tableName, String primaryKey,