use of com.netflix.astyanax.impl.AstyanaxConfigurationImpl in project coprhd-controller by CoprHD.
the class DbClientContext method checkAndResetConsistencyLevel.
private void checkAndResetConsistencyLevel(DrUtil drUtil, String svcName) {
if (isRetryFailedWriteWithLocalQuorum() && drUtil.isMultivdc()) {
log.info("Disable retry for write failure in multiple vdc configuration");
setRetryFailedWriteWithLocalQuorum(false);
return;
}
ConsistencyLevel currentConsistencyLevel = getKeyspace().getConfig().getDefaultWriteConsistencyLevel();
if (currentConsistencyLevel.equals(ConsistencyLevel.CL_EACH_QUORUM)) {
log.debug("Write consistency level is EACH_QUORUM. No need adjust");
return;
}
log.info("Db consistency level for {} is downgraded as LOCAL_QUORUM. Check if we need reset it back", svcName);
for (Site site : drUtil.listStandbySites()) {
if (site.getState().equals(SiteState.STANDBY_PAUSED) || site.getState().equals(SiteState.STANDBY_DEGRADED)) {
// ignore a standby site which is paused by customer explicitly
continue;
}
String siteUuid = site.getUuid();
int count = drUtil.getNumberOfLiveServices(siteUuid, svcName);
if (count <= site.getNodeCount() / 2) {
log.info("Service {} of quorum nodes on site {} is down. Still keep write consistency level to LOCAL_QUORUM", svcName, siteUuid);
return;
}
}
log.info("Service {} of quorum nodes on all standby sites are up. Reset default write consistency level back to EACH_QUORUM", svcName);
AstyanaxConfigurationImpl config = (AstyanaxConfigurationImpl) keyspaceContext.getAstyanaxConfiguration();
config.setDefaultWriteConsistencyLevel(ConsistencyLevel.CL_EACH_QUORUM);
}
Aggregations