aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/org/onap
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/org/onap')
-rwxr-xr-xsrc/main/java/org/onap/music/datastore/jsonobjects/JSONCallbackResponse.java24
-rw-r--r--src/main/java/org/onap/music/datastore/jsonobjects/JsonInsert.java19
-rwxr-xr-xsrc/main/java/org/onap/music/datastore/jsonobjects/JsonNotification.java8
-rw-r--r--src/main/java/org/onap/music/lockingservice/ProtocolSupport.java30
-rwxr-xr-xsrc/main/java/org/onap/music/main/PropertiesListener.java9
-rw-r--r--src/main/java/org/onap/music/rest/RestMusicBmAPI.java27
-rw-r--r--src/main/java/org/onap/music/rest/RestMusicHealthCheckAPI.java22
7 files changed, 79 insertions, 60 deletions
diff --git a/src/main/java/org/onap/music/datastore/jsonobjects/JSONCallbackResponse.java b/src/main/java/org/onap/music/datastore/jsonobjects/JSONCallbackResponse.java
index f869c342..c5a56a71 100755
--- a/src/main/java/org/onap/music/datastore/jsonobjects/JSONCallbackResponse.java
+++ b/src/main/java/org/onap/music/datastore/jsonobjects/JSONCallbackResponse.java
@@ -27,20 +27,20 @@ import java.util.Map;
public class JSONCallbackResponse {
- private String full_table;
+ private String fullTable;
private String keyspace;
private Map<String, String> changeValue;
private String operation;
- private String table_name;
- private String primary_key;
+ private String tableName;
+ private String primaryKey;
private Object miscObjects;
private List<String> updateList;
public String getFull_table() {
- return full_table;
+ return fullTable;
}
- public void setFull_table(String full_table) {
- this.full_table = full_table;
+ public void setFull_table(String fullTable) {
+ this.fullTable = fullTable;
}
public String getKeyspace() {
return keyspace;
@@ -55,16 +55,16 @@ public class JSONCallbackResponse {
this.operation = operation;
}
public String getTable_name() {
- return table_name;
+ return tableName;
}
- public void setTable_name(String table_name) {
- this.table_name = table_name;
+ public void setTable_name(String tableName) {
+ this.tableName = tableName;
}
public String getPrimary_key() {
- return primary_key;
+ return primaryKey;
}
- public void setPrimary_key(String primary_key) {
- this.primary_key = primary_key;
+ public void setPrimary_key(String primaryKey) {
+ this.primaryKey = primaryKey;
}
public Object getMiscObjects() {
return miscObjects;
diff --git a/src/main/java/org/onap/music/datastore/jsonobjects/JsonInsert.java b/src/main/java/org/onap/music/datastore/jsonobjects/JsonInsert.java
index c79ba9b7..456fb951 100644
--- a/src/main/java/org/onap/music/datastore/jsonobjects/JsonInsert.java
+++ b/src/main/java/org/onap/music/datastore/jsonobjects/JsonInsert.java
@@ -3,6 +3,7 @@
* org.onap.music
* ===================================================================
* Copyright (c) 2017 AT&T Intellectual Property
+ * Modifications Copyright (C) 2018 IBM.
* ===================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -33,6 +34,11 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
+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;
+
@ApiModel(value = "JsonTable", description = "Json model for table vlaues insert")
@JsonIgnoreProperties(ignoreUnknown = true)
public class JsonInsert implements Serializable {
@@ -41,10 +47,11 @@ public class JsonInsert implements Serializable {
private transient Map<String, Object> values;
private String ttl;
private String timestamp;
- private transient Map<String, Object> row_specification;
+ private transient Map<String, Object> rowSpecification;
private Map<String, String> consistencyInfo;
private Map<String, byte[]> objectMap;
-
+ private static EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(JsonInsert.class);
+
@ApiModelProperty(value = "objectMap")
public Map<String, byte[]> getObjectMap() {
return objectMap;
@@ -110,11 +117,11 @@ public class JsonInsert implements Serializable {
@ApiModelProperty(value = "Information for selecting specific rows for insert")
public Map<String, Object> getRow_specification() {
- return row_specification;
+ return rowSpecification;
}
- public void setRow_specification(Map<String, Object> row_specification) {
- this.row_specification = row_specification;
+ public void setRow_specification(Map<String, Object> rowSpecification) {
+ this.rowSpecification = rowSpecification;
}
public byte[] serialize() {
@@ -124,7 +131,7 @@ public class JsonInsert implements Serializable {
out = new ObjectOutputStream(bos);
out.writeObject(this);
} catch (IOException e) {
- e.printStackTrace();
+ logger.error(EELFLoggerDelegate.errorLogger, e, AppMessages.IOERROR, ErrorSeverity.ERROR, ErrorTypes.DATAERROR);
}
return bos.toByteArray();
}
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 ce244e2c..5190de58 100755
--- a/src/main/java/org/onap/music/datastore/jsonobjects/JsonNotification.java
+++ b/src/main/java/org/onap/music/datastore/jsonobjects/JsonNotification.java
@@ -3,6 +3,7 @@
* org.onap.music
* ===================================================================
* Copyright (c) 2017 AT&T Intellectual Property
+ * Modifications Copyright (C) 2018 IBM.
* ===================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -28,6 +29,11 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
+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 io.swagger.annotations.ApiModel;
@ApiModel(value = "JsonNotification", description = "Json model for callback")
@@ -45,6 +51,7 @@ public class JsonNotification implements Serializable {
private String operation_type;
private String triggerName;
private Map<String, String> response_body;
+ private static EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(JsonNotification.class);
public String getNotify_field() {
return notify_field;
@@ -111,6 +118,7 @@ public class JsonNotification implements Serializable {
try {
return new com.fasterxml.jackson.databind.ObjectMapper().writerWithDefaultPrettyPrinter().writeValueAsString(this);
} catch (com.fasterxml.jackson.core.JsonProcessingException e) {
+ logger.error(EELFLoggerDelegate.errorLogger, e, AppMessages.EXECUTIONINTERRUPTED, ErrorSeverity.ERROR, ErrorTypes.GENERALSERVICEERROR);
return notify_field+ " : "+endpoint+ " : "+username+ " : "+password+ " : "+response_body;
}
diff --git a/src/main/java/org/onap/music/lockingservice/ProtocolSupport.java b/src/main/java/org/onap/music/lockingservice/ProtocolSupport.java
index 19f49beb..589e4e57 100644
--- a/src/main/java/org/onap/music/lockingservice/ProtocolSupport.java
+++ b/src/main/java/org/onap/music/lockingservice/ProtocolSupport.java
@@ -3,6 +3,7 @@
* org.onap.music
* ===================================================================
* Copyright (c) 2017 AT&T Intellectual Property
+ * Modifications Copyright (C) 2018 IBM.
* ===================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -128,19 +129,25 @@ class ProtocolSupport {
try {
return operation.execute();
} catch (KeeperException.SessionExpiredException e) {
- logger.error(EELFLoggerDelegate.errorLogger, e.getMessage(),AppMessages.SESSIONEXPIRED+" for: " + zookeeper + " so reconnecting due to: " + e, ErrorSeverity.ERROR, ErrorTypes.SESSIONEXPIRED);
+ logger.error(EELFLoggerDelegate.errorLogger, e,AppMessages.SESSIONEXPIRED+" for: " + zookeeper + " so reconnecting due to: " + e, ErrorSeverity.ERROR, ErrorTypes.SESSIONEXPIRED);
throw e;
} catch (KeeperException.ConnectionLossException e) {
if (exception == null) {
exception = e;
}
- logger.error(EELFLoggerDelegate.errorLogger, e.getMessage(),AppMessages.CONNCECTIVITYERROR, ErrorSeverity.ERROR, ErrorTypes.SESSIONEXPIRED);
- logger.error(EELFLoggerDelegate.errorLogger, e.getMessage(),"Attempt " + i + " failed with connection loss so attempting to reconnect: " + e);
+ logger.error(EELFLoggerDelegate.errorLogger, e,AppMessages.CONNCECTIVITYERROR, ErrorSeverity.ERROR, ErrorTypes.SESSIONEXPIRED);
+ logger.error(EELFLoggerDelegate.errorLogger, e,"Attempt " + i + " failed with connection loss so attempting to reconnect: " + e);
retryDelay(i);
}
}
- throw exception;
+ if(exception == null)
+ {
+ throw new NullPointerException();
+ }
+ else{
+ throw exception;
+ }
}
/**
@@ -148,7 +155,7 @@ class ProtocolSupport {
*
* @param path the lock path
*/
- protected void ensurePathExists(String path) {
+ protected void ensurePathExists(String path) {
ensureExists(path, null, acl, CreateMode.PERSISTENT);
}
@@ -161,7 +168,7 @@ class ProtocolSupport {
* @param flags create mode flags
*/
protected void ensureExists(final String path, final byte[] data, final List<ACL> acl,
- final CreateMode flags) {
+ final CreateMode flags) {
try {
retryOperation(new ZooKeeperOperation() {
public boolean execute() throws KeeperException, InterruptedException {
@@ -174,11 +181,10 @@ class ProtocolSupport {
}
});
} catch (KeeperException e) {
- logger.error("Error", e);
- logger.error(EELFLoggerDelegate.errorLogger, e.getMessage(),AppMessages.KEEPERERROR, ErrorSeverity.ERROR, ErrorTypes.LOCKINGERROR);
+ logger.error(EELFLoggerDelegate.errorLogger, e,AppMessages.KEEPERERROR, ErrorSeverity.ERROR, ErrorTypes.LOCKINGERROR);
} catch (InterruptedException e) {
- logger.error("Error", e);
- logger.error(EELFLoggerDelegate.errorLogger, e.getMessage(),AppMessages.EXECUTIONINTERRUPTED, ErrorSeverity.ERROR, ErrorTypes.LOCKINGERROR);
+ logger.error(EELFLoggerDelegate.errorLogger, e,AppMessages.EXECUTIONINTERRUPTED, ErrorSeverity.ERROR, ErrorTypes.LOCKINGERROR);
+
}
}
@@ -201,8 +207,8 @@ class ProtocolSupport {
try {
Thread.sleep(attemptCount * retryDelay);
} catch (InterruptedException e) {
- logger.error(EELFLoggerDelegate.errorLogger, e.getMessage(),AppMessages.EXECUTIONINTERRUPTED, ErrorSeverity.ERROR, ErrorTypes.GENERALSERVICEERROR);
- logger.error(EELFLoggerDelegate.errorLogger, e.getMessage(),"Thread failed to sleep: " + e);
+ logger.error(EELFLoggerDelegate.errorLogger, e,AppMessages.EXECUTIONINTERRUPTED, ErrorSeverity.ERROR, ErrorTypes.GENERALSERVICEERROR);
+ logger.error(EELFLoggerDelegate.errorLogger, e,"Thread failed to sleep: " + e);
Thread.currentThread().interrupt();
}
}
diff --git a/src/main/java/org/onap/music/main/PropertiesListener.java b/src/main/java/org/onap/music/main/PropertiesListener.java
index 0ed18be2..026790ee 100755
--- a/src/main/java/org/onap/music/main/PropertiesListener.java
+++ b/src/main/java/org/onap/music/main/PropertiesListener.java
@@ -3,6 +3,7 @@
* org.onap.music
* ===================================================================
* Copyright (c) 2017 AT&T Intellectual Property
+ * Modifications Copyright (C) 2018 IBM.
* ===================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -37,7 +38,7 @@ import org.onap.music.eelf.logging.format.ErrorTypes;
public class PropertiesListener implements ServletContextListener {
private Properties prop;
-
+ private static final String MUSIC_PROPERTIES="music.properties";
private static EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(PropertiesListener.class);
@Override
@@ -51,8 +52,8 @@ public class PropertiesListener implements ServletContextListener {
try {
InputStream musicProps = null;
projectProp.load(new FileInputStream(musicPropertiesFilePath));
- if (projectProp.containsKey("music.properties")) {
- musicProps = new FileInputStream(projectProp.getProperty("music.properties"));
+ if (projectProp.containsKey(MUSIC_PROPERTIES)) {
+ musicProps = new FileInputStream(projectProp.getProperty(MUSIC_PROPERTIES));
} else {
musicProps = new FileInputStream(MusicUtil.getMusicPropertiesFilePath());
}
@@ -84,7 +85,7 @@ public class PropertiesListener implements ServletContextListener {
case "music.rest.ip":
MusicUtil.setMusicRestIp(prop.getProperty(key));
break;
- case "music.properties":
+ case MUSIC_PROPERTIES:
MusicUtil.setMusicPropertiesFilePath(prop.getProperty(key));
break;
case "lock.lease.period":
diff --git a/src/main/java/org/onap/music/rest/RestMusicBmAPI.java b/src/main/java/org/onap/music/rest/RestMusicBmAPI.java
index 55eb47f2..60305bfb 100644
--- a/src/main/java/org/onap/music/rest/RestMusicBmAPI.java
+++ b/src/main/java/org/onap/music/rest/RestMusicBmAPI.java
@@ -1,7 +1,9 @@
/*
* ============LICENSE_START========================================== org.onap.music
* =================================================================== Copyright (c) 2017 AT&T
- * Intellectual Property ===================================================================
+ * Intellectual Property
+ * Modifications Copyright (C) 2018 IBM.
+ * ===================================================================
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
*
@@ -41,8 +43,6 @@ import org.onap.music.datastore.PreparedQueryObject;
import com.datastax.driver.core.DataType;
import com.datastax.driver.core.TableMetadata;
import io.swagger.annotations.Api;
-//import io.swagger.annotations.ApiOperation;
-//import io.swagger.annotations.ApiParam;
/*
* These are functions created purely for benchmarking purposes. Commented out Swagger - This should
@@ -54,7 +54,7 @@ import io.swagger.annotations.Api;
public class RestMusicBmAPI {
private static EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(RestMusicBmAPI.class);
-
+ public static final String UPDATE_CONST=" update-";
// pure zk calls...
/**
@@ -117,7 +117,7 @@ public class RestMusicBmAPI {
String operationId = UUID.randomUUID().toString();// just for debugging purposes.
String consistency = updateObj.getConsistencyInfo().get("type");
- logger.info(EELFLoggerDelegate.applicationLogger,"--------------Zookeeper " + consistency + " update-" + operationId
+ logger.info(EELFLoggerDelegate.applicationLogger,"--------------Zookeeper " + consistency + UPDATE_CONST + operationId
+ "-------------------------");
byte[] data = updateObj.serialize();
@@ -130,16 +130,17 @@ public class RestMusicBmAPI {
long leasePeriod = MusicUtil.getDefaultLockLeasePeriod();
ReturnType lockAcqResult = MusicCore.acquireLockWithLease(lockname, lockId, leasePeriod);
long lockAcqTime = System.currentTimeMillis();
- long zkPutTime = 0, lockReleaseTime = 0;
+ long zkPutTime = 0;
+ long lockReleaseTime = 0;
if (lockAcqResult.getResult().equals(ResultType.SUCCESS)) {
logger.info(EELFLoggerDelegate.applicationLogger,"acquired lock with id " + lockId);
MusicCore.pureZkWrite(lockname, data);
zkPutTime = System.currentTimeMillis();
boolean voluntaryRelease = true;
- if (consistency.equals("atomic"))
+ if (("atomic").equals(consistency))
MusicCore.releaseLock(lockId, voluntaryRelease);
- else if (consistency.equals("atomic_delete_lock"))
+ else if (("atomic_delete_lock").equals(consistency))
MusicCore.deleteLock(lockname);
lockReleaseTime = System.currentTimeMillis();
} else {
@@ -155,12 +156,12 @@ public class RestMusicBmAPI {
+ "|lock accquire time:" + (lockAcqTime - lockCreationTime)
+ "|zk put time:" + (zkPutTime - lockAcqTime);
- if (consistency.equals("atomic"))
+ if ("atomic".equals(consistency))
lockingInfo = lockingInfo + "|lock release time:" + (lockReleaseTime - zkPutTime) + "|";
- else if (consistency.equals("atomic_delete_lock"))
+ else if ("atomic_delete_lock".equals(consistency))
lockingInfo = lockingInfo + "|lock delete time:" + (lockReleaseTime - zkPutTime) + "|";
- String timingString = "Time taken in ms for Zookeeper " + consistency + " update-"
+ String timingString = "Time taken in ms for Zookeeper " + consistency + UPDATE_CONST
+ operationId + ":" + "|total operation time:" + (endTime - startTime)
+ "|json parsing time:" + (jsonParseCompletionTime - startTime)
+ "|update time:" + (actualUpdateCompletionTime - jsonParseCompletionTime)
@@ -220,7 +221,7 @@ public class RestMusicBmAPI {
long startTime = System.currentTimeMillis();
String operationId = UUID.randomUUID().toString();// just for debugging purposes.
String consistency = insObj.getConsistencyInfo().get("type");
- logger.info(EELFLoggerDelegate.applicationLogger,"--------------Cassandra " + consistency + " update-" + operationId
+ logger.info(EELFLoggerDelegate.applicationLogger,"--------------Cassandra " + consistency + UPDATE_CONST + operationId
+ "-------------------------");
PreparedQueryObject queryObject = new PreparedQueryObject();
Map<String, Object> valuesMap = insObj.getValues();
@@ -295,7 +296,7 @@ public class RestMusicBmAPI {
long endTime = System.currentTimeMillis();
- String timingString = "Time taken in ms for Cassandra " + consistency + " update-"
+ String timingString = "Time taken in ms for Cassandra " + consistency + UPDATE_CONST
+ operationId + ":" + "|total operation time:" + (endTime - startTime)
+ "|json parsing time:" + (jsonParseCompletionTime - startTime)
+ "|update time:" + (actualUpdateCompletionTime - jsonParseCompletionTime)
diff --git a/src/main/java/org/onap/music/rest/RestMusicHealthCheckAPI.java b/src/main/java/org/onap/music/rest/RestMusicHealthCheckAPI.java
index 44b4a514..f6dc4e57 100644
--- a/src/main/java/org/onap/music/rest/RestMusicHealthCheckAPI.java
+++ b/src/main/java/org/onap/music/rest/RestMusicHealthCheckAPI.java
@@ -3,6 +3,8 @@
* org.onap.music
* ===================================================================
* Copyright (c) 2017 AT&T Intellectual Property
+ *
+ * Modifications Copyright (C) 2018 IBM.
* ===================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -35,20 +37,14 @@ import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
-import javax.ws.rs.Consumes;
import javax.ws.rs.core.Response;
-import javax.ws.rs.core.Response.ResponseBuilder;
import javax.ws.rs.core.Response.Status;
-import org.onap.music.response.jsonobjects.JsonResponse;
import org.onap.music.eelf.healthcheck.MusicHealthCheck;
import org.onap.music.eelf.logging.EELFLoggerDelegate;
import org.onap.music.main.MusicUtil;
-import org.onap.music.main.ResultType;
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
import com.datastax.driver.core.ConsistencyLevel;
import io.swagger.annotations.Api;
@@ -64,7 +60,7 @@ public class RestMusicHealthCheckAPI {
private static EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(MusicUtil.class);
-
+ private static final String activeStatus = "ACTIVE";
@GET
@Path("/pingCassandra/{consistency}")
@@ -81,8 +77,8 @@ public class RestMusicHealthCheckAPI {
}
MusicHealthCheck cassHealthCheck = new MusicHealthCheck();
String status = cassHealthCheck.getCassandraStatus(consistency);
- if(status.equals("ACTIVE")) {
- resultMap.put("ACTIVE", "Cassandra Running and Listening to requests");
+ if(status.equals(activeStatus)) {
+ resultMap.put(activeStatus, "Cassandra Running and Listening to requests");
return Response.status(Status.OK).entity(resultMap).build();
} else {
resultMap.put("INACTIVE", "One or more nodes in the Cluster is/are down or not responding.");
@@ -102,8 +98,8 @@ public class RestMusicHealthCheckAPI {
Map<String, Object> resultMap = new HashMap<>();
MusicHealthCheck ZKHealthCheck = new MusicHealthCheck();
String status = ZKHealthCheck.getZookeeperStatus();
- if(status.equals("ACTIVE")) {
- resultMap.put("ACTIVE", "Zookeeper is Active and Running");
+ if(status.equals(activeStatus)) {
+ resultMap.put(activeStatus, "Zookeeper is Active and Running");
return Response.status(Status.OK).entity(resultMap).build();
}else {
resultMap.put("INACTIVE", "Zookeeper is not responding");
@@ -120,13 +116,13 @@ public class RestMusicHealthCheckAPI {
Map<String, Object> resultMap = new HashMap<>();
MusicHealthCheck healthCheck = new MusicHealthCheck();
String status = healthCheck.getZookeeperStatus();
- if(status.equals("ACTIVE")) {
+ if(status.equals(activeStatus)) {
resultMap.put("ZooKeeper", "Active");
}else {
resultMap.put("ZooKeeper", "Inactive");
}
status = healthCheck.getCassandraStatus(ConsistencyLevel.ANY.toString());
- if(status.equals("ACTIVE")) {
+ if(status.equals(activeStatus)) {
resultMap.put("Cassandra", "Active");
} else {
resultMap.put("Cassandra", "Inactive");