summaryrefslogtreecommitdiffstats
path: root/openecomp-be
diff options
context:
space:
mode:
Diffstat (limited to 'openecomp-be')
-rw-r--r--openecomp-be/dist/sdc-onboard-backend-docker/artifacts/chef-repo/cookbooks/sdc-onboard-backend/attributes/default.rb1
-rw-r--r--openecomp-be/dist/sdc-onboard-backend-docker/artifacts/chef-repo/cookbooks/sdc-onboard-backend/recipes/ON_5_setup_configuration.rb1
-rw-r--r--openecomp-be/dist/sdc-onboard-backend-docker/artifacts/chef-repo/cookbooks/sdc-onboard-backend/templates/default/configuration.yaml.erb1
-rw-r--r--openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/openecomp-nosqldb-core/src/main/java/org/openecomp/core/nosqldb/impl/cassandra/CassandraSessionFactory.java31
-rw-r--r--openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/openecomp-nosqldb-core/src/main/java/org/openecomp/core/nosqldb/util/CassandraUtils.java5
-rw-r--r--openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/openecomp-nosqldb-core/src/main/java/org/openecomp/core/nosqldb/util/ConfigurationManager.java51
-rw-r--r--openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-core/src/main/java/org/openecomp/core/zusammen/impl/CassandraConnectionInitializer.java8
7 files changed, 61 insertions, 37 deletions
diff --git a/openecomp-be/dist/sdc-onboard-backend-docker/artifacts/chef-repo/cookbooks/sdc-onboard-backend/attributes/default.rb b/openecomp-be/dist/sdc-onboard-backend-docker/artifacts/chef-repo/cookbooks/sdc-onboard-backend/attributes/default.rb
index cecc7ef5f4..013a87d391 100644
--- a/openecomp-be/dist/sdc-onboard-backend-docker/artifacts/chef-repo/cookbooks/sdc-onboard-backend/attributes/default.rb
+++ b/openecomp-be/dist/sdc-onboard-backend-docker/artifacts/chef-repo/cookbooks/sdc-onboard-backend/attributes/default.rb
@@ -12,6 +12,7 @@ default['VnfRepo']['vnfRepoPort'] = 8702
default['VnfRepo']['vnfRepoHost'] = "192.168.50.5"
#Cassandra
+default['cassandra']['cassandra_port'] = 9042
default['cassandra']['datacenter_name'] = "DC-"
default['cassandra']['cluster_name'] = "SDC-CS-"
default['cassandra']['socket_read_timeout'] = 20000
diff --git a/openecomp-be/dist/sdc-onboard-backend-docker/artifacts/chef-repo/cookbooks/sdc-onboard-backend/recipes/ON_5_setup_configuration.rb b/openecomp-be/dist/sdc-onboard-backend-docker/artifacts/chef-repo/cookbooks/sdc-onboard-backend/recipes/ON_5_setup_configuration.rb
index a8158c9313..6de66fbf4f 100644
--- a/openecomp-be/dist/sdc-onboard-backend-docker/artifacts/chef-repo/cookbooks/sdc-onboard-backend/recipes/ON_5_setup_configuration.rb
+++ b/openecomp-be/dist/sdc-onboard-backend-docker/artifacts/chef-repo/cookbooks/sdc-onboard-backend/recipes/ON_5_setup_configuration.rb
@@ -9,6 +9,7 @@ template "onboard-be-config" do
:onboard_port => node['ONBOARDING_BE'][:http_port],
:ssl_port => node['ONBOARDING_BE'][:https_port],
:cassandra_ip => node['Nodes']['CS'].join(",").gsub(/[|]/,''),
+ :cassandra_port => node['cassandra']['cassandra_port'],
:DC_NAME => node['cassandra']['datacenter_name']+node.chef_environment,
:socket_connect_timeout => node['cassandra']['socket_connect_timeout'],
:socket_read_timeout => node['cassandra']['socket_read_timeout'],
diff --git a/openecomp-be/dist/sdc-onboard-backend-docker/artifacts/chef-repo/cookbooks/sdc-onboard-backend/templates/default/configuration.yaml.erb b/openecomp-be/dist/sdc-onboard-backend-docker/artifacts/chef-repo/cookbooks/sdc-onboard-backend/templates/default/configuration.yaml.erb
index 838a323348..d73799fcd3 100644
--- a/openecomp-be/dist/sdc-onboard-backend-docker/artifacts/chef-repo/cookbooks/sdc-onboard-backend/templates/default/configuration.yaml.erb
+++ b/openecomp-be/dist/sdc-onboard-backend-docker/artifacts/chef-repo/cookbooks/sdc-onboard-backend/templates/default/configuration.yaml.erb
@@ -19,6 +19,7 @@ notifications:
cassandraConfig:
cassandraHosts: [<%= @cassandra_ip %>]
+ cassandraPort: <%= @cassandra_port %>
localDataCenter: <%= @DC_NAME %>
reconnectTimeout : 30000
socketReadTimeout: <%= @socket_read_timeout %>
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/openecomp-nosqldb-core/src/main/java/org/openecomp/core/nosqldb/impl/cassandra/CassandraSessionFactory.java b/openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/openecomp-nosqldb-core/src/main/java/org/openecomp/core/nosqldb/impl/cassandra/CassandraSessionFactory.java
index 87c0055b44..f0945a4da1 100644
--- a/openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/openecomp-nosqldb-core/src/main/java/org/openecomp/core/nosqldb/impl/cassandra/CassandraSessionFactory.java
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/openecomp-nosqldb-core/src/main/java/org/openecomp/core/nosqldb/impl/cassandra/CassandraSessionFactory.java
@@ -16,9 +16,6 @@
package org.openecomp.core.nosqldb.impl.cassandra;
-import com.datastax.driver.core.policies.DCAwareRoundRobinPolicy;
-import com.datastax.driver.core.policies.LoadBalancingPolicy;
-import com.datastax.driver.core.policies.TokenAwarePolicy;
import com.datastax.driver.core.Cluster;
import com.datastax.driver.core.ConsistencyLevel;
import com.datastax.driver.core.QueryOptions;
@@ -27,6 +24,7 @@ import com.datastax.driver.core.SSLOptions;
import com.datastax.driver.core.Session;
+import com.datastax.driver.core.policies.*;
import org.openecomp.core.nosqldb.util.CassandraUtils;
import org.openecomp.sdc.common.errors.SdcConfigurationException;
import org.openecomp.sdc.common.session.SessionContextProviderFactory;
@@ -59,8 +57,19 @@ public class CassandraSessionFactory {
* @return the session
*/
public static Session newCassandraSession() {
- Cluster.Builder builder = Cluster.builder();
String[] addresses = CassandraUtils.getAddresses();
+ int cassandraPort = CassandraUtils.getCassandraPort();
+ Long reconnectTimeout = CassandraUtils.getReconnectTimeout();
+
+ Cluster.Builder builder = Cluster.builder();
+
+ if(null != reconnectTimeout) {
+ builder.withReconnectionPolicy(new ConstantReconnectionPolicy(reconnectTimeout))
+ .withRetryPolicy(DefaultRetryPolicy.INSTANCE);
+ }
+
+ builder.withPort(cassandraPort);
+
for (String address : addresses) {
builder.addContactPoint(address);
}
@@ -70,10 +79,7 @@ public class CassandraSessionFactory {
if (isSsl) {
builder.withSSL(getSslOptions());
}
- int port = CassandraUtils.getCassandraPort();
- if (port > 0) {
- builder.withPort(port);
- }
+
//Check if user/pass
Boolean isAuthenticate = CassandraUtils.isAuthenticate();
if (isAuthenticate) {
@@ -84,18 +90,19 @@ public class CassandraSessionFactory {
setLocalDataCenter(builder);
-
Cluster cluster = builder.build();
String keyStore = SessionContextProviderFactory.getInstance().createInterface().get()
.getTenant();
+ LOGGER.info("Cassandra client created hosts: {} port: {} SSL enabled: {} reconnectTimeout",
+ addresses, cassandraPort, isSsl, reconnectTimeout);
return cluster.connect(keyStore);
}
private static void setLocalDataCenter(Cluster.Builder builder) {
String localDataCenter = CassandraUtils.getLocalDataCenter();
if (Objects.nonNull(localDataCenter)) {
- LOGGER.info("localDatacenter was provided, setting Cassndra client to use datacenter: {} as " +
- "local.", localDataCenter);
+ LOGGER.info("localDatacenter was provided, setting Cassndra client to use datacenter: {} as local.",
+ localDataCenter);
LoadBalancingPolicy tokenAwarePolicy = new TokenAwarePolicy(
DCAwareRoundRobinPolicy.builder().withLocalDc(localDataCenter).build());
@@ -165,6 +172,4 @@ public class CassandraSessionFactory {
// prevent instantiation
}
}
-
-
}
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/openecomp-nosqldb-core/src/main/java/org/openecomp/core/nosqldb/util/CassandraUtils.java b/openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/openecomp-nosqldb-core/src/main/java/org/openecomp/core/nosqldb/util/CassandraUtils.java
index cc9f626f62..30bc0a72a3 100644
--- a/openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/openecomp-nosqldb-core/src/main/java/org/openecomp/core/nosqldb/util/CassandraUtils.java
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/openecomp-nosqldb-core/src/main/java/org/openecomp/core/nosqldb/util/CassandraUtils.java
@@ -34,7 +34,10 @@ public class CassandraUtils {
public static String[] getAddresses() {
return ConfigurationManager.getInstance().getAddresses();
+ }
+ public static Long getReconnectTimeout() {
+ return ConfigurationManager.getInstance().getReconnectTimeout();
}
public static String getKeySpace() {
@@ -78,7 +81,7 @@ public class CassandraUtils {
}
public static int getCassandraPort() {
- return ConfigurationManager.getInstance().getSslPort();
+ return ConfigurationManager.getInstance().getCassandraPort();
}
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/openecomp-nosqldb-core/src/main/java/org/openecomp/core/nosqldb/util/ConfigurationManager.java b/openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/openecomp-nosqldb-core/src/main/java/org/openecomp/core/nosqldb/util/ConfigurationManager.java
index 0694acbda1..a1d5246eee 100644
--- a/openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/openecomp-nosqldb-core/src/main/java/org/openecomp/core/nosqldb/util/ConfigurationManager.java
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/openecomp-nosqldb-core/src/main/java/org/openecomp/core/nosqldb/util/ConfigurationManager.java
@@ -42,6 +42,7 @@ import java.util.function.Function;
public class ConfigurationManager {
static final String CONFIGURATION_YAML_FILE = "configuration.yaml";
+ static private final Integer DEFAULT_CASSANDRA_PORT = 9042;
private static final String CASSANDRA = "cassandra";
private static final String CASSANDRA_KEY = CASSANDRA + "Config";
private static final String DEFAULT_KEYSPACE_NAME = "dox";
@@ -50,13 +51,13 @@ public class ConfigurationManager {
private static final String CASSANDRA_AUTHENTICATE = CASSANDRA + ".authenticate";
private static final String CASSANDRA_USER = CASSANDRA + ".user";
private static final String CASSANDRA_PASSWORD = CASSANDRA + ".password";
- private static final String CASSANDRA_PORT = CASSANDRA + ".port";
private static final String CASSANDRA_SSL = CASSANDRA + ".ssl";
private static final String CASSANDRA_TRUSTSTORE = CASSANDRA + ".Truststore";
private static final String CASSANDRA_TRUSTSTORE_PASSWORD = CASSANDRA + ".TruststorePassword";
private static final String CASSANDRA_HOSTS_KEY = CASSANDRA + "Hosts";
- private static final String CASSANDRA_PORT_KEY = "port";
+ private static final String CASSANDRA_PORT_KEY = "cassandraPort";
private static final String CASSANDRA_USERNAME_KEY = "username";
+ private static final String CASSANDRA_RECONNECT_TIMEOUT = "reconnectTimeout";
@SuppressWarnings("squid:S2068")
private static final String CASSANDRA_PASSWORD_KEY = "password";
private static final String CASSANDRA_AUTHENTICATE_KEY = "authenticate";
@@ -130,6 +131,33 @@ public class ConfigurationManager {
}
/**
+ * Gets Cassandra port.
+ *
+ * @return the port
+ */
+ public int getCassandraPort() {
+ Integer cassandraPort = (Integer) cassandraConfiguration.get(CASSANDRA_PORT_KEY);
+ if (Objects.isNull(cassandraPort)) {
+ cassandraPort = DEFAULT_CASSANDRA_PORT;
+ }
+ return cassandraPort;
+ }
+
+ /**
+ * Gets Cassandra reconnection timeout
+ *
+ * @return
+ */
+ public Long getReconnectTimeout() {
+ Integer cassandraReconnectTimeout = (Integer) cassandraConfiguration.get(CASSANDRA_RECONNECT_TIMEOUT);
+ if (Objects.isNull(cassandraReconnectTimeout)) {
+ LOG.info("No Cassandra reconnect timeout are defined.");
+ return null;
+ }
+ return cassandraReconnectTimeout.longValue();
+ }
+
+ /**
* Gets key space.
*
* @return the key space
@@ -195,25 +223,6 @@ public class ConfigurationManager {
}
/**
- * Gets ssl port.
- *
- * @return the ssl port
- */
- public int getSslPort() {
- int port;
- String sslPort = System.getProperty(CASSANDRA_PORT);
- if (Objects.isNull(sslPort)) {
- sslPort = (String) cassandraConfiguration.get(CASSANDRA_PORT_KEY);
- if (Objects.isNull(sslPort)) {
- sslPort = "0";
- }
- }
- port = Integer.valueOf(sslPort);
- return port;
- }
-
-
- /**
* Is ssl boolean.
*
* @return the boolean
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-core/src/main/java/org/openecomp/core/zusammen/impl/CassandraConnectionInitializer.java b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-core/src/main/java/org/openecomp/core/zusammen/impl/CassandraConnectionInitializer.java
index 7944999a70..05c7a1a72a 100644
--- a/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-core/src/main/java/org/openecomp/core/zusammen/impl/CassandraConnectionInitializer.java
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-zusammen-lib/openecomp-zusammen-core/src/main/java/org/openecomp/core/zusammen/impl/CassandraConnectionInitializer.java
@@ -26,7 +26,9 @@ public class CassandraConnectionInitializer {
private static final String DATA_CENTER_PROPERTY_NAME = CASSANDRA_PREFIX + "datacenter";
private static final String CONSISTENCY_LEVEL_PROPERTY_NAME =
CASSANDRA_PREFIX + "consistency.level";
+ private static final String CASSANDRA_RECONNECT_TIMEOUT = CASSANDRA_PREFIX + "reconnection.delay";
private static final String NODES_PROPERTY_NAME = CASSANDRA_PREFIX + "nodes";
+ private static final String CASSANDRA_PORT_PROPERTY_NAME = CASSANDRA_PREFIX + "port";
private static final String AUTHENTICATE_PROPERTY_NAME = CASSANDRA_PREFIX + "authenticate";
private static final String SSL_PROPERTY_NAME = CASSANDRA_PREFIX + "ssl";
private static final String TRUSTSTORE_PROPERTY_NAME = CASSANDRA_PREFIX + "truststore";
@@ -50,16 +52,18 @@ public class CassandraConnectionInitializer {
static {
setSystemProperty(NODES_PROPERTY_NAME, () ->
StringUtils.join(CassandraUtils.getAddresses(), ','));
+ setSystemProperty(CASSANDRA_PORT_PROPERTY_NAME, () -> Integer.toString(CassandraUtils.getCassandraPort()));
setBooleanSystemProperty(AUTHENTICATE_PROPERTY_NAME, CassandraUtils::isAuthenticate);
setBooleanSystemProperty(SSL_PROPERTY_NAME, CassandraUtils::isSsl);
- setSystemProperty(TRUSTSTORE_PROPERTY_NAME, CassandraUtils::getTruststore);
- setSystemProperty(TRUSTSTORE_PASSWORD_PROPERTY_NAME, CassandraUtils::getTruststorePassword);
+ setNullableSystemProperty(TRUSTSTORE_PROPERTY_NAME, CassandraUtils::getTruststore);
+ setNullableSystemProperty(TRUSTSTORE_PASSWORD_PROPERTY_NAME, CassandraUtils::getTruststorePassword);
setSystemProperty(USER_PROPERTY_NAME, CassandraUtils::getUser);
setSystemProperty(PASSWORD_PROPERTY_NAME, CassandraUtils::getPassword);
setSystemProperty(KEYSPACE_PROPERTY_NAME, () -> ZUSAMMEN);
setNullableSystemProperty(DATA_CENTER_PROPERTY_NAME, CassandraUtils::getLocalDataCenter);
setNullableSystemProperty(CONSISTENCY_LEVEL_PROPERTY_NAME,
CassandraUtils::getConsistencyLevel);
+ setSystemProperty(CASSANDRA_RECONNECT_TIMEOUT, () -> Long.toString(CassandraUtils.getReconnectTimeout()));
}
private DeferredInitializer() { }