aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/org/onap/music/conductor/conditionals/MusicConditional.java
diff options
context:
space:
mode:
authorMohammad Salehe <salehe@cs.toronto.edu>2019-02-08 11:58:35 -0500
committerMohammad Salehe <salehe@cs.toronto.edu>2019-02-24 22:23:39 -0500
commitee0e4cef1eaba1691f2a69c94f9707a9dbcfcd63 (patch)
tree0ea14a449dd3e1c7cb9269dfba65bd650c8af23c /src/main/java/org/onap/music/conductor/conditionals/MusicConditional.java
parentf6b5b60d066fa47ef520c58305aa6f28827f106b (diff)
Make MusicCore non-staticdev-cassandra-only
Make MusicCore and other dependencies (MusicDataStoreHandle) non-static For compatibility, MusicCore still has a singleton instance that is statically instantiated and can be used as needed by legacy users. These changes should be made in calling sites (legacy users using singleton): MusicDataStoreHandle.getDSHandle() -> MusicCore.getInstanceDSHandle() Change-Id: I02b67f316dc21a1498157bc68cc32bf76d3ec01e Issue-ID: MUSIC-148 Signed-off-by: Mohammad Salehe <salehe@cs.toronto.edu>
Diffstat (limited to 'src/main/java/org/onap/music/conductor/conditionals/MusicConditional.java')
-rw-r--r--src/main/java/org/onap/music/conductor/conditionals/MusicConditional.java13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/main/java/org/onap/music/conductor/conditionals/MusicConditional.java b/src/main/java/org/onap/music/conductor/conditionals/MusicConditional.java
index 839fbbe8..debd2706 100644
--- a/src/main/java/org/onap/music/conductor/conditionals/MusicConditional.java
+++ b/src/main/java/org/onap/music/conductor/conditionals/MusicConditional.java
@@ -33,6 +33,7 @@ import org.onap.music.eelf.logging.EELFLoggerDelegate;
import org.onap.music.eelf.logging.format.AppMessages;
import org.onap.music.eelf.logging.format.ErrorSeverity;
import org.onap.music.eelf.logging.format.ErrorTypes;
+import org.onap.music.exceptions.MusicLockingException;
import org.onap.music.main.MusicCore;
import org.onap.music.main.MusicUtil;
import org.onap.music.main.ResultType;
@@ -123,15 +124,15 @@ public class MusicConditional {
ReturnType lockAcqResult = MusicCore.acquireLock(fullyQualifiedKey, lockId);
if (lockAcqResult.getResult().equals(ResultType.SUCCESS)) {
try {
- results = MusicDataStoreHandle.getDSHandle().executeQuorumConsistencyGet(queryBank.get(MusicUtil.SELECT));
+ results = MusicCore.getInstanceDSHandle().executeQuorumConsistencyGet(queryBank.get(MusicUtil.SELECT));
} catch (Exception e) {
return new ReturnType(ResultType.FAILURE, e.getMessage());
}
if (results.all().isEmpty()) {
- MusicDataStoreHandle.getDSHandle().executePut(queryBank.get(MusicUtil.INSERT), "critical");
+ MusicCore.getInstanceDSHandle().executePut(queryBank.get(MusicUtil.INSERT), "critical");
return new ReturnType(ResultType.SUCCESS, "insert");
} else {
- MusicDataStoreHandle.getDSHandle().executePut(queryBank.get(MusicUtil.UPDATE), "critical");
+ MusicCore.getInstanceDSHandle().executePut(queryBank.get(MusicUtil.UPDATE), "critical");
return new ReturnType(ResultType.SUCCESS, "update");
}
} else {
@@ -179,7 +180,7 @@ public class MusicConditional {
try {
ReturnType lockAcqResult = MusicCore.acquireLockWithLease(key, lockId, leasePeriod);
if (lockAcqResult.getResult().equals(ResultType.SUCCESS)) {
- Row row = MusicDataStoreHandle.getDSHandle().executeQuorumConsistencyGet(queryBank.get(MusicUtil.SELECT)).one();
+ Row row = MusicCore.getInstanceDSHandle().executeQuorumConsistencyGet(queryBank.get(MusicUtil.SELECT)).one();
if(row != null) {
Map<String, String> updatedValues = cascadeColumnUpdateSpecific(row, cascadeColumnValues, casscadeColumnName, planId);
@@ -192,14 +193,14 @@ public class MusicConditional {
update.addValue(MusicUtil.convertToActualDataType(DataType.text(), vector_ts));
update.addValue(MusicUtil.convertToActualDataType(DataType.text(), primaryKeyValue));
try {
- MusicDataStoreHandle.getDSHandle().executePut(update, "critical");
+ MusicCore.getInstanceDSHandle().executePut(update, "critical");
} catch (Exception ex) {
return new ReturnType(ResultType.FAILURE, ex.getMessage());
}
}else {
return new ReturnType(ResultType.FAILURE,"Cannot find data related to key: "+primaryKey);
}
- MusicDataStoreHandle.getDSHandle().executePut(queryBank.get(MusicUtil.UPSERT), "critical");
+ MusicCore.getInstanceDSHandle().executePut(queryBank.get(MusicUtil.UPSERT), "critical");
return new ReturnType(ResultType.SUCCESS, "update success");
} else {