diff options
author | Thomas Nelson (arthurdent3) <nelson24@att.com> | 2019-10-02 18:09:23 -0400 |
---|---|---|
committer | Thomas Nelson (arthurdent3) <nelson24@att.com> | 2019-10-03 17:28:55 -0400 |
commit | 48b02dfdc78a6412d568a14b015ccb9439a1dbb5 (patch) | |
tree | ae9dfd7d47d643fcd7e1b4206b525ee0f98f1550 /music-rest/src | |
parent | a681a9e295dc2b8f35dd42251f795d0079471ac0 (diff) |
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) <nelson24@att.com>
Change-Id: I7e1a4c34de5dc9a0e90adf30d1f4d1bac698ceae
Signed-off-by: Thomas Nelson (arthurdent3) <nelson24@att.com>
Diffstat (limited to 'music-rest/src')
-rw-r--r-- | music-rest/src/main/java/org/onap/music/conductor/conditionals/MusicConditional.java | 6 | ||||
-rw-r--r-- | music-rest/src/test/java/org/onap/music/unittests/TstRestMusicLockAPI.java | 8 |
2 files changed, 7 insertions, 7 deletions
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(); |