Package backtype.storm

Examples of backtype.storm.Config


    StormWrapper.submitTopology(conf, builder);
  }

  public Main(String[] args) {
    final String confPath = args[0];
    final Config conf = SystemParameters.fileToStormConfig(confPath);
    final QueryPlan queryPlan = chooseQueryPlan(conf);

    addVariablesToMap(conf, confPath);
    putBatchSizes(queryPlan, conf);
    final TopologyBuilder builder = createTopology(queryPlan, conf);
View Full Code Here


    }
   
    public static void main(String[] args) throws Exception {
        LocalDRPC drpc = new LocalDRPC();

        Config conf = new Config();
        LocalCluster cluster = new LocalCluster();
       
        cluster.submitTopology("reach", conf, buildTopology(drpc));
       
        Thread.sleep(2000);
View Full Code Here

    final String result = (String) conf.get(key);
    return result != null;
  }

  public static Config mapToStormConfig(Map map) {
    final Config conf = new Config();
    conf.putAll(map);
    setStormVariables(conf);
    return conf;
  }
View Full Code Here

        int parallelismHint = 1;
        if (cmd.hasOption(CMD_OPT_PARALLELISM_HINT)) {
            parallelismHint = Integer.parseInt(cmd.getOptionValue(CMD_OPT_PARALLELISM_HINT));
        }

        Config conf = createConfig(cmd);

        beforeCreateTopology(cmd, conf);

        LOGGER.info("Creating topology: " + getTopologyName());
        StormTopology topology = createTopology(parallelismHint);
View Full Code Here

    protected void beforeCreateTopology(CommandLine cmd, Config conf) throws Exception {

    }

    protected Config createConfig(CommandLine cmd) {
        Config conf = new Config();
        conf.put("topology.kryo.factory", DefaultKryoFactory.class.getName());
        for (String key : getConfiguration().getKeys()) {
            conf.put(key, getConfiguration().get(key));
        }
        conf.put(Config.TOPOLOGY_MESSAGE_TIMEOUT_SECS, 10000);
        conf.put(Config.TOPOLOGY_MAX_SPOUT_PENDING, 100);
        if (cmd.hasOption(CMD_OPT_TASKS_PER_BOLT)) {
            conf.put(Config.TOPOLOGY_TASKS, Integer.parseInt(cmd.getOptionValue(CMD_OPT_TASKS_PER_BOLT)));
        }
        if (cmd.hasOption(CMD_OPT_NUM_WORKERS)) {
            conf.setNumWorkers(Integer.parseInt(cmd.getOptionValue(CMD_OPT_NUM_WORKERS)));
        }
        conf.setDebug(false);
        return conf;
    }
View Full Code Here

import backtype.storm.utils.Utils;

