summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVikram Potturi(apotturi) <vp9004@att.com>2018-04-30 18:32:55 -0400
committerVikram Potturi(apotturi) <vp9004@att.com>2018-04-30 18:32:55 -0400
commitf54f44d747c8744c62184ccb0f1cb75681ae79b6 (patch)
treec5a12a601a4bd901c0062811a018d1f9a867a719
parent174b3b1db95d277ec8788ae751d6ebb20707c964 (diff)
Added loadbalancing
Change-Id: I513e5add00620fc9ba39cf49af3b8ba25e91d124 Issue-ID: MUSIC-73 Signed-off-by: Vikram Potturi(apotturi) <vp9004@att.com>
-rw-r--r--jar/src/main/java/org/onap/music/datastore/MusicDataStore.java29
1 files changed, 24 insertions, 5 deletions
diff --git a/jar/src/main/java/org/onap/music/datastore/MusicDataStore.java b/jar/src/main/java/org/onap/music/datastore/MusicDataStore.java
index 5daeb76c..78389be5 100644
--- a/jar/src/main/java/org/onap/music/datastore/MusicDataStore.java
+++ b/jar/src/main/java/org/onap/music/datastore/MusicDataStore.java
@@ -171,13 +171,14 @@ public class MusicDataStore {
"Building with credentials "+MusicUtil.getCassName()+" & "+MusicUtil.getCassPwd());
cluster = Cluster.builder().withPort(9042)
.withCredentials(MusicUtil.getCassName(), MusicUtil.getCassPwd())
- .withLoadBalancingPolicy(new RoundRobinPolicy())
+ //.withLoadBalancingPolicy(new RoundRobinPolicy())
.withPoolingOptions(poolingOptions)
.addContactPoints(addresses).build();
}
else
cluster = Cluster.builder().withPort(9042)
- .withLoadBalancingPolicy(new RoundRobinPolicy())
+ //.withLoadBalancingPolicy(new RoundRobinPolicy())
+ .withPoolingOptions(poolingOptions)
.addContactPoints(addresses).build();
Metadata metadata = cluster.getMetadata();
@@ -206,9 +207,27 @@ public class MusicDataStore {
* @param address
*/
private void connectToCassaCluster(String address) throws MusicServiceException {
- cluster = Cluster.builder().withPort(9042)
- .withCredentials(MusicUtil.getCassName(), MusicUtil.getCassPwd())
- .addContactPoint(address).build();
+ String[] addresses = null;
+ addresses = address.split(",");
+ PoolingOptions poolingOptions = new PoolingOptions();
+ poolingOptions
+ .setConnectionsPerHost(HostDistance.LOCAL, 4, 10)
+ .setConnectionsPerHost(HostDistance.REMOTE, 2, 4);
+ if(MusicUtil.getCassName() != null && MusicUtil.getCassPwd() != null) {
+ logger.info(EELFLoggerDelegate.applicationLogger,
+ "Building with credentials "+MusicUtil.getCassName()+" & "+MusicUtil.getCassPwd());
+ cluster = Cluster.builder().withPort(9042)
+ .withCredentials(MusicUtil.getCassName(), MusicUtil.getCassPwd())
+ .withLoadBalancingPolicy(new RoundRobinPolicy())
+ .withPoolingOptions(poolingOptions)
+ .addContactPoints(addresses).build();
+ }
+ else {
+ cluster = Cluster.builder().withPort(9042)
+ .withLoadBalancingPolicy(new RoundRobinPolicy())
+ .withPoolingOptions(poolingOptions)
+ .addContactPoints(addresses).build();
+ }
Metadata metadata = cluster.getMetadata();
logger.info(EELFLoggerDelegate.applicationLogger, "Connected to cassa cluster "
+ metadata.getClusterName() + " at " + address);