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(); } }
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(); } }
/** * 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() { 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; } } }