use of com.emc.storageos.coordinator.client.model.Site in project coprhd-controller by CoprHD.
the class DrSiteNetworkMonitor method checkPing.
private void checkPing() {
Site localSite = drUtil.getLocalSite();
SiteNetworkState localNetworkState = drUtil.getSiteNetworkState(localSite.getUuid());
if (!NetworkHealth.GOOD.equals(localNetworkState.getNetworkHealth()) || localNetworkState.getNetworkLatencyInMs() != 0) {
localNetworkState.setNetworkLatencyInMs(0);
localNetworkState.setNetworkHealth(NetworkHealth.GOOD);
coordinatorClient.setTargetInfo(localSite.getUuid(), localNetworkState);
}
for (Site site : drUtil.listSites()) {
if (drUtil.isLocalSite(site)) {
// skip local site
continue;
}
SiteNetworkState siteNetworkState = drUtil.getSiteNetworkState(site.getUuid());
NetworkHealth previousState = siteNetworkState.getNetworkHealth();
String host = site.getVipEndPoint();
double ping = drUtil.testPing(host, SOCKET_TEST_PORT, NETWORK_TIMEOUT);
// if ping successful get an average, format to 3 decimal places
if (ping != -1) {
ping = (ping + drUtil.testPing(host, SOCKET_TEST_PORT, NETWORK_TIMEOUT) + drUtil.testPing(host, SOCKET_TEST_PORT, NETWORK_TIMEOUT)) / 3;
DecimalFormat df = new DecimalFormat("#.###");
ping = Double.parseDouble(df.format(ping));
}
_log.info("Ping: " + ping);
siteNetworkState.setNetworkLatencyInMs(ping);
if (ping > NETWORK_SLOW_THRESHOLD) {
siteNetworkState.setNetworkHealth(NetworkHealth.SLOW);
_log.warn("Network for standby {} is slow", site.getName());
AlertsLogger.getAlertsLogger().warn(String.format("Network for standby %s is Broken:" + "Latency was reported as %f ms", site.getName(), ping));
} else if (ping < 0) {
siteNetworkState.setNetworkHealth(NetworkHealth.BROKEN);
_log.error("Network for standby {} is broken", site.getName());
AlertsLogger.getAlertsLogger().error(String.format("Network for standby %s is Broken:" + "Latency was reported as %s ms", site.getName(), ping));
} else {
siteNetworkState.setNetworkHealth(NetworkHealth.GOOD);
}
coordinatorClient.setTargetInfo(site.getUuid(), siteNetworkState);
if (drUtil.isActiveSite()) {
SiteState state = site.getState();
if (SiteState.STANDBY_ADDING == state || SiteState.STANDBY_RESUMING == state) {
_log.info("Skip mail alert during add-standby or resume-standby for {}", site.getUuid());
continue;
}
if (!NetworkHealth.BROKEN.equals(previousState) && NetworkHealth.BROKEN.equals(siteNetworkState.getNetworkHealth())) {
// Add to systemevent log
_alertLog.error(MessageFormat.format("Network connection to site %s has been broken.", site.getName()));
// send email alert
mailHandler.sendSiteNetworkBrokenMail(site);
}
}
}
}
use of com.emc.storageos.coordinator.client.model.Site in project coprhd-controller by CoprHD.
the class IpReconfigManager method assureIPConsistent.
/**
* Assure local site IP info is consistent with that in ZK.
* (DR/GEO procedures store IP info in ZK even for single site since Yoda.)
*/
void assureIPConsistent() {
InterProcessLock lock = null;
try {
log.info("Assuring local site IPs are consistent with ZK ...");
lock = _coordinator.getCoordinatorClient().getLock(UPDATE_ZKIP_LOCK);
lock.acquire();
log.info("Got lock for updating local site IPs into ZK ...");
Site site = drUtil.getLocalSite();
if (localIpinfo.weakEqual(site.getVip(), site.getVip6(), site.getHostIPv4AddressMap(), site.getHostIPv6AddressMap())) {
log.info("local site IPs are consistent with ZK, no need to update.");
return;
} else {
log.info("local site IPs are not consistent with ZK, updating.");
log.info(" local ipinfo:{}", localIpinfo.toString());
log.info(" zk ipinfo: vip={}", site.getVip());
log.info(" zk ipinfo: vip6={}", site.getVip6());
SortedSet<String> nodeIds = new TreeSet<String>(site.getHostIPv4AddressMap().keySet());
for (String nodeId : nodeIds) {
log.info(" {}: ipv4={}", nodeId, site.getHostIPv4AddressMap().get(nodeId));
log.info(" {}: ipv6={}", nodeId, site.getHostIPv6AddressMap().get(nodeId));
}
}
site.setVip6(localIpinfo.getIpv6Setting().getNetworkVip6());
site.setVip(localIpinfo.getIpv4Setting().getNetworkVip());
Map<String, String> ipv4Addresses = new HashMap<>();
Map<String, String> ipv6Addresses = new HashMap<>();
int nodeIndex = 1;
for (String nodeip : localIpinfo.getIpv4Setting().getNetworkAddrs()) {
String nodeId;
nodeId = IpReconfigConstants.VDC_NODE_PREFIX + nodeIndex++;
ipv4Addresses.put(nodeId, nodeip);
}
nodeIndex = 1;
for (String nodeip : localIpinfo.getIpv6Setting().getNetworkAddrs()) {
String nodeId;
nodeId = IpReconfigConstants.VDC_NODE_PREFIX + nodeIndex++;
ipv6Addresses.put(nodeId, nodeip);
}
site.setHostIPv4AddressMap(ipv4Addresses);
site.setHostIPv6AddressMap(ipv6Addresses);
site.setNodeCount(localIpinfo.getNodeCount());
_coordinator.getCoordinatorClient().persistServiceConfiguration(site.toConfiguration());
// wake up syssvc to regenerate configurations
drUtil.updateVdcTargetVersion(_coordinator.getCoordinatorClient().getSiteId(), SiteInfo.IP_OP_CHANGE, System.currentTimeMillis());
log.info("Finished update local site IPs into ZK");
} catch (Exception e) {
log.warn("Unexpected exception during updating local site IPs into ZK", e);
} finally {
if (lock != null) {
try {
lock.release();
} catch (Exception e) {
log.warn("Unexpected exception during unlocking update_zkip lock", e);
}
}
}
}
use of com.emc.storageos.coordinator.client.model.Site in project coprhd-controller by CoprHD.
the class DbDowntimeTracker method run.
/**
* Monitor dbsvc and geodbsvc online/offline event and record downtime in ZK
*/
public void run() {
DrUtil drUtil = new DrUtil(coordinator.getCoordinatorClient());
if (drUtil.isStandby()) {
log.info("Current site is standby, no need to monitor dbsvc and geodbsvc status");
return;
}
log.info("Monitoring dbsvc and geodbsvc status");
try (AutoCloseable lock = getTrackerLock()) {
for (Site site : drUtil.listSites()) {
updateSiteDbsvcStatus(site);
}
} catch (Exception e) {
log.warn("Failed to monitor db status", e);
}
}
use of com.emc.storageos.coordinator.client.model.Site in project coprhd-controller by CoprHD.
the class VdcOpHandler method changeSiteState.
protected void changeSiteState(SiteState from, SiteState to) {
List<Site> newSites = drUtil.listSitesInState(from);
for (Site newSite : newSites) {
log.info("Change standby site {} state from {} to {}", new Object[] { newSite.getSiteShortId(), from, to });
newSite.setLastState(from);
newSite.setState(to);
coordinator.getCoordinatorClient().persistServiceConfiguration(newSite.toConfiguration());
}
}
use of com.emc.storageos.coordinator.client.model.Site 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);
}
}
Aggregations