use of backtype.storm.testing.TestWordSpout 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");
}
}
Aggregations