Skip to content

Commit

Permalink
Merge pull request #8 from softvis-research/development
Browse files Browse the repository at this point in the history
merge development into master
  • Loading branch information
rmllr authored Aug 31, 2020
2 parents 75a67e8 + f4cfe94 commit 3cf9d8b
Show file tree
Hide file tree
Showing 10 changed files with 23 additions and 143 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,4 @@ public interface CallsDescriptor extends Descriptor, WeightDescriptor {

@Relation.Incoming
MethodDescriptor getCaller();

}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
public interface RecordDescriptor extends KiekerDescriptor, DirectoryDescriptor {

@Relation("CONTAINS")
List<TraceDescriptor> getTraces();
List<MethodDescriptor> getMethods();

@Relation("CONTAINS")
List<MeasurementDescriptor> getMeasurements();
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,17 @@ protected RecordDescriptor getContainerDescriptor(File container, ScannerContext
final RecordDescriptor recordDescriptor = scannerContext.getStore().addDescriptorType(directoryDescriptor, RecordDescriptor.class);

// Set record receiver that maps read records to corresponding descriptors
KiekerRecordReceiver kiekerRecordReceiver = new KiekerRecordReceiver(new KiekerHelper(scannerContext, recordDescriptor));
KiekerHelper kiekerHelper = new KiekerHelper(scannerContext, recordDescriptor);
KiekerRecordReceiver kiekerRecordReceiver = new KiekerRecordReceiver(kiekerHelper);

// Set filesystem directory reader (reads *.map, *.dat, *.bin, *.xz files in a directory)
// Todo use another reader
FSDirectoryReader fsDirectoryReader = new FSDirectoryReader(container, kiekerRecordReceiver, true);
fsDirectoryReader.run();

// add all methods to record
kiekerHelper.addMethodsToRecord();

return recordDescriptor;
}

Expand All @@ -70,7 +74,6 @@ protected RecordDescriptor getContainerDescriptor(File container, ScannerContext
*/
@Override
protected void enterContainer(File container, RecordDescriptor containerDescriptor, ScannerContext scannerContext) throws IOException {

}

/**
Expand All @@ -82,6 +85,5 @@ protected void enterContainer(File container, RecordDescriptor containerDescript
*/
@Override
protected void leaveContainer(File container, RecordDescriptor containerDescriptor, ScannerContext scannerContext) throws IOException {

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import com.github.benmanes.caffeine.cache.Cache;
import com.github.benmanes.caffeine.cache.Caffeine;
import kieker.common.record.IMonitoringRecord;
import kieker.common.record.flow.trace.TraceMetadata;
import kieker.common.record.flow.trace.operation.AbstractOperationEvent;
import kieker.common.record.flow.trace.operation.AfterOperationEvent;
import kieker.common.record.flow.trace.operation.BeforeOperationEvent;
Expand Down Expand Up @@ -36,7 +35,6 @@ public class KiekerHelper {
private RecordDescriptor recordDescriptor;
private Cache<MethodDescriptorKey, MethodDescriptor> methodDescriptorCache;
private Cache<CallsDescriptorKey, CallsDescriptor> callsDescriptorCache;
private Map<Long, TraceDescriptor> traceCache;
private Map<String, Stack<BeforeOperationEvent>> timestampCache;
private final String REGEX_FOR_METHOD_NAME = "([a-zA-Z0-9_]+) *\\(";

Expand All @@ -45,7 +43,6 @@ public KiekerHelper(ScannerContext scannerContext, RecordDescriptor recordDescri
this.recordDescriptor = recordDescriptor;
this.methodDescriptorCache = Caffeine.newBuilder().maximumSize(100000).build();
this.callsDescriptorCache = Caffeine.newBuilder().maximumSize(10000000).build();
this.traceCache = new HashMap<>();
this.timestampCache = new HashMap<>();
}

Expand All @@ -60,17 +57,6 @@ void createRecord(KiekerMetadataRecord record) {
recordDescriptor.setNumberOfRecords(record.getNumberOfRecords());
}

void createTrace(TraceMetadata trace) {
TraceDescriptor traceDescriptor = scannerContext.getStore().create(TraceDescriptor.class);
traceDescriptor.setLoggingTimestamp(trace.getLoggingTimestamp());
traceDescriptor.setTraceId(trace.getTraceId());
traceDescriptor.setThreadId(trace.getThreadId());
traceDescriptor.setSessionId(trace.getSessionId());
traceDescriptor.setHostname(trace.getHostname());
recordDescriptor.getTraces().add(traceDescriptor);
traceCache.put(trace.getTraceId(), traceDescriptor);
}

void createEvent(AbstractOperationEvent event) {
if (event instanceof BeforeOperationEvent || event instanceof AfterOperationEvent) {
if (event instanceof BeforeOperationEvent) {
Expand All @@ -83,10 +69,6 @@ void createEvent(AbstractOperationEvent event) {
BeforeOperationEvent beforeOperationEvent = popFromTimestampStack(methodDescriptor.getSignature());
if (beforeOperationEvent != null) {
methodDescriptor.setDuration(methodDescriptor.getDuration() + (event.getTimestamp() - beforeOperationEvent.getTimestamp()));
// add method to trace if not already done
if (!getTraceDescriptor(event).getMethods().contains(methodDescriptor)) {
getTraceDescriptor(event).getMethods().add(methodDescriptor);
}
} else {
LOGGER.warn("BeforeOperationEvent for method " + methodDescriptor.getSignature() + " missing.");
}
Expand All @@ -96,12 +78,14 @@ void createEvent(AbstractOperationEvent event) {
CallOperationEvent callOperationEvent = (CallOperationEvent) event;
MethodDescriptor caller = getMethodDescriptor(callOperationEvent.getCallerClassSignature(), callOperationEvent.getCallerOperationSignature());
MethodDescriptor callee = getMethodDescriptor(callOperationEvent.getCalleeClassSignature(), callOperationEvent.getCalleeOperationSignature());
// update number of incoming and outgoing calls
if (callOperationEvent.getOrderIndex() == 1) {
caller.setIncomingCalls(caller.getIncomingCalls() + 1);
}
caller.setOutgoingCalls(caller.getOutgoingCalls() + 1);
callee.setIncomingCalls(callee.getIncomingCalls() + 1);
// add call
addCall(caller, callee);
// add caller to trace if not already done
if (!getTraceDescriptor(event).getMethods().contains(caller)) {
getTraceDescriptor(event).getMethods().add(caller);
}
}
}

Expand All @@ -127,27 +111,19 @@ private synchronized BeforeOperationEvent popFromTimestampStack(String signature
}
}

private TraceDescriptor getTraceDescriptor(AbstractOperationEvent event) {
TraceDescriptor traceDescriptor;
if (traceCache.containsKey(event.getTraceId())) {
traceDescriptor = traceCache.get(event.getTraceId());
} else {
traceDescriptor = scannerContext.getStore().create(TraceDescriptor.class);
traceDescriptor.setTraceId(event.getTraceId());
recordDescriptor.getTraces().add(traceDescriptor);
traceCache.put(event.getTraceId(), traceDescriptor);
}
return traceDescriptor;
}

private MethodDescriptor getMethodDescriptor(String fqn, String signature) {
return methodDescriptorCache.get(MethodDescriptorKey.builder().type(fqn).signature(signature).build(), methodDescriptorKey -> {
Map<String, Object> params = new HashMap<>();
params.put("fqn", fqn);
params.put("typeName", fqn.substring(fqn.lastIndexOf(".") + 1));
params.put("signature", signature);
params.put("methodName", getMethodNameFromSignature(signature));
return scannerContext.getStore().executeQuery("MERGE (t:Kieker:Type{fqn:$fqn}) ON CREATE SET t.name=$typeName MERGE (t)-[:DECLARES]->(m:Kieker:Method{signature:$signature,name:$methodName}) RETURN m", params).getSingleResult().get("m", MethodDescriptor.class);
// exclude encoded signature as no method name can be created
if (signature.endsWith(")")) {
params.put("methodName", getMethodNameFromSignature(signature));
return scannerContext.getStore().executeQuery("MERGE (t:Kieker:Type{fqn:$fqn}) ON CREATE SET t.name=$typeName MERGE (t)-[:DECLARES]->(m:Kieker:Method{signature:$signature,name:$methodName}) RETURN m", params).getSingleResult().get("m", MethodDescriptor.class);
} else {
return scannerContext.getStore().executeQuery("MERGE (t:Kieker:Type{fqn:$fqn}) ON CREATE SET t.name=$typeName MERGE (t)-[:DECLARES]->(m:Kieker:Method{signature:$signature}) RETURN m", params).getSingleResult().get("m", MethodDescriptor.class);
}
});
}

Expand Down Expand Up @@ -276,4 +252,8 @@ private static class CallsDescriptorKey {
private MethodDescriptor callee;

}

public void addMethodsToRecord() {
recordDescriptor.getMethods().addAll(methodDescriptorCache.asMap().values());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import kieker.analysis.plugin.reader.util.IMonitoringRecordReceiver;
import kieker.common.record.IMonitoringRecord;
import kieker.common.record.flow.trace.TraceMetadata;
import kieker.common.record.flow.trace.operation.AbstractOperationEvent;
import kieker.common.record.misc.KiekerMetadataRecord;
import kieker.common.record.system.*;
Expand Down Expand Up @@ -34,8 +33,6 @@ public KiekerRecordReceiver(KiekerHelper kiekerHelper) {
public boolean newMonitoringRecord(IMonitoringRecord iMonitoringRecord) {
if (iMonitoringRecord instanceof KiekerMetadataRecord) {
kiekerHelper.createRecord((KiekerMetadataRecord) iMonitoringRecord);
} else if (iMonitoringRecord instanceof TraceMetadata) {
kiekerHelper.createTrace((TraceMetadata) iMonitoringRecord);
} else if (iMonitoringRecord instanceof AbstractOperationEvent) {
kiekerHelper.createEvent((AbstractOperationEvent) iMonitoringRecord);
} else if (iMonitoringRecord instanceof CPUUtilizationRecord || iMonitoringRecord instanceof DiskUsageRecord ||
Expand Down
1 change: 0 additions & 1 deletion src/main/resources/META-INF/jqassistant-plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
<description>Provides a scanner for Kieker files.</description>
<model>
<class>org.jqassistant.contrib.plugin.kieker.api.model.MethodDescriptor</class>
<class>org.jqassistant.contrib.plugin.kieker.api.model.TraceDescriptor</class>
<class>org.jqassistant.contrib.plugin.kieker.api.model.TypeDescriptor</class>
<class>org.jqassistant.contrib.plugin.kieker.api.model.RecordDescriptor</class>
<class>org.jqassistant.contrib.plugin.kieker.api.model.CallsDescriptor</class>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ public void testMethod() {
// kieker.examples.monitoring.aspectj.Bookstore.searchBook()"
assertThat(testResultProperties.getColumn("m.signature").get(0).toString(),
equalTo("public void kieker.examples.monitoring.aspectj.Bookstore.searchBook()"));
// two events have this function -> 1 After- plus 1 BeforeOperationEvent
assertThat(testResultProperties.getColumn("m.signature").size(), equalTo(1));
store.commitTransaction();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@ public void testRecord() {
File directory = new File(TEST_DIRECTORY_PATH);
store.beginTransaction();
getScanner().scan(directory, TEST_DIRECTORY_PATH, DefaultScope.NONE);
TestResult testResult = query("MATCH (:Record)-[:CONTAINS]->(t:Trace) RETURN t");
// one record with two traces
assertThat(testResult.getColumn("t").size(), equalTo(2));

// test property values
TestResult testResultProperties = query(
Expand Down

This file was deleted.

0 comments on commit 3cf9d8b

Please sign in to comment.