aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/org/onap/music/datastore
diff options
context:
space:
mode:
authorNelson, Thomas (arthurdent3) <nelson24@att.com>2019-05-09 14:16:37 +0000
committerTschaen, Brendan <ctschaen@att.com>2019-05-13 14:34:05 -0400
commitd6e7b63cc580e7b3822be61fe92a493ad5e222a3 (patch)
tree5a055529781a2989585075e13426979464f5fb33 /src/main/java/org/onap/music/datastore
parent9a8b8ae8d7c8d6931f99def68068f8936a8cc0b3 (diff)
Changes Listed below:
- Added build version API - Updated Keyspace active to use Properties setting - Update Libraries Netty,jbcrypt,Jackson Databind and log4j - Removed some irrelivant files - Updated some usint tests to ignore some tests(This will be updated soon) - Bugfixes - Missing Values, inform user. - Respond with proper error - Fix Locking Contention issue. - Add locking retry for atomic calls. Change-Id: Ie218dd92edb0c20e4a0efe33eeaaec84e5293c44 Issue-ID: MUSIC-393 Signed-off-by: Nelson, Thomas (arthurdent3) <nelson24@att.com>
Diffstat (limited to 'src/main/java/org/onap/music/datastore')
-rw-r--r--src/main/java/org/onap/music/datastore/Condition.java1
-rwxr-xr-xsrc/main/java/org/onap/music/datastore/MusicDataStore.java80
-rw-r--r--src/main/java/org/onap/music/datastore/MusicDataStoreHandle.java90
-rw-r--r--src/main/java/org/onap/music/datastore/PreparedQueryObject.java5
-rwxr-xr-xsrc/main/java/org/onap/music/datastore/jsonobjects/JsonOnboard.java14
-rw-r--r--src/main/java/org/onap/music/datastore/jsonobjects/MusicResponse.java87
6 files changed, 182 insertions, 95 deletions
diff --git a/src/main/java/org/onap/music/datastore/Condition.java b/src/main/java/org/onap/music/datastore/Condition.java
index 2fd4596a..11998ab5 100644
--- a/src/main/java/org/onap/music/datastore/Condition.java
+++ b/src/main/java/org/onap/music/datastore/Condition.java
@@ -21,6 +21,7 @@
*/
package org.onap.music.datastore;
+
import java.util.Map;
import org.onap.music.main.MusicCore;
diff --git a/src/main/java/org/onap/music/datastore/MusicDataStore.java b/src/main/java/org/onap/music/datastore/MusicDataStore.java
index 1260efa0..2b88b4a8 100755
--- a/src/main/java/org/onap/music/datastore/MusicDataStore.java
+++ b/src/main/java/org/onap/music/datastore/MusicDataStore.java
@@ -44,7 +44,6 @@ import org.onap.music.eelf.logging.format.ErrorTypes;
import org.onap.music.exceptions.MusicQueryException;
import org.onap.music.exceptions.MusicServiceException;
import org.onap.music.main.MusicUtil;
-
import com.codahale.metrics.JmxReporter;
import com.datastax.driver.core.Cluster;
import com.datastax.driver.core.ColumnDefinitions;
@@ -182,16 +181,16 @@ public class MusicDataStore {
logger.info(EELFLoggerDelegate.applicationLogger,
"Building with credentials "+MusicUtil.getCassName()+" & "+MusicUtil.getCassPwd());
cluster = Cluster.builder().withPort(MusicUtil.getCassandraPort())
- .withCredentials(MusicUtil.getCassName(), MusicUtil.getCassPwd())
- //.withLoadBalancingPolicy(new RoundRobinPolicy())
- .withoutJMXReporting()
- .withPoolingOptions(poolingOptions)
- .addContactPoints(addresses).build();
+ .withCredentials(MusicUtil.getCassName(), MusicUtil.getCassPwd())
+ //.withLoadBalancingPolicy(new RoundRobinPolicy())
+ .withoutJMXReporting()
+ .withPoolingOptions(poolingOptions)
+ .addContactPoints(addresses).build();
}
else
cluster = Cluster.builder().withPort(MusicUtil.getCassandraPort())
- //.withLoadBalancingPolicy(new RoundRobinPolicy())
- .addContactPoints(addresses).build();
+ //.withLoadBalancingPolicy(new RoundRobinPolicy())
+ .addContactPoints(addresses).build();
Metadata metadata = cluster.getMetadata();
logger.info(EELFLoggerDelegate.applicationLogger, "Connected to cassa cluster "
@@ -230,13 +229,12 @@ public class MusicDataStore {
logger.info(EELFLoggerDelegate.applicationLogger,
"Building with credentials "+MusicUtil.getCassName()+" & "+MusicUtil.getCassPwd());
cluster = Cluster.builder().withPort(MusicUtil.getCassandraPort())
- .withCredentials(MusicUtil.getCassName(), MusicUtil.getCassPwd())
- //.withLoadBalancingPolicy(new RoundRobinPolicy())
- .withoutJMXReporting()
- .withPoolingOptions(poolingOptions)
- .addContactPoints(addresses).build();
- }
- else {
+ .withCredentials(MusicUtil.getCassName(), MusicUtil.getCassPwd())
+ //.withLoadBalancingPolicy(new RoundRobinPolicy())
+ .withoutJMXReporting()
+ .withPoolingOptions(poolingOptions)
+ .addContactPoints(addresses).build();
+ } else {
cluster = Cluster.builder().withPort(MusicUtil.getCassandraPort())
//.withLoadBalancingPolicy(new RoundRobinPolicy())
.withoutJMXReporting()
@@ -288,6 +286,17 @@ public class MusicDataStore {
KeyspaceMetadata ks = cluster.getMetadata().getKeyspace(keyspace);
return ks.getTable(tableName);
}
+
+ /**
+ *
+ * @param keyspace
+ * @param tableName
+ * @return TableMetadata
+ */
+ public KeyspaceMetadata returnKeyspaceMetadata(String keyspace) {
+ KeyspaceMetadata ks = cluster.getMetadata().getKeyspace(keyspace);
+ return ks;
+ }
/**
@@ -363,10 +372,10 @@ public class MusicDataStore {
if(definition.getType().toString().toLowerCase().contains("blob")) {
resultOutput.put(definition.getName(),
getBlobValue(row, definition.getName(), definition.getType()));
- }
- else
+ } else {
resultOutput.put(definition.getName(),
getColValue(row, definition.getName(), definition.getType()));
+ }
}
}
resultMap.put("row " + counter, resultOutput);
@@ -406,23 +415,6 @@ public class MusicDataStore {
"In preprared Execute Put: the actual insert query:"
+ queryObject.getQuery() + "; the values"
+ queryObject.getValues());
-/*<<<<<<< HEAD
- PreparedStatement preparedInsert = null;
- try {
-
- preparedInsert = session.prepare(queryObject.getQuery());
-
- } catch(InvalidQueryException iqe) {
- logger.error("Exception", iqe);
- logger.error(EELFLoggerDelegate.errorLogger, iqe.getMessage(),AppMessages.QUERYERROR, ErrorSeverity.CRITICAL, ErrorTypes.QUERYERROR);
- throw new MusicQueryException(iqe.getMessage());
- }catch(Exception e) {
- logger.error("Exception", e);
- logger.error(EELFLoggerDelegate.errorLogger, e.getMessage(),AppMessages.QUERYERROR, ErrorSeverity.CRITICAL, ErrorTypes.QUERYERROR);
- throw new MusicQueryException(e.getMessage());
- }
-
-=======*/
SimpleStatement preparedInsert = null;
try {
@@ -434,7 +426,7 @@ public class MusicDataStore {
logger.info(EELFLoggerDelegate.applicationLogger, "Executing simple put query");
if(queryObject.getConsistency() == null)
preparedInsert.setConsistencyLevel(ConsistencyLevel.ONE);
- else
+ else
preparedInsert.setConsistencyLevel(MusicUtil.getConsistencyLevel(queryObject.getConsistency()));
} else if (consistency.equalsIgnoreCase(MusicUtil.ONE)) {
preparedInsert.setConsistencyLevel(ConsistencyLevel.ONE);
@@ -456,9 +448,9 @@ public class MusicDataStore {
throw new MusicServiceException(ae.getMessage());
}
catch (Exception e) {
- logger.error(EELFLoggerDelegate.errorLogger, e.getMessage(),AppMessages.SESSIONFAILED+ " [" +
- queryObject.getQuery() + "]", ErrorSeverity.ERROR, ErrorTypes.QUERYERROR, e);
- throw new MusicQueryException("Executing Session Failure for Request = " + "["
+ logger.error(EELFLoggerDelegate.errorLogger, e.getMessage(),AppMessages.SESSIONFAILED + " ["
+ + queryObject.getQuery() + "]", ErrorSeverity.ERROR, ErrorTypes.QUERYERROR, e);
+ throw new MusicServiceException("Executing Session Failure for Request = " + "["
+ queryObject.getQuery() + "]" + " Reason = " + e.getMessage());
}
@@ -496,11 +488,10 @@ public class MusicDataStore {
}
if(queryObject.getConsistency() == null) {
preparedEventualGet.setConsistencyLevel(ConsistencyLevel.ONE);
+ } else {
+ preparedEventualGet.setConsistencyLevel(MusicUtil.getConsistencyLevel(queryObject.getConsistency()));
}
- else {
- preparedEventualGet.setConsistencyLevel(MusicUtil.getConsistencyLevel(queryObject.getConsistency()));
- }
- results = session.execute(preparedEventualGet.bind(queryObject.getValues().toArray()));
+ results = session.execute(preparedEventualGet.bind(queryObject.getValues().toArray()));
} catch (Exception ex) {
logger.error("Exception", ex);
@@ -555,10 +546,9 @@ public class MusicDataStore {
if (consistencyLevel.equalsIgnoreCase(CONSISTENCY_LEVEL_ONE)) {
if(queryObject.getConsistency() == null) {
statement.setConsistencyLevel(ConsistencyLevel.ONE);
+ } else {
+ statement.setConsistencyLevel(MusicUtil.getConsistencyLevel(queryObject.getConsistency()));
}
- else {
- statement.setConsistencyLevel(MusicUtil.getConsistencyLevel(queryObject.getConsistency()));
- }
}
else if (consistencyLevel.equalsIgnoreCase(CONSISTENCY_LEVEL_QUORUM)) {
statement.setConsistencyLevel(ConsistencyLevel.QUORUM);
diff --git a/src/main/java/org/onap/music/datastore/MusicDataStoreHandle.java b/src/main/java/org/onap/music/datastore/MusicDataStoreHandle.java
index dc1c43a8..b4412bf6 100644
--- a/src/main/java/org/onap/music/datastore/MusicDataStoreHandle.java
+++ b/src/main/java/org/onap/music/datastore/MusicDataStoreHandle.java
@@ -32,6 +32,7 @@ import org.onap.music.eelf.logging.EELFLoggerDelegate;
import org.onap.music.exceptions.MusicServiceException;
import org.onap.music.main.MusicUtil;
+import com.datastax.driver.core.KeyspaceMetadata;
import com.datastax.driver.core.ResultSet;
import com.datastax.driver.core.TableMetadata;
@@ -49,45 +50,45 @@ public class MusicDataStoreHandle {
* @param remoteIp
* @return
*/
- public static MusicDataStore getDSHandle(String remoteIp) {
- logger.info(EELFLoggerDelegate.metricsLogger,"Acquiring data store handle");
- long start = System.currentTimeMillis();
- if (mDstoreHandle == null) {
- mDstoreHandle = new MusicDataStore(remoteIp);
- }
- long end = System.currentTimeMillis();
- logger.info(EELFLoggerDelegate.metricsLogger,"Time taken to acquire data store handle:" + (end - start) + " ms");
- return mDstoreHandle;
- }
+ public static MusicDataStore getDSHandle(String remoteIp) {
+ logger.info(EELFLoggerDelegate.metricsLogger,"Acquiring data store handle");
+ long start = System.currentTimeMillis();
+ if (mDstoreHandle == null) {
+ mDstoreHandle = new MusicDataStore(remoteIp);
+ }
+ long end = System.currentTimeMillis();
+ logger.info(EELFLoggerDelegate.metricsLogger,"Time taken to acquire data store handle:" + (end - start) + " ms");
+ return mDstoreHandle;
+ }
/**
*
* @return
* @throws MusicServiceException
*/
- public static MusicDataStore getDSHandle() throws MusicServiceException {
- logger.info(EELFLoggerDelegate.metricsLogger,"Acquiring data store handle");
- long start = System.currentTimeMillis();
- if (mDstoreHandle == null) {
- // Quick Fix - Best to put this into every call to getDSHandle?
+ public static MusicDataStore getDSHandle() throws MusicServiceException {
+ logger.info(EELFLoggerDelegate.metricsLogger,"Acquiring data store handle");
+ long start = System.currentTimeMillis();
+ if (mDstoreHandle == null) {
+ // Quick Fix - Best to put this into every call to getDSHandle?
if (!"localhost".equals(MusicUtil.getMyCassaHost())) {
- mDstoreHandle = new MusicDataStore(MusicUtil.getMyCassaHost());
- } else {
- mDstoreHandle = new MusicDataStore();
- }
- }
- if(mDstoreHandle.getSession() == null) {
- String message = "Connection to Cassandra has not been enstablished."
- + " Please check connection properites and reboot.";
- logger.info(EELFLoggerDelegate.applicationLogger, message);
- throw new MusicServiceException(message);
- }
- long end = System.currentTimeMillis();
- logger.info(EELFLoggerDelegate.metricsLogger,"Time taken to acquire data store handle:" + (end - start) + " ms");
- return mDstoreHandle;
- }
-
-
+ mDstoreHandle = new MusicDataStore(MusicUtil.getMyCassaHost());
+ } else {
+ mDstoreHandle = new MusicDataStore();
+ }
+ }
+ if(mDstoreHandle.getSession() == null) {
+ String message = "Connection to Cassandra has not been enstablished."
+ + " Please check connection properites and reboot.";
+ logger.info(EELFLoggerDelegate.applicationLogger, message);
+ throw new MusicServiceException(message);
+ }
+ long end = System.currentTimeMillis();
+ logger.info(EELFLoggerDelegate.metricsLogger,"Time taken to acquire data store handle:" + (end - start) + " ms");
+ return mDstoreHandle;
+ }
+
+
/**
*
* @param keyspace
@@ -95,18 +96,29 @@ public class MusicDataStoreHandle {
* @return
* @throws MusicServiceException
*/
- public static TableMetadata returnColumnMetadata(String keyspace, String tablename) throws MusicServiceException {
- return getDSHandle().returnColumnMetadata(keyspace, tablename);
- }
-
+ public static TableMetadata returnColumnMetadata(String keyspace, String tablename) throws MusicServiceException {
+ return getDSHandle().returnColumnMetadata(keyspace, tablename);
+ }
+
+ /**
+ *
+ * @param keyspace
+ * @param tablename
+ * @return
+ * @throws MusicServiceException
+ */
+ public static KeyspaceMetadata returnkeyspaceMetadata(String keyspace) throws MusicServiceException {
+ return getDSHandle().returnKeyspaceMetadata(keyspace);
+ }
+
/**
*
* @param results
* @return
* @throws MusicServiceException
*/
- public static Map<String, HashMap<String, Object>> marshallResults(ResultSet results) throws MusicServiceException {
- return getDSHandle().marshalData(results);
- }
+ public static Map<String, HashMap<String, Object>> marshallResults(ResultSet results) throws MusicServiceException {
+ return getDSHandle().marshalData(results);
+ }
}
diff --git a/src/main/java/org/onap/music/datastore/PreparedQueryObject.java b/src/main/java/org/onap/music/datastore/PreparedQueryObject.java
index 9b109630..db317eb8 100644
--- a/src/main/java/org/onap/music/datastore/PreparedQueryObject.java
+++ b/src/main/java/org/onap/music/datastore/PreparedQueryObject.java
@@ -83,7 +83,7 @@ public class PreparedQueryObject {
this.consistency = consistency;
}
- /**
+ /**
*
*/
public PreparedQueryObject() {
@@ -122,7 +122,4 @@ public class PreparedQueryObject {
public String getQuery() {
return this.query.toString();
}
-
-
-
}
diff --git a/src/main/java/org/onap/music/datastore/jsonobjects/JsonOnboard.java b/src/main/java/org/onap/music/datastore/jsonobjects/JsonOnboard.java
index 82993ebc..5b3bbd48 100755
--- a/src/main/java/org/onap/music/datastore/jsonobjects/JsonOnboard.java
+++ b/src/main/java/org/onap/music/datastore/jsonobjects/JsonOnboard.java
@@ -37,16 +37,16 @@ public class JsonOnboard {
private String aid;
private String keyspace;
- @ApiModelProperty(value = "Application Keyspace")
+ @ApiModelProperty(value = "Application Keyspace")
public String getKeyspace() {
- return keyspace;
- }
+ return keyspace;
+ }
- public void setKeyspace_name(String keyspace) {
- this.keyspace = keyspace;
- }
+ public void setKeyspace_name(String keyspace) {
+ this.keyspace = keyspace;
+ }
- @ApiModelProperty(value = "Application Password")
+ @ApiModelProperty(value = "Application Password")
public String getPassword() {
return password;
}
diff --git a/src/main/java/org/onap/music/datastore/jsonobjects/MusicResponse.java b/src/main/java/org/onap/music/datastore/jsonobjects/MusicResponse.java
new file mode 100644
index 00000000..97131fd7
--- /dev/null
+++ b/src/main/java/org/onap/music/datastore/jsonobjects/MusicResponse.java
@@ -0,0 +1,87 @@
+/*
+ * ============LICENSE_START==========================================
+ * org.onap.music
+ * ===================================================================
+ * Copyright (c) 2017 AT&T Intellectual Property
+ * ===================================================================
+ * 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
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * ============LICENSE_END=============================================
+ * ====================================================================
+ */
+package org.onap.music.datastore.jsonobjects;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.onap.music.rest.Application;
+
+public class MusicResponse implements Serializable {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+ private List<Application> applicationList = new ArrayList<>();
+ private String message;
+
+ public String getStatus() {
+ return status;
+ }
+
+ public void setStatus(String status) {
+ this.status = status;
+ }
+
+ private String status;
+
+ public void setSucces(boolean isSucces) {
+ this.isSucces = isSucces;
+ }
+
+ private boolean isSucces;
+
+ public boolean isSucces() {
+ return isSucces;
+ }
+
+ public void setisSucces(boolean isSucces) {
+ this.isSucces = isSucces;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ public List<Application> getApplicationList() {
+ return applicationList;
+ }
+
+ public void setApplicationList(List<Application> applicationList) {
+ this.applicationList = applicationList;
+ }
+
+ public void setResposne(String status, String message) {
+ this.status = status;
+ this.message = message;
+ }
+
+ public void addAppToList(Application app) {
+ applicationList.add(app);
+ }
+}