-
Notifications
You must be signed in to change notification settings - Fork 6
Implementing your own Analysis
The implementation of an Architecture is divided into its configuration and its execution.
When writing an own Architecture, i.e., a set of connected stages, you should inherit from Configuration to save you some work.
A configuration creates and connects the stages you want to execute.
Consider the following example configuration RecordReaderConfiguration. It represents a configuration for an analysis that reads monitoring records from a directory and collects them in a list.
The invoked buildProducerPipeline() creates three stages, namely an instance of InitialElementProducer, Dir2RecordsFilter and CollectorSink.
We then uses the method connectPorts to connect the stages' ports with each other.
public class RecordReaderConfiguration extends Configuration {
private final List<IMonitoringRecord> elementCollection = new LinkedList<IMonitoringRecord>();
public RecordReaderConfiguration() {
this.buildProducerPipeline();
}
private void buildProducerPipeline() {
ClassNameRegistryRepository classNameRegistryRepository = new ClassNameRegistryRepository();
File logDir = new File("src/test/data/bookstore-logs");
// create stages
InitialElementProducer<File> initialElementProducer = new InitialElementProducer<File>(logDir);
Dir2RecordsFilter dir2RecordsFilter = new Dir2RecordsFilter(classNameRegistryRepository);
CollectorSink<IMonitoringRecord> collector = new CollectorSink<IMonitoringRecord>(this.elementCollection);
// connect stages
connectPorts(initialElementProducer.getOutputPort(), dir2RecordsFilter.getInputPort());
connectPorts(dir2RecordsFilter.getOutputPort(), collector.getInputPort());
}
public List<IMonitoringRecord> getElementCollection() {
return this.elementCollection;
}
}The following snippet shows the default code for creating and running an own execution:
Configuration configuration = ... // e.g., new RecordReaderConfiguration();
final Execution execution = new Execution(configuration);
execution.executeBlocking();The executeBlocking method of an Execution starts the execution and waits for it to finish successfully.