private static boolean attemptToCreateKeyspaceOnHost(InetSocketAddress host, CassandraKeyValueServiceConfig config) throws TException { try { CassandraClient client = CassandraClientFactory.getClientInternal(host, config); KsDef ksDef = createKsDefForFresh(client, config); client.system_add_keyspace(ksDef); log.info("Created keyspace: {}", SafeArg.of("keyspace", config.getKeyspaceOrThrow())); CassandraKeyValueServices.waitForSchemaVersions(config, client, "after adding the initial empty keyspace"); return true; } catch (InvalidRequestException e) { return keyspaceAlreadyExists(host, config); } }
@Test public void freshInstanceSetsStrategyOptions() throws TException { setTopology(createDetails(DC_1, RACK_1, HOST_1), createDetails(DC_1, RACK_1, HOST_2), createDetails(DC_1, RACK_1, HOST_3), createDetails(DC_2, RACK_1, HOST_4)); when(config.replicationFactor()).thenReturn(3); KsDef ksDef = CassandraVerifier.createKsDefForFresh(client, config); assertThat(ksDef.strategy_options).isEqualTo(ImmutableMap.of(DC_1, "3", DC_2, "3")); }
private static boolean attemptToCreateKeyspaceOnHost(InetSocketAddress host, CassandraKeyValueServiceConfig config) throws TException { try { CassandraClient client = CassandraClientFactory.getClientInternal(host, config); KsDef ksDef = createKsDefForFresh(client, config); client.system_add_keyspace(ksDef); log.info("Created keyspace: {}", SafeArg.of("keyspace", config.getKeyspaceOrThrow())); CassandraKeyValueServices.waitForSchemaVersions(config, client, "after adding the initial empty keyspace"); return true; } catch (InvalidRequestException e) { return keyspaceAlreadyExists(host, config); } }