Search in sources :

Example 51 with LocalCluster

use of org.apache.storm.LocalCluster in project storm by apache.

the class SampleOpenTsdbBoltTopology method main.

public static void main(String[] args) throws Exception {
    if (args.length == 0) {
        throw new IllegalArgumentException("There should be at least one argument. Run as `SampleOpenTsdbBoltTopology <tsdb-url>`");
    }
    TopologyBuilder topologyBuilder = new TopologyBuilder();
    topologyBuilder.setSpout("metric-gen", new MetricGenSpout(), 5);
    String openTsdbUrl = args[0];
    OpenTsdbClient.Builder builder = OpenTsdbClient.newBuilder(openTsdbUrl).sync(30_000).returnDetails();
    final OpenTsdbBolt openTsdbBolt = new OpenTsdbBolt(builder, Collections.singletonList(TupleOpenTsdbDatapointMapper.DEFAULT_MAPPER));
    openTsdbBolt.withBatchSize(10).withFlushInterval(2).failTupleForFailedMetrics();
    topologyBuilder.setBolt("opentsdb", openTsdbBolt).shuffleGrouping("metric-gen");
    Config conf = new Config();
    conf.setDebug(true);
    if (args.length > 1) {
        conf.setNumWorkers(3);
        StormSubmitter.submitTopologyWithProgressBar(args[1], conf, topologyBuilder.createTopology());
    } else {
        conf.setMaxTaskParallelism(3);
        try (LocalCluster cluster = new LocalCluster();
            LocalTopology topo = cluster.submitTopology("word-count", conf, topologyBuilder.createTopology())) {
            Thread.sleep(30000);
        }
        System.exit(0);
    }
}
Also used : LocalCluster(org.apache.storm.LocalCluster) OpenTsdbClient(org.apache.storm.opentsdb.client.OpenTsdbClient) TopologyBuilder(org.apache.storm.topology.TopologyBuilder) OpenTsdbBolt(org.apache.storm.opentsdb.bolt.OpenTsdbBolt) Config(org.apache.storm.Config) LocalTopology(org.apache.storm.LocalCluster.LocalTopology)

Example 52 with LocalCluster

use of org.apache.storm.LocalCluster in project storm by apache.

the class JpmmlRunnerTestTopology method submitTopologyLocalCluster.

private void submitTopologyLocalCluster(StormTopology topology, Config config) throws Exception {
    LocalCluster cluster = new LocalCluster();
    cluster.submitTopology(tplgyName, config, topology);
    stopWaitingForInput();
}
Also used : LocalCluster(org.apache.storm.LocalCluster)

Example 53 with LocalCluster

use of org.apache.storm.LocalCluster in project storm by apache.

the class WordCountTridentRedisMap method main.

public static void main(String[] args) throws Exception {
    if (args.length != 3) {
        System.out.println("Usage: WordCountTrident 0(storm-local)|1(storm-cluster) redis-host redis-port");
        System.exit(1);
    }
    Integer flag = Integer.valueOf(args[0]);
    String redisHost = args[1];
    Integer redisPort = Integer.valueOf(args[2]);
    Config conf = new Config();
    conf.setMaxSpoutPending(5);
    if (flag == 0) {
        try (LocalCluster cluster = new LocalCluster();
            LocalTopology topo = cluster.submitTopology("test_wordCounter_for_redis", conf, buildTopology(redisHost, redisPort))) {
            Thread.sleep(60 * 1000);
        }
        System.exit(0);
    } else if (flag == 1) {
        conf.setNumWorkers(3);
        StormSubmitter.submitTopology("test_wordCounter_for_redis", conf, buildTopology(redisHost, redisPort));
    } else {
        System.out.println("Usage: WordCountTrident 0(storm-local)|1(storm-cluster) redis-host redis-port");
    }
}
Also used : LocalCluster(org.apache.storm.LocalCluster) Config(org.apache.storm.Config) JedisPoolConfig(org.apache.storm.redis.common.config.JedisPoolConfig) LocalTopology(org.apache.storm.LocalCluster.LocalTopology)

Example 54 with LocalCluster

use of org.apache.storm.LocalCluster in project storm by apache.

the class EsIndexTopology method main.

