use of backtype.storm.tuple.Tuple in project heron by twitter.
the class OutputCollectorImpl method emit.
@Override
public List<Integer> emit(String streamId, Collection<Tuple> anchors, List<Object> tuple) {
if (anchors != null) {
ArrayList<com.twitter.heron.api.tuple.Tuple> l = new ArrayList<com.twitter.heron.api.tuple.Tuple>();
for (Tuple t : anchors) {
TupleImpl i = (TupleImpl) t;
l.add(i.getDelegate());
}
return delegate.emit(streamId, l, tuple);
} else {
return delegate.emit(streamId, (Collection<com.twitter.heron.api.tuple.Tuple>) null, tuple);
}
}
use of backtype.storm.tuple.Tuple in project pulsar by yahoo.
the class PulsarBoltTest method testBasic.
@Test
public void testBasic() throws Exception {
String msgContent = "hello world";
Tuple tuple = getMockTuple(msgContent);
bolt.execute(tuple);
for (int i = 0; i < NO_OF_RETRIES; i++) {
Thread.sleep(1000);
if (mockCollector.acked()) {
break;
}
}
Assert.assertTrue(mockCollector.acked());
Assert.assertFalse(mockCollector.failed());
Assert.assertNull(mockCollector.getLastError());
Assert.assertEquals(tuple, mockCollector.getAckedTuple());
Message msg = consumer.receive(5, TimeUnit.SECONDS);
consumer.acknowledge(msg);
Assert.assertEquals(msgContent, new String(msg.getData()));
}
use of backtype.storm.tuple.Tuple in project pulsar by yahoo.
the class PulsarBoltTest method testExecuteFailure.
@Test
public void testExecuteFailure() throws Exception {
String msgContent = "throw exception";
Tuple tuple = getMockTuple(msgContent);
bolt.execute(tuple);
Assert.assertFalse(mockCollector.acked());
Assert.assertTrue(mockCollector.failed());
Assert.assertNotNull(mockCollector.getLastError());
}
use of backtype.storm.tuple.Tuple in project pulsar by yahoo.
the class PulsarBoltTest method testMetrics.
@Test
public void testMetrics() throws Exception {
bolt.resetMetrics();
String msgContent = "hello world";
Tuple tuple = getMockTuple(msgContent);
for (int i = 0; i < 10; i++) {
bolt.execute(tuple);
}
for (int i = 0; i < NO_OF_RETRIES; i++) {
Thread.sleep(1000);
if (mockCollector.getNumTuplesAcked() == 10) {
break;
}
}
@SuppressWarnings("rawtypes") Map metrics = (Map) bolt.getValueAndReset();
Assert.assertEquals(((Long) metrics.get(PulsarBolt.NO_OF_MESSAGES_SENT)).longValue(), 10);
Assert.assertEquals(((Double) metrics.get(PulsarBolt.PRODUCER_RATE)).doubleValue(), 10.0 / pulsarBoltConf.getMetricsTimeIntervalInSecs());
Assert.assertEquals(((Double) metrics.get(PulsarBolt.PRODUCER_THROUGHPUT_BYTES)).doubleValue(), ((double) msgContent.getBytes().length * 10) / pulsarBoltConf.getMetricsTimeIntervalInSecs());
metrics = bolt.getMetrics();
Assert.assertEquals(((Long) metrics.get(PulsarBolt.NO_OF_MESSAGES_SENT)).longValue(), 0);
for (int i = 0; i < 10; i++) {
Message msg = consumer.receive(5, TimeUnit.SECONDS);
consumer.acknowledge(msg);
}
}
Aggregations