private BatchResponse onStreamTermination(PartitionReader p) { EventMetaInfo meta = genEventMeta(OnStreamTermination, p); try { fireSendEvents(null, meta); if (LOGGER.isDebugEnabled()) LOGGER.debug( " Terminate stream of " + p.getId()); } catch (Exception e) { LOGGER.error( "Excpetion occurs during streamTermination.", e); registerError(e); onException(p, e); return null; } return meta.getBatchResponse(); }
/** * send drop stream signal */ private BatchResponse onException(PartitionReader p, Exception ex) { EventMetaInfo meta = genEventMeta(OnException, p, ex); try { fireSendEvents(null, meta); if (LOGGER.isInfoEnabled()) LOGGER.info( taskId + " on exception for " + p.getId(), ex); } catch (Throwable e) { LOGGER.error( taskId + " fail to on exception for " + p.getId(), e); registerError(e); } return meta.getBatchResponse(); }
private void onIdle(PartitionReader p) { EventMetaInfo meta = genEventMeta(OnIdle, p); try { fireSendEvents(null, meta); } catch (Throwable e) { LOGGER.error( "Error occurs when invoke onIdle() for " + p.getId(), e); registerError(e); } this.handleResponse(p, 0, meta.getBatchResponse()); }
private void onNextBatch(PartitionReader p) { int batchSize = cache.size(); // send events EventMetaInfo meta = genEventMeta(OnNextBatch, p, batchSize); try { fireSendEvents(cache, meta); incrementEventSentCounter(batchSize); long start = p.getReadOffset() - batchSize; long end = p.getReadOffset() - 1; if (LOGGER.isDebugEnabled()) LOGGER.debug( "Send events of " + p.getId() + " from " + start + " to " + end); } catch (Exception e) { LOGGER.error( "Excpetion in EventSink during flush.", e); registerError(e); incrementEventDroppedCounter(batchSize); BatchResponse res = onException(p, e); handleResponse(p, 0, res); return; } this.handleResponse(p, batchSize, meta.getBatchResponse()); }