... | ... | @@ -8,10 +8,10 @@ As a simple introduction, we will implement an architecture which counts all fil |
|
|
In order to work with TeeTime you need to make sure it is added to your project. Further assistance on doing so can be found in the download section.
|
|
|
|
|
|
##### Used files in this tutorial:
|
|
|
- [DirReader.java](https://build.se.informatik.uni-kiel.de/gitlab/teetime/teetime/blob/master/src/test/java/teetime/examples/filecounter/DirReader.java)
|
|
|
- [FileCounter.java](https://build.se.informatik.uni-kiel.de/gitlab/teetime/teetime/blob/master/src/test/java/teetime/examples/filecounter/FileCounter.java)
|
|
|
- [ResultPrinter.java](https://build.se.informatik.uni-kiel.de/gitlab/teetime/teetime/blob/master/src/test/java/teetime/examples/filecounter/ResultPrinter.java)
|
|
|
- [PrintResultConfig.java](https://build.se.informatik.uni-kiel.de/gitlab/teetime/teetime/blob/master/src/test/java/teetime/examples/filecounter/PrintResultConfig.java)
|
|
|
- [DirReader.java](https://build.se.informatik.uni-kiel.de/teetime/teetime/blob/master/src/test/java/teetime/examples/filecounter/DirReader.java)
|
|
|
- [FileCounter.java](https://build.se.informatik.uni-kiel.de/teetime/teetime/blob/master/src/test/java/teetime/examples/filecounter/FileCounter.java)
|
|
|
- [ResultPrinter.java](https://build.se.informatik.uni-kiel.de/teetime/teetime/blob/master/src/test/java/teetime/examples/filecounter/ResultPrinter.java)
|
|
|
- [PrintResultConfig.java](https://build.se.informatik.uni-kiel.de/teetime/teetime/blob/master/src/test/java/teetime/examples/filecounter/PrintResultConfig.java)
|
|
|
|
|
|
### Separate that Logic
|
|
|
|
... | ... | @@ -39,7 +39,7 @@ Our first stage will be the ```DirReader```. It visits all directories and sends |
|
|
This is a perfect task to start working with TeeTime: implement this logic into a single stage.
|
|
|
You may extend from ```teetime.framework.AbstractProducerStage``` and use its field ```outputPort``` to send elements to the next stage.
|
|
|
Make sure you use ```terminate()``` after the stage is done with all its work, so that the framework knows the job is done.
|
|
|
A suitable solution can be found [here](https://build.se.informatik.uni-kiel.de/gitlab/teetime/teetime/blob/master/src/test/java/teetime/examples/filecounter/DirReader.java).
|
|
|
A suitable solution can be found [here](https://build.se.informatik.uni-kiel.de/teetime/teetime/blob/master/src/test/java/teetime/examples/filecounter/DirReader.java).
|
|
|
|
|
|
The next task is to implement the ```FileCounter```.
|
|
|
It receives elements of the type ```File``` and simply increments a counter upon each incoming element.
|
... | ... | @@ -47,12 +47,12 @@ It receives elements of the type ```File``` and simply increments a counter upon |
|
|
The counter only contains the correct result if the architecture is about to terminate.
|
|
|
So make sure you override the method ```onTerminating()``` to send the final result.
|
|
|
One more hint: you may use ```createInputPort()``` or ```createOutputPort()``` to create additional ports.
|
|
|
Of course, there is also a [sample solution](https://build.se.informatik.uni-kiel.de/gitlab/teetime/teetime/blob/master/src/test/java/teetime/examples/filecounter/FileCounter.java) for this part.
|
|
|
Of course, there is also a [sample solution](https://build.se.informatik.uni-kiel.de/teetime/teetime/blob/master/src/test/java/teetime/examples/filecounter/FileCounter.java) for this part.
|
|
|
|
|
|
After all the hard work, we will finish everything by implementing the ```ResultPrinter```.
|
|
|
It receives elements of the type ```Integer``` and prints them to the console.
|
|
|
As this is a simple consumer, ```teetime.framework.AbstractConsumerStage``` should also be used here.
|
|
|
This few lines of code may look like [this](https://build.se.informatik.uni-kiel.de/gitlab/teetime/teetime/blob/master/src/test/java/teetime/examples/filecounter/ResultPrinter.java).
|
|
|
This few lines of code may look like [this](https://build.se.informatik.uni-kiel.de/teetime/teetime/blob/master/src/test/java/teetime/examples/filecounter/ResultPrinter.java).
|
|
|
|
|
|
### Connect them Stages
|
|
|
|
... | ... | @@ -61,7 +61,7 @@ Analogous to integrated circuits which are connected through their ports, we onl |
|
|
For this purpose we can use the class ```teetime.framework.Configuration```.
|
|
|
We create instances of our three stages and connect them correctly.
|
|
|
Please remember that TeeTime only supports uni-directed communication.
|
|
|
A sample solution can look like [this](https://build.se.informatik.uni-kiel.de/gitlab/teetime/teetime/blob/master/src/test/java/teetime/examples/filecounter/PrintResultConfig.java).
|
|
|
A sample solution can look like [this](https://build.se.informatik.uni-kiel.de/teetime/teetime/blob/master/src/test/java/teetime/examples/filecounter/PrintResultConfig.java).
|
|
|
|
|
|
### Execute that Configuration
|
|
|
|
... | ... | |