int[] intsThisHour;
int[] intsPrevHour;
double doubleVal;
int intVal;
MediationSummaryStatistic statistic = new MediationSummaryStatistic();
sequenceString = SEQUENCE + direction + MAX_PROCESSING_TIME + "-" + sequence;
doubles = client
.getMediationStatHourlySummaryDouble(serverId, sequenceString, startTime, endTime);
doubleVal = BAMMath.max(doubles);
statistic.setMaxProcessingTime(doubleVal);
sequenceString = SEQUENCE + direction + MIN_PROCESSING_TIME + "-" + sequence;
doubles = client
.getMediationStatHourlySummaryDouble(serverId, sequenceString, startTime, endTime);
doubleVal = BAMMath.min(doubles);
statistic.setMinProcessingTime(doubleVal);
sequenceString = SEQUENCE + direction + AVG_PROCESSING_TIME + "-" + sequence;
doubles = client
.getMediationStatHourlySummaryDouble(serverId, sequenceString, startTime, endTime);
doubleVal = BAMMath.avg(doubles);
statistic.setAvgProcessingTime(doubleVal);
// sequenceString = SEQUENCE + direction + CUMULATIVE_COUNT + "-" + sequence;
// ints = client.getMediationStatHourlySummaryInt(serverId, sequenceString, startTime, endTime);
// intVal = BAMMath.max(ints) - BAMMath.min(ints);
// statistic.setCount(intVal);
//
// sequenceString = SEQUENCE + direction + FAULT_COUNT + "-" + sequence;
// ints = client.getMediationStatHourlySummaryInt(serverId, sequenceString, 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);
sequenceString = createMediationKeyString(SEQUENCE, direction, CUMULATIVE_COUNT, sequence);
intsThisHour = client.getDataForMediationMaxCount(serverId, sequenceString, startTime, endTime);
intsPrevHour = client.getDataForMediationMaxCount(serverId, sequenceString, 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 {
sequenceString = createMediationKeyString(SEQUENCE, direction, FAULT_COUNT, sequence);
intsThisHour = client.getDataForMediationMaxCount(serverId, sequenceString, startTime, endTime);
intsPrevHour = client.getDataForMediationMaxCount(serverId, sequenceString, 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