Skip to content

Commit

Permalink
Merge pull request #2474 from yma96/master
Browse files Browse the repository at this point in the history
Update Cassandra reconnect policy and default delay value
  • Loading branch information
yma96 authored Oct 15, 2024
2 parents 01bfb7c + 4e427c6 commit c958f0f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ public class CassandraConfig

private int writeRetries = 3;

private long constantDelayMs = 60000;

public CassandraConfig()
{
}
Expand Down Expand Up @@ -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()
{
Expand Down

0 comments on commit c958f0f

Please sign in to comment.