Skip to content

Commit

Permalink
Remove elastic_admin RF adjustment
Browse files Browse the repository at this point in the history
  • Loading branch information
vroyer committed Oct 18, 2019
1 parent 714c0f1 commit 18076ba
Showing 1 changed file with 6 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1225,30 +1225,21 @@ public void createOrUpdateElasticAdminKeyspace() {
logger.error((Supplier<?>) () -> new ParameterizedMessage("Failed to initialize table {}.{}", elasticAdminKeyspaceName, ELASTIC_ADMIN_METADATA_TABLE),e);
}
} else {
// adjust keyspace RF to the number of nodes
// check keyspace RF to the number of nodes
Map<String,String> replication = result.one().getFrozenTextMap("replication");
logger.debug("keyspace={} replication={}", elasticAdminKeyspaceName, replication);

if (!NetworkTopologyStrategy.class.getName().equals(replication.get("class")))
throw new ConfigurationException("Keyspace ["+this.elasticAdminKeyspaceName+"] should use "+NetworkTopologyStrategy.class.getName()+" replication strategy");

int currentRF = -1;
if (replication.get(DatabaseDescriptor.getLocalDataCenter()) != null) {
if (replication.get(DatabaseDescriptor.getLocalDataCenter()) != null && replication.containsKey(DatabaseDescriptor.getLocalDataCenter())) {
currentRF = Integer.valueOf(replication.get(DatabaseDescriptor.getLocalDataCenter()).toString());
}
int targetRF = getLocalDataCenterSize();
if (targetRF != currentRF) {
replication.put(DatabaseDescriptor.getLocalDataCenter(), Integer.toString(targetRF));
try {
String query = String.format(Locale.ROOT, "ALTER KEYSPACE \"%s\" WITH replication = %s",
elasticAdminKeyspaceName, FBUtilities.json(replication).replaceAll("\"", "'"));
logger.info(query);
process(ConsistencyLevel.LOCAL_ONE, ClientState.forInternalCalls(), query);
} catch (Throwable e) {
logger.error((Supplier<?>) () -> new ParameterizedMessage("Failed to alter keyspace [{}]", elasticAdminKeyspaceName), e);
}
} else {
logger.info("Keep unchanged keyspace={} datacenter={} RF={}", elasticAdminKeyspaceName, DatabaseDescriptor.getLocalDataCenter(), targetRF);
if (currentRF < 3) {
logger.warn("Keyspace [{}] replication factor {}={}, you should increase this replication factor " +
"to avoid possible issue if quorum cannot be reach to update the elasticsearch mapping.",
this.elasticAdminKeyspaceName, DatabaseDescriptor.getLocalDataCenter(), currentRF);
}
}

Expand Down

0 comments on commit 18076ba

Please sign in to comment.