@Override public void run() { try { Thread.sleep(1000); } catch (InterruptedException e) { // NOOP } queue.putTaskIds(taskIds); } });
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()); } }
@Test public void testPollTaskIdsFirst() throws InterruptedException { ShellBoltMessageQueue queue = new ShellBoltMessageQueue(); // put bolt message first, then put task ids queue.putBoltMsg(new BoltMsg()); ArrayList<Integer> taskIds = Lists.newArrayList(1, 2, 3); queue.putTaskIds(taskIds); Object msg = queue.poll(10, TimeUnit.SECONDS); // task ids should be pulled first assertTrue(msg instanceof List<?>); assertEquals(msg, taskIds); }
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()); } }