if (logTimer.expired()) { long stop = clock.currentTimeInMillis(); LOGGER.info("\t Exported {} records for table '{}' after {}", rows, table.id(),
private void delaySnapshotIfNeeded() { Duration delay = taskContext.getConfig().getSnapshotDelay(); if (delay.isZero() || delay.isNegative()) { return; } Threads.Timer timer = Threads.timer(Clock.SYSTEM, delay); Metronome metronome = Metronome.parker(ConfigurationDefaults.RETURN_CONTROL_INTERVAL, Clock.SYSTEM); while (!timer.expired()) { try { logger.info("The connector will wait for {}s before proceeding", timer.remaining().getSeconds()); metronome.pause(); } catch (InterruptedException e) { Thread.currentThread().interrupt(); logger.debug("Interrupted while awaiting initial snapshot delay"); return; } } }
if (logTimer.expired()) { long stop = clock.currentTimeInMillis(); LOGGER.info("\t Exported {} records for table '{}' after {}", rows, table.id(),
final Timer timeout = Threads.timer(Clock.SYSTEM, ConfigurationDefaults.RETURN_CONTROL_INTERVAL); while (records == null) { if (timeout.expired()) { Assert.fail("Subsequent reader has not started");
/** * Returns the next batch of elements from this queue. May be empty in case no * elements have arrived in the maximum waiting time. * * @throws InterruptedException * if this thread has been interrupted while waiting for more * elements to arrive */ public List<T> poll() throws InterruptedException { LoggingContext.PreviousContext previousContext = loggingContextSupplier.get(); try { LOGGER.debug("polling records..."); List<T> records = new ArrayList<>(); final Timer timeout = Threads.timer(Clock.SYSTEM, Temporals.max(pollInterval, ConfigurationDefaults.RETURN_CONTROL_INTERVAL)); while (!timeout.expired() && queue.drainTo(records, maxBatchSize) == 0) { throwProducerFailureIfPresent(); LOGGER.debug("no records available yet, sleeping a bit..."); // no records yet, so wait a bit metronome.pause(); LOGGER.debug("checking for more records..."); } return records; } finally { previousContext.restore(); } }
private void delaySnapshotIfNeeded() { Duration delay = taskContext.getConfig().getSnapshotDelay(); if (delay.isZero() || delay.isNegative()) { return; } Threads.Timer timer = Threads.timer(Clock.SYSTEM, delay); Metronome metronome = Metronome.parker(ConfigurationDefaults.RETURN_CONTROL_INTERVAL, Clock.SYSTEM); while (!timer.expired()) { try { logger.info("The connector will wait for {}s before proceeding", timer.remaining().getSeconds()); metronome.pause(); } catch (InterruptedException e) { Thread.currentThread().interrupt(); logger.debug("Interrupted while awaiting initial snapshot delay"); return; } } }
/** * Delays snapshot execution as per the {@link CommonConnectorConfig#SNAPSHOT_DELAY_MS} parameter. */ private void delaySnapshotIfNeeded(ChangeEventSourceContext context) throws InterruptedException { Duration snapshotDelay = connectorConfig.getSnapshotDelay(); if (snapshotDelay.isZero() || snapshotDelay.isNegative()) { return; } Timer timer = Threads.timer(Clock.SYSTEM, snapshotDelay); Metronome metronome = Metronome.parker(ConfigurationDefaults.RETURN_CONTROL_INTERVAL, Clock.SYSTEM); while(!timer.expired()) { if (!context.isRunning()) { throw new InterruptedException("Interrupted while awaiting initial snapshot delay"); } LOGGER.info("The connector will wait for {}s before proceeding", timer.remaining().getSeconds()); metronome.pause(); } }
@Override public void heartbeat(Map<String, ?> partition, Map<String, ?> offset, BlockingConsumer<SourceRecord> consumer) throws InterruptedException { if (heartbeatTimeout.expired()) { forcedBeat(partition, offset, consumer); heartbeatTimeout = resetHeartbeat(); } }
if (timeout.expired()) { break;
final Timer timeout = Threads.timer(Clock.SYSTEM, ConfigurationDefaults.RETURN_CONTROL_INTERVAL); while (records == null) { if (timeout.expired()) { Assert.fail("Subsequent reader has not started");
/** * Returns the next batch of elements from this queue. May be empty in case no * elements have arrived in the maximum waiting time. * * @throws InterruptedException * if this thread has been interrupted while waiting for more * elements to arrive */ public List<T> poll() throws InterruptedException { LoggingContext.PreviousContext previousContext = loggingContextSupplier.get(); try { LOGGER.debug("polling records..."); List<T> records = new ArrayList<>(); final Timer timeout = Threads.timer(Clock.SYSTEM, Temporals.max(pollInterval, ConfigurationDefaults.RETURN_CONTROL_INTERVAL)); while (!timeout.expired() && queue.drainTo(records, maxBatchSize) == 0) { throwProducerFailureIfPresent(); LOGGER.debug("no records available yet, sleeping a bit..."); // no records yet, so wait a bit metronome.pause(); LOGGER.debug("checking for more records..."); } return records; } finally { previousContext.restore(); } }
/** * Delays snapshot execution as per the {@link CommonConnectorConfig#SNAPSHOT_DELAY_MS} parameter. */ private void delaySnapshotIfNeeded(ChangeEventSourceContext context) throws InterruptedException { Duration snapshotDelay = connectorConfig.getSnapshotDelay(); if (snapshotDelay.isZero() || snapshotDelay.isNegative()) { return; } Timer timer = Threads.timer(Clock.SYSTEM, snapshotDelay); Metronome metronome = Metronome.parker(ConfigurationDefaults.RETURN_CONTROL_INTERVAL, Clock.SYSTEM); while(!timer.expired()) { if (!context.isRunning()) { throw new InterruptedException("Interrupted while awaiting initial snapshot delay"); } LOGGER.info("The connector will wait for {}s before proceeding", timer.remaining().getSeconds()); metronome.pause(); } }
private void delaySnapshotIfNeeded() throws InterruptedException { Duration delay = Duration.ofMillis(context.getConnectionContext().config.getLong(CommonConnectorConfig.SNAPSHOT_DELAY_MS)); if (delay.isZero() || delay.isNegative()) { return; } Threads.Timer timer = Threads.timer(Clock.SYSTEM, delay); Metronome metronome = Metronome.parker(ConfigurationDefaults.RETURN_CONTROL_INTERVAL, Clock.SYSTEM); while(!timer.expired()) { if (!running.get()) { throw new InterruptedException("Interrupted while awaiting initial snapshot delay"); } logger.info("The connector will wait for {}s before proceeding", timer.remaining().getSeconds()); metronome.pause(); } }
@Override public void heartbeat(Map<String, ?> partition, Map<String, ?> offset, BlockingConsumer<SourceRecord> consumer) throws InterruptedException { if (heartbeatTimeout.expired()) { forcedBeat(partition, offset, consumer); heartbeatTimeout = resetHeartbeat(); } }
@Override public List<SourceRecord> poll() throws InterruptedException { super.poll(); // Stop when we've reached the timeout threshold if (timer != null && timer.expired()) { stop(); } return null; } }