aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/org/onap/music/conductor/conditionals/MusicConditional.java
diff options
context:
space:
mode:
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.java17
1 files changed, 11 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 c97ccfab..0e8cc14a 100644
--- a/src/main/java/org/onap/music/conductor/conditionals/MusicConditional.java
+++ b/src/main/java/org/onap/music/conductor/conditionals/MusicConditional.java
@@ -47,6 +47,7 @@ import com.datastax.driver.core.TableMetadata;
public class MusicConditional {
private static EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(RestMusicDataAPI.class);
+ private static final String CRITICAL = "critical";
public static ReturnType conditionalInsert(String keyspace, String tablename, String casscadeColumnName,
Map<String, Object> casscadeColumnData, String primaryKey, Map<String, Object> valuesMap,
@@ -107,6 +108,7 @@ public class MusicConditional {
return lockAcqResult;
}
} catch (Exception e) {
+ logger.error(EELFLoggerDelegate.errorLogger, e.getMessage(),AppMessages.EXECUTIONINTERRUPTED);
MusicCore.destroyLockRef(lockId);
return new ReturnType(ResultType.FAILURE, e.getMessage());
}
@@ -122,17 +124,17 @@ public class MusicConditional {
MusicLockState mls = MusicCore.getLockingServiceHandle()
.getLockState(keyspace + "." + tableName + "." + primaryKey);
- if (mls.getLockHolder().equals(lockId) == true) {
+ if (mls.getLockHolder().equals(lockId)) {
try {
results = MusicCore.getDSHandle().executeCriticalGet(queryBank.get(MusicUtil.SELECT));
} catch (Exception e) {
return new ReturnType(ResultType.FAILURE, e.getMessage());
}
if (results.all().isEmpty()) {
- MusicCore.getDSHandle().executePut(queryBank.get(MusicUtil.INSERT), "critical");
+ MusicCore.getDSHandle().executePut(queryBank.get(MusicUtil.INSERT), CRITICAL);
return new ReturnType(ResultType.SUCCESS, "insert");
} else {
- MusicCore.getDSHandle().executePut(queryBank.get(MusicUtil.UPDATE), "critical");
+ MusicCore.getDSHandle().executePut(queryBank.get(MusicUtil.UPDATE), CRITICAL);
return new ReturnType(ResultType.SUCCESS, "update");
}
} else {
@@ -143,6 +145,7 @@ public class MusicConditional {
} catch (Exception e) {
StringWriter sw = new StringWriter();
e.printStackTrace(new PrintWriter(sw));
+ logger.error(EELFLoggerDelegate.errorLogger, e.getMessage(),AppMessages.EXECUTIONINTERRUPTED, ErrorSeverity.ERROR, ErrorTypes.LOCKINGERROR);
String exceptionAsString = sw.toString();
return new ReturnType(ResultType.FAILURE,
"Exception thrown while doing the critical put, check sanctity of the row/conditions:\n"
@@ -169,6 +172,7 @@ public class MusicConditional {
}
} catch (Exception e) {
+ logger.error(EELFLoggerDelegate.errorLogger, e.getMessage(),AppMessages.EXECUTIONINTERRUPTED, ErrorSeverity.ERROR, ErrorTypes.LOCKINGERROR);
MusicCore.destroyLockRef(lockId);
return new ReturnType(ResultType.FAILURE, e.getMessage());
@@ -181,7 +185,7 @@ public class MusicConditional {
MusicLockState mls = MusicCore.getLockingServiceHandle()
.getLockState(keyspace + "." + tableName + "." + primaryKeyValue);
- if (mls.getLockHolder().equals(lockId) == true) {
+ if (mls.getLockHolder().equals(lockId)) {
Row row = MusicCore.getDSHandle().executeCriticalGet(queryBank.get(MusicUtil.SELECT)).one();
if(row != null) {
@@ -195,14 +199,14 @@ public class MusicConditional {
update.addValue(MusicUtil.convertToActualDataType(DataType.text(), vector_ts));
update.addValue(MusicUtil.convertToActualDataType(DataType.text(), primaryKeyValue));
try {
- MusicCore.getDSHandle().executePut(update, "critical");
+ MusicCore.getDSHandle().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);
}
- MusicCore.getDSHandle().executePut(queryBank.get(MusicUtil.UPSERT), "critical");
+ MusicCore.getDSHandle().executePut(queryBank.get(MusicUtil.UPSERT), CRITICAL);
return new ReturnType(ResultType.SUCCESS, "update success");
} else {
@@ -211,6 +215,7 @@ public class MusicConditional {
}
} catch (Exception e) {
+ logger.error(EELFLoggerDelegate.errorLogger, e.getMessage(),AppMessages.EXECUTIONINTERRUPTED, ErrorSeverity.ERROR, ErrorTypes.LOCKINGERROR);
StringWriter sw = new StringWriter();
e.printStackTrace(new PrintWriter(sw));
String exceptionAsString = sw.toString();