use of com.yahoo.bullet.record.BulletRecord in project bullet-storm by yahoo.
the class FilterBoltTest method testRateLimiting.
@Test
public void testRateLimiting() {
config = new BulletStormConfig();
RateLimitError rateLimitError = new RateLimitError(42.0, config);
bolt = new RateLimitedFilterBolt(2, rateLimitError, config);
bolt = ComponentUtils.prepare(new HashMap<>(), bolt, collector);
Tuple query = makeIDTuple(TupleClassifier.Type.QUERY_TUPLE, "42", makeSimpleAggregationFilterQuery("field", singletonList("b235gf23b"), EQUALS, RAW, 100, Window.Unit.RECORD, 1, Window.Unit.RECORD, 1), METADATA);
bolt.execute(query);
BulletRecord record = RecordBox.get().add("field", "b235gf23b").getRecord();
Tuple matching = makeRecordTuple(record);
bolt.execute(matching);
bolt.execute(matching);
Tuple expected = makeSlidingTuple(TupleClassifier.Type.DATA_TUPLE, "42", record);
Assert.assertTrue(wasRawRecordEmittedTo(TopologyConstants.DATA_STREAM, 2, expected));
bolt.execute(matching);
Tuple error = TupleUtils.makeIDTuple(TupleClassifier.Type.ERROR_TUPLE, "42", rateLimitError);
Assert.assertTrue(collector.wasNthEmitted(error, 3));
}
use of com.yahoo.bullet.record.BulletRecord in project bullet-storm by yahoo.
the class FilterBoltTest method testMissingRateLimit.
@Test
public void testMissingRateLimit() {
config = new BulletStormConfig();
bolt = new RateLimitedFilterBolt(2, null, config);
bolt = ComponentUtils.prepare(new HashMap<>(), bolt, collector);
Tuple query = makeIDTuple(TupleClassifier.Type.QUERY_TUPLE, "42", makeSimpleAggregationFilterQuery("field", singletonList("b235gf23b"), EQUALS, RAW, 100, Window.Unit.RECORD, 1, Window.Unit.RECORD, 1), METADATA);
bolt.execute(query);
BulletRecord record = RecordBox.get().add("field", "b235gf23b").getRecord();
Tuple matching = makeRecordTuple(record);
bolt.execute(matching);
bolt.execute(matching);
Tuple expected = makeSlidingTuple(TupleClassifier.Type.DATA_TUPLE, "42", record);
Assert.assertTrue(wasRawRecordEmittedTo(TopologyConstants.DATA_STREAM, 2, expected));
Assert.assertEquals(collector.getEmittedCount(), 2);
bolt.execute(matching);
Assert.assertEquals(collector.getEmittedCount(), 2);
}
use of com.yahoo.bullet.record.BulletRecord in project bullet-storm by yahoo.
the class FilterBoltTest method testFilteringUsingProjectedName.
@Test
public void testFilteringUsingProjectedName() {
Tuple query = makeIDTuple(TupleClassifier.Type.QUERY_TUPLE, "42", makeProjectionFilterQuery("mid", singletonList("123"), EQUALS, Pair.of("field", "id"), Pair.of("map_field.id", "mid")), METADATA);
bolt.execute(query);
BulletRecord record = RecordBox.get().add("field", "b235gf23b").add("timestamp", 92L).addMap("map_field", Pair.of("id", "123"), Pair.of("bar", "foo")).getRecord();
Tuple matching = makeRecordTuple(record);
bolt.execute(matching);
BulletRecord expectedRecord = RecordBox.get().add("id", "b235gf23b").add("mid", "123").getRecord();
Tuple expected = makeDataTuple(TupleClassifier.Type.DATA_TUPLE, "42", expectedRecord);
Assert.assertFalse(wasRawRecordEmittedTo(TopologyConstants.DATA_STREAM, expected));
}
use of com.yahoo.bullet.record.BulletRecord in project bullet-storm by yahoo.
the class FilterBoltTest method testCompleteSignal.
@Test
public void testCompleteSignal() {
Tuple query = makeIDTuple(TupleClassifier.Type.QUERY_TUPLE, "42", makeSimpleAggregationFilterQuery("field", singletonList("b235gf23b"), EQUALS, RAW, 5, Window.Unit.RECORD, 1, Window.Unit.RECORD, 1), METADATA);
bolt.execute(query);
BulletRecord record = RecordBox.get().add("field", "b235gf23b").getRecord();
Tuple matching = makeRecordTuple(record);
bolt.execute(matching);
bolt.execute(matching);
Tuple expected = makeSlidingTuple(TupleClassifier.Type.DATA_TUPLE, "42", record);
Assert.assertTrue(wasRawRecordEmittedTo(TopologyConstants.DATA_STREAM, 2, expected));
Assert.assertEquals(collector.getEmittedCount(), 2);
Tuple complete = makeIDTuple(TupleClassifier.Type.METADATA_TUPLE, "42", new Metadata(Metadata.Signal.COMPLETE, null));
bolt.execute(complete);
bolt.execute(matching);
bolt.execute(matching);
Assert.assertEquals(collector.getEmittedCount(), 2);
}
use of com.yahoo.bullet.record.BulletRecord in project bullet-storm by yahoo.
the class FilterBoltTest method testKillSignal.
@Test
public void testKillSignal() {
Tuple query = makeIDTuple(TupleClassifier.Type.QUERY_TUPLE, "42", makeSimpleAggregationFilterQuery("field", singletonList("b235gf23b"), EQUALS, RAW, 5, Window.Unit.RECORD, 1, Window.Unit.RECORD, 1), METADATA);
bolt.execute(query);
BulletRecord record = RecordBox.get().add("field", "b235gf23b").getRecord();
Tuple matching = makeRecordTuple(record);
bolt.execute(matching);
bolt.execute(matching);
Tuple expected = makeSlidingTuple(TupleClassifier.Type.DATA_TUPLE, "42", record);
Assert.assertTrue(wasRawRecordEmittedTo(TopologyConstants.DATA_STREAM, 2, expected));
Assert.assertEquals(collector.getEmittedCount(), 2);
Tuple kill = makeIDTuple(TupleClassifier.Type.METADATA_TUPLE, "42", new Metadata(Metadata.Signal.KILL, null));
bolt.execute(kill);
bolt.execute(matching);
bolt.execute(matching);
Assert.assertEquals(collector.getEmittedCount(), 2);
}
Aggregations