use of backtype.storm.topology.TopologyBuilder in project jstorm by alibaba.
the class UserDefinedHostsTopology method test.
public static void test() {
TopologyBuilder builder = new TopologyBuilder();
builder.setSpout("word", new TestWordSpout(), 10);
builder.setBolt("exclaim1", new ExclamationLoggingBolt(), 3).noneGrouping("word");
builder.setBolt("exclaim2", new ExclamationLoggingBolt(), 2).shuffleGrouping("exclaim1");
String hostname = NetWorkUtils.hostname();
List<String> hosts = new ArrayList<String>();
hosts.add(hostname);
/*********
*
* This make sure all worker run on the user-defined hosts
*
*
*
*/
conf.put(Config.ISOLATION_SCHEDULER_MACHINES, hosts);
String[] className = Thread.currentThread().getStackTrace()[1].getClassName().split("\\.");
String topologyName = className[className.length - 1];
try {
JStormHelper.runTopology(builder.createTopology(), topologyName, conf, 60, new Validator(conf), isLocal);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
Assert.fail("Failed");
}
}
use of backtype.storm.topology.TopologyBuilder in project jstorm by alibaba.
the class UserDefinedWorkerTopology method test.
public static void test() {
TopologyBuilder builder = new TopologyBuilder();
builder.setSpout(SPOUT_NAME, new RandomIntegerSpout(), 2);
builder.setBolt(BOLT1_NAME, new CheckBolt(false), 3).localOrShuffleGrouping(SPOUT_NAME);
builder.setBolt(BOLT2_NAME, new CheckBolt(true), 3).localOrShuffleGrouping(SPOUT_NAME);
Config conf = new Config();
conf.setDebug(true);
if (isLocal == false) {
prepare();
conf.setNumWorkers(workerNumber);
try {
setUserDefinedWorker(conf);
} catch (Exception e) {
// TODO Auto-generated catch block
Assert.fail("Failed to set user defined worker");
}
}
String[] className = Thread.currentThread().getStackTrace()[1].getClassName().split("\\.");
String topologyName = className[className.length - 1];
try {
JStormHelper.runTopology(builder.createTopology(), topologyName, conf, 60, new Validator(), isLocal);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
Assert.fail("Failed");
}
}
use of backtype.storm.topology.TopologyBuilder in project jstorm by alibaba.
the class TridentFastWordCount method test.
public static void test() {
TopologyBuilder builder = new TopologyBuilder();
String[] className = Thread.currentThread().getStackTrace()[1].getClassName().split("\\.");
String topologyName = className[className.length - 1];
if (isLocal) {
drpc = new LocalDRPC();
}
try {
JStormHelper.runTopology(buildTopology(drpc), topologyName, conf, 60, new JStormHelper.CheckAckedFail(conf), isLocal);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
Assert.fail("Failed");
}
}
use of backtype.storm.topology.TopologyBuilder in project jstorm by alibaba.
the class TridentMapExample method test.
public static void test() {
TopologyBuilder builder = new TopologyBuilder();
builder.setSpout("spout", new InOrderSpout(), 8);
builder.setBolt("count", new Check(), 8).fieldsGrouping("spout", new Fields("c1"));
Config conf = new Config();
conf.setMaxSpoutPending(20);
String[] className = Thread.currentThread().getStackTrace()[1].getClassName().split("\\.");
String topologyName = className[className.length - 1];
if (isLocal) {
drpc = new LocalDRPC();
}
try {
JStormHelper.runTopology(buildTopology(drpc), topologyName, conf, 60, new DrpcValidator(), isLocal);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
Assert.fail("Failed");
}
}
use of backtype.storm.topology.TopologyBuilder in project jstorm by alibaba.
the class TridentMinMaxOfDevicesTopology method test.
public static void test() {
TopologyBuilder builder = new TopologyBuilder();
builder.setSpout("spout", new InOrderSpout(), 8);
builder.setBolt("count", new Check(), 8).fieldsGrouping("spout", new Fields("c1"));
conf.setMaxSpoutPending(20);
String[] className = Thread.currentThread().getStackTrace()[1].getClassName().split("\\.");
String topologyName = className[className.length - 1];
if (isLocal) {
drpc = new LocalDRPC();
}
try {
JStormHelper.runTopology(buildDevicesTopology(), topologyName, conf, 60, new JStormHelper.CheckAckedFail(conf), isLocal);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
Assert.fail("Failed");
}
}
Aggregations