Search in sources :

Example 6 with TestWordSpout

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");
    }
}
Also used : TopologyBuilder(backtype.storm.topology.TopologyBuilder) TestWordSpout(backtype.storm.testing.TestWordSpout) ArrayList(java.util.ArrayList)

Aggregations

TestWordSpout (backtype.storm.testing.TestWordSpout)6 TopologyBuilder (backtype.storm.topology.TopologyBuilder)4 Fields (backtype.storm.tuple.Fields)3 Config (backtype.storm.Config)2 IntermediateRankingsBolt (org.apache.storm.starter.bolt.IntermediateRankingsBolt)2 RollingCountBolt (org.apache.storm.starter.bolt.RollingCountBolt)2 TotalRankingsBolt (org.apache.storm.starter.bolt.TotalRankingsBolt)2 ILocalCluster (backtype.storm.ILocalCluster)1 LocalCluster (backtype.storm.LocalCluster)1 StormTopology (backtype.storm.generated.StormTopology)1 CompleteTopologyParam (backtype.storm.testing.CompleteTopologyParam)1 MkClusterParam (backtype.storm.testing.MkClusterParam)1 MockedSources (backtype.storm.testing.MockedSources)1 TestAggregatesCounter (backtype.storm.testing.TestAggregatesCounter)1 TestGlobalCount (backtype.storm.testing.TestGlobalCount)1 TestJob (backtype.storm.testing.TestJob)1 TestWordCounter (backtype.storm.testing.TestWordCounter)1 Values (backtype.storm.tuple.Values)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1