public void run() { while (_running) { try { if (sendHeartbeatFlag.get()) { LOG.debug("BOLT - sending heartbeat request to subprocess"); String genId = Long.toString(_rand.nextLong()); _process.writeBoltMsg(createHeartbeatBoltMessage(genId)); sendHeartbeatFlag.compareAndSet(true, false); } Object write = _pendingWrites.poll(1, SECONDS); if (write instanceof BoltMsg) { _process.writeBoltMsg((BoltMsg) write); } else if (write instanceof List<?>) { _process.writeTaskIds((List<Integer>) write); } else if (write != null) { throw new RuntimeException( "Unknown class type to write: " + write.getClass().getName()); } } catch (InterruptedException e) { // It's likely that Bolt is shutting down so no need to die. // just ignore and loop will be terminated eventually } catch (Throwable t) { die(t); } } }
public void run() { while (_running) { try { if (sendHeartbeatFlag.get()) { LOG.debug("BOLT - sending heartbeat request to subprocess"); String genId = Long.toString(_rand.nextLong()); _process.writeBoltMsg(createHeartbeatBoltMessage(genId)); sendHeartbeatFlag.compareAndSet(true, false); } Object write = _pendingWrites.poll(1, SECONDS); if (write instanceof BoltMsg) { _process.writeBoltMsg((BoltMsg) write); } else if (write instanceof List<?>) { _process.writeTaskIds((List<Integer>) write); } else if (write != null) { throw new RuntimeException( "Unknown class type to write: " + write.getClass().getName()); } } catch (InterruptedException e) { // It's likely that Bolt is shutting down so no need to die. // just ignore and loop will be terminated eventually } catch (Throwable t) { die(t); } } }