/** * Create a new DRPCConfig by reading in a file. * * @param file The file containing DRPC settings. */ public DRPCConfig(String file) { // Load and merge with default bullet-storm settings. Storm defaults also contain the DRPC settings. this(new BulletStormConfig(file)); VALIDATOR.validate(this); }
/** * Create a new DRPCConfig by reading in a file. * * @param file The file containing DRPC settings. */ public DRPCConfig(String file) { // Load and merge with default bullet-storm settings. Storm defaults also contain the DRPC settings. this(new BulletStormConfig(file)); VALIDATOR.validate(this); }
@Test public void testCleanup() { TestQueryBolt bolt = new TestQueryBolt(new BulletStormConfig()); bolt.cleanup(); Assert.assertTrue(bolt.isCleaned()); }
@Test public void testNoFiles() { BulletStormConfig config = new BulletStormConfig((String) null); Assert.assertEquals(config.get(BulletStormConfig.TOPOLOGY_NAME), BulletStormConfig.DEFAULT_TOPOLOGY_NAME); Assert.assertEquals(config.get(BulletStormConfig.QUERY_MAX_DURATION), BulletStormConfig.DEFAULT_QUERY_MAX_DURATION); Assert.assertEquals(config.get(BulletStormConfig.AGGREGATION_MAX_SIZE), BulletStormConfig.DEFAULT_AGGREGATION_MAX_SIZE); config = new BulletStormConfig(""); Assert.assertEquals(config.get(BulletStormConfig.TOPOLOGY_NAME), BulletStormConfig.DEFAULT_TOPOLOGY_NAME); }
@Test public void testGettingNonStormSettingsOnly() { BulletStormConfig config = new BulletStormConfig((Config) null); config.set(BulletStormConfig.CUSTOM_STORM_SETTING_PREFIX + "storm.foo", "bar"); config.set(BulletStormConfig.CUSTOM_STORM_SETTING_PREFIX + "bar", "baz"); Map<String, Object> settings = config.getCustomStormSettings(); Assert.assertEquals(settings.size(), 2); Assert.assertEquals(settings.get("storm.foo"), "bar"); Assert.assertEquals(settings.get("bar"), "baz"); }
@BeforeMethod public void setup() { builder = new CustomTopologyBuilder(); builder.setThrowExceptionOnCreate(false); config = new BulletStormConfig(); }
@Test public void testDefaultInitialization() { BulletStormConfig config = new BulletStormConfig(); Assert.assertEquals(config.get(BulletStormConfig.TOPOLOGY_NAME), BulletStormConfig.DEFAULT_TOPOLOGY_NAME); Assert.assertEquals(config.get(BulletStormConfig.QUERY_MAX_DURATION), BulletStormConfig.DEFAULT_QUERY_MAX_DURATION); Assert.assertEquals(config.get(BulletStormConfig.AGGREGATION_MAX_SIZE), BulletStormConfig.DEFAULT_AGGREGATION_MAX_SIZE); }
@Test public void testNullMetaTupleIgnored() { CustomCollector collector = new CustomCollector(); TestQueryBolt bolt = new TestQueryBolt(new BulletStormConfig()); ComponentUtils.prepare(bolt, collector); Map<String, Querier> queries = bolt.getQueries(); queries.put("foo", null); Tuple meta = makeIDTuple(Type.METADATA_TUPLE, "foo", null); bolt.execute(meta); Assert.assertTrue(queries.containsKey("foo")); } }
private static BulletStormConfig oneRecordConfig() { BulletStormConfig config = new BulletStormConfig(); // Set aggregation default size to 1 since most queries here are RAW with filtering and projections. This // makes them isClosedForPartition even if they are not done. immediately. config.set(BulletStormConfig.AGGREGATION_DEFAULT_SIZE, 1); config.validate(); return config; }
@Test public void testCustomConfig() { BulletStormConfig config = new BulletStormConfig("src/test/resources/test_config.yaml"); Assert.assertEquals(config.get(BulletStormConfig.TOPOLOGY_NAME), "test"); Assert.assertEquals(config.get(BulletStormConfig.QUERY_DEFAULT_DURATION), 1000L); Assert.assertEquals(config.get(BulletStormConfig.QUERY_MAX_DURATION), 10000L); Assert.assertEquals(config.get("fake.setting"), "bar"); // Defaulted Assert.assertEquals(config.get(BulletStormConfig.TOPOLOGY_METRICS_ENABLE), false); Assert.assertEquals(config.get(BulletStormConfig.AGGREGATION_MAX_SIZE), BulletConfig.DEFAULT_AGGREGATION_MAX_SIZE); Assert.assertEquals(config.get(BulletStormConfig.QUERY_SPOUT_CPU_LOAD), BulletStormConfig.DEFAULT_QUERY_SPOUT_CPU_LOAD); }
@Test public void testRegisteringIMetricsConsumer() { Config config = new Config(); BulletStormConfig bulletStormConfig = new BulletStormConfig(); Assert.assertNull(bulletStormConfig.get(CustomIMetricsConsumer.CUSTOM_METRICS_REGISTERED)); ReflectionUtils.registerMetricsConsumer(LoggingMetricsConsumer.class.getName(), config, bulletStormConfig); Assert.assertNull(config.get(Config.TOPOLOGY_METRICS_CONSUMER_REGISTER)); ReflectionUtils.registerMetricsConsumer(CustomIMetricsConsumer.class.getName(), config, bulletStormConfig); Assert.assertNotNull(config.get(Config.TOPOLOGY_METRICS_CONSUMER_REGISTER)); Assert.assertTrue((Boolean) bulletStormConfig.get(CustomIMetricsConsumer.CUSTOM_METRICS_REGISTERED)); } }
@Test(expectedExceptions = RuntimeException.class, expectedExceptionsMessageRegExp = ".*Cannot create PubSub.*") public void testFailingToCreatePubSub() { BulletStormConfig config = new BulletStormConfig("src/test/resources/test_config.yaml"); config.set(BulletConfig.PUBSUB_CLASS_NAME, "fake.class"); ComponentUtils.prepare(new ResultBolt(config), collector); }
@Test(expectedExceptions = IllegalStateException.class) public void testWindowMinEmitIsTooSmall() { BulletStormConfig config = new BulletStormConfig((Config) null); config.set(BulletStormConfig.TICK_SPOUT_INTERVAL, 100); config.set(BulletStormConfig.JOIN_BOLT_WINDOW_PRE_START_DELAY_TICKS, 3); config.set(BulletStormConfig.WINDOW_MIN_EMIT_EVERY, 100); config.validate(); } }
@BeforeMethod public void setup() { BulletStormConfig config = new BulletStormConfig("src/test/resources/test_config.yaml"); bolt = new ResultBolt(config); collector = new CustomCollector(); ComponentUtils.prepare(bolt, collector); publisher = (CustomPublisher) bolt.getPublisher(); }
@Test(expectedExceptions = RuntimeException.class, expectedExceptionsMessageRegExp = ".*Cannot create PubSub.*") public void testFailingToCreatePubSub() { BulletStormConfig config = new BulletStormConfig("src/test/resources/test_config.yaml"); config.set(BulletConfig.PUBSUB_CLASS_NAME, "fake.class"); QuerySpout spout = new QuerySpout(config); ComponentUtils.open(spout, emitter); spout.activate(); }
private static BulletStormConfig configWithRawMaxAndNoMeta() { BulletStormConfig config = new BulletStormConfig(); config.set(BulletStormConfig.RAW_AGGREGATION_MAX_SIZE, RAW_MAX_SIZE); config.set(BulletStormConfig.RESULT_METADATA_ENABLE, false); config.validate(); return config; }
private static BulletStormConfig configWithRawMaxAndEmptyMeta() { BulletStormConfig config = new BulletStormConfig(); config.set(BulletStormConfig.RAW_AGGREGATION_MAX_SIZE, RAW_MAX_SIZE); config.set(BulletStormConfig.RESULT_METADATA_ENABLE, true); config.validate(); config.set(BulletStormConfig.RESULT_METADATA_METRICS, new HashMap<>()); return config; }
@Test public void testTickIntervalIsHighEnough() { BulletStormConfig config = new BulletStormConfig((Config) null); config.set(BulletStormConfig.TICK_SPOUT_INTERVAL, 1); config.validate(); Assert.assertEquals(config.get(BulletStormConfig.TICK_SPOUT_INTERVAL), BulletStormConfig.DEFAULT_TICK_SPOUT_INTERVAL); config.set(BulletStormConfig.TICK_SPOUT_INTERVAL, BulletStormConfig.TICK_INTERVAL_MINIMUM); config.validate(); Assert.assertEquals(config.get(BulletStormConfig.TICK_SPOUT_INTERVAL), BulletStormConfig.TICK_INTERVAL_MINIMUM); }
@Test(expectedExceptions = IllegalStateException.class) public void testPreStartDelayIsTooSmall() { BulletStormConfig config = new BulletStormConfig((Config) null); config.set(BulletStormConfig.TICK_SPOUT_INTERVAL, 100); config.set(BulletStormConfig.JOIN_BOLT_WINDOW_PRE_START_DELAY_TICKS, 3); config.set(BulletStormConfig.WINDOW_MIN_EMIT_EVERY, 400); config.validate(); }
@BeforeMethod public void setup() { emitter = new CustomEmitter(); BulletStormConfig config = new BulletStormConfig("src/test/resources/test_config.yaml"); spout = ComponentUtils.open(new QuerySpout(config), emitter); spout.activate(); subscriber = (CustomSubscriber) spout.getSubscriber(); }