public void execute(Tuple input) { if (_exception != null) { throw new RuntimeException(_exception); } //just need an id String genId = Long.toString(_rand.nextLong()); _inputs.put(genId, input); try { BoltMsg boltMsg = createBoltMessage(input, genId); _pendingWrites.putBoltMsg(boltMsg); } catch (InterruptedException e) { // It's likely that Bolt is shutting down so no need to throw RuntimeException // just ignore } }
@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); }
public void execute(Tuple input) { if (_exception != null) { throw new RuntimeException(_exception); } //just need an id String genId = Long.toString(_rand.nextLong()); _inputs.put(genId, input); try { BoltMsg boltMsg = createBoltMessage(input, genId); _pendingWrites.putBoltMsg(boltMsg); } catch(InterruptedException e) { // It's likely that Bolt is shutting down so no need to throw RuntimeException // just ignore } }