Search in sources :

Example 26 with Metadata

use of com.yahoo.bullet.pubsub.Metadata in project bullet-core by yahoo.

the class RESTResultPublisherTest method testSend.

@Test
public void testSend() throws Exception {
    CompletableFuture<Response> response = getOkFuture(getOkResponse(null));
    BoundRequestBuilder mockBuilder = mockBuilderWith(response);
    AsyncHttpClient mockClient = mockClientWith(mockBuilder);
    RESTResultPublisher publisher = new RESTResultPublisher(mockClient);
    PubSubMessage message = new PubSubMessage("someId", "someContent", new Metadata(null, "custom/url"));
    publisher.send(message);
    verify(mockClient).preparePost("custom/url");
    verify(mockBuilder).setBody("{\"id\":\"someId\",\"sequence\":-1,\"content\":\"someContent\",\"metadata\":{\"signal\":null,\"content\":\"custom/url\"}}");
    verify(mockBuilder).setHeader(RESTPublisher.CONTENT_TYPE, RESTPublisher.APPLICATION_JSON);
}
Also used : Response(org.asynchttpclient.Response) RESTPubSubTest.getOkResponse(com.yahoo.bullet.pubsub.rest.RESTPubSubTest.getOkResponse) BoundRequestBuilder(org.asynchttpclient.BoundRequestBuilder) PubSubMessage(com.yahoo.bullet.pubsub.PubSubMessage) Metadata(com.yahoo.bullet.pubsub.Metadata) AsyncHttpClient(org.asynchttpclient.AsyncHttpClient) Test(org.testng.annotations.Test)

Example 27 with Metadata

use of com.yahoo.bullet.pubsub.Metadata in project bullet-core by yahoo.

the class RESTResultPublisherTest method testSendBadURL.

@Test(expectedExceptions = ClassCastException.class)
public void testSendBadURL() throws Exception {
    CompletableFuture<Response> response = getOkFuture(getOkResponse(null));
    BoundRequestBuilder mockBuilder = mockBuilderWith(response);
    AsyncHttpClient mockClient = mockClientWith(mockBuilder);
    RESTResultPublisher publisher = new RESTResultPublisher(mockClient);
    PubSubMessage message = new PubSubMessage("someId", "someContent", new Metadata(null, 88));
    publisher.send(message);
}
Also used : Response(org.asynchttpclient.Response) RESTPubSubTest.getOkResponse(com.yahoo.bullet.pubsub.rest.RESTPubSubTest.getOkResponse) BoundRequestBuilder(org.asynchttpclient.BoundRequestBuilder) PubSubMessage(com.yahoo.bullet.pubsub.PubSubMessage) Metadata(com.yahoo.bullet.pubsub.Metadata) AsyncHttpClient(org.asynchttpclient.AsyncHttpClient) Test(org.testng.annotations.Test)

Example 28 with Metadata

use of com.yahoo.bullet.pubsub.Metadata in project bullet-core by yahoo.

the class RESTQueryPublisher method send.

@Override
public void send(PubSubMessage message) throws PubSubException {
    // Put responseURL in the metadata so the ResponsePublisher knows to which host to send the response
    Metadata metadata = message.getMetadata();
    metadata = metadata == null ? new Metadata() : metadata;
    metadata.setContent(resultURL);
    message.setMetadata(metadata);
    sendToURL(queryURL, message);
}
Also used : Metadata(com.yahoo.bullet.pubsub.Metadata)

Example 29 with Metadata

use of com.yahoo.bullet.pubsub.Metadata in project bullet-storm by yahoo.

the class JoinBoltTest method testQueryIdentifierMetadata.

@Test
public void testQueryIdentifierMetadata() {
    config = configWithRawMaxAndEmptyMeta();
    enableMetadataInConfig(config, Concept.QUERY_METADATA.getName(), "meta");
    enableMetadataInConfig(config, Concept.QUERY_ID.getName(), "id");
    setup(new JoinBolt(config));
    Tuple query = TupleUtils.makeIDTuple(TupleClassifier.Type.QUERY_TUPLE, "42", "{}", EMPTY);
    bolt.execute(query);
    List<BulletRecord> sent = sendRawRecordTuplesTo(bolt, "42");
    Meta meta = new Meta();
    meta.add("meta", singletonMap("id", "42"));
    Tuple expected = TupleUtils.makeTuple(TupleClassifier.Type.RESULT_TUPLE, "42", Clip.of(sent).add(meta).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));
    Assert.assertEquals(collector.getAllEmittedTo(TopologyConstants.RESULT_STREAM).count(), 1);
    Assert.assertEquals(collector.getAllEmittedTo(TopologyConstants.FEEDBACK_STREAM).count(), 1);
}
Also used : Meta(com.yahoo.bullet.result.Meta) BulletRecord(com.yahoo.bullet.record.BulletRecord) 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)

Example 30 with Metadata

use of com.yahoo.bullet.pubsub.Metadata in project bullet-storm by yahoo.

the class JoinBoltTest method testKillSignal.

@Test
public void testKillSignal() {
    config.set(BulletStormConfig.TOPOLOGY_METRICS_BUILT_IN_ENABLE, true);
    config.validate();
    setup(bolt);
    Tuple query = TupleUtils.makeIDTuple(TupleClassifier.Type.QUERY_TUPLE, "42", "{}", EMPTY);
    bolt.execute(query);
    List<BulletRecord> sent = sendRawRecordTuplesTo(bolt, "42", RAW_MAX_SIZE - 1);
    Assert.assertEquals(collector.getEmittedCount(), 0);
    Assert.assertEquals(context.getLongMetric(TopologyConstants.ACTIVE_QUERIES_METRIC), Long.valueOf(1));
    Tuple kill = TupleUtils.makeIDTuple(TupleClassifier.Type.METADATA_TUPLE, "42", new Metadata(Metadata.Signal.KILL, null));
    bolt.execute(kill);
    Assert.assertEquals(collector.getEmittedCount(), 0);
    Assert.assertEquals(context.getLongMetric(TopologyConstants.ACTIVE_QUERIES_METRIC), Long.valueOf(0));
}
Also used : BulletRecord(com.yahoo.bullet.record.BulletRecord) 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

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