Search in sources :

Example 1 with Metadata

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);
}
Also used : Clip(com.yahoo.bullet.result.Clip) Meta(com.yahoo.bullet.result.Meta) Metadata(com.yahoo.bullet.pubsub.Metadata)

Example 2 with Metadata

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;
}
Also used : Metadata(com.yahoo.bullet.pubsub.Metadata)

Example 3 with 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);
}
Also used : PubSubMessage(com.yahoo.bullet.pubsub.PubSubMessage) Metadata(com.yahoo.bullet.pubsub.Metadata) Test(org.testng.annotations.Test)

Example 4 with Metadata

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());
}
Also used : PubSubMessage(com.yahoo.bullet.pubsub.PubSubMessage) Metadata(com.yahoo.bullet.pubsub.Metadata) Test(org.testng.annotations.Test)

Example 5 with Metadata

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);
}
Also used : BulletRecord(com.yahoo.bullet.record.BulletRecord) Metadata(com.yahoo.bullet.pubsub.Metadata) TupleUtils.makeTuple(com.yahoo.bullet.storm.testing.TupleUtils.makeTuple) TupleUtils.makeRawTuple(com.yahoo.bullet.storm.testing.TupleUtils.makeRawTuple) Tuple(org.apache.storm.tuple.Tuple) TupleUtils.makeIDTuple(com.yahoo.bullet.storm.testing.TupleUtils.makeIDTuple) Test(org.testng.annotations.Test) DistributionTest(com.yahoo.bullet.aggregations.DistributionTest) TopKTest(com.yahoo.bullet.aggregations.TopKTest) CountDistinctTest(com.yahoo.bullet.aggregations.CountDistinctTest)

Aggregations

Metadata (com.yahoo.bullet.pubsub.Metadata)45 Test (org.testng.annotations.Test)35 Tuple (org.apache.storm.tuple.Tuple)31 CountDistinctTest (com.yahoo.bullet.aggregations.CountDistinctTest)25 DistributionTest (com.yahoo.bullet.aggregations.DistributionTest)25 TopKTest (com.yahoo.bullet.aggregations.TopKTest)25 BulletRecord (com.yahoo.bullet.record.BulletRecord)25 GroupByTest (com.yahoo.bullet.aggregations.GroupByTest)22 PubSubMessage (com.yahoo.bullet.pubsub.PubSubMessage)11 GroupOperation (com.yahoo.bullet.aggregations.grouping.GroupOperation)7 RateLimitError (com.yahoo.bullet.querying.RateLimitError)7 ArrayList (java.util.ArrayList)6 BulletConfig (com.yahoo.bullet.common.BulletConfig)5 Meta (com.yahoo.bullet.result.Meta)5 CountDistinct (com.yahoo.bullet.aggregations.CountDistinct)4 Distribution (com.yahoo.bullet.aggregations.Distribution)4 TopK (com.yahoo.bullet.aggregations.TopK)4 GroupData (com.yahoo.bullet.aggregations.grouping.GroupData)4 COUNT (com.yahoo.bullet.aggregations.grouping.GroupOperation.GroupOperationType.COUNT)4 COUNT_FIELD (com.yahoo.bullet.aggregations.sketches.QuantileSketch.COUNT_FIELD)4