Search in sources :

Example 56 with TopologyBuilder

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

Example 57 with TopologyBuilder

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");
    }
}
Also used : TopologyBuilder(backtype.storm.topology.TopologyBuilder) Config(backtype.storm.Config)

Example 58 with TopologyBuilder

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");
    }
}
Also used : JStormHelper(com.alibaba.starter.utils.JStormHelper) TopologyBuilder(backtype.storm.topology.TopologyBuilder) LocalDRPC(backtype.storm.LocalDRPC)

Example 59 with TopologyBuilder

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");
    }
}
Also used : InOrderSpout(org.apache.storm.starter.InOrderDeliveryTest.InOrderSpout) Fields(backtype.storm.tuple.Fields) TopologyBuilder(backtype.storm.topology.TopologyBuilder) Config(backtype.storm.Config) Check(org.apache.storm.starter.InOrderDeliveryTest.Check) LocalDRPC(backtype.storm.LocalDRPC)

Example 60 with TopologyBuilder

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");
    }
}
Also used : InOrderSpout(org.apache.storm.starter.InOrderDeliveryTest.InOrderSpout) JStormHelper(com.alibaba.starter.utils.JStormHelper) Fields(backtype.storm.tuple.Fields) TopologyBuilder(backtype.storm.topology.TopologyBuilder) Check(org.apache.storm.starter.InOrderDeliveryTest.Check) LocalDRPC(backtype.storm.LocalDRPC)

Aggregations

TopologyBuilder (backtype.storm.topology.TopologyBuilder)75 Config (backtype.storm.Config)38 Fields (backtype.storm.tuple.Fields)29 LocalCluster (backtype.storm.LocalCluster)23 Test (org.junit.Test)15 Map (java.util.Map)14 HashMap (java.util.HashMap)12 JStormHelper (com.alibaba.starter.utils.JStormHelper)8 LocalDRPC (backtype.storm.LocalDRPC)7 BoltDeclarer (backtype.storm.topology.BoltDeclarer)6 JStormUnitTestMetricValidator (com.jstorm.example.unittests.utils.JStormUnitTestMetricValidator)5 ArrayList (java.util.ArrayList)5 CoordinatedBolt (backtype.storm.coordination.CoordinatedBolt)4 IdStreamSpec (backtype.storm.coordination.CoordinatedBolt.IdStreamSpec)4 SourceArgs (backtype.storm.coordination.CoordinatedBolt.SourceArgs)4 HashSet (java.util.HashSet)4 TestWordSpout (backtype.storm.testing.TestWordSpout)3 BaseWindowedBolt (backtype.storm.topology.base.BaseWindowedBolt)3 JStormUnitTestValidator (com.jstorm.example.unittests.utils.JStormUnitTestValidator)3 Check (org.apache.storm.starter.InOrderDeliveryTest.Check)3