Search in sources :

Example 6 with AstyanaxConfigurationImpl

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);
}
Also used : ConsistencyLevel(com.netflix.astyanax.model.ConsistencyLevel) Site(com.emc.storageos.coordinator.client.model.Site) AstyanaxConfigurationImpl(com.netflix.astyanax.impl.AstyanaxConfigurationImpl)

Aggregations

AstyanaxConfigurationImpl (com.netflix.astyanax.impl.AstyanaxConfigurationImpl)6 ConnectionPoolConfigurationImpl (com.netflix.astyanax.connectionpool.impl.ConnectionPoolConfigurationImpl)4 AstyanaxContext (com.netflix.astyanax.AstyanaxContext)3 SSLConnectionContext (com.netflix.astyanax.connectionpool.SSLConnectionContext)3 ConnectionException (com.netflix.astyanax.connectionpool.exceptions.ConnectionException)3 NodeDiscoveryType (com.netflix.astyanax.connectionpool.NodeDiscoveryType)2 CountingConnectionPoolMonitor (com.netflix.astyanax.connectionpool.impl.CountingConnectionPoolMonitor)2 ConsistencyLevel (com.netflix.astyanax.model.ConsistencyLevel)2 List (java.util.List)2 ConfigurationException (org.apache.cassandra.exceptions.ConfigurationException)2 Site (com.emc.storageos.coordinator.client.model.Site)1 DrUtil (com.emc.storageos.coordinator.client.service.DrUtil)1 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)1 Keyspace (com.netflix.astyanax.Keyspace)1 Host (com.netflix.astyanax.connectionpool.Host)1 ConnectionPoolType (com.netflix.astyanax.connectionpool.impl.ConnectionPoolType)1 SimpleAuthenticationCredentials (com.netflix.astyanax.connectionpool.impl.SimpleAuthenticationCredentials)1 Murmur3Partitioner (com.netflix.astyanax.partitioner.Murmur3Partitioner)1 Partitioner (com.netflix.astyanax.partitioner.Partitioner)1 PermanentStorageException (com.thinkaurelius.titan.diskstorage.PermanentStorageException)1