Search in sources :

Example 1 with InOutThroughputStatistics

use of com.emc.fapiclient.ws.InOutThroughputStatistics 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)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 InOutThroughputStatistics (com.emc.fapiclient.ws.InOutThroughputStatistics)1 RpaStatistics (com.emc.fapiclient.ws.RpaStatistics)1 RpaUID (com.emc.fapiclient.ws.RpaUID)1 SystemStatistics (com.emc.fapiclient.ws.SystemStatistics)1 TrafficStatistics (com.emc.fapiclient.ws.TrafficStatistics)1 RecoverPointException (com.emc.storageos.recoverpoint.exceptions.RecoverPointException)1