Search in sources :

Example 6 with LocalDRPC

use of backtype.storm.LocalDRPC 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 7 with LocalDRPC

use of backtype.storm.LocalDRPC 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)

Example 8 with LocalDRPC

use of backtype.storm.LocalDRPC in project jstorm by alibaba.

the class TridentMinMaxOfVehiclesTopology 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(buildVehiclesTopology(), 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)

Example 9 with LocalDRPC

use of backtype.storm.LocalDRPC in project jstorm by alibaba.

the class TridentWordCount method test.

public static void test() {
    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 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) LocalDRPC(backtype.storm.LocalDRPC)

Example 10 with LocalDRPC

use of backtype.storm.LocalDRPC in project jstorm by alibaba.

the class BasicDRPCTopologyTest method testBasicDRPCTopology.

@Test
public void testBasicDRPCTopology() {
    LinearDRPCTopologyBuilder topologyBuilder = new LinearDRPCTopologyBuilder("exclamation");
    topologyBuilder.addBolt(new BasicDRPCTopology.ExclaimBolt(), 3);
    Config config = new Config();
    config.put(Config.TOPOLOGY_NAME, "BasicDRPCTopologyTest");
    LocalDRPC localDRPC = new LocalDRPC();
    JStormUnitTestDRPCValidator validator = new JStormUnitTestDRPCValidator(localDRPC) {

        @Override
        public boolean validate(Map config) {
            String result = executeLocalDRPC("exclamation", "hello");
            assertEquals("hello!", result);
            result = executeLocalDRPC("exclamation", "goodbye");
            assertEquals("goodbye!", result);
            return true;
        }
    };
    try {
        JStormUnitTestRunner.submitTopology(topologyBuilder.createLocalTopology(localDRPC), config, 120, validator);
    } finally {
        localDRPC.shutdown();
    }
}
Also used : Config(backtype.storm.Config) LocalDRPC(backtype.storm.LocalDRPC) JStormUnitTestDRPCValidator(com.jstorm.example.unittests.utils.JStormUnitTestDRPCValidator) BasicDRPCTopology(org.apache.storm.starter.BasicDRPCTopology) LinearDRPCTopologyBuilder(backtype.storm.drpc.LinearDRPCTopologyBuilder) Map(java.util.Map) Test(org.junit.Test)

Aggregations

LocalDRPC (backtype.storm.LocalDRPC)14 TopologyBuilder (backtype.storm.topology.TopologyBuilder)7 Fields (backtype.storm.tuple.Fields)7 Config (backtype.storm.Config)6 JStormUnitTestDRPCValidator (com.jstorm.example.unittests.utils.JStormUnitTestDRPCValidator)5 Map (java.util.Map)5 Test (org.junit.Test)5 JStormHelper (com.alibaba.starter.utils.JStormHelper)4 Check (org.apache.storm.starter.InOrderDeliveryTest.Check)4 InOrderSpout (org.apache.storm.starter.InOrderDeliveryTest.InOrderSpout)4 LocalCluster (backtype.storm.LocalCluster)3 LinearDRPCTopologyBuilder (backtype.storm.drpc.LinearDRPCTopologyBuilder)3 JStormUnitTestValidator (com.jstorm.example.unittests.utils.JStormUnitTestValidator)3 HashMap (java.util.HashMap)3 TridentState (storm.trident.TridentState)3 TridentTopology (storm.trident.TridentTopology)3 MapGet (storm.trident.operation.builtin.MapGet)3 Sum (storm.trident.operation.builtin.Sum)3 DRPCSpout (backtype.storm.drpc.DRPCSpout)2 ReturnResults (backtype.storm.drpc.ReturnResults)2