Search in sources :

Example 41 with Site

use of com.emc.storageos.coordinator.client.model.Site in project coprhd-controller by CoprHD.

the class SchemaUtil method checkStrategyOptionsForDROnActive.

/**
 * Remove paused sites from db/geodb strategy options on the active site.
 *
 * @param strategyOptions
 * @return true to indicate keyspace strategy option is changed
 */
private boolean checkStrategyOptionsForDROnActive(Map<String, String> strategyOptions) {
    boolean changed = false;
    // iterate through all the sites and exclude the paused ones
    for (Site site : drUtil.listSites()) {
        String dcId = drUtil.getCassandraDcId(site);
        if (site.getState().equals(SiteState.STANDBY_PAUSED) && strategyOptions.containsKey(dcId)) {
            _log.info("Remove dc {} from strategy options", dcId);
            strategyOptions.remove(dcId);
            changed = true;
        }
    }
    return changed;
}
Also used : Site(com.emc.storageos.coordinator.client.model.Site)

Example 42 with Site

use of com.emc.storageos.coordinator.client.model.Site in project coprhd-controller by CoprHD.

the class SchemaUtil method checkStrategyOptionsForGeo.

/**
 * Add new VDC into the geodb strategy options
 *
 * @param strategyOptions
 * @return true to indicate keyspace strategy option is changed
 */
private boolean checkStrategyOptionsForGeo(Map<String, String> strategyOptions) {
    if (onStandby) {
        _log.info("Only active site updates geo strategy operation. Do nothing on standby site");
        return false;
    }
    if (!isGeoDbsvc()) {
        // update local db strategy option in multivdc configuration only
        if (!drUtil.isMultivdc()) {
            return false;
        }
        if (backCompatPreYoda) {
            _log.info("Upgraded from preyoda release. Keep db strategy options unchanged.");
            return false;
        }
        // for local db, check if current vdc id is in the list
        if (!strategyOptions.containsKey(_vdcShortId)) {
            strategyOptions.clear();
            _log.info("Add {} to strategy options", _vdcShortId);
            strategyOptions.put(_vdcShortId, Integer.toString(getReplicationFactor()));
            return true;
        }
        return false;
    }
    _log.debug("vdcList = {}", _vdcList);
    // on newly added vdc - vdc short id is changed
    if (_vdcList.size() == 1 && !_vdcList.contains(_vdcShortId)) {
        strategyOptions.clear();
    }
    // on removed vdc, its strategyOption need be reset
    boolean isDrConfig = drUtil.listSites().size() > 1;
    if (_vdcList.size() == 1 && strategyOptions.size() > 1 && !isDrConfig) {
        strategyOptions.clear();
    }
    String dcName = _vdcShortId;
    Site currentSite = null;
    try {
        currentSite = drUtil.getLocalSite();
    } catch (Exception e) {
    // ignore
    }
    if (currentSite != null) {
        dcName = drUtil.getCassandraDcId(currentSite);
    }
    if (strategyOptions.containsKey(dcName)) {
        return false;
    }
    _log.info("Add {} to strategy options", dcName);
    strategyOptions.put(dcName, Integer.toString(getReplicationFactor()));
    return true;
}
Also used : Site(com.emc.storageos.coordinator.client.model.Site) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) OperationException(com.netflix.astyanax.connectionpool.exceptions.OperationException) ConnectionException(com.netflix.astyanax.connectionpool.exceptions.ConnectionException) UnknownHostException(java.net.UnknownHostException)

Example 43 with Site

use of com.emc.storageos.coordinator.client.model.Site in project coprhd-controller by CoprHD.

the class SchemaUtil method checkAndInitSchemaOnStandby.

