use of com.linkedin.databus.core.DbusErrorEvent in project databus by linkedin.
the class RemoteExceptionHandler method suspendConnectionOnError.
private void suspendConnectionOnError(Throwable exception) throws InvalidEventException, InterruptedException {
// suspend pull threads
_sourcesConn.getConnectionStatus().suspendOnError(exception);
// send an error event to dispatcher through dbusEventBuffer
DbusEventInternalReadable errorEvent = null;
if (exception instanceof BootstrapDatabaseTooOldException) {
errorEvent = _eventFactory.createErrorEvent(new DbusErrorEvent(exception, DbusEventInternalWritable.BOOTSTRAPTOOOLD_ERROR_SRCID));
} else if (exception instanceof PullerRetriesExhaustedException) {
errorEvent = _eventFactory.createErrorEvent(new DbusErrorEvent(exception, DbusEventInternalWritable.PULLER_RETRIES_EXPIRED));
} else {
throw new InvalidEventException("Got an unrecognizable exception ");
}
byte[] errorEventBytes = new byte[errorEvent.getRawBytes().limit()];
if (LOG.isDebugEnabled()) {
LOG.debug("error event size: " + errorEventBytes.length);
LOG.debug("error event:" + errorEvent.toString());
}
errorEvent.getRawBytes().get(errorEventBytes);
ByteArrayInputStream errIs = new ByteArrayInputStream(errorEventBytes);
ReadableByteChannel errRbc = Channels.newChannel(errIs);
boolean success = false;
int retryCounter = 0;
while (!success && retryCounter < 10) {
String errMsg = "Sending an internal system event to dispatcher. Retry count = " + retryCounter;
DbusPrettyLogUtils.logExceptionAtInfo(errMsg, exception, LOG);
success = _dbusEventBuffer.readEvents(errRbc) > 0 ? true : false;
if (!success) {
LOG.warn("Unable to send an internal system event to dispatcher. Will retry later " + retryCounter);
retryCounter++;
Thread.sleep(1000);
}
}
}
use of com.linkedin.databus.core.DbusErrorEvent in project databus by linkedin.
the class GenericDispatcher method processErrorEvent.
private boolean processErrorEvent(DispatcherState curState, DbusEventInternalReadable nextEvent) {
boolean success = false;
DbusErrorEvent errorEvent = null;
if (nextEvent.isErrorEvent()) {
errorEvent = DbusEventSerializable.getErrorEventFromDbusEvent(nextEvent);
if (null == errorEvent) {
_log.error("Null error event received at dispatcher");
} else {
_log.info("Delivering error event to consumers: " + errorEvent);
ConsumerCallbackResult callbackResult = ConsumerCallbackResult.ERROR;
try {
callbackResult = _asyncCallback.onError(errorEvent.returnActualException());
} catch (RuntimeException e) {
_log.error("Internal onError error: " + e.getMessage(), e);
}
success = ConsumerCallbackResult.isSuccess(callbackResult);
}
} else {
_log.error("Unexcpected event received while DbusErrorEvent is expected! " + nextEvent);
}
return success;
}
Aggregations