Search in sources :

Example 6 with DrUtil

use of com.emc.storageos.coordinator.client.service.DrUtil in project coprhd-controller by CoprHD.

the class DbClientContext method init.

public void init(final HostSupplierImpl hostSupplier) {
    String svcName = hostSupplier.getDbSvcName();
    log.info("Initializing hosts for {}", svcName);
    List<Host> hosts = hostSupplier.get();
    if ((hosts != null) && (hosts.isEmpty())) {
        throw new IllegalStateException(String.format("DbClientContext.init() : host list in hostsupplier for %s is empty", svcName));
    } else {
        int hostCount = hosts == null ? 0 : hosts.size();
        log.info(String.format("number of hosts in the hostsupplier for %s is %d", svcName, hostCount));
    }
    Partitioner murmur3partitioner = Murmur3Partitioner.get();
    Map<String, Partitioner> partitioners = new HashMap<>();
    partitioners.put("org.apache.cassandra.dht.Murmur3Partitioner.class.getCanonicalName()", murmur3partitioner);
    ConsistencyLevel readCL = ConsistencyLevel.CL_LOCAL_QUORUM;
    ConsistencyLevel writeCL = ConsistencyLevel.CL_EACH_QUORUM;
    ConnectionPoolConfigurationImpl cfg = new ConnectionPoolConfigurationImpl(DEFAULT_CN_POOL_NANE).setMaxConns(maxConnections).setMaxConnsPerHost(maxConnectionsPerHost).setConnectTimeout(DEFAULT_CONN_TIMEOUT).setMaxBlockedThreadsPerHost(DEFAULT_MAX_BLOCKED_THREADS).setPartitioner(murmur3partitioner);
    log.info("The client to node is encrypted={}", isClientToNodeEncrypted);
    if (isClientToNodeEncrypted) {
        SSLConnectionContext sslContext = getSSLConnectionContext();
        cfg.setSSLConnectionContext(sslContext);
    }
    // TODO revisit it to see if we need set different retry policy, timeout, discovery delay etc for geodb
    keyspaceContext = new AstyanaxContext.Builder().withHostSupplier(hostSupplier).forCluster(clusterName).forKeyspace(keyspaceName).withAstyanaxConfiguration(new AstyanaxConfigurationImpl().setConnectionPoolType(ConnectionPoolType.ROUND_ROBIN).setDiscoveryDelayInSeconds(svcListPoolIntervalSec).setDefaultReadConsistencyLevel(readCL).setDefaultWriteConsistencyLevel(writeCL).setTargetCassandraVersion("2.0").setPartitioners(partitioners).setRetryPolicy(retryPolicy)).withConnectionPoolConfiguration(cfg).withTracerFactory(new KeyspaceTracerFactoryImpl()).withConnectionPoolMonitor(new CustomConnectionPoolMonitor(monitorIntervalSecs)).buildKeyspace(ThriftFamilyFactory.getInstance());
    keyspaceContext.start();
    keyspace = keyspaceContext.getClient();
    // Check and reset default write consistency level
    final DrUtil drUtil = new DrUtil(hostSupplier.getCoordinatorClient());
    if (drUtil.isMultivdc()) {
        // geodb in mutlivdc should be EACH_QUORUM always. Never retry for write failures
        setRetryFailedWriteWithLocalQuorum(false);
        log.info("Retry for failed write with LOCAL_QUORUM: {}", retryFailedWriteWithLocalQuorum);
    } else {
        setRetryFailedWriteWithLocalQuorum(true);
    }
    if (drUtil.isActiveSite() && !drUtil.isMultivdc()) {
        log.info("Schedule db consistency level monitor on DR active site");
        exe.scheduleWithFixedDelay(new Runnable() {

            @Override
            public void run() {
                try {
                    checkAndResetConsistencyLevel(drUtil, hostSupplier.getDbSvcName());
                } catch (Exception ex) {
                    log.warn("Encounter Unexpected exception during check consistency level. Retry in next run", ex);
                }
            }
        }, 60, DEFAULT_CONSISTENCY_LEVEL_CHECK_SEC, TimeUnit.SECONDS);
    }
    initDone = true;
}
Also used : HashMap(java.util.HashMap) DrUtil(com.emc.storageos.coordinator.client.service.DrUtil) Host(com.netflix.astyanax.connectionpool.Host) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) ConnectionException(com.netflix.astyanax.connectionpool.exceptions.ConnectionException) ConsistencyLevel(com.netflix.astyanax.model.ConsistencyLevel) SSLConnectionContext(com.netflix.astyanax.connectionpool.SSLConnectionContext) ConnectionPoolConfigurationImpl(com.netflix.astyanax.connectionpool.impl.ConnectionPoolConfigurationImpl) AstyanaxContext(com.netflix.astyanax.AstyanaxContext) AstyanaxConfigurationImpl(com.netflix.astyanax.impl.AstyanaxConfigurationImpl) Murmur3Partitioner(com.netflix.astyanax.partitioner.Murmur3Partitioner) Partitioner(com.netflix.astyanax.partitioner.Partitioner)

