Search in sources :

Example 1 with ExclamationBolt

use of org.apache.flink.storm.exclamation.operators.ExclamationBolt in project flink by apache.

the class ExclamationTopology method buildTopology.

public static TopologyBuilder buildTopology() {
    final TopologyBuilder builder = new TopologyBuilder();
    // get input data
    if (fileInputOutput) {
        // read the text file from given input path
        final String[] tokens = textPath.split(":");
        final String inputFile = tokens[tokens.length - 1];
        builder.setSpout(spoutId, new FiniteFileSpout(inputFile));
    } else {
        builder.setSpout(spoutId, new FiniteInMemorySpout(WordCountData.WORDS));
    }
    builder.setBolt(firstBoltId, new ExclamationBolt(), 3).shuffleGrouping(spoutId);
    builder.setBolt(secondBoltId, new ExclamationBolt(), 2).shuffleGrouping(firstBoltId);
    // emit result
    if (fileInputOutput) {
        // 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(secondBoltId);
    } else {
        builder.setBolt(sinkId, new BoltPrintSink(formatter), 4).shuffleGrouping(secondBoltId);
    }
    return builder;
}
Also used : FiniteInMemorySpout(org.apache.flink.storm.util.FiniteInMemorySpout) ExclamationBolt(org.apache.flink.storm.exclamation.operators.ExclamationBolt) BoltFileSink(org.apache.flink.storm.util.BoltFileSink) TopologyBuilder(org.apache.storm.topology.TopologyBuilder) FiniteFileSpout(org.apache.flink.storm.util.FiniteFileSpout) BoltPrintSink(org.apache.flink.storm.util.BoltPrintSink)

Example 2 with ExclamationBolt

use of org.apache.flink.storm.exclamation.operators.ExclamationBolt in project flink by apache.

the class ExclamationWithBolt method main.

// *************************************************************************
// PROGRAM
// *************************************************************************
public static void main(final String[] args) throws Exception {
    if (!parseParameters(args)) {
        return;
    }
    // set up the execution environment
    final StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
    // set Storm configuration
    StormConfig config = new StormConfig();
    config.put(ExclamationBolt.EXCLAMATION_COUNT, new Integer(exclamationNum));
    env.getConfig().setGlobalJobParameters(config);
    // get input data
    final DataStream<String> text = getTextDataStream(env);
    final DataStream<String> exclaimed = text.transform("StormBoltTokenizer", TypeExtractor.getForObject(""), new BoltWrapper<String, String>(new ExclamationBolt(), new String[] { Utils.DEFAULT_STREAM_ID })).map(new ExclamationMap());
    // emit result
    if (fileOutput) {
        exclaimed.writeAsText(outputPath);
    } else {
        exclaimed.print();
    }
    // execute program
    env.execute("Streaming WordCount with bolt tokenizer");
}
Also used : StormConfig(org.apache.flink.storm.util.StormConfig) ExclamationBolt(org.apache.flink.storm.exclamation.operators.ExclamationBolt) BoltWrapper(org.apache.flink.storm.wrappers.BoltWrapper) StreamExecutionEnvironment(org.apache.flink.streaming.api.environment.StreamExecutionEnvironment)

Aggregations

ExclamationBolt (org.apache.flink.storm.exclamation.operators.ExclamationBolt)2 BoltFileSink (org.apache.flink.storm.util.BoltFileSink)1 BoltPrintSink (org.apache.flink.storm.util.BoltPrintSink)1 FiniteFileSpout (org.apache.flink.storm.util.FiniteFileSpout)1 FiniteInMemorySpout (org.apache.flink.storm.util.FiniteInMemorySpout)1 StormConfig (org.apache.flink.storm.util.StormConfig)1 BoltWrapper (org.apache.flink.storm.wrappers.BoltWrapper)1 StreamExecutionEnvironment (org.apache.flink.streaming.api.environment.StreamExecutionEnvironment)1 TopologyBuilder (org.apache.storm.topology.TopologyBuilder)1