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);
}
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);
}
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);
}
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);
}
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));
}
Aggregations