use of backtype.storm.Config in project jstorm by alibaba.
the class TridentSpoutCoordinator method getComponentConfiguration.
@Override
public Map<String, Object> getComponentConfiguration() {
Config ret = new Config();
ret.setMaxTaskParallelism(1);
return ret;
}
use of backtype.storm.Config in project jstorm by alibaba.
the class SingleJoinTest method test_single_join.
@Test
public void test_single_join() {
receiveCounter.set(0);
try {
FeederSpout genderSpout = new FeederSpout(new Fields("id", "gender"));
FeederSpout ageSpout = new FeederSpout(new Fields("id", "age"));
TopologyBuilder builder = new TopologyBuilder();
builder.setSpout("gender", genderSpout);
builder.setSpout("age", ageSpout);
builder.setBolt("join", new SingleJoinBolt(new Fields("gender", "age"))).fieldsGrouping("gender", new Fields("id")).fieldsGrouping("age", new Fields("id"));
Config conf = new Config();
conf.setDebug(true);
LocalCluster cluster = new LocalCluster();
cluster.submitTopology("join-example", conf, builder.createTopology());
for (int i = 0; i < 10; i++) {
String gender;
if (i % 2 == 0) {
gender = "male";
} else {
gender = "female";
}
genderSpout.feed(new Values(i, gender));
}
for (int i = 9; i >= 0; i--) {
ageSpout.feed(new Values(i, i + 20));
}
JStormUtils.sleepMs(60 * 1000);
assertNotSame(0, receiveCounter.get());
cluster.shutdown();
} catch (Exception e) {
Assert.fail("Failed to run SingleJoinExample");
}
}
use of backtype.storm.Config in project jstorm by alibaba.
the class TransactionalWordsTest method test_transaction_word.
@Test
public void test_transaction_word() {
try {
MemoryTransactionalSpout spout = new MemoryTransactionalSpout(DATA, new Fields("word"), PARTITION_TAKE_PER_BATCH);
TransactionalTopologyBuilder builder = new TransactionalTopologyBuilder("top-n-words", "spout", spout, 2);
builder.setBolt("count", new KeyedCountUpdater(), 5).fieldsGrouping("spout", new Fields("word"));
builder.setBolt("bucketize", new Bucketize()).shuffleGrouping("count");
builder.setBolt("buckets", new BucketCountUpdater(), 5).fieldsGrouping("bucketize", new Fields("bucket"));
LocalCluster cluster = new LocalCluster();
Config config = new Config();
config.setDebug(true);
config.setMaxSpoutPending(3);
cluster.submitTopology("top-n-topology", config, builder.buildTopology());
JStormUtils.sleepMs(60 * 1000);
assertEquals(false, outOfOrder.get());
assertNotSame(0, receiveCounter1.get());
assertNotSame(0, receiveCounter2.get());
//cluster.killTopology("top-n-topology");
//cluster.shutdown();
} catch (Exception e) {
e.printStackTrace();
Assert.fail("Failed to run simple transaction");
}
}
use of backtype.storm.Config in project jstorm by alibaba.
the class TestSuite method init.
@BeforeClass
public static void init() {
cluster = new LocalCluster();
conf = new Config();
conf.put(Config.TOPOLOGY_MAX_TASK_PARALLELISM, 1);
esConfig = new EsConfig("test", "127.0.0.1:9300");
}
use of backtype.storm.Config in project jstorm by alibaba.
the class WordCountTopology method main.
/**
* Main method
*/
public static void main(String[] args) throws AlreadyAliveException, InvalidTopologyException {
if (args.length != 1) {
throw new RuntimeException("Specify topology name");
}
int parallelism = 10;
TopologyBuilder builder = new TopologyBuilder();
builder.setSpout("word", new WordSpout(), parallelism);
builder.setBolt("consumer", new ConsumerBolt(), parallelism).fieldsGrouping("word", new Fields("word"));
Config conf = new Config();
conf.setNumStmgrs(parallelism);
/*
Set config here
*/
StormSubmitter.submitTopology(args[0], conf, builder.createTopology());
}
Aggregations