AggregationPerformer<E> aggregationPerformer = new AggregationPerformer<>(aggregator); aggregationPerformer.processCollection(data); data = aggregationPerformer.getResultList();
/** * {@inheritDoc} */ @SuppressWarnings("unchecked") @Override protected void processData(DefaultData defaultData, Map<?, ?> kryoPreferences) { Long key = Long.valueOf(defaultData.getPlatformIdent()); AggregationPerformer<E> aggregationPerformer = aggregationPerformerMap.get(key); if (null == aggregationPerformer) { aggregationPerformer = aggregationPerformerMap.putIfAbsent(key, new AggregationPerformer<>(aggregator)); if (null == aggregationPerformer) { aggregationPerformer = aggregationPerformerMap.get(key); } } // deal with no saving of the invocation affiliation for cached views as well if (Boolean.FALSE.equals(kryoPreferences.get(KryoSerializationPreferences.WRITE_INVOCATION_AFFILIATION_DATA)) && (defaultData instanceof InvocationAwareData)) { InvocationAwareData invocationAwareData = (InvocationAwareData) defaultData; Map<Long, MutableInt> temp = invocationAwareData.getInvocationsParentsIdMap(); invocationAwareData.setInvocationsParentsIdMap(Collections.<Long, MutableInt> emptyMap()); aggregationPerformer.processElement((E) defaultData); invocationAwareData.setInvocationsParentsIdMap(temp); } else { aggregationPerformer.processElement((E) defaultData); } }
/** * {@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)); } }
/** * Process the collection of elements. * * @param collection * Collection that should be aggregated. */ public void processCollection(Collection<E> collection) { for (E element : collection) { processElement(element); } }
/** * 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 void doRefresh(IProgressMonitor monitor, IRootEditor rootEditor) { monitor.beginTask("Getting HTTP timer data information", IProgressMonitor.UNKNOWN); List<HttpTimerData> aggregatedHttpData; if (autoUpdate) { aggregatedHttpData = httptimerDataAccessService.getAggregatedTimerData(template, httpCatorizationOnRequestMethodActive); } else { aggregatedHttpData = httptimerDataAccessService.getAggregatedTimerData(template, httpCatorizationOnRequestMethodActive, fromDate, toDate); } if (regExActive && CollectionUtils.isNotEmpty(aggregatedHttpData)) { AggregationPerformer<HttpTimerData> aggregationPerformer = new AggregationPerformer<>(new RegExHttpAggregator(httpSensorTypeIdent, httpCatorizationOnRequestMethodActive)); aggregationPerformer.processCollection(aggregatedHttpData); aggregatedHttpData = aggregationPerformer.getResultList(); } timerDataList.clear(); if (CollectionUtils.isNotEmpty(aggregatedHttpData)) { timerDataList.addAll(aggregatedHttpData); } monitor.done(); }
aggregationPerformer = new AggregationPerformer<>(aggregator); aggregationPerformer.processCollection(passedData); } else { returnList.addAll(passedData); returnList = aggregationPerformer.getResultList();
@Test public void aggregationWithInspectITHeaderTwoDifferent() { final HttpTimerData data = new HttpTimerData(); Map<String, String> map1 = new HashMap<>(); MapUtils.putAll(map1, new String[][] { { HttpTimerData.INSPECTIT_TAGGING_HEADER, "tag1" } }); data.setHeaders(map1); data.getHttpInfo().setUri("URI"); data.getHttpInfo().setRequestMethod("GET"); final HttpTimerData data2 = new HttpTimerData(); Map<String, String> map2 = new HashMap<>(); MapUtils.putAll(map2, new String[][] { { HttpTimerData.INSPECTIT_TAGGING_HEADER, "tag2" } }); data2.setHeaders(map2); data2.getHttpInfo().setUri("URI"); data2.getHttpInfo().setRequestMethod("GET"); final List<HttpTimerData> input = new ArrayList<>(); Collections.addAll(input, data, data2); AggregationPerformer<HttpTimerData> aggregationPerformer = new AggregationPerformer<>(new HttpTimerDataAggregator(false, false)); aggregationPerformer.processCollection(input); final List<HttpTimerData> output = aggregationPerformer.getResultList(); assertThat(output, is(notNullValue())); assertThat(output.size(), is(equalTo(2))); }
@Test public void aggregationURI() { 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, false)); aggregationPerformer.processCollection(input); final List<HttpTimerData> output = aggregationPerformer.getResultList(); assertThat(output, is(notNullValue())); assertThat(output.size(), is(equalTo(1))); HttpTimerData result = output.get(0); assertThat(result.getHttpInfo().getUri(), is(equalTo("URI"))); assertThat(result.getHttpInfo().hasInspectItTaggingHeader(), is(equalTo(false))); assertThat(result.getDuration(), is(equalTo(600d))); assertThat(result.getCpuDuration(), is(equalTo(30d))); }
Collections.addAll(input, data, data2); AggregationPerformer<HttpTimerData> aggregationPerformer = new AggregationPerformer<>(new HttpTimerDataAggregator(false, false)); aggregationPerformer.processCollection(input); final List<HttpTimerData> output = aggregationPerformer.getResultList();
@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))); }