Search in sources :

Example 1 with SystemStatistics

use of com.emc.fapiclient.ws.SystemStatistics in project coprhd-controller by CoprHD.

the class RecoverPointClient method getRPSystemStatistics.

/**
 * Get RP site statistics for use in collectStatisticsInformation
 *
 * @param RecoverPointVolumeProtectionInfo copyToModify - Volume info for the CG to add a journal volume to
 *
 * @param String journalWWNToDelete - WWN of the journal volume to delete
 *
 * @return RecoverPointStatisticsResponse
 *
 * @throws RecoverPointException
 */
public RecoverPointStatisticsResponse getRPSystemStatistics() throws RecoverPointException {
    logger.info("Collecting RecoverPoint System Statistics.");
    RecoverPointStatisticsResponse response = new RecoverPointStatisticsResponse();
    try {
        Map<Long, Double> siteAvgCPUUsageMap = new HashMap<Long, Double>();
        Map<Long, Long> siteInputAvgThroughput = new HashMap<Long, Long>();
        Map<Long, Long> siteOutputAvgThroughput = new HashMap<Long, Long>();
        Map<Long, Long> siteIncomingAvgWrites = new HashMap<Long, Long>();
        SystemStatistics systemStatistics = functionalAPI.getSystemStatistics();
        Set<ClusterUID> ClusterUIDList = new HashSet<ClusterUID>();
        List<RpaStatistics> rpaStatisticsList = systemStatistics.getRpaStatistics();
        for (RpaStatistics rpaStatistics : rpaStatisticsList) {
            ClusterUID siteID = rpaStatistics.getRpaUID().getClusterUID();
            boolean foundSite = false;
            for (ClusterUID siteListUID : ClusterUIDList) {
                if (siteID.getId() == siteListUID.getId()) {
                    foundSite = true;
                    break;
                }
            }
            if (!foundSite) {
                ClusterUIDList.add(siteID);
            }
        }
        for (ClusterUID ClusterUID : ClusterUIDList) {
            List<Double> rpaCPUList = new LinkedList<Double>();
            List<Long> rpaSiteInputAvgThroughputList = new LinkedList<Long>();
            List<Long> rpaSiteOutputAvgThroughputList = new LinkedList<Long>();
            List<Long> rpaSiteInputAvgIncomingWritesList = new LinkedList<Long>();
            for (RpaStatistics rpaStatistics : rpaStatisticsList) {
                if (rpaStatistics.getRpaUID().getClusterUID().getId() == ClusterUID.getId()) {
                    rpaCPUList.add(Double.valueOf(rpaStatistics.getCpuUsage()));
                    rpaSiteInputAvgThroughputList.add(rpaStatistics.getTraffic().getApplicationThroughputStatistics().getInThroughput());
                    for (ConnectionOutThroughput cot : rpaStatistics.getTraffic().getApplicationThroughputStatistics().getConnectionsOutThroughputs()) {
                        rpaSiteOutputAvgThroughputList.add(cot.getOutThroughput());
                    }
                    rpaSiteInputAvgIncomingWritesList.add(rpaStatistics.getTraffic().getApplicationIncomingWrites());
                }
            }
            Double cpuTotalUsage = 0.0;
            Long incomingWritesTotal = Long.valueOf(0);
            Long inputThoughputTotal = Long.valueOf(0);
            Long outputThoughputTotal = Long.valueOf(0);
            for (Double rpaCPUs : rpaCPUList) {
                cpuTotalUsage += rpaCPUs;
            }
            for (Long siteInputThroughput : rpaSiteInputAvgThroughputList) {
                inputThoughputTotal += siteInputThroughput;
            }
            for (Long siteOutputThroughput : rpaSiteOutputAvgThroughputList) {
                outputThoughputTotal += siteOutputThroughput;
            }
            for (Long incomingWrites : rpaSiteInputAvgIncomingWritesList) {
                incomingWritesTotal += incomingWrites;
            }
            logger.info("Average CPU usage for site: " + ClusterUID.getId() + " is " + cpuTotalUsage / rpaCPUList.size());
            logger.info("Average input throughput for site: " + ClusterUID.getId() + " is " + inputThoughputTotal / rpaCPUList.size() + " kb/s");
            logger.info("Average output throughput for site: " + ClusterUID.getId() + " is " + outputThoughputTotal / rpaCPUList.size() + " kb/s");
            logger.info("Average incoming writes for site: " + ClusterUID.getId() + " is " + incomingWritesTotal / rpaCPUList.size() + " writes/s");
            siteAvgCPUUsageMap.put(ClusterUID.getId(), cpuTotalUsage / rpaCPUList.size());
            siteInputAvgThroughput.put(ClusterUID.getId(), inputThoughputTotal / rpaCPUList.size());
            siteOutputAvgThroughput.put(ClusterUID.getId(), outputThoughputTotal / rpaCPUList.size());
            siteIncomingAvgWrites.put(ClusterUID.getId(), incomingWritesTotal / rpaCPUList.size());
        }
        response.setSiteCPUUsageMap(siteAvgCPUUsageMap);
        response.setSiteInputAvgIncomingWrites(siteIncomingAvgWrites);
        response.setSiteOutputAvgThroughput(siteOutputAvgThroughput);
        response.setSiteInputAvgThroughput(siteInputAvgThroughput);
        List<ProtectionSystemParameters> systemParameterList = new LinkedList<ProtectionSystemParameters>();
        MonitoredParametersStatus monitoredParametersStatus = functionalAPI.getMonitoredParametersStatus();
        List<MonitoredParameter> monitoredParameterList = monitoredParametersStatus.getParameters();
        for (MonitoredParameter monitoredParameter : monitoredParameterList) {
            ProtectionSystemParameters param = response.new ProtectionSystemParameters();
            param.parameterName = monitoredParameter.getKey().getParameterType().value();
            param.parameterLimit = monitoredParameter.getValue().getParameterWaterMarks().getLimit();
            param.currentParameterValue = monitoredParameter.getValue().getValue();
            if (monitoredParameter.getKey().getClusterUID() != null) {
                param.siteID = monitoredParameter.getKey().getClusterUID().getId();
            }
            systemParameterList.add(param);
        }
        response.setParamList(systemParameterList);
        for (ProtectionSystemParameters monitoredParameter : response.getParamList()) {
            logger.info("Key: " + monitoredParameter.parameterName);
            logger.info("Current Value: " + monitoredParameter.currentParameterValue);
            logger.info("Max Value: " + monitoredParameter.parameterLimit);
        }
        return response;
    } catch (FunctionalAPIActionFailedException_Exception e) {
        throw RecoverPointException.exceptions.failedToGetStatistics(e);
    } catch (FunctionalAPIInternalError_Exception e) {
        throw RecoverPointException.exceptions.failedToGetStatistics(e);
    } catch (Exception e) {
        throw RecoverPointException.exceptions.failedToGetStatistics(e);
    }
}
Also used : RpaStatistics(com.emc.fapiclient.ws.RpaStatistics) ProtectionSystemParameters(com.emc.storageos.recoverpoint.responses.RecoverPointStatisticsResponse.ProtectionSystemParameters) HashMap(java.util.HashMap) HashSet(java.util.HashSet) FunctionalAPIActionFailedException_Exception(com.emc.fapiclient.ws.FunctionalAPIActionFailedException_Exception) ConnectionOutThroughput(com.emc.fapiclient.ws.ConnectionOutThroughput) MonitoredParameter(com.emc.fapiclient.ws.MonitoredParameter) LinkedList(java.util.LinkedList) FunctionalAPIValidationException_Exception(com.emc.fapiclient.ws.FunctionalAPIValidationException_Exception) FunctionalAPIActionFailedException_Exception(com.emc.fapiclient.ws.FunctionalAPIActionFailedException_Exception) FunctionalAPIInternalError_Exception(com.emc.fapiclient.ws.FunctionalAPIInternalError_Exception) RecoverPointException(com.emc.storageos.recoverpoint.exceptions.RecoverPointException) RecoverPointStatisticsResponse(com.emc.storageos.recoverpoint.responses.RecoverPointStatisticsResponse) ClusterUID(com.emc.fapiclient.ws.ClusterUID) FunctionalAPIInternalError_Exception(com.emc.fapiclient.ws.FunctionalAPIInternalError_Exception) SystemStatistics(com.emc.fapiclient.ws.SystemStatistics) MonitoredParametersStatus(com.emc.fapiclient.ws.MonitoredParametersStatus)

