Search in sources :

Example 41 with TopologyBuilder

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, "");
}
Also used : Fields(org.apache.storm.tuple.Fields) GeneralTopologyContext(org.apache.storm.task.GeneralTopologyContext) TopologyBuilder(org.apache.storm.topology.TopologyBuilder) HashMap(java.util.HashMap) Config(org.apache.storm.Config) Values(org.apache.storm.tuple.Values) TupleImpl(org.apache.storm.tuple.TupleImpl)

Example 42 with TopologyBuilder

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, "");
}
Also used : Fields(org.apache.storm.tuple.Fields) GeneralTopologyContext(org.apache.storm.task.GeneralTopologyContext) TopologyBuilder(org.apache.storm.topology.TopologyBuilder) HashMap(java.util.HashMap) Config(org.apache.storm.Config) Values(org.apache.storm.tuple.Values) TupleImpl(org.apache.storm.tuple.TupleImpl)

Example 43 with TopologyBuilder

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, "");
}
Also used : Fields(org.apache.storm.tuple.Fields) GeneralTopologyContext(org.apache.storm.task.GeneralTopologyContext) TopologyBuilder(org.apache.storm.topology.TopologyBuilder) HashMap(java.util.HashMap) Config(org.apache.storm.Config) Values(org.apache.storm.tuple.Values) TupleImpl(org.apache.storm.tuple.TupleImpl)

Example 44 with TopologyBuilder

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();
}
Also used : TopologyBuilder(org.apache.storm.topology.TopologyBuilder) KafkaSpoutTestBolt(org.apache.storm.kafka.spout.test.KafkaSpoutTestBolt)

Example 45 with TopologyBuilder

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();
}
Also used : MqttOptions(org.apache.storm.mqtt.common.MqttOptions) TopologyBuilder(org.apache.storm.topology.TopologyBuilder) MqttBolt(org.apache.storm.mqtt.bolt.MqttBolt) ITuple(org.apache.storm.tuple.ITuple) StringMessageMapper(org.apache.storm.mqtt.mappers.StringMessageMapper)

Aggregations

TopologyBuilder (org.apache.storm.topology.TopologyBuilder)119 Config (org.apache.storm.Config)63 Fields (org.apache.storm.tuple.Fields)36 LocalCluster (org.apache.storm.LocalCluster)28 HashMap (java.util.HashMap)25 LocalTopology (org.apache.storm.LocalCluster.LocalTopology)24 Test (org.junit.Test)17 TestWordSpout (org.apache.storm.testing.TestWordSpout)16 Map (java.util.Map)12 StormTopology (org.apache.storm.generated.StormTopology)12 BoltDeclarer (org.apache.storm.topology.BoltDeclarer)9 Values (org.apache.storm.tuple.Values)9 FlinkLocalCluster (org.apache.flink.storm.api.FlinkLocalCluster)8 Cluster (org.apache.storm.scheduler.Cluster)8 INimbus (org.apache.storm.scheduler.INimbus)8 SchedulerAssignmentImpl (org.apache.storm.scheduler.SchedulerAssignmentImpl)8 SupervisorDetails (org.apache.storm.scheduler.SupervisorDetails)8 Topologies (org.apache.storm.scheduler.Topologies)8 TopologyDetails (org.apache.storm.scheduler.TopologyDetails)8 BoltFileSink (org.apache.flink.storm.util.BoltFileSink)7