Search in sources :

Example 6 with RateLimitError

use of com.yahoo.bullet.querying.RateLimitError 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));
}
Also used : BulletRecord(com.yahoo.bullet.record.BulletRecord) RateLimitError(com.yahoo.bullet.querying.RateLimitError) Metadata(com.yahoo.bullet.pubsub.Metadata) Tuple(org.apache.storm.tuple.Tuple) Test(org.testng.annotations.Test) GroupByTest(com.yahoo.bullet.aggregations.GroupByTest) DistributionTest(com.yahoo.bullet.aggregations.DistributionTest) TopKTest(com.yahoo.bullet.aggregations.TopKTest) CountDistinctTest(com.yahoo.bullet.aggregations.CountDistinctTest)

Aggregations

RateLimitError (com.yahoo.bullet.querying.RateLimitError)6 CountDistinctTest (com.yahoo.bullet.aggregations.CountDistinctTest)5 DistributionTest (com.yahoo.bullet.aggregations.DistributionTest)5 TopKTest (com.yahoo.bullet.aggregations.TopKTest)5 Tuple (org.apache.storm.tuple.Tuple)5 Test (org.testng.annotations.Test)5 GroupByTest (com.yahoo.bullet.aggregations.GroupByTest)4 BulletRecord (com.yahoo.bullet.record.BulletRecord)4 Metadata (com.yahoo.bullet.pubsub.Metadata)3 BulletConfig (com.yahoo.bullet.common.BulletConfig)2 Querier (com.yahoo.bullet.querying.Querier)1 TupleUtils.makeIDTuple (com.yahoo.bullet.storm.testing.TupleUtils.makeIDTuple)1 TupleUtils.makeRawTuple (com.yahoo.bullet.storm.testing.TupleUtils.makeRawTuple)1 TupleUtils.makeTuple (com.yahoo.bullet.storm.testing.TupleUtils.makeTuple)1 HashMap (java.util.HashMap)1