use of com.emc.storageos.coordinator.client.model.SiteNetworkState.NetworkHealth in project coprhd-controller by CoprHD.
the class SiteMapper method mapWithNetwork.
public SiteRestRep mapWithNetwork(Site from, DrUtil drUtil) {
if (from == null) {
return null;
}
SiteRestRep to = new SiteRestRep();
map(from, to);
NetworkHealth networkHealth = drUtil.getSiteNetworkState(from.getUuid()).getNetworkHealth();
SiteState state = from.getState();
// Skip network health state amid ADDING/RESUMING
if (networkHealth != null && SiteState.STANDBY_ADDING != state && SiteState.STANDBY_RESUMING != state) {
to.setNetworkHealth(networkHealth.toString());
}
// check if syssvc are up
boolean runningState = drUtil.isSiteUp(from.getUuid());
if (runningState && !from.getState().equals(SiteState.ACTIVE)) {
// check if dbsvc are up
SiteMonitorResult monitorResult = drUtil.getCoordinator().getTargetInfo(from.getUuid(), SiteMonitorResult.class);
if (monitorResult != null && monitorResult.getDbQuorumLostSince() > 0) {
runningState = false;
}
}
to.setRunningState(runningState);
return to;
}
use of com.emc.storageos.coordinator.client.model.SiteNetworkState.NetworkHealth 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);
}
}
}
}
Aggregations