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());
}
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;
}
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);
}
}
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();
}
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);
}
Aggregations