use of com.linkedin.databus.client.pub.ConsumerCallbackResult in project databus by linkedin.
the class LoggingConsumer method onStartBootstrapSource.
@Override
public ConsumerCallbackResult onStartBootstrapSource(String source, Schema sourceSchema) {
startSourceStats(sourceSchema);
ConsumerCallbackResult result = super.onStartBootstrapSource(source, sourceSchema);
return doStartSource(source, sourceSchema, result, true);
}
use of com.linkedin.databus.client.pub.ConsumerCallbackResult in project databus by linkedin.
the class LoggingConsumer method onStartSource.
@Override
public ConsumerCallbackResult onStartSource(String source, Schema sourceSchema) {
startSourceStats(sourceSchema);
ConsumerCallbackResult result = super.onStartSource(source, sourceSchema);
return doStartSource(source, sourceSchema, result, false);
}
use of com.linkedin.databus.client.pub.ConsumerCallbackResult in project databus by linkedin.
the class GenericDispatcher method storeCheckpoint.
protected boolean storeCheckpoint(DispatcherState curState, Checkpoint cp, SCN winScn) throws IOException {
boolean debugEnabled = _log.isDebugEnabled();
if (debugEnabled)
_log.debug("About to store checkpoint");
boolean success = true;
//processBatch - returns false ; then
ConsumerCallbackResult callbackResult = getAsyncCallback().onCheckpoint(winScn);
boolean persistCheckpoint = !ConsumerCallbackResult.isSkipCheckpoint(callbackResult) && ConsumerCallbackResult.isSuccess(callbackResult);
if (persistCheckpoint) {
if (null != getCheckpointPersistor()) {
getCheckpointPersistor().storeCheckpointV3(getSubsciptionsList(), cp, _registrationId);
++_numCheckPoints;
}
curState.storeCheckpoint(cp, winScn);
removeEvents(curState);
if (debugEnabled)
_log.debug("Checkpoint saved: " + cp.toString());
} else {
if (debugEnabled)
_log.debug("Checkpoint " + cp + " not saved as callback returned " + callbackResult);
}
return success;
}
use of com.linkedin.databus.client.pub.ConsumerCallbackResult in project databus by linkedin.
the class GenericDispatcher method doStopDispatch.
protected void doStopDispatch(DispatcherState curState) {
boolean debugEnabled = _log.isDebugEnabled();
if (debugEnabled)
_log.debug("Entered stopConsumption");
if (null != curState.getEventsIterator()) {
curState.getEventsIterator().close();
}
if (null != curState.getLastSuccessfulIterator()) {
curState.getLastSuccessfulIterator().close();
}
ConsumerCallbackResult stopSuccess = ConsumerCallbackResult.ERROR;
try {
stopSuccess = _asyncCallback.onStopConsumption();
} catch (RuntimeException e) {
DbusPrettyLogUtils.logExceptionAtError("Internal stopConsumption error", e, _log);
}
if (ConsumerCallbackResult.SUCCESS == stopSuccess || ConsumerCallbackResult.CHECKPOINT == stopSuccess) {
if (debugEnabled)
_log.debug("stopConsumption succeeded.");
} else {
getStatus().suspendOnError(new RuntimeException("Stop dispatcher failed"));
_log.error("stopConsumption failed.");
}
getStatus().suspendOnError(new RuntimeException("Processing of events stopped"));
_stopDispatch.set(true);
if ((_serverHandle != null) && _serverHandle.isClusterEnabled()) {
_log.error("Suspend while in clusterMode: shutting down");
_serverHandle.shutdownAsynchronously();
return;
}
}
use of com.linkedin.databus.client.pub.ConsumerCallbackResult in project databus by linkedin.
the class GenericDispatcher method doStartStreamEventWindow.
protected boolean doStartStreamEventWindow(DispatcherState curState) {
boolean success = true;
boolean debugEnabled = _log.isDebugEnabled();
if (debugEnabled)
_log.debug("Entered startDataEventSequence");
if (!curState.getStateId().equals(StateId.START_STREAM_EVENT_WINDOW)) {
success = false;
_log.error("START_STREAM_EVENT_WINDOW state expected but found : " + curState.getStateId());
} else {
ConsumerCallbackResult callbackResult = ConsumerCallbackResult.ERROR;
try {
callbackResult = getAsyncCallback().onStartDataEventSequence(curState.getStartWinScn());
} catch (RuntimeException e) {
_log.error("Internal onStartDataEventSequence error: " + e.getMessage(), e);
}
success = ConsumerCallbackResult.isSuccess(callbackResult);
if (success) {
if (debugEnabled)
_log.debug("startDataEventSequence succeeded:" + curState.getStartWinScn());
} else {
_log.error("startDataEventSequence failed:" + curState.getStartWinScn());
}
}
return success;
}
Aggregations