diff --git a/subsys/cassandra/src/main/java/org/commonjava/indy/subsys/cassandra/CassandraClient.java b/subsys/cassandra/src/main/java/org/commonjava/indy/subsys/cassandra/CassandraClient.java index e70fc3edff..8401878313 100644 --- a/subsys/cassandra/src/main/java/org/commonjava/indy/subsys/cassandra/CassandraClient.java +++ b/subsys/cassandra/src/main/java/org/commonjava/indy/subsys/cassandra/CassandraClient.java @@ -18,6 +18,7 @@ import com.datastax.driver.core.Cluster; import com.datastax.driver.core.Session; import com.datastax.driver.core.SocketOptions; +import com.datastax.driver.core.policies.ConstantReconnectionPolicy; import org.commonjava.indy.subsys.cassandra.config.CassandraConfig; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -75,6 +76,8 @@ private void init() socketOptions.setReadTimeoutMillis( config.getReadTimeoutMillis() ); Cluster.Builder builder = Cluster.builder() .withoutJMXReporting() + .withReconnectionPolicy( + new ConstantReconnectionPolicy( config.getConstantDelayMs() ) ) .withRetryPolicy( new ConfigurableRetryPolicy( config.getReadRetries(), config.getWriteRetries() ) ) .addContactPoint( host ) diff --git a/subsys/cassandra/src/main/java/org/commonjava/indy/subsys/cassandra/config/CassandraConfig.java b/subsys/cassandra/src/main/java/org/commonjava/indy/subsys/cassandra/config/CassandraConfig.java index eac31b1e18..612f1c41bc 100644 --- a/subsys/cassandra/src/main/java/org/commonjava/indy/subsys/cassandra/config/CassandraConfig.java +++ b/subsys/cassandra/src/main/java/org/commonjava/indy/subsys/cassandra/config/CassandraConfig.java @@ -45,6 +45,8 @@ public class CassandraConfig private int writeRetries = 3; + private long constantDelayMs = 60000; + public CassandraConfig() { } @@ -152,6 +154,17 @@ public void setWriteRetries( int writeRetries ) this.writeRetries = writeRetries; } + public long getConstantDelayMs() + { + return constantDelayMs; + } + + @ConfigName( "cassandra.reconnect.delay" ) + public void setConstantDelayMs( long constantDelayMs ) + { + this.constantDelayMs = constantDelayMs; + } + @Override public String getDefaultConfigFileName() {