Include lockstate codec by defualt 09/96309/2
authorTschaen, Brendan <ctschaen@att.com>
Thu, 26 Sep 2019 21:07:06 +0000 (17:07 -0400)
committerTschaen, Brendan <ctschaen@att.com>
Mon, 30 Sep 2019 15:06:43 +0000 (11:06 -0400)
Change-Id: I5a39b2c865cff205af9d650e54157b992e748973
Issue-ID: MUSIC-508
Signed-off-by: Tschaen, Brendan <ctschaen@att.com>
music-core/src/main/java/org/onap/music/datastore/MusicDataStore.java
music-core/src/test/java/org/onap/music/unittests/CassandraCQL.java

index 5a65868..97fc1d3 100755 (executable)
@@ -77,6 +77,28 @@ public class MusicDataStore {
     private Cluster cluster;
 
 
+    /**
+     * 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
      */
@@ -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);
index 7b116bc..582744f 100644 (file)
@@ -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();