Test new datacenter name

This commit is contained in:
Ahmed Salah Tawfik Ibrahim 2023-12-07 14:14:23 +01:00
parent 02bc40b6e8
commit 70d7e31540
2 changed files with 8 additions and 6 deletions

View File

@ -145,7 +145,7 @@ public class CassandraClusterConnection {
CqlSession cqlSession = configBuilder(CqlSession.builder()) CqlSession cqlSession = configBuilder(CqlSession.builder())
.addContactPoints(hosts) .addContactPoints(hosts)
.withKeyspace(KEYSPACE_NAME) .withKeyspace(KEYSPACE_NAME)
.withLocalDatacenter("1") .withLocalDatacenter(datacenterName)
.build(); .build();
_log.info("[OK] Connected to Keyspace {} ", KEYSPACE_NAME); _log.info("[OK] Connected to Keyspace {} ", KEYSPACE_NAME);
return cqlSession; return cqlSession;
@ -180,7 +180,7 @@ public class CassandraClusterConnection {
private static void createKeyspace(String keyspaceName, int replicationFactor) { private static void createKeyspace(String keyspaceName, int replicationFactor) {
try (CqlSession cqlSession = configBuilder(CqlSession.builder()) try (CqlSession cqlSession = configBuilder(CqlSession.builder())
.addContactPoints(hosts) .addContactPoints(hosts)
.withLocalDatacenter("1") .withLocalDatacenter(datacenterName)
.build()) { .build()) {
cqlSession.execute(SchemaBuilder.createKeyspace(keyspaceName) cqlSession.execute(SchemaBuilder.createKeyspace(keyspaceName)
.ifNotExists() .ifNotExists()
@ -196,7 +196,7 @@ public class CassandraClusterConnection {
ResultSet toreturn; ResultSet toreturn;
try (CqlSession cqlSession = configBuilder(CqlSession.builder()) try (CqlSession cqlSession = configBuilder(CqlSession.builder())
.addContactPoints(hosts) .addContactPoints(hosts)
.withLocalDatacenter("1") .withLocalDatacenter(datacenterName)
.build()) { .build()) {
toreturn = cqlSession.execute(SchemaBuilder.dropKeyspace(keyspaceName).ifExists().build()); toreturn = cqlSession.execute(SchemaBuilder.dropKeyspace(keyspaceName).ifExists().build());
_log.info("Keyspace {} dropped.", keyspaceName); _log.info("Keyspace {} dropped.", keyspaceName);
@ -207,7 +207,7 @@ public class CassandraClusterConnection {
private void createTables(){ private void createTables(){
try (CqlSession cqlSession = configBuilder(CqlSession.builder()) try (CqlSession cqlSession = configBuilder(CqlSession.builder())
.addContactPoints(hosts) .addContactPoints(hosts)
.withLocalDatacenter("1") .withLocalDatacenter(datacenterName)
.withKeyspace(keyspaceName) .withKeyspace(keyspaceName)
.build()) { .build()) {

View File

@ -98,8 +98,10 @@ public class RunningCluster implements Serializable {
for (ServiceEndpoint res : resources) { for (ServiceEndpoint res : resources) {
AccessPoint found = res.profile().accessPoints().iterator().next(); AccessPoint found = res.profile().accessPoints().iterator().next();
host = found.address(); host = found.address();
datacenterName = found.description(); //datacenterName = found.description();
keyspaceName = found.name(); datacenterName="d4science_datacenter";
//keyspaceName = found.name();
keyspaceName="dev_keyspace";
} }
} }
} catch (Exception e) { } catch (Exception e) {