public class ApplicationUtilities
extends java.lang.Object
Utilities include:
Constructor and Description |
---|
ApplicationUtilities(java.util.Properties props) |
Modifier and Type | Method and Description |
---|---|
<T> Range<T> |
getRange(java.lang.String sensorId,
java.lang.String label,
java.lang.Class<T> clazz)
Get the Range for a sensor range configuration item.
|
java.lang.String |
getSensorPropertyName(java.lang.String sensorId,
java.lang.String label,
java.lang.String kind)
Get the property name for a sensor's configuration item.
|
<T> TStream<T> |
logStream(TStream<T> stream,
java.lang.String eventTag,
java.lang.String baseName)
Log every tuple on the stream using the
FileStreams connector. |
<T> TStream<T> |
traceStream(TStream<T> stream,
java.lang.String sensorId,
Supplier<java.lang.String> label)
Trace a stream to System.out if the sensor id's "label" has been configured
to enable tracing.
|
<T> TStream<T> |
traceStream(TStream<T> stream,
Supplier<java.lang.String> label)
Trace a stream to System.out if the "label" has been configured
to enable tracing.
|
public <T> TStream<T> traceStream(TStream<T> stream, java.lang.String sensorId, Supplier<java.lang.String> label)
If tracing has not been enabled in the config, the topology will not be augmented to trace the stream.
stream
- the stream to tracelabel
- some unique labelpublic <T> TStream<T> traceStream(TStream<T> stream, Supplier<java.lang.String> label)
If tracing has not been enabled in the config, the topology will not be augmented to trace the stream.
stream
- the stream to tracelabel
- some unique labelpublic java.lang.String getSensorPropertyName(java.lang.String sensorId, java.lang.String label, java.lang.String kind)
sensorId
- the sensor's idlabel
- the label for an instance of "kind" (e.g., "tempThreshold")kind
- the kind of configuration item (e.g., "range")public <T> Range<T> getRange(java.lang.String sensorId, java.lang.String label, java.lang.Class<T> clazz)
sensorId
- the sensor's idlabel
- the range's labelclazz
- the Range's type (e.g., Integer.class)public <T> TStream<T> logStream(TStream<T> stream, java.lang.String eventTag, java.lang.String baseName)
FileStreams
connector.
The logs are added to the directory as specified by the "application.log.dir" property. The directory will be created as needed.
The "active" (open / being written) log file name is .<baseName>
.
Completed stable logs have a name of <baseName>_YYYYMMDD_HHMMSS
.
The log entry format being used is:
[<date>] [<eventTag>] <tuple>.toString()
See FileStreams.textFileWriter(TStream, quarks.function.Supplier, quarks.function.Supplier)
stream
- the TStreambaseName
- the base log nameeventTag
- a tag that gets added to the log entryCopyright IBM 2015,2016 - 2f6ad0e-20160307-0902