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;
}
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");
}
Aggregations