Example 2 with SystemStatistics

use of com.emc.fapiclient.ws.SystemStatistics in project coprhd-controller by CoprHD.

the class RecoverPointUtils method getPreferredRPAForNewCG.

/**
 * Returns the preferred RPA number to use as the primary RPA for a new
 * consistency group. The preferred RPA is determined by examining the
 * current throughput for all of the passed in cluster's RPAs and selecting
 * the RPA that is currently handling the least amount of throughput.
 *
 * @param impl - the established connection to an appliance
 * @param clusterUID - corresponding to the site that we are trying to determine the preferred RPA for.
 * @return RpaUID - object with the preferred RPA number
 * @throws FunctionalAPIActionFailedException_Exception
 * @throws FunctionalAPIInternalError_Exception
 */
public static RpaUID getPreferredRPAForNewCG(FunctionalAPIImpl impl, ClusterUID clusterUID) throws FunctionalAPIActionFailedException_Exception, FunctionalAPIInternalError_Exception {
    RpaUID preferredRPA = new RpaUID();
    // set the cluster UID to the value being passed
    preferredRPA.setClusterUID(clusterUID);
    // default the rpa to 1
    preferredRPA.setRpaNumber(1);
    try {
        SystemStatistics systemStatistics = impl.getSystemStatistics();
        List<RpaStatistics> rpaStatisticsList = systemStatistics.getRpaStatistics();
        Long smallestThroughput = Long.valueOf(0);
        Long currenThroughput = Long.valueOf(0);
        for (RpaStatistics rpaStatistics : rpaStatisticsList) {
            if (rpaStatistics.getRpaUID().getClusterUID().getId() == clusterUID.getId()) {
                currenThroughput = Long.valueOf(0);
                logger.info("Looking at current throughput for RPA " + rpaStatistics.getRpaUID().getRpaNumber() + " on cluster " + rpaStatistics.getRpaUID().getClusterUID().getId());
                TrafficStatistics trafficStatistics = rpaStatistics.getTraffic();
                InOutThroughputStatistics throughput = trafficStatistics.getApplicationThroughputStatistics();
                List<ConnectionOutThroughput> out = throughput.getConnectionsOutThroughputs();
                for (ConnectionOutThroughput a : out) {
                    logger.info("RPA " + rpaStatistics.getRpaUID().getRpaNumber() + " throughput to cluster " + a.getCluster().getId() + ": " + a.getOutThroughput() + " bytes/sec");
                    currenThroughput += a.getOutThroughput();
                }
                if (smallestThroughput.longValue() == 0) {
                    smallestThroughput = currenThroughput;
                }
                logger.info("Total throughput for RPA " + rpaStatistics.getRpaUID().getRpaNumber() + ": " + currenThroughput.toString() + " bytes/sec");
                if (currenThroughput.compareTo(smallestThroughput) <= 0) {
                    smallestThroughput = currenThroughput;
                    preferredRPA.setRpaNumber(rpaStatistics.getRpaUID().getRpaNumber());
                }
            }
        }
    } catch (Exception e) {
        logger.error(e.getMessage());
        logger.info("Encountered error determining the preferred RPA, defaulting to RPA 1");
        preferredRPA.setRpaNumber(1);
        return preferredRPA;
    }
    logger.info("Selected RPA " + preferredRPA.getRpaNumber() + " of cluster " + preferredRPA.getClusterUID().getId() + " for the new consistency group");
    return preferredRPA;
}
Also used : RpaStatistics(com.emc.fapiclient.ws.RpaStatistics) TrafficStatistics(com.emc.fapiclient.ws.TrafficStatistics) SystemStatistics(com.emc.fapiclient.ws.SystemStatistics) ConnectionOutThroughput(com.emc.fapiclient.ws.ConnectionOutThroughput) RpaUID(com.emc.fapiclient.ws.RpaUID) InOutThroughputStatistics(com.emc.fapiclient.ws.InOutThroughputStatistics) FunctionalAPIActionFailedException_Exception(com.emc.fapiclient.ws.FunctionalAPIActionFailedException_Exception) FunctionalAPIValidationException_Exception(com.emc.fapiclient.ws.FunctionalAPIValidationException_Exception) FunctionalAPIInternalError_Exception(com.emc.fapiclient.ws.FunctionalAPIInternalError_Exception) RecoverPointException(com.emc.storageos.recoverpoint.exceptions.RecoverPointException)

