|
21 | 21 | import com.datastax.driver.core.ResultSet; |
22 | 22 | import com.datastax.driver.core.Row; |
23 | 23 | import com.datastax.driver.core.Session; |
| 24 | +import com.datastax.driver.core.policies.ConstantReconnectionPolicy; |
24 | 25 | import com.datastax.driver.mapping.Mapper; |
25 | 26 | import com.datastax.driver.mapping.MappingManager; |
26 | 27 | import com.datastax.driver.mapping.Result; |
@@ -87,6 +88,8 @@ public class CassandraPathDB |
87 | 88 |
|
88 | 89 | private int replicationFactor = 1; // keyspace replica, default 1 |
89 | 90 |
|
| 91 | + private long reconnectDelay = 60000; |
| 92 | + |
90 | 93 | private PreparedStatement preparedExistQuery, preparedListQuery, preparedListCheckEmpty, preparedContainingQuery, preparedExistFileQuery, |
91 | 94 | preparedUpdateExpiration, preparedReverseMapIncrement, preparedReverseMapReduction, |
92 | 95 | preparedFilesystemIncrement, preparedFilesystemReduction, preparedFilesystemList; |
@@ -114,8 +117,15 @@ public CassandraPathDB( PathMappedStorageConfig config ) |
114 | 117 | int port = (Integer) config.getProperty( CassandraPathDBUtils.PROP_CASSANDRA_PORT ); |
115 | 118 | String username = (String) config.getProperty( CassandraPathDBUtils.PROP_CASSANDRA_USER ); |
116 | 119 | String password = (String) config.getProperty( CassandraPathDBUtils.PROP_CASSANDRA_PASS ); |
| 120 | + Long delay = (Long) config.getProperty( CassandraPathDBUtils.PROP_CASSANDRA_RECONNECT_DELAY ); |
117 | 121 |
|
118 | 122 | Cluster.Builder builder = Cluster.builder().withoutJMXReporting().addContactPoint( host ).withPort( port ); |
| 123 | + if ( delay != null ) |
| 124 | + { |
| 125 | + reconnectDelay = delay; |
| 126 | + } |
| 127 | + builder.withReconnectionPolicy( new ConstantReconnectionPolicy( reconnectDelay ) ); |
| 128 | + |
119 | 129 | if ( isNotBlank( username ) && isNotBlank( password ) ) |
120 | 130 | { |
121 | 131 | logger.debug( "Build with credentials, user: {}, pass: ****", username ); |
|
0 commit comments