Search in sources :

Example 6 with SiteInfo

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

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

the class CoordinatorClientExt method isActiveSiteHealthy.

/**
 * Check if DR active site is stable and there is ZK leader in active site
 *
 * @return true for stable, otherwise false
 */
public boolean isActiveSiteHealthy() {
    DrUtil drUtil = new DrUtil(_coordinator);
    String activeSiteId = drUtil.getActiveSite().getUuid();
    boolean isActiveSiteLeaderAlive = false;
    boolean isActiveSiteStable = false;
    SiteInfo siteInfo = _coordinator.getTargetInfo(SiteInfo.class);
    if (StringUtils.isEmpty(activeSiteId) && SiteInfo.DR_OP_SWITCHOVER.equals(siteInfo.getActionRequired())) {
        activeSiteId = siteInfo.getTargetSiteUUID();
    }
    if (StringUtils.isEmpty(activeSiteId) || drUtil.getLocalSite().getUuid().equals(activeSiteId)) {
        _log.info("Can't find active site id or local site is active, set active healthy as false");
    } else {
        Site activeSite = drUtil.getSiteFromLocalVdc(activeSiteId);
        isActiveSiteLeaderAlive = isZKLeaderAlive(activeSite);
        isActiveSiteStable = isActiveSiteStable(activeSite);
        _log.info("Active site ZK is alive: {}, active site stable is :{}", isActiveSiteLeaderAlive, isActiveSiteStable);
    }
    return isActiveSiteLeaderAlive && isActiveSiteStable;
}
Also used : Site(com.emc.storageos.coordinator.client.model.Site) SiteInfo(com.emc.storageos.coordinator.client.model.SiteInfo) DrUtil(com.emc.storageos.coordinator.client.service.DrUtil)

Example 8 with SiteInfo

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

the class IpsecService method updateTargetSiteInfo.

private void updateTargetSiteInfo(long vdcConfigVersion) {
    DrUtil drUtil = new DrUtil(coordinator);
    for (Site site : drUtil.listSites()) {
        SiteInfo siteInfo;
        String siteId = site.getUuid();
        SiteInfo currentSiteInfo = coordinator.getTargetInfo(siteId, SiteInfo.class);
        if (currentSiteInfo != null) {
            siteInfo = new SiteInfo(vdcConfigVersion, SiteInfo.IPSEC_OP_ROTATE_KEY, currentSiteInfo.getTargetDataRevision(), SiteInfo.ActionScope.VDC);
        } else {
            siteInfo = new SiteInfo(vdcConfigVersion, SiteInfo.IPSEC_OP_ROTATE_KEY, SiteInfo.ActionScope.VDC);
        }
        coordinator.setTargetInfo(siteId, siteInfo);
        log.info("VDC target version updated to {} for site {}", siteInfo.getVdcConfigVersion(), siteId);
    }
}
Also used : Site(com.emc.storageos.coordinator.client.model.Site) SiteInfo(com.emc.storageos.coordinator.client.model.SiteInfo) DrUtil(com.emc.storageos.coordinator.client.service.DrUtil)

Example 9 with SiteInfo

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

the class DbRebuildRunnable method isLastDataSyncCurrent.

// check if the last data sync time is later than the target site info update
private boolean isLastDataSyncCurrent(Configuration dbConfig) {
    SiteInfo targetSiteInfo = coordinator.getTargetInfo(SiteInfo.class);
    String value = dbConfig.getConfig(DbConfigConstants.LAST_DATA_SYNC_TIME);
    return value != null && Long.valueOf(value) > targetSiteInfo.getVdcConfigVersion();
}
Also used : SiteInfo(com.emc.storageos.coordinator.client.model.SiteInfo)

Example 10 with SiteInfo

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

the class IPsecManager method updateTargetSiteInfo.

private String updateTargetSiteInfo(long vdcConfigVersion) {
    for (Site site : drUtil.listSites()) {
        SiteInfo siteInfo;
        String siteId = site.getUuid();
        SiteInfo currentSiteInfo = coordinator.getTargetInfo(siteId, SiteInfo.class);
        if (currentSiteInfo != null) {
            siteInfo = new SiteInfo(vdcConfigVersion, SiteInfo.IPSEC_OP_ROTATE_KEY, currentSiteInfo.getTargetDataRevision(), SiteInfo.ActionScope.VDC);
        } else {
            siteInfo = new SiteInfo(vdcConfigVersion, SiteInfo.IPSEC_OP_ROTATE_KEY, SiteInfo.ActionScope.VDC);
        }
        coordinator.setTargetInfo(siteId, siteInfo);
        log.info("VDC target version updated to {} for site {}", siteInfo.getVdcConfigVersion(), siteId);
    }
    return Long.toString(vdcConfigVersion);
}
Also used : Site(com.emc.storageos.coordinator.client.model.Site) 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