use of com.emc.fapiclient.ws.TrafficStatistics 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;
}
Aggregations