In this lab you will use the Pipeline API to do filtering and simple transformation on an event stream.
- Familiarize yourself with the
Pipeline
API - Write code to do basic data transformation and filtering
NOTE: if you are having trouble, we provide an example solution in the
Solutions
directory.
In this lab, the source is a stream of Fahrenheit temperatures. You
will write a Pipeline
to process the stream. The Pipeline
will
- use
StreamStage.map
to convert the Fahrenheit temperatures to Celsius - use
StreamStage.filter
to keep only temperature that are below 0 - write the stream of negative Celsius temperatures to a log
Start by reviewing the javadoc for these two methods in https://docs.hazelcast.org/docs/latest/javadoc/index.html?com/hazelcast/jet/pipeline/StreamStage.html
Open Lab2.java
and follow the instructions.
NOTE
Notice that in this exercise, the Pipeline is being constructed in multiple statements while, in the previous exercise it was constructed with one long statement.
The two formats are logically equivalent but the multi-statement approach can make the pipeline code easier to understand. You can see that each statement adds a new operation to a previous
StreamStage
and each statement that is not awriteTo
returns a newStreamStage
.
You can run Management Center with
docker run -d -p 8080:8080 hazelcast/management-center
.
To connect to your cluster, use
cluster name: dev
member address: host.docker.internal