Search in sources :

Example 1 with MonitoredParametersStatus

use of com.emc.fapiclient.ws.MonitoredParametersStatus 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)

Aggregations

ClusterUID (com.emc.fapiclient.ws.ClusterUID)1 ConnectionOutThroughput (com.emc.fapiclient.ws.ConnectionOutThroughput)1 FunctionalAPIActionFailedException_Exception (com.emc.fapiclient.ws.FunctionalAPIActionFailedException_Exception)1 FunctionalAPIInternalError_Exception (com.emc.fapiclient.ws.FunctionalAPIInternalError_Exception)1 FunctionalAPIValidationException_Exception (com.emc.fapiclient.ws.FunctionalAPIValidationException_Exception)1 MonitoredParameter (com.emc.fapiclient.ws.MonitoredParameter)1 MonitoredParametersStatus (com.emc.fapiclient.ws.MonitoredParametersStatus)1 RpaStatistics (com.emc.fapiclient.ws.RpaStatistics)1 SystemStatistics (com.emc.fapiclient.ws.SystemStatistics)1 RecoverPointException (com.emc.storageos.recoverpoint.exceptions.RecoverPointException)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