From 48b02dfdc78a6412d568a14b015ccb9439a1dbb5 Mon Sep 17 00:00:00 2001 From: "Thomas Nelson (arthurdent3)" Date: Wed, 2 Oct 2019 18:09:23 -0400 Subject: Update locking to use Threadsafe set Had to create whole new method for Atomic Lock Creation. Added thread safe set to contol lock creation per key. Updated the deadlock to use local_quorum Removed some uneeded import Updated some logging. Issue-ID: MUSIC-512 Signed-off-by: Thomas Nelson (arthurdent3) Change-Id: I7e1a4c34de5dc9a0e90adf30d1f4d1bac698ceae Signed-off-by: Thomas Nelson (arthurdent3) --- .../org/onap/music/conductor/conditionals/MusicConditional.java | 6 +++--- .../test/java/org/onap/music/unittests/TstRestMusicLockAPI.java | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) (limited to 'music-rest/src') diff --git a/music-rest/src/main/java/org/onap/music/conductor/conditionals/MusicConditional.java b/music-rest/src/main/java/org/onap/music/conductor/conditionals/MusicConditional.java index 18fa8a18..ebaa3a1f 100644 --- a/music-rest/src/main/java/org/onap/music/conductor/conditionals/MusicConditional.java +++ b/music-rest/src/main/java/org/onap/music/conductor/conditionals/MusicConditional.java @@ -94,9 +94,9 @@ public class MusicConditional { String key = keyspace + "." + tablename + "." + primaryKey; String lockId; try { - lockId = MusicCore.createLockReference(key); + lockId = MusicCore.createLockReferenceAtomic(key); } catch (MusicLockingException e) { - return new ReturnType(ResultType.FAILURE, e.getMessage()); + return new ReturnType(ResultType.FAILURE, e.getMessage()); } long leasePeriod = MusicUtil.getDefaultLockLeasePeriod(); ReturnType lockAcqResult = MusicCore.acquireLockWithLease(key, lockId, leasePeriod); @@ -169,7 +169,7 @@ public class MusicConditional { throws MusicLockingException, MusicQueryException, MusicServiceException { String key = dataObj.getKeyspace() + "." + dataObj.getTableName() + "." + dataObj.getPrimaryKeyValue(); - String lockId = MusicCore.createLockReference(key); + String lockId = MusicCore.createLockReferenceAtomic(key); long leasePeriod = MusicUtil.getDefaultLockLeasePeriod(); ReturnType lockAcqResult = MusicCore.acquireLockWithLease(key, lockId, leasePeriod); diff --git a/music-rest/src/test/java/org/onap/music/unittests/TstRestMusicLockAPI.java b/music-rest/src/test/java/org/onap/music/unittests/TstRestMusicLockAPI.java index e9321d25..91781a34 100644 --- a/music-rest/src/test/java/org/onap/music/unittests/TstRestMusicLockAPI.java +++ b/music-rest/src/test/java/org/onap/music/unittests/TstRestMusicLockAPI.java @@ -437,11 +437,11 @@ public class TstRestMusicLockAPI { "abc66ccc-d857-4e90-b1e5-df98a3d40ce6", appName); System.out.println("Status: " + response.getStatus() + ". Entity " + response.getEntity()); assertEquals(400, response.getStatus()); - } + } - @SuppressWarnings("unchecked") - @Test - public void test_deadlock() throws Exception { + @SuppressWarnings("unchecked") + @Test + public void test_deadlock() throws Exception { System.out.println("Testing deadlock"); createAndInsertIntoTable(); insertAnotherIntoTable(); -- cgit 1.2.3-korg