PageViewCount extends StormBenchmark { @Override public StormTopology getTopology(Config config) { final int spoutNum = BenchmarkUtils.getInt(config, SPOUT_NUM, DEFAULT_SPOUT_NUM); final int viewBoltNum = BenchmarkUtils.getInt(config, VIEW_NUM, DEFAULT_VIEW_BOLT_NUM); final int cntBoltNum = BenchmarkUtils.getInt(config, COUNT_NUM, DEFAULT_COUNT_BOLT_NUM); spout = new KafkaSpout(KafkaUtils.getSpoutConfig( config, new SchemeAsMultiScheme(new StringScheme()))); TopologyBuilder builder = new TopologyBuilder(); builder.setSpout(SPOUT_ID, spout, spoutNum); builder.setBolt(VIEW_ID, new PageViewBolt(Item.URL, Item.ONE), viewBoltNum) .localOrShuffleGrouping(SPOUT_ID); builder.setBolt(COUNT_ID, new WordCount.Count(), cntBoltNum) .fieldsGrouping(VIEW_ID, new Fields(Item.URL.toString())); return builder.createTopology(); }  @Override StormTopology getTopology(Config config); static final String SPOUT_ID; static final String SPOUT_NUM; static final String VIEW_ID; static final String VIEW_NUM; static final String COUNT_ID; static final String COUNT_NUM; static final int DEFAULT_SPOUT_NUM; static final int DEFAULT_VIEW_BOLT_NUM; static final int DEFAULT_COUNT_BOLT_NUM; }
@Test public void componentParallelismCouldBeSetThroughConfig() { StormBenchmark benchmark = new PageViewCount(); Config config = new Config(); config.put(PageViewCount.SPOUT_NUM, 3); config.put(PageViewCount.VIEW_NUM, 4); config.put(PageViewCount.COUNT_NUM, 5); StormTopology topology = benchmark.getTopology(config); assertThat(topology).isNotNull(); TestUtils.verifyParallelism(Utils.getComponentCommon(topology, PageViewCount.SPOUT_ID), 3); TestUtils.verifyParallelism(Utils.getComponentCommon(topology, PageViewCount.VIEW_ID), 4); TestUtils.verifyParallelism(Utils.getComponentCommon(topology, PageViewCount.COUNT_ID), 5); }