public class ConsoleWaterDetector
extends java.lang.Object
The topology graph in the console currently allows for 3 distinct "views" of the topology:
Selecting any of these, with the exception of "Static flow", adds a legend to the topology which allows the user to identify elements of the view.
The "Static flow" view shows the toology in an unchanging state - that is if tuple counts are available the lines (connections) representing the edges of the topology are not updated, nor are the circles (representing the vertices) dimensions updated. The purpose of this view is to give the user an indication of the topology map of the application.
The "Oplet kind" view colors the oplets or vertices displayed in the topology graph (the circles) by their corresponding Oplet kind.
If "Tuple count" is selected the legend reflects ranges of tuple counts measured since the application was started.
Note: The DevelopmentProvider class overrides the submit method of the DirectProvider class and adds a Metrics counter to the submitted topology. If a counter is not added to the topology (or to an individual oplet), the "Tuple count" view selection is not enabled.
In the lower half of the edgent console is a chart displaying metrics, if available. In this example metrics
are available since the DevelopmentProvider class is being used. Note that the DevelopmentProvider class adds a Metrics counter
to all oplets in the topology, with the exception of certain oplet types. For further information
about how metrics are added to a topology, see the details in the org.apache.edgent.metrics.Metrics class and the counter method.
A counter can be added to an individual oplet, and not the entire topology. For an example of this
see the org.apache.edgent.samples.utils.metrics.DevelopmentMetricsSample.
The org.apache.edgent.metric.Metrics class also provides a rate meter. Rate meters must be added to individual oplets and are not currently available for the entire topology.
The metrics chart displayed is a bar chart by default. If a rate meter is added to an oplet it will be displayed as a line chart over the last 20 measures (the interval to refresh the line chart is every 2 1/2 seconds). If a counter is added to a single oplet, the tuple count can also be displayed as a line chart.
ConsoleWaterDetector scenario: A county agency is responsible for ensuring the safety of residents well water. Each well they monitor has four different sensor types:
This application topology monitors 3 wells:
Constructor and Description |
---|
ConsoleWaterDetector() |
Modifier and Type | Method and Description |
---|---|
static TStream<com.google.gson.JsonObject> |
alertFilter(TStream<com.google.gson.JsonObject> readingsDetector,
int wellId,
boolean simulateNormal)
Look through the stream and check to see if any of the measurements cause concern.
|
static java.lang.String |
formatAlertOutput(com.google.gson.JsonObject alertObj,
java.lang.String wellId,
java.lang.String alertType)
Formats the output of the alert, containing the well id, sensor type and value of the sensor
|
static void |
main(java.lang.String[] args) |
static java.util.List<TStream<com.google.gson.JsonObject>> |
splitAlert(TStream<com.google.gson.JsonObject> alertStream,
int wellId)
Splits the incoming TStream<JsonObject> into individual TStreams based on the sensor type
|
static TStream<com.google.gson.JsonObject> |
waterDetector(Topology topology,
int wellId)
Creates a TStream<JsonObject> for each sensor reading for each well.
|
public static void main(java.lang.String[] args) throws java.lang.Exception
java.lang.Exception
public static TStream<com.google.gson.JsonObject> waterDetector(Topology topology, int wellId)
topology
- Topology providing the tuples for the sensorswellId
- Id of the well sending the measurementspublic static TStream<com.google.gson.JsonObject> alertFilter(TStream<com.google.gson.JsonObject> readingsDetector, int wellId, boolean simulateNormal)
readingsDetector
- The TStream<JsonObject> that represents all of the different sensor readings for the wellwellId
- The id of the wellsimulateNormal
- Make this stream simulate all readings within the normal range, and therefore will not pass through the filterpublic static java.util.List<TStream<com.google.gson.JsonObject>> splitAlert(TStream<com.google.gson.JsonObject> alertStream, int wellId)
alertStream
- The TStream<JsonObject> that we know has some out of range condition - it could be temp, acidity, ecoli or lead
- or all of themwellId
- The id of the well that has the out of range readingspublic static java.lang.String formatAlertOutput(com.google.gson.JsonObject alertObj, java.lang.String wellId, java.lang.String alertType)
alertObj
- The tuple that contains out of range readingswellId
- The id of the wellalertType
- The type of sensor that has the possible alert on itCopyright © 2016 The Apache Software Foundation. All Rights Reserved - bbe71fa-20161201-1641