private boolean checkAndInitSchemaOnStandby(KeyspaceDefinition kd) throws ConnectionException {
    _log.info("try scan and setup db on standby site ...");
    if (kd == null) {
        _log.info("keyspace not exist yet. Wait {} seconds for schema from active site", DBINIT_RETRY_INTERVAL);
        return false;
    } else {
        _log.info("keyspace exist already");
        String currentDbSchemaVersion = _coordinator.getCurrentDbSchemaVersion();
        if (currentDbSchemaVersion == null) {
            _log.info("set current version for standby site {}", _service.getVersion());
            setCurrentVersion(_service.getVersion());
        }
        Site currentSite = drUtil.getLocalSite();
        if (SiteState.STANDBY_SYNCING.equals(currentSite.getState())) {
            // and shouldn't be relied on any more.
            while (clientContext.ensureSchemaAgreement()) {
                // one reachable node from the other site (which contains the latest db schema).
                if (getReachableDcCount() > 1) {
                    break;
                }
            }
        }
        checkStrategyOptions();
        return true;
    }
}
Also used : Site(com.emc.storageos.coordinator.client.model.Site)

Example 44 with Site

use of com.emc.storageos.coordinator.client.model.Site in project coprhd-controller by CoprHD.

the class StorageDriverManager method updateMetaData.

private void updateMetaData() {
    Site activeSite = drUtil.getActiveSite();
    List<StorageDriversInfo> infos = getDriversInfo(activeSite.getUuid());
    if (activeSite.getNodeCount() != infos.size()) {
        log.warn("Not all nodes are online, skip updating meta data");
        return;
    }
    boolean installFinished = updateInstallMetadata(infos);
    boolean uninstallFinished = updateUninstallMetadata(infos);
    boolean upgradeFinished = updateUpgradeMetadata(infos);
    if (installFinished || uninstallFinished || upgradeFinished) {
        restartControllerServices();
    }
}
Also used : Site(com.emc.storageos.coordinator.client.model.Site) StorageDriversInfo(com.emc.storageos.coordinator.client.model.StorageDriversInfo)

Example 45 with Site

use of com.emc.storageos.coordinator.client.model.Site in project coprhd-controller by CoprHD.

the class StorageDriverManager method hasActiveSiteFinishDownload.

private boolean hasActiveSiteFinishDownload(String driverFileName) {
    Site activeSite = drUtil.getActiveSite();
    String activeSiteId = activeSite.getUuid();
    List<StorageDriversInfo> infos = getDriversInfo(activeSiteId);
    if (activeSite.getNodeCount() != infos.size()) {
        // there're offline node in active site
        return false;
    }
    for (StorageDriversInfo info : infos) {
        if (!info.getInstalledDrivers().contains(driverFileName)) {
            return false;
        }
    }
    return true;
}
Also used : Site(com.emc.storageos.coordinator.client.model.Site) StorageDriversInfo(com.emc.storageos.coordinator.client.model.StorageDriversInfo)

Aggregations

Site (com.emc.storageos.coordinator.client.model.Site)79 RetryableCoordinatorException (com.emc.storageos.coordinator.exceptions.RetryableCoordinatorException)21 APIException (com.emc.storageos.svcs.errorhandling.resources.APIException)21 CoordinatorException (com.emc.storageos.coordinator.exceptions.CoordinatorException)20 UnknownHostException (java.net.UnknownHostException)18 Produces (javax.ws.rs.Produces)17 InternalServerErrorException (com.emc.storageos.svcs.errorhandling.resources.InternalServerErrorException)16 Path (javax.ws.rs.Path)15 ZkPath (com.emc.storageos.coordinator.common.impl.ZkPath)14 ArrayList (java.util.ArrayList)14 DrUtil (com.emc.storageos.coordinator.client.service.DrUtil)11 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)11 InterProcessLock (org.apache.curator.framework.recipes.locks.InterProcessLock)11 SiteInfo (com.emc.storageos.coordinator.client.model.SiteInfo)10 POST (javax.ws.rs.POST)10 SiteState (com.emc.storageos.coordinator.client.model.SiteState)9 Configuration (com.emc.storageos.coordinator.common.Configuration)8 VirtualDataCenter (com.emc.storageos.db.client.model.VirtualDataCenter)8 Consumes (javax.ws.rs.Consumes)8 ClusterInfo (com.emc.vipr.model.sys.ClusterInfo)6