use of org.apache.storm.topology.TopologyBuilder in project storm by apache.
the class BackPressureTopo method getTopology.
static StormTopology getTopology(Map<String, Object> conf) {
Long sleepMs = ObjectReader.getLong(conf.get(SLEEP_MS));
// 1 - Setup Spout --------
ConstSpout spout = new ConstSpout("some data").withOutputFields("string");
// 2 - Setup DevNull Bolt --------
ThrottledBolt bolt = new ThrottledBolt(sleepMs);
// 3 - Setup Topology --------
TopologyBuilder builder = new TopologyBuilder();
builder.setSpout(SPOUT_ID, spout, Helper.getInt(conf, SPOUT_COUNT, 1));
BoltDeclarer bd = builder.setBolt(BOLT_ID, bolt, Helper.getInt(conf, BOLT_COUNT, 1));
bd.localOrShuffleGrouping(SPOUT_ID);
return builder.createTopology();
}
use of org.apache.storm.topology.TopologyBuilder in project storm by apache.
the class HdfsSpoutNullBoltTopo method getTopology.
static StormTopology getTopology(Map<String, Object> config) {
final int spoutNum = Helper.getInt(config, SPOUT_NUM, DEFAULT_SPOUT_NUM);
final int boltNum = Helper.getInt(config, BOLT_NUM, DEFAULT_BOLT_NUM);
final String fileFormat = Helper.getStr(config, "text");
final String hdfsUri = Helper.getStr(config, HDFS_URI);
final String sourceDir = Helper.getStr(config, SOURCE_DIR);
final String archiveDir = Helper.getStr(config, ARCHIVE_DIR);
final String badDir = Helper.getStr(config, BAD_DIR);
// 1 - Setup Hdfs Spout --------
HdfsSpout spout = new HdfsSpout().setReaderType(fileFormat).setHdfsUri(hdfsUri).setSourceDir(sourceDir).setArchiveDir(archiveDir).setBadFilesDir(badDir).withOutputFields(TextFileReader.defaultFields);
// 2 - DevNull Bolt --------
DevNullBolt bolt = new DevNullBolt();
// 3 - Setup Topology --------
TopologyBuilder builder = new TopologyBuilder();
builder.setSpout(SPOUT_ID, spout, spoutNum);
builder.setBolt(BOLT_ID, bolt, boltNum).localOrShuffleGrouping(SPOUT_ID);
return builder.createTopology();
}
use of org.apache.storm.topology.TopologyBuilder in project storm by apache.
the class SimplifiedWordCountTopo method getTopology.
static StormTopology getTopology(Map<String, Object> config) {
final int spoutNum = Helper.getInt(config, SPOUT_NUM, DEFAULT_SPOUT_NUM);
final int cntBoltNum = Helper.getInt(config, BOLT_NUM, DEFAULT_COUNT_BOLT_NUM);
final String inputFile = Helper.getStr(config, INPUT_FILE);
TopologyBuilder builder = new TopologyBuilder();
builder.setSpout(SPOUT_ID, new WordGenSpout(inputFile), spoutNum);
builder.setBolt(COUNT_ID, new CountBolt(), cntBoltNum).fieldsGrouping(SPOUT_ID, new Fields(WordGenSpout.FIELDS));
return builder.createTopology();
}
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), topologyContext.getComponentId(1), 1, "");
}
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), topologyContext.getComponentId(1), 1, "");
}
Aggregations