use of com.linkedin.databus.client.pub.ConsumerCallbackResult in project databus by linkedin.
the class GenericDispatcher method doEndStreamSource.
protected boolean doEndStreamSource(DispatcherState curState) {
boolean success = true;
boolean debugEnabled = _log.isDebugEnabled();
if (debugEnabled)
_log.debug("Entered endSource");
if (!curState.getStateId().equals(StateId.END_STREAM_SOURCE)) {
success = false;
_log.error("END_STREAM_SOURCE state expected but found :" + curState.getStateId());
} else if (null == curState.getCurrentSource()) {
success = false;
_log.error("Missing source information in the current state");
} else if (curState.getCurrentSource().getId() >= 0) {
String sourceName = curState.getCurrentSource().getName();
ConsumerCallbackResult callbackResult = ConsumerCallbackResult.ERROR;
try {
callbackResult = getAsyncCallback().onEndSource(sourceName, curState.getCurrentSourceSchema());
} catch (RuntimeException e) {
_log.error("Internal onEndSource error:" + e.getMessage(), e);
}
success = ConsumerCallbackResult.isSuccess(callbackResult);
if (!success) {
_log.error("Method endSource() failed for the source : " + sourceName);
} else {
if (debugEnabled)
_log.debug("endSource succeeded:" + sourceName);
curState.resetSourceInfo();
curState.switchToExpectStreamDataEvents();
}
}
return success;
}
use of com.linkedin.databus.client.pub.ConsumerCallbackResult in project databus by linkedin.
the class GenericDispatcher method processDataEvent.
protected boolean processDataEvent(DispatcherState curState, DbusEvent event) {
ConsumerCallbackResult callbackResult = getAsyncCallback().onDataEvent(event, curState.getEventDecoder());
boolean success = ConsumerCallbackResult.isSuccess(callbackResult);
if (!success) {
_log.error("Method onDataEvent failed on consumer callback returned an error.");
} else {
_log.debug("Event queued: " + event.toString());
}
return success;
}
use of com.linkedin.databus.client.pub.ConsumerCallbackResult in project databus by linkedin.
the class GenericDispatcher method doRollback.
protected void doRollback(DispatcherState curState, SCN rollbackScn, boolean checkRetries, boolean regressItr) {
boolean success = true;
boolean debugEnabled = _log.isDebugEnabled();
if (!curState.getStateId().equals(StateId.ROLLBACK)) {
success = false;
_log.error("ROLLBACK state is expected by the dispatcher, but the current state is:" + curState.getStateId());
}
int retriesLeft = Integer.MAX_VALUE;
if (checkRetries) {
retriesLeft = getStatus().getRetriesLeft();
_log.info("Rolling back the dispatcher to last successful checkpoint. Number of remaining retries for dispatcher to replay events = " + retriesLeft);
success = success && (retriesLeft > 0);
if (success) {
if (0 == getStatus().getRetriesNum())
getStatus().retryOnError("rollback");
else
getStatus().retryOnLastError();
}
}
if (success) {
Checkpoint lastCp = curState.getLastSuccessfulCheckpoint();
if ((null != lastCp) || (!regressItr)) {
ConsumerCallbackResult callbackResult = ConsumerCallbackResult.ERROR;
try {
_log.info("Rolling back to SCN : " + rollbackScn);
callbackResult = getAsyncCallback().onRollback(rollbackScn);
} catch (RuntimeException e) {
_log.error("Internal onRollback error: " + e.getMessage(), e);
}
success = ConsumerCallbackResult.isSuccess(callbackResult);
if (success) {
if (debugEnabled)
_log.debug("Rollback consumer callback succeeded");
} else {
_log.error("Rollback consumer callback failed");
}
}
if (regressItr) {
if (null != curState.getLastSuccessfulIterator()) {
_log.info("Rolled back to last successful checkpoint position in the buffer: " + curState.getLastSuccessfulIterator());
_currentWindowSizeInBytes = 0;
curState.switchToReplayDataEvents();
} else {
_log.fatal("Unable to rollback, this usually means that the events belonging to the last checkpoint" + " are no longer to be found in the buffer. Please checkpoint more frequently to avoid this. Restarting the client " + "will fix this problem, last checkpoint found: \n" + lastCp);
curState.switchToClosed();
}
}
} else {
DispatcherRetriesExhaustedException exp = new DispatcherRetriesExhaustedException();
_log.info("Invoke onError callback as dispatcher retries have exhausted");
getAsyncCallback().onError(exp);
curState.switchToClosed();
}
}
use of com.linkedin.databus.client.pub.ConsumerCallbackResult in project databus by linkedin.
the class BootstrapProducerCallback method onStartDataEventSequence.
@Override
public ConsumerCallbackResult onStartDataEventSequence(SCN startScn) {
_srcRm.start();
_totalNumEvents = 0;
ConsumerCallbackResult success = ConsumerCallbackResult.SUCCESS;
try {
if (_oldWindowScn == -1) {
initWindowScn();
}
} catch (SQLException e) {
if (null != _statsCollector)
_statsCollector.registerSQLException();
LOG.error("Got SQLException in startDataEventSequence Hanlder!! Connections will be reset !!", e);
try {
reset();
} catch (DatabusException e2) {
DbusPrettyLogUtils.logExceptionAtError("Unable to reset connection", e2, LOG);
} catch (SQLException sqlEx) {
DbusPrettyLogUtils.logExceptionAtError("Got exception while resetting connections. Stopping Client !!", sqlEx, LOG);
return ConsumerCallbackResult.ERROR_FATAL;
}
success = ConsumerCallbackResult.ERROR;
}
return success;
}
use of com.linkedin.databus.client.pub.ConsumerCallbackResult in project databus by linkedin.
the class BatchingDatabusCombinedConsumer method onBootstrapEvent.
@Override
public ConsumerCallbackResult onBootstrapEvent(DbusEvent e, DbusEventDecoder eventDecoder) {
T eventObj = eventDecoder.getTypedValue(e, (T) null, _payloadClass);
ConsumerCallbackResult result = addBootstrapEvent(eventObj);
return result;
}
Aggregations