protected void simplySendEvents(Collection<JetstreamEvent> events) { EventMetaInfo meta = new EventMetaInfo(); super.fireSendEvents(events, meta); incrementEventSentCounter(events.size()); }
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(); }
private EventMetaInfo genEventMeta(BatchSourceCommand action, PartitionReader p, Exception ex) { BatchSource source = new BatchSource(p.getTopic(), p.getPartition()); return new EventMetaInfo(action, source, ex); }
/** * 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 EventMetaInfo genEventMeta(BatchSourceCommand action, PartitionReader p) { BatchSource source = new BatchSource(p.getTopic(), p.getPartition()); return new EventMetaInfo(action, source); }
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 EventMetaInfo genEventMeta(BatchSourceCommand action, PartitionReader p, int batchSize) { BatchSource source = new BatchSource(p.getTopic(), p.getPartition(), p.getReadOffset() - batchSize); return new EventMetaInfo(action, source); }
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()); }