@Override public String name() { return delegate.name(); }
@Override public String name() { return delegate.name(); }
void onHeartbeatReceived() { logger.debug("Received heartbeat message from {}", delegate.name()); missingHeartbeatsCount.decrementAndGet(); }
@Override public void onError(Throwable e) { logger.error("Heartbeat receiver subscription got an error. This will close the connection " + delegate.name(), e); shutdown(e); }
@Override public void onError(Throwable e) { logger.warn("Failed to send heartbeat message; terminating the connection " + delegate.name(), e); shutdown(e); }
@Override public void onNext(Long aLong) { if (missingHeartbeatsCount.incrementAndGet() > tolerance) { logger.warn("More than {} heartbeat messages missed; closing the connection {}", tolerance, delegate.name()); shutdown(MISSING_HEARTBEAT_EXCEPTION); } else { logger.debug("Sending heartbeat message in the connection {}", delegate.name()); submit(Heartbeat.INSTANCE).subscribe(new Subscriber<Void>() { @Override public void onCompleted() { } @Override public void onError(Throwable e) { logger.warn("Failed to send heartbeat message; terminating the connection " + delegate.name(), e); shutdown(e); } @Override public void onNext(Void aVoid) { } }); } } }