use of com.yahoo.bullet.pubsub.Metadata in project bullet-storm by yahoo.
the class JoinBoltTest method testRateLimitingWithTicks.
@Test
public void testRateLimitingWithTicks() {
RateLimitError rateLimitError = new RateLimitError(42.0, config);
bolt = new RateLimitedJoinBolt(2, rateLimitError, config);
setup(bolt);
Tuple query = TupleUtils.makeIDTuple(TupleClassifier.Type.QUERY_TUPLE, "42", makeAggregationQuery(RAW, 10));
bolt.execute(query);
List<BulletRecord> sent = sendRawRecordTuplesTo(bolt, "42", 2);
Assert.assertEquals(collector.getEmittedCount(), 0);
Tuple tick = TupleUtils.makeTuple(TupleClassifier.Type.TICK_TUPLE);
bolt.execute(tick);
Assert.assertEquals(collector.getEmittedCount(), 2);
Tuple expected = TupleUtils.makeTuple(TupleClassifier.Type.RESULT_TUPLE, "42", Clip.of(sent).add(rateLimitError.makeMeta()).asJSON(), new Metadata(Metadata.Signal.FAIL, null));
Assert.assertTrue(wasResultEmittedTo(TopologyConstants.RESULT_STREAM, expected));
Tuple metadata = TupleUtils.makeTuple(TupleClassifier.Type.FEEDBACK_TUPLE, "42", new Metadata(Metadata.Signal.KILL, null));
Assert.assertTrue(wasMetadataEmittedTo(TopologyConstants.FEEDBACK_STREAM, metadata));
}
use of com.yahoo.bullet.pubsub.Metadata in project bullet-storm by yahoo.
the class JoinBoltTest method isSameMetadata.
private static boolean isSameMetadata(Object actual, Object expected) {
Metadata actualMetadata = (Metadata) actual;
Metadata expectedMetadata = (Metadata) expected;
if (actualMetadata.getSignal() != expectedMetadata.getSignal()) {
return false;
}
Serializable actualContent = actualMetadata.getContent();
Serializable expectedContent = expectedMetadata.getContent();
return actualContent == expectedContent || actualContent.equals(expectedContent);
}
use of com.yahoo.bullet.pubsub.Metadata in project bullet-storm by yahoo.
the class JoinBoltTest method testDataWithoutQuery.
@Test
public void testDataWithoutQuery() {
sendRawRecordTuplesTo(bolt, "42", RAW_MAX_SIZE - 2);
Assert.assertEquals(collector.getEmittedCount(), 0);
Tuple query = TupleUtils.makeIDTuple(TupleClassifier.Type.QUERY_TUPLE, "42", "{}");
bolt.execute(query);
List<BulletRecord> sent = sendRawRecordTuplesTo(bolt, "42", RAW_MAX_SIZE);
Assert.assertEquals(collector.getEmittedCount(), 2);
Tuple expected = TupleUtils.makeTuple(TupleClassifier.Type.RESULT_TUPLE, "42", Clip.of(sent).asJSON(), COMPLETED);
Assert.assertTrue(wasResultEmittedTo(TopologyConstants.RESULT_STREAM, expected));
Tuple metadata = TupleUtils.makeTuple(TupleClassifier.Type.FEEDBACK_TUPLE, "42", new Metadata(Metadata.Signal.COMPLETE, null));
Assert.assertTrue(wasMetadataEmittedTo(TopologyConstants.FEEDBACK_STREAM, metadata));
}
use of com.yahoo.bullet.pubsub.Metadata in project bullet-storm by yahoo.
the class JoinBoltTest method testMetadataIsNotReplaced.
@Test
public void testMetadataIsNotReplaced() {
Metadata actualMetadata = new Metadata(null, "foo");
Tuple query = TupleUtils.makeIDTuple(TupleClassifier.Type.QUERY_TUPLE, "42", "{}", actualMetadata);
bolt.execute(query);
List<BulletRecord> sent = sendRawRecordTuplesTo(bolt, "42", RAW_MAX_SIZE);
Metadata expectedMetadata = new Metadata(Metadata.Signal.COMPLETE, "foo");
Assert.assertEquals(collector.getEmittedCount(), 2);
Tuple expected = TupleUtils.makeTuple(TupleClassifier.Type.RESULT_TUPLE, "42", Clip.of(sent).asJSON(), expectedMetadata);
Assert.assertTrue(wasResultEmittedTo(TopologyConstants.RESULT_STREAM, expected));
Tuple metadata = TupleUtils.makeTuple(TupleClassifier.Type.FEEDBACK_TUPLE, "42", new Metadata(Metadata.Signal.COMPLETE, "foo"));
Assert.assertTrue(wasMetadataEmittedTo(TopologyConstants.FEEDBACK_STREAM, metadata));
}
use of com.yahoo.bullet.pubsub.Metadata in project bullet-storm by yahoo.
the class QueryBoltTest method testMetaTupleRemovingQueries.
@Test
public void testMetaTupleRemovingQueries() {
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 complete = makeIDTuple(Type.METADATA_TUPLE, "foo", new Metadata(Signal.COMPLETE, null));
bolt.execute(complete);
Assert.assertFalse(queries.containsKey("foo"));
queries.put("foo", null);
Tuple fail = makeIDTuple(Type.METADATA_TUPLE, "foo", new Metadata(Signal.KILL, null));
bolt.execute(fail);
Assert.assertFalse(queries.containsKey("foo"));
}
Aggregations