use of org.apache.storm.tuple.Tuple in project storm by apache.
the class TestJoinBolt method testThreeStreamMixedJoin.
@Test
public void testThreeStreamMixedJoin() throws Exception {
ArrayList<Tuple> userStream = makeStream("users", userFields, users);
ArrayList<Tuple> storesStream = makeStream("stores", storeFields, stores);
ArrayList<Tuple> cityStream = makeStream("cities", cityFields, cities);
TupleWindow window = makeTupleWindow(userStream, cityStream, storesStream);
JoinBolt bolt = new JoinBolt(JoinBolt.Selector.STREAM, "users", userFields[2]).join("stores", "city", "users").leftJoin("cities", "cityName", "users").select("name,storeName,city,country");
MockCollector collector = new MockCollector();
bolt.prepare(null, null, collector);
bolt.execute(window);
printResults(collector);
// stores.length+1 as 2 users in Bengaluru
Assert.assertEquals(stores.length + 1, collector.actualResults.size());
}
use of org.apache.storm.tuple.Tuple in project storm by apache.
the class ShellBolt method handleEmit.
private void handleEmit(ShellMsg shellMsg) throws InterruptedException {
List<Tuple> anchors = new ArrayList<>();
List<String> recvAnchors = shellMsg.getAnchors();
if (recvAnchors != null) {
for (String anchor : recvAnchors) {
Tuple t = _inputs.get(anchor);
if (t == null) {
throw new RuntimeException("Anchored onto " + anchor + " after ack/fail");
}
anchors.add(t);
}
}
if (shellMsg.getTask() == 0) {
List<Integer> outtasks = _collector.emit(shellMsg.getStream(), anchors, shellMsg.getTuple());
if (shellMsg.areTaskIdsNeeded()) {
_pendingWrites.putTaskIds(outtasks);
}
} else {
_collector.emitDirect((int) shellMsg.getTask(), shellMsg.getStream(), anchors, shellMsg.getTuple());
}
}
use of org.apache.storm.tuple.Tuple in project storm by apache.
the class ShellBolt method handleFail.
private void handleFail(Object id) {
Tuple failed = _inputs.remove(id);
if (failed == null) {
throw new RuntimeException("Failed a non-existent or already acked/failed id: " + id);
}
_collector.fail(failed);
}
use of org.apache.storm.tuple.Tuple in project storm by apache.
the class ShellBolt method handleAck.
private void handleAck(Object id) {
Tuple acked = _inputs.remove(id);
if (acked == null) {
throw new RuntimeException("Acked a non-existent or already acked/failed id: " + id);
}
_collector.ack(acked);
}
use of org.apache.storm.tuple.Tuple in project storm by apache.
the class BatchHelper method fail.
public void fail(Exception e) {
collector.reportError(e);
for (Tuple t : tupleBatch) {
collector.fail(t);
}
tupleBatch.clear();
forceFlush = false;
}
Aggregations