use of com.yahoo.bullet.pubsub.Metadata in project bullet-storm by yahoo.
the class JoinBolt method emitRateLimitError.
private void emitRateLimitError(String id, Querier querier, RateLimitError error) {
Metadata metadata = bufferedMetadata.get(id);
Meta meta = error.makeMeta();
Clip clip = querier.finish();
clip.getMeta().merge(meta);
emitResult(id, withSignal(metadata, Metadata.Signal.FAIL), clip);
emitMetaSignal(id, Metadata.Signal.KILL);
updateCount(rateExceededQueries, 1L);
removeQuery(id);
}
use of com.yahoo.bullet.pubsub.Metadata in project bullet-storm by yahoo.
the class QueryBolt method onMeta.
/**
* Handles a metadata message for a query.
*
* @param tuple The metadata tuple.
* @return The created {@link Metadata}.
*/
protected Metadata onMeta(Tuple tuple) {
String id = tuple.getString(TopologyConstants.ID_POSITION);
Metadata metadata = (Metadata) tuple.getValue(TopologyConstants.METADATA_POSITION);
if (metadata == null) {
return null;
}
Metadata.Signal signal = metadata.getSignal();
if (signal == Metadata.Signal.KILL || signal == Metadata.Signal.COMPLETE) {
removeQuery(id);
log.info("Received {} signal and killed query: {}", signal, id);
}
return metadata;
}
use of com.yahoo.bullet.pubsub.Metadata in project bullet-storm by yahoo.
the class DRPCResultPublisherTest method testFailing.
@Test(expectedExceptions = PubSubException.class)
public void testFailing() throws Exception {
injectedMockBolt.setFailNumber(1);
Assert.assertEquals(injectedMockBolt.getCount(), 0);
PubSubMessage message = new PubSubMessage("foo", "{}", new Metadata(null, makeReturnInfo("a", "testHost", 80)));
publisher.send(message);
}
use of com.yahoo.bullet.pubsub.Metadata in project bullet-storm by yahoo.
the class DRPCResultPublisherTest method testSending.
@Test
public void testSending() throws Exception {
Assert.assertEquals(injectedMockBolt.getCount(), 0);
PubSubMessage message = new PubSubMessage("foo", "{}", new Metadata(null, makeReturnInfo("a", "testHost", 80)));
publisher.send(message);
Assert.assertEquals(injectedMockBolt.getCount(), 1);
Assert.assertTrue(collector.isAcked());
Assert.assertFalse(collector.isFailed());
// Output is no longer present
Assert.assertFalse(collector.haveOutput());
Assert.assertNull(collector.reset());
message = new PubSubMessage("bar", "{}", new Metadata(null, makeReturnInfo("b", "testHost", 80)));
publisher.send(message);
Assert.assertEquals(injectedMockBolt.getCount(), 2);
Assert.assertTrue(collector.isAcked());
Assert.assertFalse(collector.isFailed());
Assert.assertFalse(collector.haveOutput());
Assert.assertNull(collector.reset());
}
use of com.yahoo.bullet.pubsub.Metadata 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);
}
Aggregations