Aggregations

ConnectionOutThroughput (com.emc.fapiclient.ws.ConnectionOutThroughput)2 FunctionalAPIActionFailedException_Exception (com.emc.fapiclient.ws.FunctionalAPIActionFailedException_Exception)2 FunctionalAPIInternalError_Exception (com.emc.fapiclient.ws.FunctionalAPIInternalError_Exception)2 FunctionalAPIValidationException_Exception (com.emc.fapiclient.ws.FunctionalAPIValidationException_Exception)2 RpaStatistics (com.emc.fapiclient.ws.RpaStatistics)2 SystemStatistics (com.emc.fapiclient.ws.SystemStatistics)2 RecoverPointException (com.emc.storageos.recoverpoint.exceptions.RecoverPointException)2 ClusterUID (com.emc.fapiclient.ws.ClusterUID)1 InOutThroughputStatistics (com.emc.fapiclient.ws.InOutThroughputStatistics)1 MonitoredParameter (com.emc.fapiclient.ws.MonitoredParameter)1 MonitoredParametersStatus (com.emc.fapiclient.ws.MonitoredParametersStatus)1 RpaUID (com.emc.fapiclient.ws.RpaUID)1 TrafficStatistics (com.emc.fapiclient.ws.TrafficStatistics)1 RecoverPointStatisticsResponse (com.emc.storageos.recoverpoint.responses.RecoverPointStatisticsResponse)1 ProtectionSystemParameters (com.emc.storageos.recoverpoint.responses.RecoverPointStatisticsResponse.ProtectionSystemParameters)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 LinkedList (java.util.LinkedList)1