// ======================= PROXY ========================
public MediationSummaryStatistic getProxyServiceStatHourlySummary(int serverId, String proxyService,
String direction, BAMCalendar startTime, BAMCalendar endTime) throws BAMException {
BAMSummaryGenerationDSClient client = null;
try {
client = BAMUtil.getBAMSummaryGenerationDSClient();
String proxyServiceString;
double[] doubles;
int[] intsThisHour;
int[] intsPrevHour;
double doubleVal;
int intVal;
MediationSummaryStatistic statistic = new MediationSummaryStatistic();
proxyServiceString = PROXY_SERVICE + direction + MAX_PROCESSING_TIME + "-" + proxyService;
doubles = client.getMediationStatHourlySummaryDouble(serverId, proxyServiceString, startTime,
endTime);
doubleVal = BAMMath.max(doubles);
statistic.setMaxProcessingTime(doubleVal);
proxyServiceString = PROXY_SERVICE + direction + MIN_PROCESSING_TIME + "-" + proxyService;
doubles = client.getMediationStatHourlySummaryDouble(serverId, proxyServiceString, startTime,
endTime);
doubleVal = BAMMath.min(doubles);
statistic.setMinProcessingTime(doubleVal);
proxyServiceString = PROXY_SERVICE + direction + AVG_PROCESSING_TIME + "-" + proxyService;
doubles = client.getMediationStatHourlySummaryDouble(serverId, proxyServiceString, startTime,
endTime);
doubleVal = BAMMath.avg(doubles);
statistic.setAvgProcessingTime(doubleVal);
// proxyServiceString = PROXY_SERVICE + direction + CUMULATIVE_COUNT + "-" + proxyService;
// ints = client.getMediationStatHourlySummaryInt(serverId, proxyServiceString, startTime, endTime);
// intVal = BAMMath.max(ints) - BAMMath.min(ints);
// statistic.setCount(intVal);
//
// proxyServiceString = PROXY_SERVICE + direction + FAULT_COUNT + "-" + proxyService;
// ints = client.getMediationStatHourlySummaryInt(serverId, proxyServiceString, startTime, endTime);
// intVal = BAMMath.max(ints) - BAMMath.min(ints);
// statistic.setFaultCount(intVal);
BAMCalendar prevStartTime = BAMCalendar.getInstance(startTime);
prevStartTime.add(BAMCalendar.HOUR, -24);
BAMCalendar prevEndTime = BAMCalendar.getInstance(endTime);
prevEndTime.add(BAMCalendar.HOUR, -1);
proxyServiceString = createMediationKeyString(PROXY_SERVICE, direction, CUMULATIVE_COUNT, proxyService);
intsThisHour = client.getDataForMediationMaxCount(serverId, proxyServiceString, startTime, endTime);
intsPrevHour = client.getDataForMediationMaxCount(serverId, proxyServiceString, prevStartTime, prevEndTime);
intVal = BAMMath.max(intsThisHour) - BAMMath.max(intsPrevHour);
statistic.setCount(intVal >=0 ? intVal : BAMMath.max(intsThisHour));
if (BAMMath.max(intsThisHour) <= 0){
statistic.setAllZeros();
} else {
proxyServiceString = createMediationKeyString(PROXY_SERVICE, direction, FAULT_COUNT, proxyService);
intsThisHour = client.getDataForMediationMaxCount(serverId, proxyServiceString, startTime, endTime);
intsPrevHour = client.getDataForMediationMaxCount(serverId, proxyServiceString, prevStartTime, prevEndTime);
intVal = BAMMath.max(intsThisHour) - BAMMath.max(intsPrevHour);
statistic.setFaultCount(intVal >=0 ? intVal : BAMMath.max(intsThisHour));
}
return statistic;
} catch (Exception e) {
throw new BAMException("Could not retrieve hourly summary for serverId: " + serverId
+ "proxyService: " + proxyService + direction + " start time: "
+ startTime.getBAMTimestamp(), e);
} finally {
if (client != null) {
client.cleanup();
}
}
}