Search in sources :

Example 11 with Site

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

the class DbManager method getSite.

private Site getSite(InetAddress endpoint) {
    IEndpointSnitch snitch = DatabaseDescriptor.getEndpointSnitch();
    String dcName = snitch.getDatacenter(endpoint);
    for (Site site : drUtil.listSites()) {
        String cassandraDcId = drUtil.getCassandraDcId(site);
        if (cassandraDcId.equals(dcName)) {
            return site;
        }
    }
    return null;
}
Also used : Site(com.emc.storageos.coordinator.client.model.Site) IEndpointSnitch(org.apache.cassandra.locator.IEndpointSnitch)

Example 12 with Site

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

the class DbRebuildRunnable method run.

@Override
public void run() {
    if (isRunning) {
        log.info("db rebuild in progress, nothing to do");
        return;
    }
    DrUtil drUtil = new DrUtil(coordinator);
    Site localSite = drUtil.getLocalSite();
    if (!localSite.getState().equals(SiteState.STANDBY_SYNCING)) {
        log.info("db in sync, nothing to do");
        return;
    }
    Configuration dbconfig = coordinator.queryConfiguration(coordinator.getSiteId(), coordinator.getVersionedDbConfigPath(service.getName(), service.getVersion()), service.getId());
    if (isLastDataSyncCurrent(dbconfig)) {
        log.info("last data sync time is later than the target site info update, nothing to do");
        return;
    }
    Site primarySite = drUtil.getActiveSite();
    String sourceDc = drUtil.getCassandraDcId(primarySite);
    log.info("starting db rebuild from source dc {}", sourceDc);
    isRunning = true;
    StorageService.instance.rebuild(sourceDc);
    long currentSyncTime = System.currentTimeMillis();
    log.info("local db rebuild finishes. Updating last data sync time to {}", currentSyncTime);
    dbconfig.setConfig(DbConfigConstants.LAST_DATA_SYNC_TIME, String.valueOf(currentSyncTime));
    coordinator.persistServiceConfiguration(coordinator.getSiteId(), dbconfig);
    if (dbRebuildComplete(Constants.DBSVC_NAME) && dbRebuildComplete(Constants.GEODBSVC_NAME)) {
        localSite = drUtil.getLocalSite();
        // do nothing if it gets set to STANDBY_ERROR earlier
        if (localSite.getState().equals(SiteState.STANDBY_SYNCING)) {
            purgeOldDataRevision(drUtil);
            // reset heartbeat for this site
            SiteMonitorResult dbHeartbeat = coordinator.getTargetInfo(localSite.getUuid(), SiteMonitorResult.class);
            if (dbHeartbeat != null) {
                dbHeartbeat.setDbQuorumLostSince(0);
                coordinator.setTargetInfo(localSite.getUuid(), dbHeartbeat);
                log.info("Reset db heartbeat state for {}", localSite.getUuid());
            }
            log.info("all db rebuild finish, updating site state to STANDBY_SYNCED");
            localSite.setState(SiteState.STANDBY_SYNCED);
            coordinator.persistServiceConfiguration(localSite.toConfiguration());
        }
    }
    isRunning = false;
}
Also used : Site(com.emc.storageos.coordinator.client.model.Site) Configuration(com.emc.storageos.coordinator.common.Configuration) SiteMonitorResult(com.emc.storageos.coordinator.client.model.SiteMonitorResult) DrUtil(com.emc.storageos.coordinator.client.service.DrUtil)

Example 13 with Site

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

the class DrInternodeAuthenticator method validateConfiguration.

/**
 * Called by Cassandra startup routine to initialize this instance
 */
