Skip to content
Snippets Groups Projects
Commit e074f6db authored by Jürgen Walter's avatar Jürgen Walter
Browse files

new resource demand filter

parent b91afb57
No related branches found
No related tags found
No related merge requests found
package tools.descartes.pmx.core.filter.resourcedemands;
import java.text.DecimalFormat;
import java.text.NumberFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.SortedSet;
import kieker.analysis.IProjectContext;
import kieker.analysis.plugin.annotation.InputPort;
import kieker.analysis.plugin.annotation.OutputPort;
import kieker.analysis.plugin.annotation.Plugin;
import kieker.common.configuration.Configuration;
import kieker.common.record.IMonitoringRecord;
import kieker.common.record.controlflow.OperationExecutionRecord;
import kieker.common.record.system.CPUUtilizationRecord;
import kieker.common.util.signature.ClassOperationSignaturePair;
import kieker.common.util.signature.Signature;
import kieker.tools.traceAnalysis.filter.AbstractTraceAnalysisFilter;
import kieker.tools.traceAnalysis.filter.executionRecordTransformation.ExecutionRecordTransformationFilter;
import kieker.tools.traceAnalysis.systemModel.AbstractMessage;
import kieker.tools.traceAnalysis.systemModel.Execution;
import kieker.tools.traceAnalysis.systemModel.ExecutionTrace;
import kieker.tools.traceAnalysis.systemModel.ExecutionTraceBasedSession;
import kieker.tools.traceAnalysis.systemModel.MessageTrace;
import org.apache.log4j.Logger;
import tools.descartes.librede.Librede;
import tools.descartes.librede.ResultTable;
import tools.descartes.librede.approach.ResponseTimeApproximationApproach;
import tools.descartes.librede.approach.ServiceDemandLawApproach;
import tools.descartes.librede.approach.ZhangKalmanFilterApproach;
import tools.descartes.librede.configuration.ConfigurationFactory;
import tools.descartes.librede.configuration.EstimationApproachConfiguration;
import tools.descartes.librede.configuration.EstimationSpecification;
import tools.descartes.librede.configuration.ExporterConfiguration;
import tools.descartes.librede.configuration.InputSpecification;
import tools.descartes.librede.configuration.LibredeConfiguration;
import tools.descartes.librede.configuration.OutputSpecification;
import tools.descartes.librede.configuration.Parameter;
import tools.descartes.librede.configuration.Resource;
import tools.descartes.librede.configuration.Service;
import tools.descartes.librede.configuration.TraceConfiguration;
import tools.descartes.librede.configuration.TraceToEntityMapping;
import tools.descartes.librede.configuration.ValidationSpecification;
import tools.descartes.librede.configuration.WorkloadDescription;
import tools.descartes.librede.export.IExporter;
import tools.descartes.librede.export.csv.CsvExporter;
import tools.descartes.librede.linalg.LinAlg;
import tools.descartes.librede.linalg.Matrix;
import tools.descartes.librede.linalg.Vector;
import tools.descartes.librede.registry.Registry;
import tools.descartes.librede.repository.IMonitoringRepository;
import tools.descartes.librede.repository.MemoryObservationRepository;
import tools.descartes.librede.repository.StandardMetric;
import tools.descartes.librede.repository.TimeSeries;
import tools.descartes.librede.util.RepositoryUtil;
import tools.descartes.librede.util.RepositoryUtil.Range;
@Plugin(name = "Class and interface filter, CAIF", description = "Extracts class-information from incoming monitoring records", outputPorts = {
@OutputPort(name = ResourceDemandFilter2.OUTPUT_PORT_NAME, description = "Outputs untouched information", eventTypes = { IMonitoringRecord.class }),
@OutputPort(name = ResourceDemandFilter2.OUTPUT_PORT_NAME_OTHER, description = "Outputs untouched information", eventTypes = { IMonitoringRecord.class }),
@OutputPort(name = ResourceDemandFilter2.OUTPUT_PORT_NAME_DEMANDS, description = "Outputs resource demands", eventTypes = { HashMap.class }), })
public class ResourceDemandFilter2 extends AbstractTraceAnalysisFilter {
private static final Logger log = Logger
.getLogger(ResourceDemandFilter2.class);
public static final String INPUT_PORT_NAME_MESSAGE_TRACES = "messageTraces";
public static final String OUTPUT_PORT_NAME = "forwardingOpExRecord";
public static final String OUTPUT_PORT_NAME_OTHER = "untouchedIMonitoringRecord";
public static final String OUTPUT_PORT_NAME_DEMANDS = "resourceDemands";
/**
* Name of the configuration property to pass the directory of the output.
*/
public static final String CONFIG_PROPERTY_NAME_OUTPUT_FN = "outputDirectory";
/**
* By default, writes output files to this file in the working directory.
*/
private final String outputPath;
private static Map<String, TimeSeries> timeSeriesMap;
Map<String, List<String>> externalCallMethods = new HashMap<String, List<String>>();
Map<String, Double> externalCallTime = new HashMap<String, Double>();
public ResourceDemandFilter2(final Configuration configuration,
final IProjectContext projectContext) {
super(configuration, projectContext);
this.outputPath = configuration
.getPathProperty(CONFIG_PROPERTY_NAME_OUTPUT_FN);
timeSeriesMap = new HashMap<String, TimeSeries>();
}
@InputPort(name = ResourceDemandFilter2.INPUT_PORT_NAME_MESSAGE_TRACES, description = "Extract class-information from monitoring record", eventTypes = { MessageTrace.class })
public void runFilter(final MessageTrace session) {
List<AbstractMessage> messages = session.getSequenceAsVector();
for (AbstractMessage message : messages) {
Execution x = message.getSendingExecution();
Execution y = message.getReceivingExecution();
//log.info(message);
if (x.getEss() < y.getEss()) {
String key = x.getAllocationComponent().getAssemblyComponent()
.getType().getTypeName()
+ "." + x.getOperation().getSignature().getName();
List<String> list = externalCallMethods.get(key);
double time = (y.getTout() - y.getTin() ); // / (1000.0 *1000.0 * 1000.0); // in seconds;
double timeSum;
if(externalCallTime.get(key) == null){
timeSum = 0;
}else{
timeSum = externalCallTime.get(key);
}
externalCallTime.put(key, timeSum + time);
if (list == null) {
list = new ArrayList<String>();
}
list.add(y.getAllocationComponent().getAssemblyComponent()
.getType().getTypeName()
+ "." + y.getOperation().getSignature().getName());
externalCallMethods.put(key, list);
}
}
NumberFormat formatter = new DecimalFormat("#0.00000000");
for (String key : externalCallMethods.keySet()) {
log.info(formatter.format(externalCallTime.get(key)/ (1000.0 *1000.0 *
1000.0))+ " sec external for "+key + " " + externalCallMethods.get(key) );
}
// //Auflsung der Zeimessung < 1ms
// // Michael Kupperberg auflsung von Timern
// Signature signature = componentNameSignaturePair.getSignature();
//
// addToTimeSeries(timestamp,
// componentNameSignaturePair.getSimpleClassname()
// +"."+signature.getName(), exTime);
// super.deliver(OUTPUT_PORT_NAME, opExRecord);
}
@Override
public Configuration getCurrentConfiguration() {
return new Configuration();
}
/**
* {@inheritDoc}
*/
@Override
public void terminate(final boolean errorBeforeTermination) {
log.info(ResourceDemandFilter2.class + " terminated");
}
}
......@@ -6,6 +6,7 @@ import kieker.analysis.IAnalysisController;
import kieker.analysis.exception.AnalysisConfigurationException;
import kieker.analysis.plugin.reader.filesystem.FSReader;
import kieker.common.configuration.Configuration;
import kieker.tools.traceAnalysis.filter.flow.TraceEventRecords2ExecutionAndMessageTraceFilter;
import tools.descartes.pmx.core.filter.FilterPortTuple;
import tools.descartes.pmx.core.util.filter.CpuFilterPlugin;
import tools.descartes.pmx.core.util.filter.ExecutionTimeFilterPlugin;
......@@ -14,9 +15,10 @@ import tools.descartes.pmx.core.util.filter.ResourceFilterPlugin;
public class ResourceDemandFilterAppender {
public static FilterPortTuple addResourceDemandFilter(
final FilterPortTuple reader_fpt, String resultPath, IAnalysisController analysisController)
final FilterPortTuple reader_fpt, String resultPath,
IAnalysisController analysisController)
throws AnalysisConfigurationException {
final Configuration exTimeFilterConfig = new Configuration();
exTimeFilterConfig.setProperty(
ExecutionTimeFilterPlugin.CONFIG_PROPERTY_NAME_TS_NANOS, "1");
......@@ -29,16 +31,19 @@ public class ResourceDemandFilterAppender {
final MemSwapFilterPlugin memSwapFilter = new MemSwapFilterPlugin(
new Configuration(), analysisController);
// Connect components.
analysisController.connect(reader_fpt.filter, FSReader.OUTPUT_PORT_NAME_RECORDS,
exTimeFilter, ExecutionTimeFilterPlugin.INPUT_PORT_NAME);
analysisController.connect(reader_fpt.filter, FSReader.OUTPUT_PORT_NAME_RECORDS,
resourceFilter, ResourceFilterPlugin.INPUT_PORT_NAME);
analysisController.connect(reader_fpt.filter, FSReader.OUTPUT_PORT_NAME_RECORDS,
cpuFilter, CpuFilterPlugin.INPUT_PORT_NAME);
analysisController.connect(reader_fpt.filter, FSReader.OUTPUT_PORT_NAME_RECORDS,
memSwapFilter, MemSwapFilterPlugin.INPUT_PORT_NAME);
analysisController.connect(reader_fpt.filter,
FSReader.OUTPUT_PORT_NAME_RECORDS, exTimeFilter,
ExecutionTimeFilterPlugin.INPUT_PORT_NAME);
analysisController.connect(reader_fpt.filter,
FSReader.OUTPUT_PORT_NAME_RECORDS, resourceFilter,
ResourceFilterPlugin.INPUT_PORT_NAME);
analysisController.connect(reader_fpt.filter,
FSReader.OUTPUT_PORT_NAME_RECORDS, cpuFilter,
CpuFilterPlugin.INPUT_PORT_NAME);
analysisController.connect(reader_fpt.filter,
FSReader.OUTPUT_PORT_NAME_RECORDS, memSwapFilter,
MemSwapFilterPlugin.INPUT_PORT_NAME);
final Configuration resourceDemandFilterConfiguration = new Configuration();
resourceDemandFilterConfiguration.setProperty(
ResourceDemandFilter.CONFIG_PROPERTY_NAME_OUTPUT_FN, resultPath
......@@ -51,7 +56,33 @@ public class ResourceDemandFilterAppender {
analysisController.connect(exTimeFilter,
ExecutionTimeFilterPlugin.OUTPUT_PORT_NAME_VALID,
resourceDemandFilter, ResourceDemandFilter.INPUT_PORT_NAME);
return new FilterPortTuple(resourceDemandFilter, ResourceDemandFilter.OUTPUT_PORT_NAME_DEMANDS);
return new FilterPortTuple(resourceDemandFilter,
ResourceDemandFilter.OUTPUT_PORT_NAME_DEMANDS);
}
public static FilterPortTuple addResourceDemandFilter2(
final FilterPortTuple traceEvents2ExecutionAndMessageTraceFilter,
String resultPath, IAnalysisController analysisController)
throws AnalysisConfigurationException {
final Configuration resourceDemandFilterConfiguration = new Configuration();
resourceDemandFilterConfiguration.setProperty(
ResourceDemandFilter.CONFIG_PROPERTY_NAME_OUTPUT_FN, resultPath
+ "/resourcedemands/");
(new File(resultPath + "/resourcedemands/")).mkdir();
ResourceDemandFilter2 resourceDemandFilter2 = new ResourceDemandFilter2(
resourceDemandFilterConfiguration, analysisController);
analysisController
.connect(
traceEvents2ExecutionAndMessageTraceFilter.filter,
TraceEventRecords2ExecutionAndMessageTraceFilter.OUTPUT_PORT_NAME_MESSAGE_TRACE,
resourceDemandFilter2,
ResourceDemandFilter2.INPUT_PORT_NAME_MESSAGE_TRACES);
return traceEvents2ExecutionAndMessageTraceFilter;
}
}
......@@ -27,6 +27,7 @@ import tools.descartes.pmx.core.filter.KiekerFilterAppender;
import tools.descartes.pmx.core.filter.controlflow.MyControlFlowFilter;
import tools.descartes.pmx.core.filter.controlflow.MyControlFlowFilter2;
import tools.descartes.pmx.core.filter.resourcedemands.ObjectExporter;
import tools.descartes.pmx.core.filter.resourcedemands.ResourceDemandFilter;
import tools.descartes.pmx.core.filter.resourcedemands.ResourceDemandFilterAppender;
import tools.descartes.pmx.core.filter.usage.UsageFilterAppender;
......@@ -41,19 +42,10 @@ public class SystemFilterAppender {
FilterPortTuple traceReconstruction_fpt = KiekerFilterAppender
.addStandardGraphFilters(analysisController,
systemModelRepository, reader_fpt);
FilterPortTuple sessionReconstruction_fpt = KiekerFilterAppender
.addSessionReconstructionFilters(analysisController,
traceReconstruction_fpt);
FilterPortTuple resourceDemand_fpt = ResourceDemandFilterAppender.addResourceDemandFilter(reader_fpt,
resultPath, analysisController);
UsageFilterAppender.addUsageFilter(sessionReconstruction_fpt,
analysisController, resultPath);
resultPath, analysisController);
SystemFilterAppender.addSystem2HTMLFilter(systemModelRepository,
analysisController, resultPath);
// ControlFlowFilterAppender.addControlFlowFilter(analysisController,
// systemModelRepository, resultPath, traces_fpt,
// traceReconstruction_fpt, builder);
SystemFilterAppender.addSystemFilter(traces_fpt,
traceReconstruction_fpt, resourceDemand_fpt, systemModelRepository, builder,
analysisController, resultPath);
......@@ -157,7 +149,7 @@ public class SystemFilterAppender {
TraceReconstructionFilter.OUTPUT_PORT_NAME_MESSAGE_TRACE,
operationDependencyGraphAllocationFilter,
OperationDependencyGraphAllocationFilter.INPUT_PORT_NAME_MESSAGE_TRACES);
analysisController
.connect(
traceEvents2ExecutionAndMessageTraceFilter.filter,
......@@ -172,6 +164,8 @@ public class SystemFilterAppender {
performanceModelFilter,
PerformanceModelFilter.INPUT_PORT_NAME_OPERATION_GRAPH);
ResourceDemandFilterAppender.addResourceDemandFilter2(traceEvents2ExecutionAndMessageTraceFilter, "resultPath", analysisController);
}
public static void addSystem2HTMLFilter(
......
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