Search in sources :

Example 31 with LocalCluster

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

the class TestTopology method submitTopology.

private static void submitTopology(TopologyBuilder builder) {
    try {
        if (local_mode(conf)) {
            LocalCluster cluster = new LocalCluster();
            cluster.submitTopology(String.valueOf(conf.get("topology.name")), conf, builder.createTopology());
            Thread.sleep(200000);
            cluster.shutdown();
        } else {
            StormSubmitter.submitTopology(String.valueOf(conf.get("topology.name")), conf, builder.createTopology());
        }
    } catch (Exception e) {
        LOG.error(e.getMessage(), e.getCause());
    }
}
Also used : LocalCluster(backtype.storm.LocalCluster) FileNotFoundException(java.io.FileNotFoundException)

Example 32 with LocalCluster

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

the class TestTopology method submitTopology.

private static void submitTopology(TopologyBuilder builder) {
    try {
        if (local_mode(conf)) {
            LocalCluster cluster = new LocalCluster();
            cluster.submitTopology(String.valueOf(conf.get("topology.name")), conf, builder.createTopology());
            Thread.sleep(200000);
            cluster.shutdown();
        } else {
            StormSubmitter.submitTopology(String.valueOf(conf.get("topology.name")), conf, builder.createTopology());
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : LocalCluster(backtype.storm.LocalCluster)

Example 33 with LocalCluster

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

the class TridentWindowingInmemoryStoreTopology method test.

public static void test() {
    String[] className = Thread.currentThread().getStackTrace()[1].getClassName().split("\\.");
    String topologyName = className[className.length - 1];
    try {
        WindowsStoreFactory mapState = new InMemoryWindowsStoreFactory();
        List<? extends WindowConfig> list = Arrays.asList(SlidingCountWindow.of(1000, 100), TumblingCountWindow.of(1000), SlidingDurationWindow.of(new BaseWindowedBolt.Duration(6, TimeUnit.SECONDS), new BaseWindowedBolt.Duration(3, TimeUnit.SECONDS)), TumblingDurationWindow.of(new BaseWindowedBolt.Duration(3, TimeUnit.SECONDS)));
        for (WindowConfig windowConfig : list) {
            LocalCluster cluster = new LocalCluster();
            cluster.submitTopology("wordCounter", conf, buildTopology(mapState, windowConfig));
            Utils.sleep(60 * 1000);
            cluster.shutdown();
        }
        for (WindowConfig windowConfig : list) {
            String name = topologyName + "." + windowConfig.getWindowLength() + "." + windowConfig.getSlidingLength();
            JStormHelper.runTopology(buildTopology(mapState, windowConfig), name, conf, 60, new JStormHelper.CheckAckedFail(conf), isLocal);
        }
    } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
        Assert.fail("Failed");
    }
}
Also used : WindowConfig(storm.trident.windowing.config.WindowConfig) LocalCluster(backtype.storm.LocalCluster) JStormHelper(com.alibaba.starter.utils.JStormHelper) InMemoryWindowsStoreFactory(storm.trident.windowing.InMemoryWindowsStoreFactory) WindowsStoreFactory(storm.trident.windowing.WindowsStoreFactory) InMemoryWindowsStoreFactory(storm.trident.windowing.InMemoryWindowsStoreFactory)

Example 34 with LocalCluster

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

the class TestSuite method init.

@BeforeClass
public static void init() {
    cluster = new LocalCluster();
    conf = new Config();
    conf.put(Config.TOPOLOGY_MAX_TASK_PARALLELISM, 1);
    esConfig = new EsConfig("test", "127.0.0.1:9300");
}
Also used : LocalCluster(backtype.storm.LocalCluster) EsConfig(com.alibaba.jstorm.elasticsearch.common.EsConfig) Config(backtype.storm.Config) EsConfig(com.alibaba.jstorm.elasticsearch.common.EsConfig) BeforeClass(org.junit.BeforeClass)

Example 35 with LocalCluster

use of backtype.storm.LocalCluster in project storm-hbase by ypf412.

the class DumpToHBaseTopology method main.

/**
 * HBase Data Dump to Another HBase Table Topology
 * @param args
 * @throws Exception
 */
public static void main(String[] args) throws Exception {
    TopologyBuilder builder = new TopologyBuilder();
    PropConfig pc = new PropConfig("storm.properties");
    int topoWorkers = Integer.valueOf(pc.getProperty("storm.topolopy.workers"));
    int spoutTasks = Integer.valueOf(pc.getProperty("storm.spout.tasks"));
    builder.setSpout("hbaseSpout", new HBaseSpout(), spoutTasks);
    int boltTasks = spoutTasks;
    builder.setBolt("dumpBolt", new DumpToHBaseBolt(), boltTasks).fieldsGrouping("hbaseSpout", new Fields("sharding"));
    Config conf = new Config();
    conf.put(Constants.STORM_PROP_CONF_FILE, "storm.properties");
    conf.put(Constants.HBASE_PROP_CONF_FILE, "hbase.properties");
    if (args != null && args.length > 0) {
        // run on storm cluster
        conf.setNumAckers(1);
        conf.setNumWorkers(topoWorkers);
        StormSubmitter.submitTopology(args[0], conf, builder.createTopology());
    } else {
        // run on local cluster
        conf.setMaxTaskParallelism(3);
        LocalCluster cluster = new LocalCluster();
        cluster.submitTopology("test", conf, builder.createTopology());
        Utils.sleep(10000);
        cluster.killTopology("test");
        cluster.shutdown();
    }
}
Also used : DumpToHBaseBolt(ypf412.storm.bolt.DumpToHBaseBolt) LocalCluster(backtype.storm.LocalCluster) HBaseSpout(ypf412.storm.spout.HBaseSpout) Fields(backtype.storm.tuple.Fields) TopologyBuilder(backtype.storm.topology.TopologyBuilder) Config(backtype.storm.Config) PropConfig(ypf412.storm.util.PropConfig) PropConfig(ypf412.storm.util.PropConfig)

Aggregations

LocalCluster (backtype.storm.LocalCluster)38 Config (backtype.storm.Config)31 TopologyBuilder (backtype.storm.topology.TopologyBuilder)23 Fields (backtype.storm.tuple.Fields)12 LocalDRPC (backtype.storm.LocalDRPC)3 TupleTableConfig (backtype.storm.contrib.hbase.utils.TupleTableConfig)3 TridentConfig (backtype.storm.contrib.hbase.utils.TridentConfig)2 LinearDRPCTopologyBuilder (backtype.storm.drpc.LinearDRPCTopologyBuilder)2 StormTopology (backtype.storm.generated.StormTopology)2 MemoryTransactionalSpout (backtype.storm.testing.MemoryTransactionalSpout)2 TransactionalTopologyBuilder (backtype.storm.transactional.TransactionalTopologyBuilder)2 ArrayList (java.util.ArrayList)2 Test (org.junit.Test)2 KafkaConfig (storm.kafka.KafkaConfig)2 KafkaSpout (storm.kafka.KafkaSpout)2 SpoutConfig (storm.kafka.SpoutConfig)2 TridentTopology (storm.trident.TridentTopology)2 FixedBatchSpout (storm.trident.testing.FixedBatchSpout)2 HBaseBolt (backtype.storm.contrib.hbase.bolts.HBaseBolt)1 HBaseCountersBatchBolt (backtype.storm.contrib.hbase.bolts.HBaseCountersBatchBolt)1