Skip to content
Snippets Groups Projects
Commit 8a876f3f authored by Reiner Jung's avatar Reiner Jung
Browse files

Update of architecture model creation.

parent bce6f42f
No related branches found
No related tags found
No related merge requests found
Showing
with 269 additions and 17 deletions
......@@ -25,9 +25,12 @@ subprojects {
}
dependencies {
implementation 'net.kieker-monitoring:kieker:1.15-SNAPSHOT'
implementation 'net.kieker-monitoring:kieker:1.15-SNAPSHOT:jar'
implementation 'net.sourceforge.teetime:teetime:3.0'
implementation 'com.beust:jcommander:1.78'
implementation 'ch.qos.logback:logback-classic:1.1.7'
implementation 'org.slf4j:slf4j-api:1.7.30'
implementation 'org.codehaus.groovy:groovy-all:3.0.2'
// Use JUnit test framework
testImplementation 'junit:junit:4.13'
......
......@@ -13,6 +13,8 @@ plugins {
dependencies {
implementation project(':analysis')
// https://mvnrepository.com/artifact/org.eclipse.emf/org.eclipse.emf.ecore
implementation 'org.eclipse.emf:org.eclipse.emf.ecore:2.23.0'
}
application {
......
......@@ -17,13 +17,13 @@ public class ArchitectureModelSettings {
@Parameter(names = { "-i", "--input" }, required = true, converter = FileConverter.class, description = "Input Kieker log directory")
private File inputFile;
@Parameter(names = { "-o", "--output" }, required = true, converter = FileConverter.class, description = "Output directory where to put the Kieker log directory")
@Parameter(names = { "-o", "--output" }, required = true, converter = FileConverter.class, description = "Output directory where to put the graphics")
private File outputFile;
@Parameter(names = { "-a", "--addrline" }, required = true, converter = FileConverter.class, description = "Location of the addrline tool")
private File addrlineExecutable;
@Parameter(names = { "-m", "--model" }, required = true, converter = FileConverter.class, description = "Location of the model executable")
@Parameter(names = { "-e", "--executable" }, required = true, converter = FileConverter.class, description = "Location of the executable")
private File modelExecutable;
public File getInputFile() {
......
/**
*
*/
package org.oceandsl.architecture.model;
/**
* @author reiner
*
*/
public class Call {
private final String fromClassSignature;
private final String fromOperationSignature;
private final String toClassSignature;
private final String toOperationSignature;
public Call(ECallType before, String fromClassSignature, String fromOperationSignature, String toClassSignature,
String toOperationSignature) {
this.fromClassSignature = fromClassSignature;
this.fromOperationSignature = fromOperationSignature;
this.toClassSignature = toClassSignature;
this.toOperationSignature = toOperationSignature;
}
public final String getFromClassSignature() {
return fromClassSignature;
}
public final String getFromOperationSignature() {
return fromOperationSignature;
}
public final String getToClassSignature() {
return toClassSignature;
}
public final String getToOperationSignature() {
return toOperationSignature;
}
@Override
public boolean equals(Object object) {
if (object instanceof Call) {
Call otherCall = (Call)object;
return compareValues(this.fromClassSignature, otherCall.getFromClassSignature()) &&
compareValues(this.fromOperationSignature, otherCall.getFromOperationSignature()) &&
compareValues(this.toClassSignature, otherCall.getToClassSignature()) &&
compareValues(this.toOperationSignature, otherCall.getToOperationSignature());
} else
return false;
}
private boolean compareValues(String from, String to) {
if (from == null && to == null)
return true;
return from != null && to != null && from.equals(to);
}
}
/**
*
*/
package org.oceandsl.architecture.model;
import teetime.stage.basic.AbstractTransformation;
/**
* @author reiner
*
*/
public class CountEvents<T> extends AbstractTransformation<T, T> {
private long counter;
private final long interval;
public CountEvents(final long interval) {
this.interval = interval;
}
@Override
protected void execute(final T element) throws Exception {
this.counter++;
if ((this.counter % this.interval) == 0) {
this.logger.info("Received {} events.", this.counter);
}
this.outputPort.send(element);
}
@Override
protected void onTerminating() {
this.logger.info("Received {} events.", this.counter);
super.onTerminating();
}
}
/**
*
*/
package org.oceandsl.architecture.model;
import java.util.ArrayList;
import java.util.List;
import teetime.framework.AbstractConsumerStage;
import teetime.framework.OutputPort;
/**
* @author reiner
*
*/
public class CountUniqueCalls extends AbstractConsumerStage<Call> {
private final List<StoredCall> storedCalls = new ArrayList<>();
private final OutputPort<List<StoredCall>> outputPort = this.createOutputPort();
@Override
protected void execute(final Call element) throws Exception {
for (final StoredCall storedCall : this.storedCalls) {
if (storedCall.getCall().equals(element)) {
storedCall.increment();
return;
}
}
this.storedCalls.add(new StoredCall(1, element));
}
private void printStore() {
for (final StoredCall storedCall : this.storedCalls) {
final Call call = storedCall.getCall();
this.logger.info(
String.format("%s:%s -> %s:%s (%d)", call.getFromClassSignature(), call.getFromOperationSignature(),
call.getToClassSignature(), call.getToOperationSignature(), storedCall.getCount()));
}
}
@Override
protected void onTerminating() {
this.printStore();
this.outputPort.send(this.storedCalls);
super.onTerminating();
}
private class StoredCall {
private long count;
private final Call call;
public StoredCall(final long count, final Call call) {
this.count = count;
this.call = call;
}
public Call getCall() {
return this.call;
}
public void increment() {
this.count++;
}
public long getCount() {
return this.count;
}
}
public OutputPort<List<StoredCall>> getOutputPort() {
return this.outputPort;
}
}
/**
*
*/
package org.oceandsl.architecture.model;
import java.util.HashMap;
import java.util.Map;
import kieker.common.record.flow.IFlowRecord;
import kieker.common.record.flow.trace.operation.BeforeOperationEvent;
import teetime.framework.AbstractConsumerStage;
import teetime.framework.OutputPort;
/**
* @author reiner
*
*/
public class CreateCallsStage extends AbstractConsumerStage<IFlowRecord> {
private final Map<Long,BeforeOperationEvent> cachedTraces = new HashMap<>();
private OutputPort<Call> outputPort = this.createOutputPort(Call.class);
@Override
protected void execute(IFlowRecord element) throws Exception {
if (element instanceof BeforeOperationEvent) {
BeforeOperationEvent currentEvent = (BeforeOperationEvent)element;
BeforeOperationEvent previousEvent = cachedTraces.get(currentEvent.getTraceId());
if (previousEvent != null) {
this.outputPort.send(new Call(ECallType.BEFORE,
previousEvent.getClassSignature(),
previousEvent.getOperationSignature(),
currentEvent.getClassSignature(),
currentEvent.getOperationSignature()));
}
cachedTraces.put(currentEvent.getTraceId(), currentEvent);
}
}
public OutputPort<Call> getOutputPort() {
return outputPort;
}
}
/**
*
*/
package org.oceandsl.architecture.model;
/**
* @author reiner
*
*/
public enum ECallType {
BEFORE,
AFTER
}
/**
*
*
*/
package org.oceandsl.architecture.model;
......@@ -7,8 +7,16 @@ import java.io.IOException;
import org.oceandsl.analysis.RewriteBeforeAndAfterEventsStage;
import kieker.analysis.model.DeploymentModelAssemblerStage;
import kieker.analysisteetime.model.analysismodel.assembly.AssemblyFactory;
import kieker.analysisteetime.model.analysismodel.assembly.AssemblyModel;
import kieker.analysisteetime.model.analysismodel.deployment.DeploymentFactory;
import kieker.analysisteetime.model.analysismodel.deployment.DeploymentModel;
import kieker.common.record.IMonitoringRecord;
import kieker.common.record.flow.IFlowRecord;
import kieker.tools.source.LogsReaderCompositeStage;
import teetime.framework.Configuration;
import teetime.stage.InstanceOfFilter;
/**
* @author reiner
......@@ -16,17 +24,30 @@ import teetime.framework.Configuration;
*/
public class TeetimeConfiguration extends Configuration {
public TeetimeConfiguration(ArchitectureModelSettings parameterConfiguration) throws IOException {
kieker.common.configuration.Configuration configuration = new kieker.common.configuration.Configuration();
configuration.setProperty(LogsReaderCompositeStage.LOG_DIRECTORIES,
parameterConfiguration.getInputFile().getCanonicalPath());
LogsReaderCompositeStage reader = new LogsReaderCompositeStage(configuration);
RewriteBeforeAndAfterEventsStage processor = new RewriteBeforeAndAfterEventsStage(parameterConfiguration.getAddrlineExecutable(),
parameterConfiguration.getModelExecutable());
this.connectPorts(reader.getOutputPort(), processor.getInputPort());
}
public TeetimeConfiguration(final ArchitectureModelSettings parameterConfiguration) throws IOException {
final kieker.common.configuration.Configuration configuration = new kieker.common.configuration.Configuration();
configuration.setProperty(LogsReaderCompositeStage.LOG_DIRECTORIES,
parameterConfiguration.getInputFile().getCanonicalPath());
final LogsReaderCompositeStage reader = new LogsReaderCompositeStage(configuration);
final RewriteBeforeAndAfterEventsStage processor = new RewriteBeforeAndAfterEventsStage(
parameterConfiguration.getAddrlineExecutable(), parameterConfiguration.getModelExecutable());
final InstanceOfFilter<IMonitoringRecord, IFlowRecord> instanceOfFilter = new InstanceOfFilter<>(
IFlowRecord.class);
// final CreateCallsStage callsStage = new CreateCallsStage();
// final CountUniqueCalls countStage = new CountUniqueCalls();
final CountEvents<IFlowRecord> counter = new CountEvents<>(1000000);
final AssemblyModel assemblyModel = AssemblyFactory.eINSTANCE.createAssemblyModel();
final DeploymentModel deploymentModel = DeploymentFactory.eINSTANCE.createDeploymentModel();
final DeploymentModelAssemblerStage deploymentModelAssemblerStage = new DeploymentModelAssemblerStage(
assemblyModel, deploymentModel);
this.connectPorts(reader.getOutputPort(), processor.getInputPort());
this.connectPorts(processor.getOutputPort(), instanceOfFilter.getInputPort());
this.connectPorts(instanceOfFilter.getMatchedOutputPort(), counter.getInputPort());
this.connectPorts(counter.getOutputPort(), deploymentModelAssemblerStage.getInputPort());
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment