From 764787d0e3a4682ac8345f925d83d002dc577386 Mon Sep 17 00:00:00 2001 From: Mohammad Salehe Date: Fri, 8 Feb 2019 11:29:08 -0500 Subject: 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 --- .../onap/music/service/impl/MusicCassaCore.java | 31 +++++++--------------- 1 file 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, -- cgit 1.2.3-korg