private void handleException(Exception e) { if (INTERRUPTED_EXCEPTION_TYPES.contains(e.getClass())) { LOG.info("Changes feed was interrupted"); } else { LOG.error("Caught exception while listening to changes feed:", e); } }
public void run() { try { String line = reader.readLine(); while (shouldRun && line != null) { if (line.length() > 0) { handleChange(line); } else { handleHeartbeat(); } line = reader.readLine(); } String reason = !shouldRun ? "Cancelled" : "EOF"; LOG.info("Changes feed stopped. Reason: " + reason); } catch (Exception e) { handleException(e); } finally { sendInterruptMarker(); httpResponse.abort(); try { reader.close(); } catch (IOException e) { } } }
@edu.umd.cs.findbugs.annotations.SuppressWarnings(value = "RV_RETURN_VALUE_IGNORED_BAD_PRACTICE") private void sendInterruptMarker() { LOG.debug("Sending interrupt marker in order to interrupt feed consumer"); changes.offer(INTERRUPT_MARKER); }
public void cancel() { LOG.debug("Feed cancelled"); shouldRun = false; thread.interrupt(); }
private void handleHeartbeat() { LOG.debug("Got heartbeat from DB"); }