From 779586c993dea9ed1a42ed2ad6b95fe0a16dd200 Mon Sep 17 00:00:00 2001 From: yma Date: Mon, 4 Nov 2024 17:22:03 +0800 Subject: [PATCH] Fix Cassandra init issue when reconnect --- .../pathmapped/pathdb/datastax/CassandraPathDB.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/pathdb/datastax/src/main/java/org/commonjava/storage/pathmapped/pathdb/datastax/CassandraPathDB.java b/pathdb/datastax/src/main/java/org/commonjava/storage/pathmapped/pathdb/datastax/CassandraPathDB.java index f2b70ce..650ccc2 100644 --- a/pathdb/datastax/src/main/java/org/commonjava/storage/pathmapped/pathdb/datastax/CassandraPathDB.java +++ b/pathdb/datastax/src/main/java/org/commonjava/storage/pathmapped/pathdb/datastax/CassandraPathDB.java @@ -85,7 +85,7 @@ public class CassandraPathDB private PathMappedStorageConfig config; - private final String keyspace; + private String keyspace; private int replicationFactor = 1; // keyspace replica, default 1 @@ -113,7 +113,11 @@ public CassandraPathDB( PathMappedStorageConfig config, Session session, String public CassandraPathDB( PathMappedStorageConfig config ) { this.config = config; + init(); + } + public void init() + { String host = (String) config.getProperty( CassandraPathDBUtils.PROP_CASSANDRA_HOST ); int port = (Integer) config.getProperty( CassandraPathDBUtils.PROP_CASSANDRA_PORT ); String username = (String) config.getProperty( CassandraPathDBUtils.PROP_CASSANDRA_USER ); @@ -973,7 +977,7 @@ private ResultSet executeSession ( BoundStatement bind ) if ( session == null || session.isClosed() ) { close(); - new CassandraPathDB( config ); + this.init(); } trackingRecord = session.execute( bind ); } @@ -987,7 +991,7 @@ private ResultSet executeSession ( BoundStatement bind ) if ( exception ) { close(); - new CassandraPathDB( config ); + this.init(); trackingRecord = session.execute( bind ); } }