Java Code Examples for backtype.storm.Config#put()
The following examples show how to use
backtype.storm.Config#put() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SequenceTopologyTool.java From jstorm with Apache License 2.0 | 6 votes |
public void SetRemoteTopology() throws AlreadyAliveException, InvalidTopologyException, TopologyAssignException { Config conf = getConf(); StormTopology topology = buildTopology(); conf.put(Config.STORM_CLUSTER_MODE, "distributed"); String streamName = (String) conf.get(Config.TOPOLOGY_NAME); if (streamName == null) { streamName = "SequenceTest"; } if (streamName.contains("zeromq")) { conf.put(Config.STORM_MESSAGING_TRANSPORT, "com.alibaba.jstorm.message.zeroMq.MQContext"); } else { conf.put(Config.STORM_MESSAGING_TRANSPORT, "com.alibaba.jstorm.message.netty.NettyContext"); } StormSubmitter.submitTopology(streamName, conf, topology); }
Example 2
Source File: TaskHookTopology.java From incubator-heron with Apache License 2.0 | 5 votes |
public static void main(String[] args) throws Exception { if (args.length != 1) { throw new RuntimeException("Specify topology name"); } TopologyBuilder builder = new TopologyBuilder(); builder.setSpout("word", new AckingTestWordSpout(), 2); builder.setBolt("count", new CountBolt(), 2) .shuffleGrouping("word"); Config conf = new Config(); conf.setDebug(true); // Put an arbitrary large number here if you don't want to slow the topology down conf.setMaxSpoutPending(1000 * 1000 * 1000); // To enable acking, we need to setEnableAcking true conf.setNumAckers(1); conf.put(Config.TOPOLOGY_WORKER_CHILDOPTS, "-XX:+HeapDumpOnOutOfMemoryError"); // Set the task hook List<String> taskHooks = new LinkedList<>(); taskHooks.add("org.apache.heron.examples.TaskHookTopology$TestTaskHook"); org.apache.heron.api.Config.setAutoTaskHooks(conf, taskHooks); // component resource configuration org.apache.heron.api.Config.setComponentRam(conf, "word", ByteAmount.fromMegabytes(512)); org.apache.heron.api.Config.setComponentRam(conf, "count", ByteAmount.fromMegabytes(512)); // container resource configuration org.apache.heron.api.Config.setContainerDiskRequested(conf, ByteAmount.fromGigabytes(2)); org.apache.heron.api.Config.setContainerRamRequested(conf, ByteAmount.fromGigabytes(2)); org.apache.heron.api.Config.setContainerCpuRequested(conf, 2); conf.setNumWorkers(2); StormSubmitter.submitTopology(args[0], conf, builder.createTopology()); }
Example 3
Source File: BenchmarkUtilsTest.java From storm-benchmark with Apache License 2.0 | 5 votes |
@Test(dataProvider = "getNumberOfAckers") public void ifAckEnabledShouldReturnTrueForOneOrMoreAckers(int ackers, boolean expected) { Config config = new Config(); assertThat(BenchmarkUtils.ifAckEnabled(config)).isFalse(); config.put(Config.TOPOLOGY_ACKER_EXECUTORS, ackers); assertThat(BenchmarkUtils.ifAckEnabled(config)).isEqualTo(expected); }
Example 4
Source File: WordCountTopology.java From storm-cassandra-cql with Apache License 2.0 | 5 votes |
public static void main(String[] args) throws Exception { final Config configuration = new Config(); configuration.put(MapConfiguredCqlClientFactory.TRIDENT_CASSANDRA_CQL_HOSTS, "localhost"); final LocalCluster cluster = new LocalCluster(); LocalDRPC client = new LocalDRPC(); LOG.info("Submitting topology."); cluster.submitTopology("cqlexample", configuration, buildWordCountAndSourceTopology(client)); LOG.info("Topology submitted."); Thread.sleep(10000); LOG.info("DRPC Query: Word Count [cat, dog, the, man]: {}", client.execute("words", "cat dog the man")); cluster.shutdown(); client.shutdown(); }
Example 5
Source File: FileReadWordCountTest.java From storm-benchmark with Apache License 2.0 | 5 votes |
@Test public void componentParallelismCouldBeSetThroughConfig() { StormBenchmark benchmark = new FileReadWordCount(); Config config = new Config(); config.put(WordCount.SPOUT_NUM, 3); config.put(WordCount.SPLIT_NUM, 4); config.put(WordCount.COUNT_NUM, 5); StormTopology topology = benchmark.getTopology(config); assertThat(topology).isNotNull(); TestUtils.verifyParallelism(Utils.getComponentCommon(topology, WordCount.SPOUT_ID), 3); TestUtils.verifyParallelism(Utils.getComponentCommon(topology, WordCount.SPLIT_ID), 4); TestUtils.verifyParallelism(Utils.getComponentCommon(topology, WordCount.COUNT_ID), 5); }
Example 6
Source File: RollingSortTest.java From storm-benchmark with Apache License 2.0 | 5 votes |
@Test public void componentParallelismCouldBeSetThroughConfig() { StormBenchmark benchmark = new RollingSort(); Config config = new Config(); config.put(RollingSort.SPOUT_NUM, 4); config.put(RollingSort.SORT_BOLT_NUM, 5); StormTopology topology = benchmark.getTopology(config); assertThat(topology).isNotNull(); TestUtils.verifyParallelism(Utils.getComponentCommon(topology, RollingSort.SPOUT_ID), 4); TestUtils.verifyParallelism(Utils.getComponentCommon(topology, RollingSort.SORT_BOLT_ID), 5); }
Example 7
Source File: SOLTest.java From storm-benchmark with Apache License 2.0 | 5 votes |
@Test public void componentParallelismCouldBeSetThroughConfig() { StormBenchmark benchmark = new SOL(); Config config = new Config(); config.put(SOL.SPOUT_NUM, 4); config.put(SOL.BOLT_NUM, 3); config.put(SOL.TOPOLOGY_LEVEL, 3); StormTopology topology = benchmark.getTopology(config); assertThat(topology).isNotNull(); TestUtils.verifyParallelism(Utils.getComponentCommon(topology, SOL.SPOUT_ID), 4); TestUtils.verifyParallelism(Utils.getComponentCommon(topology, SOL.BOLT_ID + "1"), 3); TestUtils.verifyParallelism(Utils.getComponentCommon(topology, SOL.BOLT_ID + "2"), 3); }
Example 8
Source File: RollingCountTest.java From storm-benchmark with Apache License 2.0 | 5 votes |
@Test public void componentParallelismCouldBeSetThroughConfig() { StormBenchmark benchmark = new RollingCount(); Config config = new Config(); config.put(RollingCount.SPOUT_NUM, 4); config.put(RollingCount.SPLIT_NUM, 5); config.put(RollingCount.COUNTER_NUM, 3); StormTopology topology = benchmark.getTopology(config); assertThat(topology).isNotNull(); TestUtils.verifyParallelism(Utils.getComponentCommon(topology, RollingCount.SPOUT_ID), 4); TestUtils.verifyParallelism(Utils.getComponentCommon(topology, RollingCount.SPLIT_ID), 5); TestUtils.verifyParallelism(Utils.getComponentCommon(topology, RollingCount.COUNTER_ID), 3); }
Example 9
Source File: UniqueVisitorTest.java From storm-benchmark with Apache License 2.0 | 5 votes |
@Test public void componentParallelismCouldBeSetThroughConfig() { StormBenchmark benchmark = new UniqueVisitor(); Config config = new Config(); config.put(UniqueVisitor.SPOUT_NUM, 3); config.put(UniqueVisitor.VIEW_NUM, 4); config.put(UniqueVisitor.UNIQUER_NUM, 5); StormTopology topology = benchmark.getTopology(config); assertThat(topology).isNotNull(); TestUtils.verifyParallelism(Utils.getComponentCommon(topology, UniqueVisitor.SPOUT_ID), 3); TestUtils.verifyParallelism(Utils.getComponentCommon(topology, UniqueVisitor.VIEW_ID), 4); TestUtils.verifyParallelism(Utils.getComponentCommon(topology, UniqueVisitor.UNIQUER_ID), 5); }
Example 10
Source File: FirstStoryDetection.java From first-stories-twitter with MIT License | 5 votes |
private static Config createTopologyConfiguration(Properties prop, boolean localMode) { Config conf = new Config(); List<String> dprcServers = new ArrayList<String>(); dprcServers.add("localhost"); conf.put(Config.DRPC_SERVERS, dprcServers); conf.put(Config.DRPC_PORT, 3772); if (!localMode) conf.put(Config.STORM_CLUSTER_MODE, new String("distributed")); conf.put("UNIQUE_WORDS_EXPECTED", prop.getProperty("UNIQUE_WORDS_EXPECTED")); conf.put("PATH_TO_OOV_FILE", prop.getProperty("PATH_TO_OOV_FILE")); conf.put("L", prop.getProperty("L")); conf.put("BucketsParallelism", prop.getProperty("BucketsParallelism")); conf.put("k", prop.getProperty("k")); conf.put("QUEUE_SIZE", prop.getProperty("QUEUE_SIZE")); List<String> countAggKeepFields = new ArrayList<String>(); countAggKeepFields.add("tweet_obj"); countAggKeepFields.add("coltweet_obj"); conf.put("countAggKeepFields", countAggKeepFields); conf.put("THRESHOLD", prop.getProperty("THRESHOLD")); conf.put("RECENT_TWEETS_TO_COMPARE_WITH", prop.getProperty("RECENT_TWEETS_TO_COMPARE_WITH")); conf.setDebug(false); conf.setNumWorkers(Integer.valueOf((String) prop .get("NUMBER_OF_WORKERS"))); conf.setMaxSpoutPending(50000000); return conf; }
Example 11
Source File: SimpleBatchTopologyTest.java From jstorm with Apache License 2.0 | 5 votes |
@Test public void testSimpleBatchTopology() { BatchTopologyBuilder batchTopologyBuilder = new BatchTopologyBuilder("SimpleBatchTopology"); batchTopologyBuilder.setSpout("batchSpout", new SimpleBatchTestSpout(), 1); batchTopologyBuilder.setBolt("batchBolt", new SimpleBatchTestBolt(), 2).shuffleGrouping("batchSpout"); Config config = new Config(); config.put(Config.TOPOLOGY_NAME, "SimpleBatchTopologyTest"); config.setMaxSpoutPending(1); JStormUnitTestRunner.submitTopology(batchTopologyBuilder.getTopologyBuilder().createTopology(), config, 120, null); }
Example 12
Source File: SalesTopology.java From storm-cassandra-cql with Apache License 2.0 | 5 votes |
public static void main(String[] args) throws Exception { final Config configuration = new Config(); configuration.put(MapConfiguredCqlClientFactory.TRIDENT_CASSANDRA_CQL_HOSTS, "localhost"); final LocalCluster cluster = new LocalCluster(); LOG.info("Submitting topology."); cluster.submitTopology("cqlexample", configuration, buildTopology()); LOG.info("Topology submitted."); Thread.sleep(600000); }
Example 13
Source File: TestSuite.java From jstorm with Apache License 2.0 | 5 votes |
@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"); }
Example 14
Source File: MultiStageAckingTopology.java From incubator-heron with Apache License 2.0 | 5 votes |
public static void main(String[] args) throws Exception { if (args.length != 1) { throw new RuntimeException("Please specify the name of the topology"); } TopologyBuilder builder = new TopologyBuilder(); int parallelism = 2; builder.setSpout("word", new AckingTestWordSpout(), parallelism); builder.setBolt("exclaim1", new ExclamationBolt(true), parallelism) .shuffleGrouping("word"); builder.setBolt("exclaim2", new ExclamationBolt(false), parallelism) .shuffleGrouping("exclaim1"); Config conf = new Config(); conf.setDebug(true); // Put an arbitrary large number here if you don't want to slow the topology down conf.setMaxSpoutPending(1000 * 1000 * 1000); // To enable acking, we need to setEnableAcking true conf.setNumAckers(1); conf.put(Config.TOPOLOGY_WORKER_CHILDOPTS, "-XX:+HeapDumpOnOutOfMemoryError"); conf.setNumWorkers(parallelism); StormSubmitter.submitTopology(args[0], conf, builder.createTopology()); }
Example 15
Source File: DRPC.java From storm-benchmark with Apache License 2.0 | 4 votes |
@Override public StormTopology getTopology(Config config) { Object sObj = config.get(SERVER); if (null == sObj) { throw new IllegalArgumentException("must set a drpc server"); } server = (String) sObj; config.put(Config.DRPC_SERVERS, Lists.newArrayList(server)); Object pObj = config.get(PORT); if (null == pObj) { throw new IllegalArgumentException("must set a drpc port"); } port = Utils.getInt(pObj); config.put(Config.DRPC_PORT, port); LOG.info("drpc server: " + server + "; drpc port: " + port); final int spoutNum = BenchmarkUtils.getInt(config, SPOUT_NUM, DEFAULT_SPOUT_NUM); final int pageNum = BenchmarkUtils.getInt(config, PAGE_NUM, DEFAULT_PAGE_BOLT_NUM); final int viewNum = BenchmarkUtils.getInt(config, VIEW_NUM, DEFAULT_VIEW_BOLT_NUM); final int userNum = BenchmarkUtils.getInt(config, USER_NUM, DEFAULT_USER_BOLT_NUM); final int followerNum = BenchmarkUtils.getInt(config, FOLLOWER_NUM, DEFAULT_FOLLOWER_BOLT_NUM); spout = new TransactionalTridentKafkaSpout( KafkaUtils.getTridentKafkaConfig(config, new SchemeAsMultiScheme(new StringScheme()))); TridentTopology trident = new TridentTopology(); TridentState urlToUsers = trident.newStream("drpc", spout).parallelismHint(spoutNum).shuffle() .each(new Fields(StringScheme.STRING_SCHEME_KEY), new Extract(Arrays.asList(Item.URL, Item.USER)), new Fields("url", "user")).parallelismHint(pageNum) .groupBy(new Fields("url")) .persistentAggregate(new MemoryMapState.Factory(), new Fields("url", "user"), new Distinct(), new Fields("user_set")) .parallelismHint(viewNum); /** debug * 1. this proves that the aggregated result has successfully persisted urlToUsers.newValuesStream() .each(new Fields("url", "user_set"), new Print("(url, user_set)"), new Fields("url2", "user_set2")); */ PageViewGenerator generator = new PageViewGenerator(); TridentState userToFollowers = trident.newStaticState(new StaticSingleKeyMapState.Factory(generator.genFollowersDB())); /** debug * 2. this proves that MemoryMapState could be read correctly trident.newStream("urlToUsers", new PageViewSpout(false)) .each(new Fields("page_view"), new Extract(Arrays.asList(Item.URL)), new Fields("url")) .each(new Fields("url"), new Print("url"), new Fields("url2")) .groupBy(new Fields("url2")) .stateQuery(urlToUsers, new Fields("url2"), new MapGet(), new Fields("users")) .each(new Fields("users"), new Print("users"), new Fields("users2")); */ /** debug * 3. this proves that StaticSingleKeyMapState could be read correctly trident.newStream("userToFollowers", new PageViewSpout(false)) .each(new Fields("page_view"), new Extract(Arrays.asList(Item.USER)), new Fields("user")) .each(new Fields("user"), new Print("user"), new Fields("user2")) .stateQuery(userToFollowers, new Fields("user2"), new MapGet(), new Fields("followers")) .each(new Fields("followers"), new Print("followers"), new Fields("followers2")); */ trident.newDRPCStream(FUNCTION, null) .each(new Fields("args"), new Print("args"), new Fields("url")) .groupBy(new Fields("url")) .stateQuery(urlToUsers, new Fields("url"), new MapGet(), new Fields("users")) .each(new Fields("users"), new Expand(), new Fields("user")).parallelismHint(userNum) .groupBy(new Fields("user")) .stateQuery(userToFollowers, new Fields("user"), new MapGet(), new Fields("followers")) .each(new Fields("followers"), new Expand(), new Fields("follower")).parallelismHint(followerNum) .groupBy(new Fields("follower")) .aggregate(new One(), new Fields("one")) .aggregate(new Fields("one"), new Sum(), new Fields("reach")); return trident.build(); }
Example 16
Source File: SequenceTopologyTool.java From jstorm with Apache License 2.0 | 4 votes |
public StormTopology buildTopology() { Config conf = getConf(); TopologyBuilder builder = new TopologyBuilder(); int spout_Parallelism_hint = JStormUtils.parseInt(conf.get(TOPOLOGY_SPOUT_PARALLELISM_HINT), 1); int bolt_Parallelism_hint = JStormUtils.parseInt(conf.get(TOPOLOGY_BOLT_PARALLELISM_HINT), 2); builder.setSpout(SequenceTopologyDef.SEQUENCE_SPOUT_NAME, new SequenceSpout(), spout_Parallelism_hint); boolean isEnableSplit = JStormUtils.parseBoolean(conf.get("enable.split"), false); if (!isEnableSplit) { builder.setBolt(SequenceTopologyDef.TOTAL_BOLT_NAME, new TotalCount(), bolt_Parallelism_hint) .localFirstGrouping(SequenceTopologyDef.SEQUENCE_SPOUT_NAME); } else { builder.setBolt(SequenceTopologyDef.SPLIT_BOLT_NAME, new SplitRecord(), bolt_Parallelism_hint) .localOrShuffleGrouping(SequenceTopologyDef.SEQUENCE_SPOUT_NAME); builder.setBolt(SequenceTopologyDef.TRADE_BOLT_NAME, new PairCount(), bolt_Parallelism_hint) .shuffleGrouping(SequenceTopologyDef.SPLIT_BOLT_NAME, SequenceTopologyDef.TRADE_STREAM_ID); builder.setBolt(SequenceTopologyDef.CUSTOMER_BOLT_NAME, new PairCount(), bolt_Parallelism_hint) .shuffleGrouping(SequenceTopologyDef.SPLIT_BOLT_NAME, SequenceTopologyDef.CUSTOMER_STREAM_ID); builder.setBolt(SequenceTopologyDef.MERGE_BOLT_NAME, new MergeRecord(), bolt_Parallelism_hint) .fieldsGrouping(SequenceTopologyDef.TRADE_BOLT_NAME, new Fields("ID")) .fieldsGrouping(SequenceTopologyDef.CUSTOMER_BOLT_NAME, new Fields("ID")); builder.setBolt(SequenceTopologyDef.TOTAL_BOLT_NAME, new TotalCount(), bolt_Parallelism_hint) .noneGrouping(SequenceTopologyDef.MERGE_BOLT_NAME); } boolean kryoEnable = JStormUtils.parseBoolean(conf.get("kryo.enable"), false); if (kryoEnable) { System.out.println("Use Kryo "); boolean useJavaSer = JStormUtils.parseBoolean(conf.get("fall.back.on.java.serialization"), true); Config.setFallBackOnJavaSerialization(conf, useJavaSer); Config.registerSerialization(conf, TradeCustomer.class); Config.registerSerialization(conf, Pair.class); } int ackerNum = JStormUtils.parseInt(conf.get(Config.TOPOLOGY_ACKER_EXECUTORS), 1); Config.setNumAckers(conf, ackerNum); int workerNum = JStormUtils.parseInt(conf.get(Config.TOPOLOGY_WORKERS), 20); conf.put(Config.TOPOLOGY_WORKERS, workerNum); return builder.createTopology(); }
Example 17
Source File: ZkTopology.java From yuzhouwan with Apache License 2.0 | 4 votes |
public static void main(String[] args) { //这个地方其实就是kafka配置文件里边的zookeeper.connect这个参数,可以去那里拿过来 String brokerZkStr = "10.100.90.201:2181/kafka_online_sample"; String brokerZkPath = "/brokers"; ZkHosts zkHosts = new ZkHosts(brokerZkStr, brokerZkPath); String topic = "mars-wap"; //以下:将offset汇报到哪个zk集群,相应配置 String offsetZkServers = "10.199.203.169"; String offsetZkPort = "2181"; List<String> zkServersList = new ArrayList<>(); zkServersList.add(offsetZkServers); //汇报offset信息的root路径 String offsetZkRoot = "/stormExample"; //存储该spout id的消费offset信息,譬如以topoName来命名 String offsetZkId = "storm-example"; SpoutConfig kafkaConfig = new SpoutConfig(zkHosts, topic, offsetZkRoot, offsetZkId); kafkaConfig.zkPort = Integer.parseInt(offsetZkPort); kafkaConfig.zkServers = zkServersList; kafkaConfig.scheme = new SchemeAsMultiScheme(new StringScheme()); KafkaSpout spout = new KafkaSpout(kafkaConfig); TopologyBuilder builder = new TopologyBuilder(); builder.setSpout("spout", spout, 1); builder.setBolt("bolt", new EsBolt("storm/docs"), 1).shuffleGrouping("spout"); Config config = new Config(); config.put("es.index.auto.create", "true"); if (args.length > 0) { try { StormSubmitter.submitTopology("storm-kafka-example", config, builder.createTopology()); } catch (Exception e) { LOG.error("", e); } } else { LocalCluster cluster = new LocalCluster(); cluster.submitTopology("test", config, builder.createTopology()); } }
Example 18
Source File: StormTopologySubmitter.java From incubator-samoa with Apache License 2.0 | 4 votes |
public static void main(String[] args) throws IOException { Properties props = StormSamoaUtils.getProperties(); String uploadedJarLocation = props.getProperty(StormJarSubmitter.UPLOADED_JAR_LOCATION_KEY); if (uploadedJarLocation == null) { logger.error("Invalid properties file. It must have key {}", StormJarSubmitter.UPLOADED_JAR_LOCATION_KEY); return; } List<String> tmpArgs = new ArrayList<String>(Arrays.asList(args)); int numWorkers = StormSamoaUtils.numWorkers(tmpArgs); args = tmpArgs.toArray(new String[0]); StormTopology stormTopo = StormSamoaUtils.argsToTopology(args); Config conf = new Config(); conf.putAll(Utils.readStormConfig()); conf.putAll(Utils.readCommandLineOpts()); conf.setDebug(false); conf.setNumWorkers(numWorkers); String profilerOption = props.getProperty(StormTopologySubmitter.YJP_OPTIONS_KEY); if (profilerOption != null) { String topoWorkerChildOpts = (String) conf.get(Config.TOPOLOGY_WORKER_CHILDOPTS); StringBuilder optionBuilder = new StringBuilder(); if (topoWorkerChildOpts != null) { optionBuilder.append(topoWorkerChildOpts); optionBuilder.append(' '); } optionBuilder.append(profilerOption); conf.put(Config.TOPOLOGY_WORKER_CHILDOPTS, optionBuilder.toString()); } Map<String, Object> myConfigMap = new HashMap<String, Object>(conf); StringWriter out = new StringWriter(); try { JSONValue.writeJSONString(myConfigMap, out); } catch (IOException e) { System.out.println("Error in writing JSONString"); e.printStackTrace(); return; } Config config = new Config(); config.putAll(Utils.readStormConfig()); NimbusClient nc = NimbusClient.getConfiguredClient(config); String topologyName = stormTopo.getTopologyName(); try { System.out.println("Submitting topology with name: " + topologyName); nc.getClient().submitTopology(topologyName, uploadedJarLocation, out.toString(), stormTopo.getStormBuilder().createTopology()); System.out.println(topologyName + " is successfully submitted"); } catch (AlreadyAliveException aae) { System.out.println("Fail to submit " + topologyName + "\nError message: " + aae.get_msg()); } catch (InvalidTopologyException ite) { System.out.println("Invalid topology for " + topologyName); ite.printStackTrace(); } catch (TException te) { System.out.println("Texception for " + topologyName); te.printStackTrace(); } }
Example 19
Source File: EsIndexBolt.java From cognition with Apache License 2.0 | 4 votes |
@Override public Map<String, Object> getComponentConfiguration() { Config conf = new Config(); conf.put(Config.TOPOLOGY_TICK_TUPLE_FREQ_SECS, manualFlushFreqSecs); return conf; }
Example 20
Source File: PersistentWordCount.java From storm-hbase with Apache License 2.0 | 4 votes |
public static void main(String[] args) throws Exception { Config config = new Config(); Map<String, Object> hbConf = new HashMap<String, Object>(); if(args.length > 0){ hbConf.put("hbase.rootdir", args[0]); } config.put("hbase.conf", hbConf); WordSpout spout = new WordSpout(); WordCounter bolt = new WordCounter(); SimpleHBaseMapper mapper = new SimpleHBaseMapper() .withRowKeyField("word") .withColumnFields(new Fields("word")) .withCounterFields(new Fields("count")) .withColumnFamily("cf"); HBaseBolt hbase = new HBaseBolt("WordCount", mapper) .withConfigKey("hbase.conf"); // wordSpout ==> countBolt ==> HBaseBolt TopologyBuilder builder = new TopologyBuilder(); builder.setSpout(WORD_SPOUT, spout, 1); builder.setBolt(COUNT_BOLT, bolt, 1).shuffleGrouping(WORD_SPOUT); builder.setBolt(HBASE_BOLT, hbase, 1).fieldsGrouping(COUNT_BOLT, new Fields("word")); if (args.length == 1) { LocalCluster cluster = new LocalCluster(); cluster.submitTopology("test", config, builder.createTopology()); Thread.sleep(30000); cluster.killTopology("test"); cluster.shutdown(); System.exit(0); } else if (args.length == 2) { StormSubmitter.submitTopology(args[1], config, builder.createTopology()); } else{ System.out.println("Usage: HdfsFileTopology <hdfs url> [topology name]"); } }