aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Nelson <nelson24@att.com>2019-06-07 18:38:04 +0000
committerGerrit Code Review <gerrit@onap.org>2019-06-07 18:38:04 +0000
commitd3e986759875605e43acabbb1283270440a1a1a7 (patch)
tree7e177f585b06d4ecbf579f0da08c7c24df5c0cf1
parent1f36e4303bf76b752eed9ebb8c79a80c31139037 (diff)
parente2031a7220812eec652354c3c705c81ef30b9dea (diff)
Merge "Relinquish locks for each transaction"
-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");
}