Search in sources :

Example 1 with SiteInfo

use of com.emc.storageos.coordinator.client.model.SiteInfo 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 2 with SiteInfo

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

the class VdcConfigMigration method migrateVdcConfigToZk.

/**
 * We store vdc ip addresses in local db(VirtualDataCenter CF) in pre-yoda. Since yoda, we move it
 * to zookeeper. We move all vdcs config to zk
 */
private void migrateVdcConfigToZk() {
    List<URI> vdcIds = dbClient.queryByType(VirtualDataCenter.class, true);
    for (URI vdcId : vdcIds) {
        VirtualDataCenter vdc = dbClient.queryObject(VirtualDataCenter.class, vdcId);
        if (vdc.getLocal()) {
            continue;
        }
        // Insert vdc info
        ConfigurationImpl vdcConfig = new ConfigurationImpl();
        vdcConfig.setKind(Site.CONFIG_KIND);
        vdcConfig.setId(vdc.getShortId());
        coordinatorClient.persistServiceConfiguration(vdcConfig);
        // insert DR active site info to ZK
        Site site = new Site();
        // TODO - we have no way to know site uuid in remote vdc during upgrade
        // no harm for now. We don't care site uuid in remote vdc at all
        site.setUuid(UUID.randomUUID().toString());
        site.setName("Default Active Site");
        site.setVdcShortId(vdc.getShortId());
        site.setSiteShortId(Constants.CONFIG_DR_FIRST_SITE_SHORT_ID);
        site.setHostIPv4AddressMap(vdc.getHostIPv4AddressesMap());
        site.setHostIPv6AddressMap(vdc.getHostIPv6AddressesMap());
        site.setState(SiteState.ACTIVE);
        site.setCreationTime(System.currentTimeMillis());
        site.setVip(vdc.getApiEndpoint());
        site.setNodeCount(vdc.getHostCount());
        coordinatorClient.persistServiceConfiguration(site.toConfiguration());
        // update Site version in ZK
        SiteInfo siteInfo = new SiteInfo(System.currentTimeMillis(), SiteInfo.NONE);
        coordinatorClient.setTargetInfo(siteInfo);
    }
    log.info("Migrated vdc config from db to zk");
}
Also used : Site(com.emc.storageos.coordinator.client.model.Site) SiteInfo(com.emc.storageos.coordinator.client.model.SiteInfo) VirtualDataCenter(com.emc.storageos.db.client.model.VirtualDataCenter) URI(java.net.URI) ConfigurationImpl(com.emc.storageos.coordinator.common.impl.ConfigurationImpl)

Example 3 with SiteInfo

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

the class VdcConfigUtil method genSiteProperties.

private void genSiteProperties(Map<String, String> vdcConfig, String vdcShortId, List<Site> sites) {
    String activeSiteId = null;
    try {
        activeSiteId = drUtil.getActiveSite().getUuid();
    } catch (RetryableCoordinatorException e) {
        log.warn("Failed to find active site id from ZK, go on since it maybe switchover case");
    }
    SiteInfo siteInfo = coordinator.getTargetInfo(SiteInfo.class);
    Site localSite = drUtil.getLocalSite();
    if (StringUtils.isEmpty(activeSiteId) && SiteInfo.DR_OP_SWITCHOVER.equals(siteInfo.getActionRequired())) {
        activeSiteId = drUtil.getSiteFromLocalVdc(siteInfo.getTargetSiteUUID()).getUuid();
    }
    Collections.sort(sites, new Comparator<Site>() {

        @Override
        public int compare(Site a, Site b) {
            return (int) (a.getCreationTime() - b.getCreationTime());
        }
    });
    List<String> shortIds = new ArrayList<>();
    for (Site site : sites) {
        if (shouldExcludeFromConfig(site)) {
            log.info("Ignore site {} of vdc {}", site.getSiteShortId(), site.getVdcShortId());
            continue;
        }
        // this will make it easier to resume the data replication.
        if (!drUtil.isLocalSite(site) && (site.getState().equals(SiteState.STANDBY_PAUSING) || site.getState().equals(SiteState.STANDBY_PAUSED) || site.getState().equals(SiteState.STANDBY_REMOVING) || site.getState().equals(SiteState.ACTIVE_FAILING_OVER) || site.getState().equals(SiteState.ACTIVE_DEGRADED))) {
            continue;
        }
        int siteNodeCnt = 0;
        Map<String, String> siteIPv4Addrs = site.getHostIPv4AddressMap();
        Map<String, String> siteIPv6Addrs = site.getHostIPv6AddressMap();
        List<String> siteHosts = getHostsFromIPAddrMap(siteIPv4Addrs, siteIPv6Addrs);
        String siteShortId = site.getSiteShortId();
        // sort the host names as vipr1, vipr2 ...
        Collections.sort(siteHosts);
        for (String hostName : siteHosts) {
            siteNodeCnt++;
            String address = siteIPv4Addrs.get(hostName);
            vdcConfig.put(String.format(VDC_SITE_IPADDR_PTN, vdcShortId, siteShortId, siteNodeCnt), address == null ? "" : address);
            address = siteIPv6Addrs.get(hostName);
            vdcConfig.put(String.format(VDC_SITE_IPADDR6_PTN, vdcShortId, siteShortId, siteNodeCnt), address == null ? "" : address);
        }
        vdcConfig.put(String.format(VDC_SITE_NODE_COUNT_PTN, vdcShortId, siteShortId), String.valueOf(siteNodeCnt));
        vdcConfig.put(String.format(VDC_SITE_VIP_PTN, vdcShortId, siteShortId), site.getVip());
        vdcConfig.put(String.format(VDC_SITE_VIP6_PTN, vdcShortId, siteShortId), site.getVip6());
        if (drUtil.isLocalSite(site)) {
            vdcConfig.put(SITE_MYID, siteShortId);
            vdcConfig.put(SITE_MY_UUID, site.getUuid());
        }
        shortIds.add(siteShortId);
    }
    Collections.sort(shortIds);
    if (drUtil.getLocalVdcShortId().equals(vdcShortId)) {
        // right now we assume that SITE_IDS and SITE_IS_STANDBY only makes sense for local VDC
        // moving forward this may or may not be the case.
        vdcConfig.put(SITE_IDS, StringUtils.join(shortIds, ','));
        vdcConfig.put(SITE_IS_STANDBY, String.valueOf(!localSite.getUuid().equals(activeSiteId)));
        vdcConfig.put(SITE_ACTIVE_ID, StringUtils.isEmpty(activeSiteId) ? DEFAULT_ACTIVE_SITE_ID : drUtil.getSiteFromLocalVdc(activeSiteId).getSiteShortId());
    }
    vdcConfig.put(String.format(VDC_SITE_IDS, vdcShortId), StringUtils.join(shortIds, ','));
}
Also used : Site(com.emc.storageos.coordinator.client.model.Site) SiteInfo(com.emc.storageos.coordinator.client.model.SiteInfo) ArrayList(java.util.ArrayList) RetryableCoordinatorException(com.emc.storageos.coordinator.exceptions.RetryableCoordinatorException)

