diff options
4 files changed, 16 insertions, 11 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(); diff --git a/src/main/java/org/onap/music/datastore/jsonobjects/JsonNotification.java b/src/main/java/org/onap/music/datastore/jsonobjects/JsonNotification.java index 1a8a93f5..ce244e2c 100755 --- a/src/main/java/org/onap/music/datastore/jsonobjects/JsonNotification.java +++ b/src/main/java/org/onap/music/datastore/jsonobjects/JsonNotification.java @@ -29,7 +29,6 @@ import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude.Include; import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; @ApiModel(value = "JsonNotification", description = "Json model for callback") @JsonIgnoreProperties(ignoreUnknown = true) diff --git a/src/main/java/org/onap/music/datastore/jsonobjects/JsonNotifyClientResponse.java b/src/main/java/org/onap/music/datastore/jsonobjects/JsonNotifyClientResponse.java index f63625e7..963352d0 100644 --- a/src/main/java/org/onap/music/datastore/jsonobjects/JsonNotifyClientResponse.java +++ b/src/main/java/org/onap/music/datastore/jsonobjects/JsonNotifyClientResponse.java @@ -22,12 +22,10 @@ package org.onap.music.datastore.jsonobjects; import java.io.Serializable; -import java.util.Map; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; @ApiModel(value = "JsonNotifyClientResponse", description = "Json model for callback") @JsonIgnoreProperties(ignoreUnknown = true) diff --git a/src/main/java/org/onap/music/main/CronJobManager.java b/src/main/java/org/onap/music/main/CronJobManager.java index 0344c4a1..4928044e 100644 --- a/src/main/java/org/onap/music/main/CronJobManager.java +++ b/src/main/java/org/onap/music/main/CronJobManager.java @@ -33,6 +33,9 @@ import javax.servlet.annotation.WebListener; import org.onap.music.datastore.PreparedQueryObject; 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.exceptions.MusicServiceException; @@ -55,7 +58,7 @@ public class CronJobManager implements ServletContextListener { try { ResultType result = MusicCore.nonKeyRelatedPut(pQuery, consistency); } catch (MusicServiceException e1) { - e1.printStackTrace(); + logger.error(EELFLoggerDelegate.errorLogger, e1.getMessage(),ErrorSeverity.ERROR); } //Zookeeper cleanup @@ -102,7 +105,7 @@ public class CronJobManager implements ServletContextListener { CachingUtil.deleteKeysFromDB(deleteKeys.toString()); } } catch (MusicServiceException e) { - e.printStackTrace(); + logger.error(EELFLoggerDelegate.errorLogger, e.getMessage(),ErrorSeverity.ERROR); } } |