Example 7 with DrUtil

use of com.emc.storageos.coordinator.client.service.DrUtil in project coprhd-controller by CoprHD.

the class CoordinatorClientImpl method isDatabaseServiceUp.

private Boolean isDatabaseServiceUp(String serviceName) {
    try {
        String siteId = _zkConnection.getSiteId();
        List<Service> services = locateAllServices(siteId, serviceName, dbVersionInfo.getSchemaVersion(), null, null);
        DrUtil drUtil = new DrUtil(this);
        Site site = drUtil.getSiteFromLocalVdc(siteId);
        log.info("Node count is {}, running {} count is {}", site.getNodeCount(), serviceName, services.size());
        return services.size() == site.getNodeCount();
    } catch (CoordinatorException e) {
        return false;
    }
}
Also used : Site(com.emc.storageos.coordinator.client.model.Site) CoordinatorException(com.emc.storageos.coordinator.exceptions.CoordinatorException) RetryableCoordinatorException(com.emc.storageos.coordinator.exceptions.RetryableCoordinatorException) DrUtil(com.emc.storageos.coordinator.client.service.DrUtil) Service(com.emc.storageos.coordinator.common.Service) ExecutorService(java.util.concurrent.ExecutorService) PropertyInfoMapper.decodeFromString(com.emc.storageos.coordinator.mapper.PropertyInfoMapper.decodeFromString)

Example 8 with DrUtil

use of com.emc.storageos.coordinator.client.service.DrUtil in project coprhd-controller by CoprHD.

the class CoordinatorClientImpl method createSiteSpecificSection.

private void createSiteSpecificSection() throws Exception {
    // create VDC parent ZNode for site config in ZK
    ConfigurationImpl vdcConfig = new ConfigurationImpl();
    vdcConfig.setKind(Site.CONFIG_KIND);
    vdcConfig.setId(vdcShortId);
    persistServiceConfiguration(vdcConfig);
    // insert DR active site info to ZK
    Site site = new Site();
    site.setUuid(getSiteId());
    site.setName("Default Site");
    site.setVdcShortId(vdcShortId);
    site.setSiteShortId(Constants.CONFIG_DR_FIRST_SITE_SHORT_ID);
    site.setState(SiteState.ACTIVE);
    site.setCreationTime(System.currentTimeMillis());
    if (StringUtils.isBlank(vip)) {
        site.setVip(PropertyConstants.IPV4_ADDR_DEFAULT);
    } else {
        site.setVip(vip);
    }
    if (StringUtils.isBlank(vip6)) {
        site.setVip6(PropertyConstants.IPV6_ADDR_DEFAULT);
    } else {
        site.setVip6(DualInetAddress.normalizeInet6Address(vip6));
    }
    site.setNodeCount(getNodeCount());
    Map<String, DualInetAddress> controlNodes = getInetAddessLookupMap().getControllerNodeIPLookupMap();
    Map<String, String> ipv4Addresses = new HashMap<>();
    Map<String, String> ipv6Addresses = new HashMap<>();
    String nodeId;
    int nodeIndex = 1;
    for (Map.Entry<String, DualInetAddress> cnode : controlNodes.entrySet()) {
        nodeId = VDC_NODE_PREFIX + nodeIndex++;
        DualInetAddress addr = cnode.getValue();
        if (addr.hasInet4()) {
            ipv4Addresses.put(nodeId, addr.getInet4());
        } else {
            ipv4Addresses.put(nodeId, PropertyConstants.IPV4_ADDR_DEFAULT);
        }
        if (addr.hasInet6()) {
            ipv6Addresses.put(nodeId, DualInetAddress.normalizeInet6Address(addr.getInet6()));
        } else {
            ipv6Addresses.put(nodeId, PropertyConstants.IPV6_ADDR_DEFAULT);
        }
    }
    site.setHostIPv4AddressMap(ipv4Addresses);
    site.setHostIPv6AddressMap(ipv6Addresses);
    persistServiceConfiguration(site.toConfiguration());
    new DrUtil(this).setLocalVdcShortId(vdcShortId);
    // update Site version in ZK
    SiteInfo siteInfo = new SiteInfo(System.currentTimeMillis(), SiteInfo.NONE);
    setTargetInfo(siteInfo);
    addSite(site.getUuid());
    log.info("Create site specific section for {} successfully", site.getUuid());
}
Also used : Site(com.emc.storageos.coordinator.client.model.Site) SiteInfo(com.emc.storageos.coordinator.client.model.SiteInfo) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) DrUtil(com.emc.storageos.coordinator.client.service.DrUtil) PropertyInfoMapper.decodeFromString(com.emc.storageos.coordinator.mapper.PropertyInfoMapper.decodeFromString) ConfigurationImpl(com.emc.storageos.coordinator.common.impl.ConfigurationImpl) Map(java.util.Map) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) ConcurrentMap(java.util.concurrent.ConcurrentMap)