@Override
public void validateConfiguration() throws ConfigurationException {
    log.info("Initializing DrInternodeAuthenticator");
    CoordinatorClient coordinatorClient = DbServiceImpl.instance.getCoordinator();
    DrUtil drUtil = new DrUtil(coordinatorClient);
    Site localSite = drUtil.getLocalSite();
    isStandbyDegraded = localSite.getState().equals(SiteState.STANDBY_DEGRADED) || localSite.getState().equals(SiteState.STANDBY_DEGRADING);
    isStandbyPaused = localSite.getState().equals(SiteState.STANDBY_PAUSING) || localSite.getState().equals(SiteState.STANDBY_PAUSED);
    isActiveDegraded = localSite.getState().equals(SiteState.ACTIVE_DEGRADED);
    Collection<String> nodeAddrList = localSite.getHostIPv4AddressMap().values();
    if (!localSite.isUsingIpv4()) {
        nodeAddrList = localSite.getHostIPv6AddressMap().values();
    }
    for (String nodeAddr : nodeAddrList) {
        try {
            localAddresses.add(InetAddress.getByName(nodeAddr));
        } catch (UnknownHostException e) {
            log.error("Invalid IP address {}", nodeAddr);
        }
    }
}
Also used : Site(com.emc.storageos.coordinator.client.model.Site) UnknownHostException(java.net.UnknownHostException) DrUtil(com.emc.storageos.coordinator.client.service.DrUtil) CoordinatorClient(com.emc.storageos.coordinator.client.service.CoordinatorClient)

Example 14 with Site

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

the class SchemaUtil method checkDataRevision.

public void checkDataRevision(String localDataRevision) {
    Site currentSite = drUtil.getLocalSite();
    SiteState siteState = currentSite.getState();
    if (siteState == SiteState.STANDBY_ADDING || siteState == SiteState.STANDBY_RESUMING || siteState == SiteState.STANDBY_SYNCING) {
        SiteInfo targetSiteInfo = _coordinator.getTargetInfo(_coordinator.getSiteId(), SiteInfo.class);
        String targetDataRevision = targetSiteInfo.getTargetDataRevision();
        _log.info("Target data revision {}", targetDataRevision);
        if (localDataRevision.equals(targetDataRevision)) {
            if (siteState != SiteState.STANDBY_SYNCING) {
                _log.info("Change site state to SYNCING and rebuild data from active site");
                currentSite.setLastState(siteState);
                currentSite.setState(SiteState.STANDBY_SYNCING);
                _coordinator.persistServiceConfiguration(currentSite.toConfiguration());
            }
            dbRebuildRunnable.run();
        } else {
            _log.info("Incompatible data revision - local {} target {}. Skip data rebuild", localDataRevision, targetDataRevision);
        }
    }
}
Also used : Site(com.emc.storageos.coordinator.client.model.Site) SiteInfo(com.emc.storageos.coordinator.client.model.SiteInfo) SiteState(com.emc.storageos.coordinator.client.model.SiteState)

Example 15 with Site

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

the class SchemaUtil method checkStrategyOptionsForDROnStandby.

/**
 * Put to be added or resumed standby site into the db/geodb strategy options on each new standby site
 *
 * @param strategyOptions
 * @return true to indicate keyspace strategy option is changed
 */
private boolean checkStrategyOptionsForDROnStandby(Map<String, String> strategyOptions) {
    // no need to add new site on active site, since dbsvc/geodbsvc are not restarted
    String dcId = drUtil.getCassandraDcId(drUtil.getLocalSite());
    if (strategyOptions.containsKey(dcId)) {
        return false;
    }
    Site localSite = drUtil.getLocalSite();
    if (localSite.getState().equals(SiteState.STANDBY_PAUSED) || localSite.getState().equals(SiteState.STANDBY_DEGRADED) || localSite.getState().equals(SiteState.STANDBY_DEGRADING)) {
        // don't add back the paused site
        _log.info("local standby site has been paused/degraded and removed from strategy options. Do nothing");
        return false;
    }
    _log.info("Add {} to strategy options", dcId);
    strategyOptions.put(dcId, Integer.toString(getReplicationFactor()));
    // If we upgrade from pre-yoda versions, the strategy option does not contains active site.
    // we do it once during first add-standby operation on standby site
    Site activeSite = drUtil.getActiveSite();
    String activeSiteDcId = drUtil.getCassandraDcId(activeSite);
    if (!strategyOptions.containsKey(activeSiteDcId)) {
        _log.info("Add {} to strategy options", activeSiteDcId);
        strategyOptions.put(activeSiteDcId, Integer.toString(activeSite.getNodeCount()));
        if (strategyOptions.containsKey("replication_factor")) {
            strategyOptions.remove("replication_factor");
        }
    }
    return true;
}
Also used : Site(com.emc.storageos.coordinator.client.model.Site)

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