Skip to content

Commit 779586c

Browse files
committed
Fix Cassandra init issue when reconnect
1 parent 6ed2ca5 commit 779586c

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

pathdb/datastax/src/main/java/org/commonjava/storage/pathmapped/pathdb/datastax/CassandraPathDB.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public class CassandraPathDB
8585

8686
private PathMappedStorageConfig config;
8787

88-
private final String keyspace;
88+
private String keyspace;
8989

9090
private int replicationFactor = 1; // keyspace replica, default 1
9191

@@ -113,7 +113,11 @@ public CassandraPathDB( PathMappedStorageConfig config, Session session, String
113113
public CassandraPathDB( PathMappedStorageConfig config )
114114
{
115115
this.config = config;
116+
init();
117+
}
116118

119+
public void init()
120+
{
117121
String host = (String) config.getProperty( CassandraPathDBUtils.PROP_CASSANDRA_HOST );
118122
int port = (Integer) config.getProperty( CassandraPathDBUtils.PROP_CASSANDRA_PORT );
119123
String username = (String) config.getProperty( CassandraPathDBUtils.PROP_CASSANDRA_USER );
@@ -973,7 +977,7 @@ private ResultSet executeSession ( BoundStatement bind )
973977
if ( session == null || session.isClosed() )
974978
{
975979
close();
976-
new CassandraPathDB( config );
980+
this.init();
977981
}
978982
trackingRecord = session.execute( bind );
979983
}
@@ -987,7 +991,7 @@ private ResultSet executeSession ( BoundStatement bind )
987991
if ( exception )
988992
{
989993
close();
990-
new CassandraPathDB( config );
994+
this.init();
991995
trackingRecord = session.execute( bind );
992996
}
993997
}

0 commit comments

Comments
 (0)