Search in sources :

Example 1 with NetworkHealth

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;
}
Also used : SiteRestRep(com.emc.storageos.model.dr.SiteRestRep) SiteState(com.emc.storageos.coordinator.client.model.SiteState) SiteMonitorResult(com.emc.storageos.coordinator.client.model.SiteMonitorResult) NetworkHealth(com.emc.storageos.coordinator.client.model.SiteNetworkState.NetworkHealth)

Example 2 with NetworkHealth

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);
            }
        }
    }
}
Also used : Site(com.emc.storageos.coordinator.client.model.Site) SiteState(com.emc.storageos.coordinator.client.model.SiteState) NetworkHealth(com.emc.storageos.coordinator.client.model.SiteNetworkState.NetworkHealth) DecimalFormat(java.text.DecimalFormat) SiteNetworkState(com.emc.storageos.coordinator.client.model.SiteNetworkState)

Aggregations

NetworkHealth (com.emc.storageos.coordinator.client.model.SiteNetworkState.NetworkHealth)2 SiteState (com.emc.storageos.coordinator.client.model.SiteState)2 Site (com.emc.storageos.coordinator.client.model.Site)1 SiteMonitorResult (com.emc.storageos.coordinator.client.model.SiteMonitorResult)1 SiteNetworkState (com.emc.storageos.coordinator.client.model.SiteNetworkState)1 SiteRestRep (com.emc.storageos.model.dr.SiteRestRep)1 DecimalFormat (java.text.DecimalFormat)1