Search in sources :

Example 6 with ConsumerCallbackResult

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);
}
Also used : ConsumerCallbackResult(com.linkedin.databus.client.pub.ConsumerCallbackResult)

Example 7 with ConsumerCallbackResult

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);
}
Also used : ConsumerCallbackResult(com.linkedin.databus.client.pub.ConsumerCallbackResult)

Example 8 with ConsumerCallbackResult

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;
}
Also used : ConsumerCallbackResult(com.linkedin.databus.client.pub.ConsumerCallbackResult)

Example 9 with ConsumerCallbackResult

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;
    }
}
Also used : ConsumerCallbackResult(com.linkedin.databus.client.pub.ConsumerCallbackResult)

Example 10 with ConsumerCallbackResult

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;
}
Also used : ConsumerCallbackResult(com.linkedin.databus.client.pub.ConsumerCallbackResult)

Aggregations

ConsumerCallbackResult (com.linkedin.databus.client.pub.ConsumerCallbackResult)42 DatabusCombinedConsumer (com.linkedin.databus.client.pub.DatabusCombinedConsumer)9 IdNamePair (com.linkedin.databus.core.util.IdNamePair)3 IOException (java.io.IOException)3 DatabusStreamConsumer (com.linkedin.databus.client.pub.DatabusStreamConsumer)2 ConsumerCallbackStats (com.linkedin.databus.client.pub.mbean.ConsumerCallbackStats)2 UnifiedClientStats (com.linkedin.databus.client.pub.mbean.UnifiedClientStats)2 DbusEvent (com.linkedin.databus.core.DbusEvent)2 DbusEventBuffer (com.linkedin.databus.core.DbusEventBuffer)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 Hashtable (java.util.Hashtable)2 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)2 GenericRecord (org.apache.avro.generic.GenericRecord)2 AfterTest (org.testng.annotations.AfterTest)2 BeforeTest (org.testng.annotations.BeforeTest)2 Test (org.testng.annotations.Test)2 Checkpoint (com.linkedin.databus.core.Checkpoint)1 DbusErrorEvent (com.linkedin.databus.core.DbusErrorEvent)1 DispatcherRetriesExhaustedException (com.linkedin.databus.core.DispatcherRetriesExhaustedException)1