use of com.mozilla.bagheera.sink.ReplaySink in project bagheera by mozilla-metrics.
the class SimpleProducer method testBasicMessage.
@Test
public void testBasicMessage() throws IOException, InterruptedException {
// Use a ReplaySink to send messages
String destPattern = String.format("http://localhost:%d/%s/%s/%s", BAGHEERA_PORT, SubmissionHandler.ENDPOINT_SUBMIT, TEST_NAMESPACE, ReplaySink.KEY_PLACEHOLDER);
ReplaySink sink = new ReplaySink(destPattern, "1", "true", "true");
sink.store(key, json.getBytes(), timestamp);
assertEquals(1, producer.queueSize());
BagheeraMessage message = producer.getQueue().poll();
String payload = message.getPayload().toStringUtf8();
assertEquals(json, payload);
// ReplaySink doesn't preserve timestamps.
assertNotSame(timestamp, message.getTimestamp());
assertEquals(key, message.getId());
assertEquals(BagheeraMessage.Operation.CREATE_UPDATE, message.getOperation());
assertEquals("", message.getApiVersion());
assertEquals(0, message.getPartitionCount());
}
use of com.mozilla.bagheera.sink.ReplaySink in project bagheera by mozilla-metrics.
the class SimpleProducer method testDeleteWithPartitions.
@Test
public void testDeleteWithPartitions() throws IOException, InterruptedException {
// Use a ReplaySink to send messages
String destPattern = String.format("http://localhost:%d/%s/%s/%s/partition1/partition2", BAGHEERA_PORT, SubmissionHandler.ENDPOINT_SUBMIT, TEST_NAMESPACE, ReplaySink.KEY_PLACEHOLDER);
ReplaySink sink = new ReplaySink(destPattern, "1", "true", "true");
sink.delete(key);
assertEquals(1, producer.queueSize());
BagheeraMessage message = producer.getQueue().poll();
String payload = message.getPayload().toStringUtf8();
assertEquals("", payload);
// ReplaySink doesn't preserve timestamps.
assertNotSame(timestamp, message.getTimestamp());
assertEquals(key, message.getId());
assertEquals(BagheeraMessage.Operation.DELETE, message.getOperation());
// Ensure that partition information comes through.
assertEquals(2, message.getPartitionCount());
assertEquals("partition1", message.getPartition(0));
assertEquals("partition2", message.getPartition(1));
}
use of com.mozilla.bagheera.sink.ReplaySink in project bagheera by mozilla-metrics.
the class SimpleProducer method testMessageWithApiVersion.
@Test
public void testMessageWithApiVersion() throws IOException, InterruptedException {
// Use a ReplaySink to send messages
String destPattern = String.format("http://localhost:%d/5.5/%s/%s/%s/partition1/partition2", BAGHEERA_PORT, SubmissionHandler.ENDPOINT_SUBMIT, TEST_NAMESPACE, ReplaySink.KEY_PLACEHOLDER);
ReplaySink sink = new ReplaySink(destPattern, "1", "true", "true");
sink.store(key, json.getBytes(), timestamp);
assertEquals(1, producer.queueSize());
BagheeraMessage message = producer.getQueue().poll();
String payload = message.getPayload().toStringUtf8();
assertEquals(json, payload);
// ReplaySink doesn't preserve timestamps.
assertNotSame(timestamp, message.getTimestamp());
assertEquals(key, message.getId());
// Ensure that partition information comes through.
assertEquals(2, message.getPartitionCount());
assertEquals("partition1", message.getPartition(0));
assertEquals("partition2", message.getPartition(1));
assertEquals("5.5", message.getApiVersion());
}
use of com.mozilla.bagheera.sink.ReplaySink in project bagheera by mozilla-metrics.
the class SimpleProducer method testMessageWithPartitions.
@Test
public void testMessageWithPartitions() throws IOException, InterruptedException {
// Use a ReplaySink to send messages
String destPattern = String.format("http://localhost:%d/%s/%s/%s/partition1/partition2", BAGHEERA_PORT, SubmissionHandler.ENDPOINT_SUBMIT, TEST_NAMESPACE, ReplaySink.KEY_PLACEHOLDER);
ReplaySink sink = new ReplaySink(destPattern, "1", "true", "true");
sink.store(key, json.getBytes(), timestamp);
assertEquals(1, producer.queueSize());
BagheeraMessage message = producer.getQueue().poll();
String payload = message.getPayload().toStringUtf8();
assertEquals(json, payload);
// ReplaySink doesn't preserve timestamps.
assertNotSame(timestamp, message.getTimestamp());
assertEquals(key, message.getId());
assertEquals(BagheeraMessage.Operation.CREATE_UPDATE, message.getOperation());
// Ensure that partition information comes through.
assertEquals(2, message.getPartitionCount());
assertEquals("partition1", message.getPartition(0));
assertEquals("partition2", message.getPartition(1));
}
Aggregations