/** * Process the collection of elements. * * @param collection * Collection that should be aggregated. */ public void processCollection(Collection<E> collection) { for (E element : collection) { processElement(element); } }
/** * {@inheritDoc} */ @Override public int hashCode() { final int prime = 31; int result = 1; result = (prime * result) + ((exceptionAggregationType == null) ? 0 : exceptionAggregationType.hashCode()); return result; }
/** * {@inheritDoc} */ @Override public List<HttpTimerData> getTaggedAggregatedHttpTimerData(HttpTimerData httpData, boolean includeRequestMethod) { IIndexQuery query = httpDataQueryFactory.getFindAllTaggedHttpTimersQuery(httpData, null, null); return super.executeQuery(query, new HttpTimerDataAggregator(false, includeRequestMethod), false); }
@Test public void aggregationURIRequestMethods() { final HttpTimerData data = new HttpTimerData(); data.getHttpInfo().setUri("URI"); data.getHttpInfo().setRequestMethod("GET"); data.setDuration(100d); data.setCpuDuration(10d); data.calculateCpuMin(10d); data.calculateCpuMax(10d); data.setCpuDuration(10d); final HttpTimerData data2 = new HttpTimerData(); data2.getHttpInfo().setUri("URI"); data2.getHttpInfo().setRequestMethod("POST"); data2.setDuration(500d); data2.calculateCpuMin(20d); data2.calculateCpuMax(20d); data2.setCpuDuration(20d); final List<HttpTimerData> input = new ArrayList<>(); Collections.addAll(input, data, data2); AggregationPerformer<HttpTimerData> aggregationPerformer = new AggregationPerformer<>(new HttpTimerDataAggregator(true, true)); aggregationPerformer.processCollection(input); final List<HttpTimerData> output = aggregationPerformer.getResultList(); assertThat(output, is(notNullValue())); assertThat(output.size(), is(equalTo(2))); }
/** * {@inheritDoc} */ @Override public void onFinalization(StorageManager storageManager, StorageWriter storageWriter, StorageData storageData) throws Exception { for (Map.Entry<Long, AggregationPerformer<E>> entry : aggregationPerformerMap.entrySet()) { query.setPlatformIdent(entry.getKey().longValue()); AggregationPerformer<E> aggregationPerformer = entry.getValue(); storageManager.cacheStorageData(storageData, aggregationPerformer.getResultList(), storageManager.getCachedDataHash(query, aggregator)); } }
/** * No data to aggregate when no sampling rate is set. */ @Test public void noDataToAggregateWhenNoSamplingRateIsSet() { List<? extends DefaultData> resultList = null; // from time is Mon Sep 15 10:50:12 CEST 2008 Date fromDate = new Date(1221468612000L); // to time is Mon Sep 15 12:00:00 CEST 2008 Date toDate = new Date(1221472800000L); resultList = mode.adjustSamplingRate(dataObjects, fromDate, toDate, 0, new ClassLoadingInformationDataAggregator()); assertThat((Object) dataObjects, is(equalTo((Object) resultList))); }
/** * {@inheritDoc} */ @Override public Object getAggregationKey(ExceptionSensorData exceptionSensorData) { final int prime = 31; if (exceptionAggregationType == ExceptionAggregationType.THROWABLE_TYPE) { int result = 0; result = (prime * result) + ((exceptionSensorData.getThrowableType() == null) ? 0 : exceptionSensorData.getThrowableType().hashCode()); return result; } else if (exceptionAggregationType == ExceptionAggregationType.GROUP_EXCEPTION_OVERVIEW) { int result = 0; result = (prime * result) + ((exceptionSensorData.getThrowableType() == null) ? 0 : exceptionSensorData.getThrowableType().hashCode()); result = (prime * result) + ((exceptionSensorData.getErrorMessage() == null) ? 0 : exceptionSensorData.getErrorMessage().hashCode()); return result; } else if (exceptionAggregationType == ExceptionAggregationType.DISTINCT_STACK_TRACES) { int result = 0; result = (prime * result) + ((exceptionSensorData.getErrorMessage() == null) ? 0 : exceptionSensorData.getErrorMessage().hashCode()); result = (prime * result) + ((exceptionSensorData.getStackTrace() == null) ? 0 : getCorrectStackTrace(exceptionSensorData.getStackTrace()).hashCode()); return result; } return 0; }
/** * {@inheritDoc} */ @Override public void aggregate(IAggregatedData<ExceptionSensorData> aggregatedObject, ExceptionSensorData objectToAdd) { aggregatedObject.aggregate(objectToAdd); if (null != objectToAdd.getChild()) { aggregate(aggregatedObject, objectToAdd.getChild()); } }
/** * {@inheritDoc} */ @Override public List<HttpTimerData> getAggregatedTimerData(HttpTimerData httpData, boolean includeRequestMethod) { StorageIndexQuery query = httpDataQueryFactory.getFindAllHttpTimersQuery(httpData, null, null); return super.executeQuery(query, new HttpTimerDataAggregator(true, includeRequestMethod)); }
/** * No data to aggregate when an empty list is passed. */ @Test public void emptyListAsParameter() { List<? extends DefaultData> resultList = null; Sensitivity sensitivity = SamplingRateControl.Sensitivity.VERY_COARSE; // from time is Mon Sep 15 10:50:12 CEST 2008 Date fromDate = new Date(1221468612000L); // to time is Mon Sep 15 12:00:00 CEST 2008 Date toDate = new Date(1221472800000L); resultList = mode.adjustSamplingRate(null, fromDate, toDate, sensitivity.getValue(), new ClassLoadingInformationDataAggregator()); assertThat(resultList, is(nullValue())); }
/** * Process the list of elements starting from the fromIndex (inclusive) to toIndex (exclusive). * * @param list * List of elements. * @param fromIndex * Starting index. * @param toIndex * Ending index. */ public void processList(List<E> list, int fromIndex, int toIndex) { int size = list.size(); if ((fromIndex < 0) || (fromIndex >= size)) { throw new IllegalArgumentException("Starting index " + fromIndex + " is not valid for given list of size " + size); } if ((toIndex < fromIndex) || (toIndex > size)) { throw new IllegalArgumentException("Ending index " + toIndex + " is not valid for given list of size " + size + " and starting index " + fromIndex); } for (int i = fromIndex; i < toIndex; i++) { E element = list.get(i); processElement(element); } }
/** * {@inheritDoc} */ @Override public IAggregatedData<ExceptionSensorData> getClone(ExceptionSensorData exceptionData) { AggregatedExceptionSensorData clone = new AggregatedExceptionSensorData(); clone.setPlatformIdent(exceptionData.getPlatformIdent()); clone.setSensorTypeIdent(exceptionData.getSensorTypeIdent()); clone.setThrowableType(exceptionData.getThrowableType()); if ((exceptionAggregationType == ExceptionAggregationType.GROUP_EXCEPTION_OVERVIEW) || (exceptionAggregationType == ExceptionAggregationType.DISTINCT_STACK_TRACES)) { clone.setErrorMessage(exceptionData.getErrorMessage()); } if (exceptionAggregationType == ExceptionAggregationType.DISTINCT_STACK_TRACES) { clone.setStackTrace(getCorrectStackTrace(exceptionData.getStackTrace())); } return clone; }
/** * {@inheritDoc} */ @Override public List<HttpTimerData> getAggregatedTimerData(HttpTimerData httpData, boolean includeRequestMethod, Date fromDate, Date toDate) { StorageIndexQuery query = httpDataQueryFactory.getFindAllHttpTimersQuery(httpData, fromDate, toDate); return super.executeQuery(query, new HttpTimerDataAggregator(true, includeRequestMethod)); }
/** * When the passed data object list isn't empty, then the result list shouldn't be empty too. */ @Test public void resultValuesExist() { List<? extends DefaultData> resultList = null; Sensitivity sensitivity = SamplingRateControl.Sensitivity.VERY_COARSE; // from time is Mon Sep 15 10:50:12 CEST 2008 Date fromDate = new Date(1221468612000L); // to time is Mon Sep 15 12:00:00 CEST 2008 Date toDate = new Date(1221472800000L); resultList = mode.adjustSamplingRate(dataObjects, fromDate, toDate, sensitivity.getValue(), new ClassLoadingInformationDataAggregator()); assertThat(resultList, is(notNullValue())); }
/** * {@inheritDoc} */ @Override public List<HttpTimerData> getTaggedAggregatedTimerData(HttpTimerData httpData, boolean includeRequestMethod, Date fromDate, Date toDate) { StorageIndexQuery query = httpDataQueryFactory.getFindAllTaggedHttpTimersQuery(httpData, fromDate, toDate); return super.executeQuery(query, new HttpTimerDataAggregator(false, includeRequestMethod)); }
/** * {@inheritDoc} */ @Override public void setInputDefinition(InputDefinition inputDefinition) { super.setInputDefinition(inputDefinition); template = new ClassLoadingInformationData(); template.setPlatformIdent(inputDefinition.getIdDefinition().getPlatformId()); template.setSensorTypeIdent(inputDefinition.getIdDefinition().getSensorTypeId()); template.setId(-1L); dataAccessService = inputDefinition.getRepositoryDefinition().getGlobalDataAccessService(); aggregator = new ClassLoadingInformationDataAggregator(); }
/** * {@inheritDoc} */ @Override public List<HttpTimerData> getAggregatedHttpTimerData(HttpTimerData httpData, boolean includeRequestMethod) { IIndexQuery query = httpDataQueryFactory.getFindAllHttpTimersQuery(httpData, null, null); return super.executeQuery(query, new HttpTimerDataAggregator(true, includeRequestMethod), false); }
/** * {@inheritDoc} */ @Override public List<HttpTimerData> getTaggedAggregatedTimerData(HttpTimerData httpData, boolean includeRequestMethod) { StorageIndexQuery query = httpDataQueryFactory.getFindAllTaggedHttpTimersQuery(httpData, null, null); return super.executeQuery(query, new HttpTimerDataAggregator(false, includeRequestMethod)); }
/** * {@inheritDoc} */ @Override public List<HttpTimerData> getAggregatedHttpTimerData(HttpTimerData httpData, boolean includeRequestMethod, Date fromDate, Date toDate) { IIndexQuery query = httpDataQueryFactory.getFindAllHttpTimersQuery(httpData, fromDate, toDate); return super.executeQuery(query, new HttpTimerDataAggregator(true, includeRequestMethod), false); }
/** * {@inheritDoc} */ @Override public List<HttpTimerData> getTaggedAggregatedHttpTimerData(HttpTimerData httpData, boolean includeRequestMethod, Date fromDate, Date toDate) { IIndexQuery query = httpDataQueryFactory.getFindAllTaggedHttpTimersQuery(httpData, fromDate, toDate); return super.executeQuery(query, new HttpTimerDataAggregator(false, includeRequestMethod), false); }