Example 4 with SiteInfo

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

the class CoordinatorClientImpl method getDifferentVdcConfigVersionCommon.

/**
 * Common method to compare vdcConfigVersions with target's vdcConfigVersion
 *
 * @param vdcConfigVersions
 *            nodes' vdcConfigVersions
 * @return list of nodes which configVersions are different from the target's
 */
private List<String> getDifferentVdcConfigVersionCommon(final Map<Service, VdcConfigVersion> vdcConfigVersions) {
    List<String> differentConfigVersions = new ArrayList<String>();
    SiteInfo targetSiteInfo = getTargetInfo(SiteInfo.class);
    if (targetSiteInfo == null) {
        return differentConfigVersions;
    }
    String targetVdcConfigVersion = String.valueOf(targetSiteInfo.getVdcConfigVersion());
    for (Map.Entry<Service, VdcConfigVersion> entry : vdcConfigVersions.entrySet()) {
        if (!StringUtils.equals(targetVdcConfigVersion, entry.getValue().getConfigVersion())) {
            differentConfigVersions.add(entry.getKey().getId());
        }
    }
    return differentConfigVersions;
}
Also used : SiteInfo(com.emc.storageos.coordinator.client.model.SiteInfo) ArrayList(java.util.ArrayList) Service(com.emc.storageos.coordinator.common.Service) ExecutorService(java.util.concurrent.ExecutorService) PropertyInfoMapper.decodeFromString(com.emc.storageos.coordinator.mapper.PropertyInfoMapper.decodeFromString) Map(java.util.Map) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) ConcurrentMap(java.util.concurrent.ConcurrentMap) VdcConfigVersion(com.emc.storageos.coordinator.client.model.VdcConfigVersion)

Example 5 with SiteInfo

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

the class DrUtil method updateVdcTargetVersion.

public void updateVdcTargetVersion(String siteId, String action, long vdcConfigVersion, long dataRevision) throws Exception {
    SiteInfo siteInfo = new SiteInfo(vdcConfigVersion, action, String.valueOf(dataRevision));
    coordinator.setTargetInfo(siteId, siteInfo);
    log.info("VDC target version updated to {} for site {}", siteInfo.getVdcConfigVersion(), siteId);
}
Also used : SiteInfo(com.emc.storageos.coordinator.client.model.SiteInfo)

Aggregations

SiteInfo (com.emc.storageos.coordinator.client.model.SiteInfo)14 Site (com.emc.storageos.coordinator.client.model.Site)10 DrUtil (com.emc.storageos.coordinator.client.service.DrUtil)3 ArrayList (java.util.ArrayList)3 Produces (javax.ws.rs.Produces)3 ConfigurationImpl (com.emc.storageos.coordinator.common.impl.ConfigurationImpl)2 RetryableCoordinatorException (com.emc.storageos.coordinator.exceptions.RetryableCoordinatorException)2 PropertyInfoMapper.decodeFromString (com.emc.storageos.coordinator.mapper.PropertyInfoMapper.decodeFromString)2 SiteList (com.emc.storageos.model.dr.SiteList)2 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)2 ConcurrentMap (java.util.concurrent.ConcurrentMap)2 GET (javax.ws.rs.GET)2 Path (javax.ws.rs.Path)2 SiteState (com.emc.storageos.coordinator.client.model.SiteState)1 VdcConfigVersion (com.emc.storageos.coordinator.client.model.VdcConfigVersion)1 Service (com.emc.storageos.coordinator.common.Service)1 ZkPath (com.emc.storageos.coordinator.common.impl.ZkPath)1