aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTschaen, Brendan <ctschaen@att.com>2019-05-28 10:03:24 -0400
committerTschaen, Brendan <ctschaen@att.com>2019-05-30 16:08:07 -0400
commite2031a7220812eec652354c3c705c81ef30b9dea (patch)
treef8f286b47657724e0a39e4b6ae4f8bb2d7b2b03f
parent65b45cafb4dff93bef52e91f2ab3f2a772e4472e (diff)
Relinquish locks for each transaction
Change-Id: I44c10c0cc7857cfb647386507218a4e608b24687 Issue-ID: MUSIC-399 Signed-off-by: Tschaen, Brendan <ctschaen@att.com>
-rwxr-xr-xmdbc-server/src/main/java/org/onap/music/mdbc/MdbcConnection.java7
-rw-r--r--mdbc-server/src/main/java/org/onap/music/mdbc/StateManager.java2
-rwxr-xr-xmdbc-server/src/main/java/org/onap/music/mdbc/mixins/MusicInterface.java7
-rw-r--r--mdbc-server/src/main/java/org/onap/music/mdbc/mixins/MusicMixin.java13
4 files changed, 23 insertions, 6 deletions
diff --git a/mdbc-server/src/main/java/org/onap/music/mdbc/MdbcConnection.java b/mdbc-server/src/main/java/org/onap/music/mdbc/MdbcConnection.java
index 0189f48..3cbd1e0 100755
--- a/mdbc-server/src/main/java/org/onap/music/mdbc/MdbcConnection.java
+++ b/mdbc-server/src/main/java/org/onap/music/mdbc/MdbcConnection.java
@@ -218,8 +218,9 @@ public class MdbcConnection implements Connection {
//\TODO try to execute outside of the critical path of commit
try {
- if(partition != null)
- relinquishIfRequired(partition);
+ if(partition != null) {
+ mi.relinquish(partition);
+ }
} catch (MDBCServiceException e) {
logger.warn("Error trying to relinquish: "+partition.toString());
}
@@ -256,7 +257,7 @@ public class MdbcConnection implements Connection {
logger.debug("Connection was closed for id:" + id);
}
try {
- mi.relinquish(partition.getLockId(),partition.getMRIIndex().toString());
+ mi.relinquish(partition);
} catch (MDBCServiceException e) {
throw new SQLException("Failure during relinquish of partition",e);
}
diff --git a/mdbc-server/src/main/java/org/onap/music/mdbc/StateManager.java b/mdbc-server/src/main/java/org/onap/music/mdbc/StateManager.java
index 4ee60bf..e284103 100644
--- a/mdbc-server/src/main/java/org/onap/music/mdbc/StateManager.java
+++ b/mdbc-server/src/main/java/org/onap/music/mdbc/StateManager.java
@@ -389,7 +389,7 @@ public class StateManager {
private void relinquish(DatabasePartition partition){
try {
- musicInterface.relinquish(partition.getLockId(),partition.getMRIIndex().toString());
+ musicInterface.relinquish(partition);
} catch (MDBCServiceException e) {
logger.error("Relinquish failed, would need to forcefully obtain lock later");
}
diff --git a/mdbc-server/src/main/java/org/onap/music/mdbc/mixins/MusicInterface.java b/mdbc-server/src/main/java/org/onap/music/mdbc/mixins/MusicInterface.java
index 67ee5ab..62259a8 100755
--- a/mdbc-server/src/main/java/org/onap/music/mdbc/mixins/MusicInterface.java
+++ b/mdbc-server/src/main/java/org/onap/music/mdbc/mixins/MusicInterface.java
@@ -276,6 +276,13 @@ public interface MusicInterface {
/**
* This functions relinquishes a range
+ * @param partition db partition to be relinquished
+ * @throws MusicLockingException
+ */
+ public void relinquish(DatabasePartition partition) throws MDBCServiceException;
+
+ /**
+ * This functions relinquishes a range
* @param lockId id of the lock to be relinquished
* @param rangeId id of the range to be relinquished
* @throws MusicLockingException
diff --git a/mdbc-server/src/main/java/org/onap/music/mdbc/mixins/MusicMixin.java b/mdbc-server/src/main/java/org/onap/music/mdbc/mixins/MusicMixin.java
index 67d30ff..6939d78 100644
--- a/mdbc-server/src/main/java/org/onap/music/mdbc/mixins/MusicMixin.java
+++ b/mdbc-server/src/main/java/org/onap/music/mdbc/mixins/MusicMixin.java
@@ -2191,6 +2191,15 @@ public class MusicMixin implements MusicInterface {
}
+ @Override
+ public void relinquish(DatabasePartition partition) throws MDBCServiceException {
+ String ownerId = partition.getLockId();
+ String rangeId = partition.getMRIIndex().toString();
+ if(ownerId==null||ownerId.isEmpty()||rangeId==null||rangeId.isEmpty()){
+ return;
+ }
+ unlockKeyInMusic(musicRangeInformationTableName, rangeId, ownerId);
+ }
@Override
public void relinquish(String lockId, String rangeId) throws MDBCServiceException{
@@ -2207,7 +2216,7 @@ public class MusicMixin implements MusicInterface {
private boolean canTryRelinquishing(){
//\TODO: Fix this!!!! REALLY IMPORTANT TO BE FIX
// This should actually have some mechanism to relinquish ownership
- return false;
+ return true;
}
@Override
@@ -2226,7 +2235,7 @@ public class MusicMixin implements MusicInterface {
if(lockQueueSize> 1){
//If there is any other node waiting, we just relinquish ownership
try {
- relinquish(partition.getLockId(),partition.getMRIIndex().toString());
+ relinquish(partition);
} catch (MDBCServiceException e) {
logger.error("Error relinquishing lock, will use timeout to solve");
}