Search in sources :

Example 41 with Config

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

the class TridentSpoutCoordinator method getComponentConfiguration.

@Override
public Map<String, Object> getComponentConfiguration() {
    Config ret = new Config();
    ret.setMaxTaskParallelism(1);
    return ret;
}
Also used : Config(backtype.storm.Config)

Example 42 with Config

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

the class SingleJoinTest method test_single_join.

@Test
public void test_single_join() {
    receiveCounter.set(0);
    try {
        FeederSpout genderSpout = new FeederSpout(new Fields("id", "gender"));
        FeederSpout ageSpout = new FeederSpout(new Fields("id", "age"));
        TopologyBuilder builder = new TopologyBuilder();
        builder.setSpout("gender", genderSpout);
        builder.setSpout("age", ageSpout);
        builder.setBolt("join", new SingleJoinBolt(new Fields("gender", "age"))).fieldsGrouping("gender", new Fields("id")).fieldsGrouping("age", new Fields("id"));
        Config conf = new Config();
        conf.setDebug(true);
        LocalCluster cluster = new LocalCluster();
        cluster.submitTopology("join-example", conf, builder.createTopology());
        for (int i = 0; i < 10; i++) {
            String gender;
            if (i % 2 == 0) {
                gender = "male";
            } else {
                gender = "female";
            }
            genderSpout.feed(new Values(i, gender));
        }
        for (int i = 9; i >= 0; i--) {
            ageSpout.feed(new Values(i, i + 20));
        }
        JStormUtils.sleepMs(60 * 1000);
        assertNotSame(0, receiveCounter.get());
        cluster.shutdown();
    } catch (Exception e) {
        Assert.fail("Failed to run SingleJoinExample");
    }
}
Also used : LocalCluster(backtype.storm.LocalCluster) Fields(backtype.storm.tuple.Fields) TopologyBuilder(backtype.storm.topology.TopologyBuilder) Config(backtype.storm.Config) Values(backtype.storm.tuple.Values) FeederSpout(backtype.storm.testing.FeederSpout) Test(org.junit.Test)

Example 43 with Config

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

the class TransactionalWordsTest method test_transaction_word.

@Test
public void test_transaction_word() {
    try {
        MemoryTransactionalSpout spout = new MemoryTransactionalSpout(DATA, new Fields("word"), PARTITION_TAKE_PER_BATCH);
        TransactionalTopologyBuilder builder = new TransactionalTopologyBuilder("top-n-words", "spout", spout, 2);
        builder.setBolt("count", new KeyedCountUpdater(), 5).fieldsGrouping("spout", new Fields("word"));
        builder.setBolt("bucketize", new Bucketize()).shuffleGrouping("count");
        builder.setBolt("buckets", new BucketCountUpdater(), 5).fieldsGrouping("bucketize", new Fields("bucket"));
        LocalCluster cluster = new LocalCluster();
        Config config = new Config();
        config.setDebug(true);
        config.setMaxSpoutPending(3);
        cluster.submitTopology("top-n-topology", config, builder.buildTopology());
        JStormUtils.sleepMs(60 * 1000);
        assertEquals(false, outOfOrder.get());
        assertNotSame(0, receiveCounter1.get());
        assertNotSame(0, receiveCounter2.get());
    //cluster.killTopology("top-n-topology");
    //cluster.shutdown();
    } catch (Exception e) {
        e.printStackTrace();
        Assert.fail("Failed to run simple transaction");
    }
}
Also used : LocalCluster(backtype.storm.LocalCluster) MemoryTransactionalSpout(backtype.storm.testing.MemoryTransactionalSpout) Fields(backtype.storm.tuple.Fields) Config(backtype.storm.Config) TransactionalTopologyBuilder(backtype.storm.transactional.TransactionalTopologyBuilder) Test(org.junit.Test)

Example 44 with Config

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

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

the class WordCountTopology method main.

/**
     * Main method
     */
public static void main(String[] args) throws AlreadyAliveException, InvalidTopologyException {
    if (args.length != 1) {
        throw new RuntimeException("Specify topology name");
    }
    int parallelism = 10;
    TopologyBuilder builder = new TopologyBuilder();
    builder.setSpout("word", new WordSpout(), parallelism);
    builder.setBolt("consumer", new ConsumerBolt(), parallelism).fieldsGrouping("word", new Fields("word"));
    Config conf = new Config();
    conf.setNumStmgrs(parallelism);
    /*
    Set config here
    */
    StormSubmitter.submitTopology(args[0], conf, builder.createTopology());
}
Also used : Fields(backtype.storm.tuple.Fields) TopologyBuilder(backtype.storm.topology.TopologyBuilder) Config(backtype.storm.Config)

Aggregations

Config (backtype.storm.Config)75 TopologyBuilder (backtype.storm.topology.TopologyBuilder)38 LocalCluster (backtype.storm.LocalCluster)31 Fields (backtype.storm.tuple.Fields)19 Test (org.junit.Test)8 StormTopology (backtype.storm.generated.StormTopology)7 Map (java.util.Map)7 LocalDRPC (backtype.storm.LocalDRPC)6 ArrayList (java.util.ArrayList)4 ILocalCluster (backtype.storm.ILocalCluster)3 TupleTableConfig (backtype.storm.contrib.hbase.utils.TupleTableConfig)3 LinearDRPCTopologyBuilder (backtype.storm.drpc.LinearDRPCTopologyBuilder)3 MkClusterParam (backtype.storm.testing.MkClusterParam)3 TestJob (backtype.storm.testing.TestJob)3 TransactionalTopologyBuilder (backtype.storm.transactional.TransactionalTopologyBuilder)3 Values (backtype.storm.tuple.Values)3 TridentConfig (backtype.storm.contrib.hbase.utils.TridentConfig)2 DRPCSpout (backtype.storm.drpc.DRPCSpout)2 ReturnResults (backtype.storm.drpc.ReturnResults)2 FeederSpout (backtype.storm.testing.FeederSpout)2