/** * {@inheritDoc} */ public boolean isOnlyFoundInInvocations() { return getInvocationAffiliationPercentage() == 1d; }
/** * {@inheritDoc} */ @Override public boolean canBeProcessed(DefaultData defaultData) { if (null == defaultData) { return false; } else if (!(defaultData instanceof MethodSensorData)) { // we only put to buffer method sensor data return false; } else if (defaultData instanceof InvocationAwareData) { // we don't put to buffer elements that are inside of invocation if (!((InvocationAwareData) defaultData).isOnlyFoundOutsideInvocations()) { return false; } } else if (defaultData instanceof InvocationSequenceData) { // we don't put to buffer invocations that are not root if (((InvocationSequenceData) defaultData).getParentSequence() != null) { return false; } } return true; }
/** * {@inheritDoc} */ @SuppressWarnings("unchecked") @Override public void write(Kryo kryo, Output output, T object) { ObjectMap<Object, Object> garphContext = kryo.getGraphContext(); if (Boolean.FALSE.equals(garphContext.get(KryoSerializationPreferences.WRITE_INVOCATION_AFFILIATION_DATA))) { Map<Long, MutableInt> temp = object.getInvocationsParentsIdMap(); object.setInvocationsParentsIdMap(Collections.<Long, MutableInt> emptyMap()); super.write(kryo, output, object); object.setInvocationsParentsIdMap(temp); } else { super.write(kryo, output, object); } } }
/** * Tests the simple aggregation when objects are in same invocations. */ @Test public void simpleSameParentsAggregation() { InvocationAwareData i1 = getInvocationAwareData(); i1.addInvocationParentId(Long.valueOf(1)); InvocationAwareData i2 = getInvocationAwareData(); i2.addInvocationParentId(Long.valueOf(1)); i1.aggregateInvocationAwareData(i2); assertThat(i1.getObjectsInInvocationsCount(), is(equalTo(2))); assertThat(i1.getInvocationParentsIdSet().size(), is(equalTo(1))); assertThat(i1.getInvocationParentsIdSet(), contains(1L)); }
/** * {@inheritDoc} */ @Override public DetailsTable generate(DefaultData defaultData, RepositoryDefinition repositoryDefinition, Composite parent, FormToolkit toolkit) { InvocationAwareData invocationAwareData = (InvocationAwareData) defaultData; DetailsTable table = new DetailsTable(parent, toolkit, "Invocation Affiliation", 1); table.addContentRow("In Invocations:", null, new DetailsCellContent[] { new YesNoDetailsCellContent(!invocationAwareData.isOnlyFoundOutsideInvocations()) }); if (!invocationAwareData.isOnlyFoundOutsideInvocations()) { int percentage = (int) (invocationAwareData.getInvocationAffiliationPercentage() * 100); int invocations = invocationAwareData.getInvocationParentsIdSet().size(); String affiliation = TextFormatter.getInvocationAffilliationPercentageString(percentage, invocations).getString(); table.addContentRow("Affiliation:", null, new DetailsCellContent[] { new DetailsCellContent(affiliation) }); } return table; }
when(invocationAwareData.isOnlyFoundInInvocations()).thenReturn(false); when(invocationAwareData.isOnlyFoundOutsideInvocations()).thenReturn(false); processor.process(invocationAwareData, entityManager); verifyZeroInteractions(buffer, entityManager); when(invocationAwareData.isOnlyFoundInInvocations()).thenReturn(false); when(invocationAwareData.isOnlyFoundOutsideInvocations()).thenReturn(true); processor.process(invocationAwareData, entityManager); ArgumentCaptor<IBufferElement> captor = ArgumentCaptor.forClass(IBufferElement.class);
/** * {@inheritDoc} */ @Override public void doRefresh(IProgressMonitor monitor, IRootEditor rootEditor) { monitor.beginTask("Updating Invocation Overview", IProgressMonitor.UNKNOWN); monitor.subTask("Retrieving the Invocation Overview from the CMR"); List<InvocationSequenceData> invocData; Set<Long> invocationIdsSet = new HashSet<>(); for (InvocationAwareData invocationAwareData : invocationAwareDataList) { if (null != invocationAwareData.getInvocationParentsIdSet()) { invocationIdsSet.addAll(invocationAwareData.getInvocationParentsIdSet()); } } long platformIdent = getInputDefinition().getIdDefinition().getPlatformId(); invocData = getDataAccessService().getInvocationSequenceOverview(platformIdent, invocationIdsSet, getLimit(), getResultComparator()); getInvocationSequenceData().clear(); if (!invocData.isEmpty()) { monitor.subTask("Displaying the Invocation Overview"); getInvocationSequenceData().addAll(invocData); } monitor.done(); }
/** * {@inheritDoc} */ @Override public boolean canBeProcessed(DefaultData defaultData) { if (null != defaultData) { // only directly index the invocation aware data that is in invocation return (defaultData instanceof InvocationAwareData) && ((InvocationAwareData) defaultData).isOnlyFoundInInvocations(); } return false; }
/** * Aggregates the data correlated to the invocation parents. Note that this method has to be * called from the subclasses when they implement any kind of aggregation. * * @param invocationAwareData * Data to aggregate to current object. */ public void aggregateInvocationAwareData(InvocationAwareData invocationAwareData) { if (null != invocationAwareData.getInvocationsParentsIdMap()) { if (null == invocationsParentsIdMap) { invocationsParentsIdMap = new HashMap<Long, MutableInt>(); } for (Map.Entry<Long, MutableInt> entry : invocationAwareData.getInvocationsParentsIdMap().entrySet()) { MutableInt count = invocationsParentsIdMap.get(entry.getKey()); if (null != count) { count.add(entry.getValue().getValue()); } else { invocationsParentsIdMap.put(entry.getKey(), new MutableInt(entry.getValue().getValue())); } } } }
/** * Aggregates the values given in the supplied timer data parameter to the objects data. * * @param timerData * Data to be aggregated into current object. */ public void aggregateTimerData(TimerData timerData) { super.aggregateInvocationAwareData(timerData); this.setCount(this.getCount() + timerData.getCount()); this.setDuration(this.getDuration() + timerData.getDuration()); this.calculateMax(timerData.getMax()); this.calculateMin(timerData.getMin()); if (timerData.isCpuMetricDataAvailable()) { this.setCpuDuration(this.getCpuDuration() + timerData.getCpuDuration()); this.calculateCpuMax(timerData.getCpuMax()); this.calculateCpuMin(timerData.getCpuMin()); } if (timerData.isExclusiveTimeDataAvailable()) { this.addExclusiveDuration(timerData.getExclusiveDuration()); this.setExclusiveCount(this.getExclusiveCount() + timerData.getExclusiveCount()); this.calculateExclusiveMax(timerData.getExclusiveMax()); this.calculateExclusiveMin(timerData.getExclusiveMin()); } this.charting = this.charting | timerData.isCharting(); }
return true; if (!super.equals(obj)) { return false;
/** * Tests the simple aggregation when objects are in different invocations. */ @Test public void simpleDifferentParentsAggregation() { InvocationAwareData i1 = getInvocationAwareData(); i1.addInvocationParentId(Long.valueOf(1)); InvocationAwareData i2 = getInvocationAwareData(); i2.addInvocationParentId(Long.valueOf(2)); i1.aggregateInvocationAwareData(i2); assertThat(i1.getObjectsInInvocationsCount(), is(equalTo(2))); assertThat(i1.getInvocationParentsIdSet().size(), is(equalTo(2))); assertThat(i1.getInvocationParentsIdSet(), contains(1L, 2L)); }
when(invocationAwareData.isOnlyFoundInInvocations()).thenReturn(false); when(invocationAwareData.isOnlyFoundOutsideInvocations()).thenReturn(false); processor.process(invocationAwareData, entityManager); when(invocationAwareData.isOnlyFoundOutsideInvocations()).thenReturn(true); processor.process(invocationAwareData, entityManager); verifyZeroInteractions(log, indexingTree, entityManager); when(invocationAwareData.isOnlyFoundInInvocations()).thenReturn(true); when(invocationAwareData.isOnlyFoundOutsideInvocations()).thenReturn(false); processor.process(invocationAwareData, entityManager); verify(indexingTree, times(1)).put(invocationAwareData);
idSet.addAll(((InvocationAwareData) template).getInvocationParentsIdSet());
return true; if (!super.equals(obj)) { return false;
/** * Tests the complicated aggregation when objects are in same invocations. */ @Test public void complicatedSameParentsAggregation() { InvocationAwareData i1 = getInvocationAwareData(); i1.addInvocationParentId(Long.valueOf(1)); InvocationAwareData i2 = getInvocationAwareData(); i2.addInvocationParentId(Long.valueOf(2)); i1.aggregateInvocationAwareData(i2); InvocationAwareData i3 = getInvocationAwareData(); i3.addInvocationParentId(Long.valueOf(1)); InvocationAwareData i4 = getInvocationAwareData(); i4.addInvocationParentId(Long.valueOf(2)); i3.aggregateInvocationAwareData(i4); i1.aggregateInvocationAwareData(i3); assertThat(i1.getObjectsInInvocationsCount(), is(equalTo(4))); assertThat(i1.getInvocationParentsIdSet().size(), is(equalTo(2))); assertThat(i1.getInvocationParentsIdSet(), contains(1L, 2L)); }
/** * {@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} */ public boolean isOnlyFoundOutsideInvocations() { return getInvocationAffiliationPercentage() == 0d; }
if (selectedObject instanceof InvocationAwareData) { InvocationAwareData invocationAwareData = (InvocationAwareData) selectedObject; if (!invocationAwareData.isOnlyFoundOutsideInvocations()) { return true;
textualDesc = TextFormatter.getInvocationAwareDataTextualRepresentation(invocationAwareData, repositoryDefinition); if (null != invocationAwareData.getInvocationParentsIdSet()) { invocationAwareDataList.add(invocationAwareData); invocationsCount += invocationAwareData.getInvocationParentsIdSet().size();