public static void main(String[] args) throws Exception {
    Config config = new Config();
    config.setNumWorkers(1);
    TopologyBuilder builder = new TopologyBuilder();
    UserDataSpout spout = new UserDataSpout();
    builder.setSpout(SPOUT_ID, spout, 1);
    EsTupleMapper tupleMapper = EsTestUtil.generateDefaultTupleMapper();
    EsConfig esConfig = new EsConfig(EsConstants.clusterName, new String[] { "localhost:9300" });
    builder.setBolt(BOLT_ID, new EsIndexBolt(esConfig, tupleMapper), 1).shuffleGrouping(SPOUT_ID);
    EsTestUtil.startEsNode();
    EsTestUtil.waitForSeconds(5);
    try (LocalCluster cluster = new LocalCluster();
        LocalTopology topo = cluster.submitTopology(TOPOLOGY_NAME, config, builder.createTopology())) {
        EsTestUtil.waitForSeconds(20);
    }
    System.exit(0);
}
Also used : LocalCluster(org.apache.storm.LocalCluster) EsConfig(org.apache.storm.elasticsearch.common.EsConfig) TopologyBuilder(org.apache.storm.topology.TopologyBuilder) EsTupleMapper(org.apache.storm.elasticsearch.common.EsTupleMapper) Config(org.apache.storm.Config) EsConfig(org.apache.storm.elasticsearch.common.EsConfig) LocalTopology(org.apache.storm.LocalCluster.LocalTopology)

Example 55 with LocalCluster

use of org.apache.storm.LocalCluster in project storm by apache.

the class SampleDruidBoltTopology method main.

public static void main(String[] args) throws Exception {
    if (args.length == 0) {
        throw new IllegalArgumentException("There should be at least one argument. Run as `SampleDruidBoltTopology <zk-url>`");
    }
    TopologyBuilder topologyBuilder = new TopologyBuilder();
    topologyBuilder.setSpout("event-gen", new SimpleSpout(), 5);
    DruidBeamFactory druidBeamFactory = new SampleDruidBeamFactoryImpl(new HashMap<String, Object>());
    DruidConfig.Builder builder = DruidConfig.newBuilder().discardStreamId(DruidConfig.DEFAULT_DISCARD_STREAM_ID);
    ITupleDruidEventMapper<Map<String, Object>> eventMapper = new TupleDruidEventMapper<>(TupleDruidEventMapper.DEFAULT_FIELD_NAME);
    DruidBeamBolt<Map<String, Object>> druidBolt = new DruidBeamBolt<Map<String, Object>>(druidBeamFactory, eventMapper, builder);
    topologyBuilder.setBolt("druid-bolt", druidBolt).shuffleGrouping("event-gen");
    topologyBuilder.setBolt("printer-bolt", new PrinterBolt()).shuffleGrouping("druid-bolt", DruidConfig.DEFAULT_DISCARD_STREAM_ID);
    Config conf = new Config();
    conf.setDebug(true);
    conf.put("druid.tranquility.zk.connect", args[0]);
    if (args.length > 1) {
        conf.setNumWorkers(3);
        StormSubmitter.submitTopologyWithProgressBar(args[1], conf, topologyBuilder.createTopology());
    } else {
        conf.setMaxTaskParallelism(3);
        try (LocalCluster cluster = new LocalCluster();
            LocalTopology topo = cluster.submitTopology("druid-test", conf, topologyBuilder.createTopology())) {
            Thread.sleep(30000);
        }
        System.exit(0);
    }
}
Also used : LocalCluster(org.apache.storm.LocalCluster) TopologyBuilder(org.apache.storm.topology.TopologyBuilder) DruidConfig(org.apache.storm.druid.bolt.DruidConfig) Config(org.apache.storm.Config) DruidBeamFactory(org.apache.storm.druid.bolt.DruidBeamFactory) DruidConfig(org.apache.storm.druid.bolt.DruidConfig) LocalTopology(org.apache.storm.LocalCluster.LocalTopology) DruidBeamBolt(org.apache.storm.druid.bolt.DruidBeamBolt) TupleDruidEventMapper(org.apache.storm.druid.bolt.TupleDruidEventMapper) ITupleDruidEventMapper(org.apache.storm.druid.bolt.ITupleDruidEventMapper) HashMap(java.util.HashMap) Map(java.util.Map)

Aggregations

LocalCluster (org.apache.storm.LocalCluster)76 Config (org.apache.storm.Config)70 LocalTopology (org.apache.storm.LocalCluster.LocalTopology)52 TopologyBuilder (org.apache.storm.topology.TopologyBuilder)28 Fields (org.apache.storm.tuple.Fields)22 Map (java.util.Map)14 StreamBuilder (org.apache.storm.streams.StreamBuilder)9 RandomIntegerSpout (org.apache.storm.starter.spout.RandomIntegerSpout)7 HashMap (java.util.HashMap)6 LocalDRPC (org.apache.storm.LocalDRPC)6 JedisPoolConfig (org.apache.storm.redis.common.config.JedisPoolConfig)6 TestWordSpout (org.apache.storm.testing.TestWordSpout)5 FileInputStream (java.io.FileInputStream)4 InputStream (java.io.InputStream)4 StormSubmitter (org.apache.storm.StormSubmitter)4 StormTopology (org.apache.storm.generated.StormTopology)4 ValueMapper (org.apache.storm.streams.operations.mappers.ValueMapper)4 TopologyContext (org.apache.storm.task.TopologyContext)4 Utils (org.apache.storm.utils.Utils)4 Yaml (org.yaml.snakeyaml.Yaml)4