aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTschaen, Brendan <ctschaen@att.com>2019-09-26 17:07:06 -0400
committerTschaen, Brendan <ctschaen@att.com>2019-09-30 11:06:43 -0400
commita681a9e295dc2b8f35dd42251f795d0079471ac0 (patch)
tree534df29824551cfb4a83989020297eaee5059cf6
parent11ee6836d6f25a1becdea60a322a72fbffd4b8b6 (diff)
Include lockstate codec by defualt
Change-Id: I5a39b2c865cff205af9d650e54157b992e748973 Issue-ID: MUSIC-508 Signed-off-by: Tschaen, Brendan <ctschaen@att.com>
-rwxr-xr-xmusic-core/src/main/java/org/onap/music/datastore/MusicDataStore.java57
-rw-r--r--music-core/src/test/java/org/onap/music/unittests/CassandraCQL.java2
2 files changed, 30 insertions, 29 deletions
diff --git a/music-core/src/main/java/org/onap/music/datastore/MusicDataStore.java b/music-core/src/main/java/org/onap/music/datastore/MusicDataStore.java
index 5a658688..97fc1d33 100755
--- a/music-core/src/main/java/org/onap/music/datastore/MusicDataStore.java
+++ b/music-core/src/main/java/org/onap/music/datastore/MusicDataStore.java
@@ -78,6 +78,28 @@ public class MusicDataStore {
/**
+ * Connect to default Cassandra address
+ */
+ public MusicDataStore() {
+ try {
+ connectToCassaCluster(MusicUtil.getMyCassaHost());
+ } catch (MusicServiceException e) {
+ logger.error(EELFLoggerDelegate.errorLogger, e.getMessage(), e);
+ }
+ }
+
+
+ /**
+ * @param cluster
+ * @param session
+ */
+ public MusicDataStore(Cluster cluster, Session session) {
+ this.session = session;
+ setCluster(cluster);
+ }
+
+
+ /**
* @param session
*/
public void setSession(Session session) {
@@ -95,6 +117,9 @@ public class MusicDataStore {
* @param cluster
*/
public void setCluster(Cluster cluster) {
+ EnumNameCodec<LockType> lockTypeCodec = new EnumNameCodec<LockType>(LockType.class);
+ cluster.getConfiguration().getCodecRegistry().register(lockTypeCodec);
+
this.cluster = cluster;
}
@@ -105,27 +130,7 @@ public class MusicDataStore {
private EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(MusicDataStore.class);
- /**
- * Connect to default Cassandra address
- */
- public MusicDataStore() {
- try {
- connectToCassaCluster(MusicUtil.getMyCassaHost());
- } catch (MusicServiceException e) {
- logger.error(EELFLoggerDelegate.errorLogger, e.getMessage(), e);
- }
- }
-
-
- /**
- * @param cluster
- * @param session
- */
- public MusicDataStore(Cluster cluster, Session session) {
- this.session = session;
- this.cluster = cluster;
- }
-
+
/**
*
* @param remoteIp
@@ -159,6 +164,7 @@ public class MusicDataStore {
.setConnectionsPerHost(HostDistance.LOCAL, 4, 10)
.setConnectionsPerHost(HostDistance.REMOTE, 2, 4);
+ Cluster cluster;
if(MusicUtil.getCassName() != null && MusicUtil.getCassPwd() != null) {
String cassPwd = CipherUtil.decryptPKC(MusicUtil.getCassPwd());
logger.info(EELFLoggerDelegate.applicationLogger,
@@ -177,16 +183,13 @@ public class MusicDataStore {
.build();
}
-
- Metadata metadata = cluster.getMetadata();
+ this.setCluster(cluster);
+ Metadata metadata = this.cluster.getMetadata();
logger.info(EELFLoggerDelegate.applicationLogger, "Connected to cassa cluster "
+ metadata.getClusterName() + " at " + address);
-
- EnumNameCodec<LockType> lockTypeCodec = new EnumNameCodec<LockType>(LockType.class);
- cluster.getConfiguration().getCodecRegistry().register(lockTypeCodec);
try {
- session = cluster.connect();
+ session = this.cluster.connect();
} catch (Exception ex) {
logger.error(EELFLoggerDelegate.errorLogger, ex.getMessage(),AppMessages.CASSANDRACONNECTIVITY,
ErrorSeverity.ERROR, ErrorTypes.SERVICEUNAVAILABLE, ex);
diff --git a/music-core/src/test/java/org/onap/music/unittests/CassandraCQL.java b/music-core/src/test/java/org/onap/music/unittests/CassandraCQL.java
index 7b116bc8..582744fb 100644
--- a/music-core/src/test/java/org/onap/music/unittests/CassandraCQL.java
+++ b/music-core/src/test/java/org/onap/music/unittests/CassandraCQL.java
@@ -236,8 +236,6 @@ public class CassandraCQL {
EmbeddedCassandraServerHelper.startEmbeddedCassandra();
Cluster cluster = new Cluster.Builder().withoutJMXReporting().withoutMetrics().addContactPoint(address).withPort(9142).build();
cluster.getConfiguration().getSocketOptions().setReadTimeoutMillis(5000);
- EnumNameCodec<LockType> lockTypeCodec = new EnumNameCodec<LockType>(LockType.class);
- cluster.getConfiguration().getCodecRegistry().register(lockTypeCodec);
Session session = cluster.connect();