use of org.apache.storm.topology.TopologyBuilder in project storm by apache.
the class AvroGenericRecordBoltTest method generateTestTuple.
private static Tuple generateTestTuple(GenericRecord record) {
TopologyBuilder builder = new TopologyBuilder();
GeneralTopologyContext topologyContext = new GeneralTopologyContext(builder.createTopology(), new Config(), new HashMap(), new HashMap(), new HashMap(), "") {
@Override
public Fields getComponentOutputFields(String componentId, String streamId) {
return new Fields("record");
}
};
return new TupleImpl(topologyContext, new Values(record), 1, "");
}
use of org.apache.storm.topology.TopologyBuilder in project storm by apache.
the class TestHdfsBolt method generateTestTuple.
private Tuple generateTestTuple(Object id, Object msg, Object city, Object state) {
TopologyBuilder builder = new TopologyBuilder();
GeneralTopologyContext topologyContext = new GeneralTopologyContext(builder.createTopology(), new Config(), new HashMap(), new HashMap(), new HashMap(), "") {
@Override
public Fields getComponentOutputFields(String componentId, String streamId) {
return new Fields("id", "msg", "city", "state");
}
};
return new TupleImpl(topologyContext, new Values(id, msg, city, state), 1, "");
}
use of org.apache.storm.topology.TopologyBuilder in project storm by apache.
the class TestSequenceFileBolt method generateTestTuple.
private Tuple generateTestTuple(Long key, String value) {
TopologyBuilder builder = new TopologyBuilder();
GeneralTopologyContext topologyContext = new GeneralTopologyContext(builder.createTopology(), new Config(), new HashMap(), new HashMap(), new HashMap(), "") {
@Override
public Fields getComponentOutputFields(String componentId, String streamId) {
return new Fields("key", "value");
}
};
return new TupleImpl(topologyContext, new Values(key, value), 1, "");
}
use of org.apache.storm.topology.TopologyBuilder in project storm by apache.
the class SingleTopicKafkaSpoutConfiguration method getTopologyKafkaSpout.
public static StormTopology getTopologyKafkaSpout(int port) {
final TopologyBuilder tp = new TopologyBuilder();
tp.setSpout("kafka_spout", new KafkaSpout<>(getKafkaSpoutConfig(port)), 1);
tp.setBolt("kafka_bolt", new KafkaSpoutTestBolt()).shuffleGrouping("kafka_spout", STREAM);
return tp.createTopology();
}
use of org.apache.storm.topology.TopologyBuilder in project storm by apache.
the class StormMqttIntegrationTest method buildMqttTopology.
public StormTopology buildMqttTopology() {
TopologyBuilder builder = new TopologyBuilder();
MqttOptions options = new MqttOptions();
options.setTopics(Arrays.asList(TEST_TOPIC));
options.setCleanConnection(false);
TestSpout spout = new TestSpout(new StringMessageMapper(), options);
MqttBolt bolt = new MqttBolt(options, new MqttTupleMapper() {
@Override
public MqttMessage toMessage(ITuple tuple) {
LOG.info("Received: {}", tuple);
return new MqttMessage(RESULT_TOPIC, RESULT_PAYLOAD.getBytes());
}
});
builder.setSpout("mqtt-spout", spout);
builder.setBolt("mqtt-bolt", bolt).shuffleGrouping("mqtt-spout");
return builder.createTopology();
}
Aggregations