Search in sources :

Example 36 with TopologyBuilder

use of org.apache.storm.topology.TopologyBuilder in project flink by apache.

the class WordCountLocal method main.

// *************************************************************************
// PROGRAM
// *************************************************************************
public static void main(final String[] args) throws Exception {
    if (!WordCountTopology.parseParameters(args)) {
        return;
    }
    // build Topology the Storm way
    final TopologyBuilder builder = WordCountTopology.buildTopology();
    final FlinkLocalCluster cluster = FlinkLocalCluster.getLocalCluster();
    Config conf = new Config();
    // only required to stabilize integration test
    conf.put(FlinkLocalCluster.SUBMIT_BLOCKING, true);
    cluster.submitTopology(topologyId, conf, FlinkTopology.createTopology(builder));
    cluster.shutdown();
}
Also used : TopologyBuilder(org.apache.storm.topology.TopologyBuilder) FlinkLocalCluster(org.apache.flink.storm.api.FlinkLocalCluster) Config(org.apache.storm.Config)

Example 37 with TopologyBuilder

use of org.apache.storm.topology.TopologyBuilder in project flink by apache.

the class WordCountLocalByName method main.

// *************************************************************************
// PROGRAM
// *************************************************************************
public static void main(final String[] args) throws Exception {
    if (!WordCountTopology.parseParameters(args)) {
        return;
    }
    // build Topology the Storm way
    final TopologyBuilder builder = WordCountTopology.buildTopology(false);
    final FlinkLocalCluster cluster = FlinkLocalCluster.getLocalCluster();
    Config conf = new Config();
    // only required to stabilize integration test
    conf.put(FlinkLocalCluster.SUBMIT_BLOCKING, true);
    cluster.submitTopology(topologyId, conf, FlinkTopology.createTopology(builder));
    cluster.shutdown();
}
Also used : TopologyBuilder(org.apache.storm.topology.TopologyBuilder) FlinkLocalCluster(org.apache.flink.storm.api.FlinkLocalCluster) Config(org.apache.storm.Config)

Example 38 with TopologyBuilder

use of org.apache.storm.topology.TopologyBuilder in project flink by apache.

the class SplitBoltTopology method buildTopology.

public static TopologyBuilder buildTopology() {
    final TopologyBuilder builder = new TopologyBuilder();
    builder.setSpout(spoutId, new RandomSpout(false, seed));
    builder.setBolt(boltId, new SplitBolt()).shuffleGrouping(spoutId);
    builder.setBolt(evenVerifierId, new VerifyAndEnrichBolt(true)).shuffleGrouping(boltId, SplitBolt.EVEN_STREAM);
    builder.setBolt(oddVerifierId, new VerifyAndEnrichBolt(false)).shuffleGrouping(boltId, SplitBolt.ODD_STREAM);
    // emit result
    if (outputPath != null) {
        // read the text file from given input path
        final String[] tokens = outputPath.split(":");
        final String outputFile = tokens[tokens.length - 1];
        builder.setBolt(sinkId, new BoltFileSink(outputFile, formatter)).shuffleGrouping(evenVerifierId).shuffleGrouping(oddVerifierId);
    } else {
        builder.setBolt(sinkId, new BoltPrintSink(formatter), 4).shuffleGrouping(evenVerifierId).shuffleGrouping(oddVerifierId);
    }
    return builder;
}
Also used : RandomSpout(org.apache.flink.storm.split.operators.RandomSpout) BoltFileSink(org.apache.flink.storm.util.BoltFileSink) TopologyBuilder(org.apache.storm.topology.TopologyBuilder) VerifyAndEnrichBolt(org.apache.flink.storm.split.operators.VerifyAndEnrichBolt) BoltPrintSink(org.apache.flink.storm.util.BoltPrintSink)

Example 39 with TopologyBuilder

use of org.apache.storm.topology.TopologyBuilder in project flink by apache.

the class SplitSpoutTopology method buildTopology.

public static TopologyBuilder buildTopology() {
    final TopologyBuilder builder = new TopologyBuilder();
    builder.setSpout(spoutId, new RandomSpout(true, seed));
    builder.setBolt(evenVerifierId, new VerifyAndEnrichBolt(true)).shuffleGrouping(spoutId, RandomSpout.EVEN_STREAM);
    builder.setBolt(oddVerifierId, new VerifyAndEnrichBolt(false)).shuffleGrouping(spoutId, RandomSpout.ODD_STREAM);
    // emit result
    if (outputPath != null) {
        // read the text file from given input path
        final String[] tokens = outputPath.split(":");
        final String outputFile = tokens[tokens.length - 1];
        builder.setBolt(sinkId, new BoltFileSink(outputFile, formatter)).shuffleGrouping(evenVerifierId).shuffleGrouping(oddVerifierId);
    } else {
        builder.setBolt(sinkId, new BoltPrintSink(formatter), 4).shuffleGrouping(evenVerifierId).shuffleGrouping(oddVerifierId);
    }
    return builder;
}
Also used : RandomSpout(org.apache.flink.storm.split.operators.RandomSpout) BoltFileSink(org.apache.flink.storm.util.BoltFileSink) TopologyBuilder(org.apache.storm.topology.TopologyBuilder) VerifyAndEnrichBolt(org.apache.flink.storm.split.operators.VerifyAndEnrichBolt) BoltPrintSink(org.apache.flink.storm.util.BoltPrintSink)

Example 40 with TopologyBuilder

use of org.apache.storm.topology.TopologyBuilder in project flink by apache.

the class SplitStreamBoltLocal method main.

// *************************************************************************
// PROGRAM
// *************************************************************************
public static void main(final String[] args) throws Exception {
    if (!SplitBoltTopology.parseParameters(args)) {
        return;
    }
    // build Topology the Storm way
    final TopologyBuilder builder = SplitBoltTopology.buildTopology();
    final FlinkLocalCluster cluster = FlinkLocalCluster.getLocalCluster();
    cluster.submitTopology(topologyId, null, FlinkTopology.createTopology(builder));
    // run topology for 5 seconds
    Utils.sleep(5 * 1000);
    cluster.shutdown();
}
Also used : TopologyBuilder(org.apache.storm.topology.TopologyBuilder) FlinkLocalCluster(org.apache.flink.storm.api.FlinkLocalCluster)

Aggregations

TopologyBuilder (org.apache.storm.topology.TopologyBuilder)118 Config (org.apache.storm.Config)62 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