Example 9 with DrUtil

use of com.emc.storageos.coordinator.client.service.DrUtil in project coprhd-controller by CoprHD.

the class ZkCmdHandler method rollbackDataRevision.

public void rollbackDataRevision() throws Exception {
    DrUtil drUtil = new DrUtil(ZKUtil.getCoordinatorClient());
    if (!precheckForRollback(drUtil)) {
        return;
    }
    LocalRepository localRepository = LocalRepository.getInstance();
    PropertyInfoExt localDataRevisionProps = localRepository.getDataRevisionPropertyInfo();
    String prevRevision = localDataRevisionProps.getProperty(Constants.KEY_PREV_DATA_REVISION);
    log.info("Previous data revision at local {}", prevRevision);
    if (StringUtils.isNotEmpty(prevRevision)) {
        long rollbackTargetRevision = Long.parseLong(prevRevision);
        drUtil.updateVdcTargetVersion(drUtil.getLocalSite().getUuid(), SiteInfo.DR_OP_CHANGE_DATA_REVISION, DrUtil.newVdcConfigVersion(), rollbackTargetRevision);
        log.info("Manual rollback to {} has been triggered", rollbackTargetRevision);
        System.out.println(String.format("Rollback to %s has been initiated successfully", prevRevision));
    } else {
        log.warn("No valid previous revision found. Skip rollback");
        System.out.println("Can't find viable previous data revision. Rollback oparation has been aborted");
    }
}
Also used : PropertyInfoExt(com.emc.storageos.coordinator.client.model.PropertyInfoExt) DrUtil(com.emc.storageos.coordinator.client.service.DrUtil) LocalRepository(com.emc.storageos.systemservices.impl.upgrade.LocalRepository)

Example 10 with DrUtil

use of com.emc.storageos.coordinator.client.service.DrUtil in project coprhd-controller by CoprHD.

the class RecoveryManager method informHibernateNodeToReconfigure.

private void informHibernateNodeToReconfigure() {
    DrUtil drUtil = new DrUtil(coordinator.getCoordinatorClient());
    if (drUtil.isMultisite()) {
        InterProcessLock lock = null;
        try {
            lock = drUtil.getDROperationLock();
            long vdcConfigVersion = DrUtil.newVdcConfigVersion();
            log.info("Has multi sites, informing the hibernate nodes to reconfigure..");
            drUtil.updateVdcTargetVersion(coordinator.getCoordinatorClient().getSiteId(), SiteInfo.DR_OP_NODE_RECOVERY, vdcConfigVersion);
        } catch (Exception e) {
            log.error("Failed to inform the hibernate nodes to reconfigure", e);
        } finally {
            try {
                if (lock != null) {
                    lock.release();
                }
            } catch (Exception ignore) {
                log.error("Release lock failed when node recovery", ignore);
            }
        }
    }
}
Also used : DrUtil(com.emc.storageos.coordinator.client.service.DrUtil) InterProcessLock(org.apache.curator.framework.recipes.locks.InterProcessLock) APIException(com.emc.storageos.svcs.errorhandling.resources.APIException) SysClientException(com.emc.storageos.systemservices.exceptions.SysClientException)

Aggregations

DrUtil (com.emc.storageos.coordinator.client.service.DrUtil)26 Site (com.emc.storageos.coordinator.client.model.Site)11 DbClientContext (com.emc.storageos.db.client.impl.DbClientContext)4 SiteInfo (com.emc.storageos.coordinator.client.model.SiteInfo)3 CoordinatorClientInetAddressMap (com.emc.storageos.coordinator.client.service.impl.CoordinatorClientInetAddressMap)3 ConfigurationImpl (com.emc.storageos.coordinator.common.impl.ConfigurationImpl)3 PropertyInfoMapper.decodeFromString (com.emc.storageos.coordinator.mapper.PropertyInfoMapper.decodeFromString)3 SiteState (com.emc.storageos.coordinator.client.model.SiteState)2 CoordinatorClient (com.emc.storageos.coordinator.client.service.CoordinatorClient)2 Configuration (com.emc.storageos.coordinator.common.Configuration)2 Service (com.emc.storageos.coordinator.common.Service)2 APIException (com.emc.storageos.svcs.errorhandling.resources.APIException)2 SysClientException (com.emc.storageos.systemservices.exceptions.SysClientException)2 ClusterInfo (com.emc.vipr.model.sys.ClusterInfo)2 IOException (java.io.IOException)2 HashMap (java.util.HashMap)2 Before (org.junit.Before)2 SiteMapper (com.emc.storageos.api.mapper.SiteMapper)1 DbVersionInfo (com.emc.storageos.coordinator.client.model.DbVersionInfo)1 MigrationStatus (com.emc.storageos.coordinator.client.model.MigrationStatus)1