aboutsummaryrefslogtreecommitdiffstats
path: root/music-core/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'music-core/src/main/java')
-rwxr-xr-xmusic-core/src/main/java/org/onap/music/datastore/MusicDataStore.java57
1 files changed, 30 insertions, 27 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);