try { logger.debug("Embedded engine is polling task for records on thread " + runningThread.get()); changeRecords = task.poll(); // blocks until there are values ... logger.debug("Embedded engine returned from polling task for records");
protected List<SourceRecord> poll() throws InterruptedException { try { return task.poll(); } catch (RetriableException e) { log.warn("{} failed to poll records from SourceTask. Will retry operation.", this, e); // Do nothing. Let the framework poll whenever it's ready. return null; } }
@Override public Record<byte[]> read() throws Exception { while (true) { if (currentBatch == null) { flushFuture = new CompletableFuture<>(); currentBatch = sourceTask.poll().iterator(); } if (currentBatch.hasNext()) { return processSourceRecord(currentBatch.next()); } else { boolean hasOutstandingRecords; synchronized (this) { hasOutstandingRecords = !outstandingRecords.isEmpty(); } if (hasOutstandingRecords) { // there is no records any more, then waiting for the batch to complete writing // to sink and the offsets are committed as well flushFuture.get(); flushFuture = null; } currentBatch = null; } } }
@Override public void run() { while (running.get()) { try { List<SourceRecord> records = task.poll(); if (records != null) { records.forEach(sourceRecord -> sharedSourceTaskContext.offer(sourceRecord, LongOffset.apply(sourceRecord.sourceOffset() == null || sourceRecord.sourceOffset().isEmpty() ? UUID.randomUUID().hashCode() :sourceRecord.sourceOffset().hashCode()), task)); } } catch (InterruptedException ie) { break; } catch (Exception e) { LOGGER.warn("Unexpected error occurred while polling task " + task.getClass().getCanonicalName(), e); } } }