From ee0e4cef1eaba1691f2a69c94f9707a9dbcfcd63 Mon Sep 17 00:00:00 2001 From: Mohammad Salehe Date: Fri, 8 Feb 2019 11:58:35 -0500 Subject: Make MusicCore non-static 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 --- .../onap/music/conductor/conditionals/MusicConditional.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'src/main/java/org/onap/music/conductor/conditionals/MusicConditional.java') 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 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 { -- cgit 1.2.3-korg