public class GeneratorInput
extends org.thales.punch.libraries.storm.api.BaseInputNode
{
type : generator_input
component : generator
settings : {
interval : 1000
messages : [
hello I am message 1
followed by message 2
.. and finally message 3
]
messages_count : 20
}
publish : [
{
stream : logs
fields : [
log
]
}
]
}
To generate content with a limited rate, set the 'interval' parameter to the expected value in milliseconds. Its default value is set to 1 second.
If you want to generate a big number of messages, you can provide "messages_count" setting, and the generator will send the messages multiple times until the required messages count is reached.
You cannot make it simpler ! If you need several fields, specify your messages as maps using a "stream" : { "field" : value } format. Here is an example to send one message on the "logs" stream (with two fields "log" and "id") and another one on a different "error" stream:
{
type: generator_input
component: spout
settings: {
messages : [
{
logs : {
log : hello I am a valid message
id : id1
}
}
{
error : {
log : hello I am a error message
id : id2
}
}
]
}
}
For test automation purpose, it is possible to request an automatic exit of the JVM depending on 'expectation' setting
of the spout and the ack/fail of the tuples (See GeneratorInput.Expectation
for possible values). One mode even allows the failed tuples to be automatically reemitted,
so that in the end, we can check the expected number of tuples and/or idempotence of the topology in disturbed environment.
Constructor and Description |
---|
GeneratorInput(org.thales.punch.libraries.storm.api.NodeSettings spoutSettings)
Create a new Generator spout
|
Modifier and Type | Method and Description |
---|---|
void |
ack(Object msgId) |
void |
fail(Object msgId) |
void |
nextTuple() |
void |
open(Map conf,
org.apache.storm.task.TopologyContext topologyContext,
org.apache.storm.spout.SpoutOutputCollector collector) |
close, deactivate, declareOutputFields, getPublishedStreams, regulate, sendLatencyRecord
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
public GeneratorInput(org.thales.punch.libraries.storm.api.NodeSettings spoutSettings)
spoutSettings
- the spout configuration.public void open(Map conf, org.apache.storm.task.TopologyContext topologyContext, org.apache.storm.spout.SpoutOutputCollector collector)
open
in interface org.apache.storm.spout.ISpout
open
in class org.thales.punch.libraries.storm.api.BaseInputNode
public void nextTuple()
public void ack(Object msgId)
ack
in interface org.apache.storm.spout.ISpout
ack
in class org.thales.punch.libraries.storm.api.BaseInputNode
public void fail(Object msgId)
fail
in interface org.apache.storm.spout.ISpout
fail
in class org.thales.punch.libraries.storm.api.BaseInputNode
Copyright © 2022. All rights reserved.