public class Topology {
  public static void main(String[] args) throws AlreadyAliveException, InvalidTopologyException {
    Map stormconf = Utils.readStormConfig();
    Config conf = new Config();
    conf.putAll(stormconf);
    conf.setMessageTimeoutSecs(10);
   
    String topologyName=args[0];
    String[] prefixlist=args[1].split(",");
    int workescount=Integer.parseInt(args[2]);
    int mb=Integer.parseInt(args[3]);
    conf.put("topology.worker.childopts", "-Xms"+mb+"m -Xmx"+mb+"m -Xmn"+(mb/2)+"m -XX:SurvivorRatio=3 -XX:PermSize=96m -XX:MaxPermSize=256m -XX:+UseParallelGC -XX:ParallelGCThreads=16 -XX:+UseAdaptiveSizePolicy -XX:+PrintGCDetails -XX:+PrintGCTimeStamps  -Xloggc:%storm.home%/logs/gc-import-%port%.log ");
    conf.setNumWorkers(workescount);
    conf.setNumAckers(Math.max(workescount/2, 4));
    String peinding=args[4];
    conf.setMaxSpoutPending(Integer.parseInt(peinding));
   
   
    List<String> assignment=(List<String>) stormconf.get(MdrillDefaultTaskAssignment.MDRILL_ASSIGNMENT_DEFAULT+"."+topologyName);
    String assignmentports=String.valueOf(stormconf.get(MdrillDefaultTaskAssignment.MDRILL_ASSIGNMENT_PORTS+"."+topologyName));
    conf.put(CustomAssignment.TOPOLOGY_CUSTOM_ASSIGNMENT, MdrillDefaultTaskAssignment.class.getName());
    conf.put(MdrillDefaultTaskAssignment.MDRILL_ASSIGNMENT_DEFAULT, assignment);
    conf.put(MdrillDefaultTaskAssignment.MDRILL_ASSIGNMENT_PORTS, assignmentports);

    TopologyBuilder builder = new TopologyBuilder();
   
    if(args.length>=6)
    {
      String tttime=args[5];
      for(String prefix:prefixlist)
      {
        if(!tttime.equals("0"))
        {
          conf.put(prefix+"-start-time", tttime);
        }
      }
    }
   
    if(args.length>=7)
    {
      String[] prefix_timeist=args[6].split(";");
      for(String prefix_time:prefix_timeist)
      {
        String[] prefix_time_col=prefix_time.split(":");
        if(prefix_time_col.length>1)
        {
          conf.put(prefix_time_col[0]+"-start-time", prefix_time_col[1]);
        }
      }
    }
   
    for(String prefix:prefixlist)
    {
      conf.put(prefix+"-validate-time", System.currentTimeMillis());
    }
   
   
    for(String prefix:prefixlist)
    {
      String mode=String.valueOf(conf.get(prefix+"-mode"));
      String threadconfig=conf.get(prefix+"-threads")!=null?String.valueOf(conf.get(prefix+"-threads")):String.valueOf(workescount);
      int threads=workescount;
      try{
        threads=Integer.parseInt(threadconfig);
      }catch(Throwable e)
      {
        threads=workescount;
      }
      int threads_reduce=threads;
      String threadconfig_reduce=conf.get(prefix+"-threads_reduce")!=null?String.valueOf(conf.get(prefix+"-threads_reduce")):String.valueOf(threads_reduce);
      try{
        threads_reduce=Integer.parseInt(threadconfig_reduce);
      }catch(Throwable e)
      {
        threads_reduce=threads;
View Full Code Here

public class CassandraReachTopology {

    public static void main(String[] args) throws Exception {
        LinearDRPCTopologyBuilder builder = new LinearDRPCTopologyBuilder("reach");

        Config config = new Config();
        String configKey = "cassandra-config";
        HashMap<String, Object> clientConfig = new HashMap<String, Object>();
        clientConfig.put(StormCassandraConstants.CASSANDRA_HOST, "localhost:9160");
        clientConfig.put(StormCassandraConstants.CASSANDRA_KEYSPACE, Arrays.asList(new String [] {"stormks"}));
        config.put(configKey, clientConfig);

        // DelimitedColumnLookupBolt tweetersBolt =
        // new DelimitedColumnLookupBolt("tweeters_delimited", "rowKey",
        // "tweeted_by", ":", "rowKey", "tweeter", true);
        //
        // DelimitedColumnLookupBolt followersBolt =
        // new DelimitedColumnLookupBolt("followers_delimited", "tweeter",
        // "followers", ":", "rowKey", "follower", true);

        // cf = "tweeters", rowkey = tuple["url"]
        TupleMapper<String, String, String> tweetersTupleMapper = new DefaultTupleMapper("stormks", "tweeters", "url");
        // cf (url -> tweeters) -> emit(url, follower)
        ColumnMapper<String, String, String> tweetersColumnsMapper = new ValuelessColumnsMapper("url", "tweeter", true);
        CassandraLookupBolt<String, String, String> tweetersBolt = new CassandraLookupBolt<String, String, String>(configKey,
                tweetersTupleMapper, tweetersColumnsMapper);

        // cf = "followers", rowkey = tuple["tweeter"]
        TupleMapper<String, String, String> followersTupleMapper = new DefaultTupleMapper("stormks", "followers", "tweeter");
        // cf (tweeter -> followers) ==> emit(url, follower)
        ValuelessColumnsMapper followersColumnsMapper = new ValuelessColumnsMapper("url", "follower", true);
        CassandraLookupBolt<String, String, String> followersBolt = new CassandraLookupBolt<String, String, String>(configKey,
                followersTupleMapper, followersColumnsMapper);

        builder.addBolt(new InitBolt());
        builder.addBolt(tweetersBolt).shuffleGrouping();
        builder.addBolt(followersBolt).shuffleGrouping();
        builder.addBolt(new PartialUniquer()).fieldsGrouping(new Fields("id", "follower"));
        builder.addBolt(new CountAggregator()).fieldsGrouping(new Fields("id"));

        if (args == null || args.length == 0) {
            config.setMaxTaskParallelism(3);
            LocalDRPC drpc = new LocalDRPC();
            LocalCluster cluster = new LocalCluster();
            if ("true".equals(System.getProperty("debug"))) {
                config.setDebug(true);
            }
            cluster.submitTopology("reach-drpc", config, builder.createLocalTopology(drpc));

            String[] urlsToTry = new String[] { "http://github.com/hmsonline", "http://github.com/nathanmarz",
                    "http://github.com/ptgoetz", "http://github.com/boneill" };
            for (String url : urlsToTry) {
                System.out.println("Reach of " + url + ": " + drpc.execute("reach", url));
            }

            cluster.shutdown();
            drpc.shutdown();
        } else {
            config.setNumWorkers(6);
            StormSubmitter.submitTopology(args[0], config, builder.createRemoteTopology());
        }
    }
View Full Code Here

import backtype.storm.utils.Utils;

public class Topology {
  public static void main(String[] args) throws AlreadyAliveException, InvalidTopologyException {
    Map stormconf = Utils.readStormConfig();
    Config conf = new Config();
    conf.putAll(stormconf);
    conf.setMessageTimeoutSecs(10);
   
    String topologyName=args[0];
    String[] prefixlist=args[1].split(",");
    int workescount=Integer.parseInt(args[2]);
    int mb=Integer.parseInt(args[3]);
    conf.put("topology.worker.childopts", "-Xms"+mb+"m -Xmx"+mb+"m -Xmn"+(mb/2)+"m -XX:SurvivorRatio=3 -XX:PermSize=96m -XX:MaxPermSize=256m -XX:+UseParallelGC -XX:ParallelGCThreads=16 -XX:+UseAdaptiveSizePolicy -XX:+PrintGCDetails -XX:+PrintGCTimeStamps  -Xloggc:%storm.home%/logs/gc-import-%port%.log ");
    conf.setNumWorkers(workescount);
    conf.setNumAckers(Math.max(workescount/2, 4));
    String peinding=args[4];
    conf.setMaxSpoutPending(Integer.parseInt(peinding));
   
   
    List<String> assignment=(List<String>) stormconf.get(MdrillDefaultTaskAssignment.MDRILL_ASSIGNMENT_DEFAULT+"."+topologyName);
    String assignmentports=String.valueOf(stormconf.get(MdrillDefaultTaskAssignment.MDRILL_ASSIGNMENT_PORTS+"."+topologyName));
    conf.put(CustomAssignment.TOPOLOGY_CUSTOM_ASSIGNMENT, MdrillDefaultTaskAssignment.class.getName());
    conf.put(MdrillDefaultTaskAssignment.MDRILL_ASSIGNMENT_DEFAULT, assignment);
    conf.put(MdrillDefaultTaskAssignment.MDRILL_ASSIGNMENT_PORTS, assignmentports);

    TopologyBuilder builder = new TopologyBuilder();
   
    if(args.length>=6)
    {
      String tttime=args[5];
      for(String prefix:prefixlist)
      {
        if(!tttime.equals("0"))
        {
          conf.put(prefix+"-start-time", tttime);
        }
      }
    }
   
    if(args.length>=7)
    {
      String[] prefix_timeist=args[6].split(";");
      for(String prefix_time:prefix_timeist)
      {
        String[] prefix_time_col=prefix_time.split(":");
        if(prefix_time_col.length>1)
        {
          conf.put(prefix_time_col[0]+"-start-time", prefix_time_col[1]);
        }
      }
    }
   
    for(String prefix:prefixlist)
    {
      conf.put(prefix+"-validate-time", System.currentTimeMillis());
    }
   
   
    for(String prefix:prefixlist)
    {
      String mode=String.valueOf(conf.get(prefix+"-mode"));
      String threadconfig=conf.get(prefix+"-threads")!=null?String.valueOf(conf.get(prefix+"-threads")):String.valueOf(workescount);
      int threads=workescount;
      try{
        threads=Integer.parseInt(threadconfig);
      }catch(Throwable e)
      {
        threads=workescount;
      }
      int threads_reduce=threads;
      String threadconfig_reduce=conf.get(prefix+"-threads_reduce")!=null?String.valueOf(conf.get(prefix+"-threads_reduce")):String.valueOf(threads_reduce);
      try{
        threads_reduce=Integer.parseInt(threadconfig_reduce);
      }catch(Throwable e)
      {
        threads_reduce=threads;
View Full Code Here

    }
   
  }
  public static void main(String[] args) throws AlreadyAliveException, InvalidTopologyException {
    Map stormconf = Utils.readStormConfig();
    Config conf = new Config();
    conf.putAll(stormconf);
    conf.setMessageTimeoutSecs(10);
   
    String topologyName=args[0];
    String[] prefixlist=args[1].split(",");
    TopologyBuilder builder = new TopologyBuilder();
   
    if(args.length>=6)
    {
      String tttime=args[5];
      for(String prefix:prefixlist)
      {
        conf.put(prefix+"-start-time", tttime);
      }
    }
   
    for(String prefix:prefixlist)
    {
      conf.put(prefix+"-validate-time", System.currentTimeMillis());
    }
   
   
    for(String prefix:prefixlist)
    {
View Full Code Here

    private static final String WORD_SPOUT = "WORD_SPOUT";
    private static final String COUNT_BOLT = "COUNT_BOLT";
    private static final String CASSANDRA_BOLT = "WORD_COUNT_CASSANDRA_BOLT";

    public static void main(String[] args) throws Exception {
        Config config = new Config();
        String configKey = "cassandra-config";
        HashMap<String, Object> clientConfig = new HashMap<String, Object>();
        clientConfig.put(StormCassandraConstants.CASSANDRA_HOST, "localhost:9160");
        clientConfig.put(StormCassandraConstants.CASSANDRA_KEYSPACE, Arrays.asList(new String [] {"stormks"}));
        config.put(configKey, clientConfig);

        TestWordSpout wordSpout = new TestWordSpout();

        TestWordCounter countBolt = new TestWordCounter();

        // create a CassandraBolt that writes to the "stormcf" column
        // family and uses the Tuple field "word" as the row key
        CassandraBatchingBolt<String, String, String> cassandraBolt = new CassandraBatchingBolt<String, String, String>(configKey,
                new DefaultTupleMapper("stormks", "stormcf", "word"));
        cassandraBolt.setAckStrategy(AckStrategy.ACK_ON_WRITE);

        // setup topology:
        // wordSpout ==> countBolt ==> cassandraBolt
        TopologyBuilder builder = new TopologyBuilder();

        builder.setSpout(WORD_SPOUT, wordSpout, 3);
        builder.setBolt(COUNT_BOLT, countBolt, 3).fieldsGrouping(WORD_SPOUT, new Fields("word"));
        builder.setBolt(CASSANDRA_BOLT, cassandraBolt, 3).shuffleGrouping(COUNT_BOLT);

        if (args.length == 0) {
            LocalCluster cluster = new LocalCluster();
            cluster.submitTopology("test", config, builder.createTopology());
            Thread.sleep(10000);
            cluster.killTopology("test");
            cluster.shutdown();
            System.exit(0);
        } else {
            config.setNumWorkers(3);
            StormSubmitter.submitTopology(args[0], config, builder.createTopology());
        }
    }
View Full Code Here

TOP

Related Classes of backtype.storm.Config

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.