DataClean extends StormBenchmark { @Override public StormTopology getTopology(Config config) { final int spoutNum = BenchmarkUtils.getInt(config, SPOUT_NUM, DEFAULT_SPOUT_NUM); final int pvBoltNum = BenchmarkUtils.getInt(config, VIEW_NUM, DEFAULT_PV_BOLT_NUM); final int filterBoltNum = BenchmarkUtils.getInt(config, FILTER_NUM, DEFAULT_FILTER_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.STATUS, Item.ALL), pvBoltNum) .localOrShuffleGrouping(SPOUT_ID); builder.setBolt(FILTER_ID, new FilterBolt<Integer>(404), filterBoltNum) .fieldsGrouping(VIEW_ID, new Fields(Item.STATUS.toString())); return builder.createTopology(); }  @Override StormTopology getTopology(Config config); final static String SPOUT_ID; final static String SPOUT_NUM; final static String VIEW_ID; final static String VIEW_NUM; final static String FILTER_ID; final static String FILTER_NUM; static final int DEFAULT_SPOUT_NUM; static final int DEFAULT_PV_BOLT_NUM; static final int DEFAULT_FILTER_BOLT_NUM; }
@Test public void componentParallelismCouldBeSetThroughConfig() { StormBenchmark benchmark = new DataClean(); Config config = new Config(); config.put(DataClean.SPOUT_NUM, 3); config.put(DataClean.VIEW_NUM, 4); config.put(DataClean.FILTER_NUM, 5); StormTopology topology = benchmark.getTopology(config); assertThat(topology).isNotNull(); TestUtils.verifyParallelism(Utils.getComponentCommon(topology, DataClean.SPOUT_ID), 3); TestUtils.verifyParallelism(Utils.getComponentCommon(topology, DataClean.VIEW_ID), 4); TestUtils.verifyParallelism(Utils.getComponentCommon(topology, DataClean.FILTER_ID), 5); }