From da01a036b92feb080949cd27d6d7273719eb4123 Mon Sep 17 00:00:00 2001 From: "Tschaen, Brendan" Date: Wed, 9 Oct 2019 10:39:45 -0400 Subject: Include owner in createLockRef Change-Id: I7403f27b739259576419a380878cf0e263f9b8c6 Issue-ID: MUSIC-502 Signed-off-by: Tschaen, Brendan --- .../java/org/onap/music/exceptions/MusicDeadlockException.java | 8 ++++---- music-core/src/main/java/org/onap/music/main/MusicCore.java | 4 ++++ .../src/main/java/org/onap/music/service/MusicCoreService.java | 8 ++++++++ .../src/main/java/org/onap/music/service/impl/MusicCassaCore.java | 3 +++ 4 files changed, 19 insertions(+), 4 deletions(-) diff --git a/music-core/src/main/java/org/onap/music/exceptions/MusicDeadlockException.java b/music-core/src/main/java/org/onap/music/exceptions/MusicDeadlockException.java index f5478e78..7a40ed91 100644 --- a/music-core/src/main/java/org/onap/music/exceptions/MusicDeadlockException.java +++ b/music-core/src/main/java/org/onap/music/exceptions/MusicDeadlockException.java @@ -23,10 +23,10 @@ package org.onap.music.exceptions; public class MusicDeadlockException extends MusicLockingException { - public String owner = null; - public String keyspace = null; - public String table = null; - public String key = null; + private String owner = null; + private String keyspace = null; + private String table = null; + private String key = null; public MusicDeadlockException() { super(); diff --git a/music-core/src/main/java/org/onap/music/main/MusicCore.java b/music-core/src/main/java/org/onap/music/main/MusicCore.java index 658f2124..72421b89 100644 --- a/music-core/src/main/java/org/onap/music/main/MusicCore.java +++ b/music-core/src/main/java/org/onap/music/main/MusicCore.java @@ -84,6 +84,10 @@ public class MusicCore { public static String createLockReference(String fullyQualifiedKey) throws MusicLockingException { return musicCore.createLockReference(fullyQualifiedKey); } + + public static String createLockReference(String fullyQualifiedKey, String owner) throws MusicLockingException { + return musicCore.createLockReference(fullyQualifiedKey, owner); + } public static String createLockReference(String fullyQualifiedKey, LockType locktype) throws MusicLockingException { return musicCore.createLockReference(fullyQualifiedKey, locktype); diff --git a/music-core/src/main/java/org/onap/music/service/MusicCoreService.java b/music-core/src/main/java/org/onap/music/service/MusicCoreService.java index b3226906..65b98852 100644 --- a/music-core/src/main/java/org/onap/music/service/MusicCoreService.java +++ b/music-core/src/main/java/org/onap/music/service/MusicCoreService.java @@ -91,6 +91,13 @@ public interface MusicCoreService { */ public String createLockReference(String fullyQualifiedKey) throws MusicLockingException; // lock name + /** + * Create a lock ref in the music lock store + * @param fullyQualifiedKey the key to create a lock on + * @param owner the owner of the lock, for deadlock prevention + */ + public String createLockReference(String fullyQualifiedKey, String owner) throws MusicLockingException; + /** * Create a lock ref in the music lock store * @param fullyQualifiedKey the key to create a lock on @@ -178,4 +185,5 @@ public interface MusicCoreService { public ReturnType deleteFromTable(JsonDelete jsonDeleteObj,MultivaluedMap rowParams) throws MusicLockingException, MusicQueryException, MusicServiceException; + } diff --git a/music-core/src/main/java/org/onap/music/service/impl/MusicCassaCore.java b/music-core/src/main/java/org/onap/music/service/impl/MusicCassaCore.java index 0d2e3f0a..47fb47b7 100644 --- a/music-core/src/main/java/org/onap/music/service/impl/MusicCassaCore.java +++ b/music-core/src/main/java/org/onap/music/service/impl/MusicCassaCore.java @@ -115,6 +115,9 @@ public class MusicCassaCore implements MusicCoreService { public String createLockReference(String fullyQualifiedKey) throws MusicLockingException { return createLockReference(fullyQualifiedKey, LockType.WRITE); } + public String createLockReference(String fullyQualifiedKey, String owner) throws MusicLockingException { + return createLockReference(fullyQualifiedKey, LockType.WRITE, owner); + } public String createLockReference(String fullyQualifiedKey, LockType locktype) throws MusicLockingException { return createLockReference(fullyQualifiedKey, locktype, null); -- cgit 1.2.3-korg