public BlockingReader(String name, String runningLogMessage) { this.name = name; this.metronome = Metronome.parker(ConfigurationDefaults.RETURN_CONTROL_INTERVAL, Clock.SYSTEM); this.runningLogMessage = runningLogMessage; }
public static Metronome parker(Duration period, Clock timeSystem) { return parker(period.toNanos(), TimeUnit.NANOSECONDS, timeSystem); } }
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(); } }
protected ServerInfo.ReplicationSlot readReplicationSlotInfo(String slotName, String pluginName) throws SQLException, InterruptedException { final String database = database(); final Metronome metronome = Metronome.parker(PAUSE_BETWEEN_REPLICATION_SLOT_RETRIEVAL_ATTEMPTS, Clock.SYSTEM);
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(); } }
/** * Create a snapshot reader. * * @param name the name of the reader * @param context the task context in which this reader is running; may not be null * @param acceptAndContinue a predicate that returns true if the tested {@link SourceRecord} should be accepted and * false if the record and all subsequent records should be ignored. The reader will stop * accepting records once {@link #enqueueRecord(SourceRecord)} is called with a record * that tests as false. Can be null. If null, all records will be accepted. */ public AbstractReader(String name, MySqlTaskContext context, HaltingPredicate acceptAndContinue) { this.name = name; this.context = context; this.connectionContext = context.getConnectionContext(); this.records = new LinkedBlockingDeque<>(context.getConnectorConfig().getMaxQueueSize()); this.maxBatchSize = context.getConnectorConfig().getMaxBatchSize(); this.pollInterval = context.getConnectorConfig().getPollInterval(); this.metronome = Metronome.parker(pollInterval, Clock.SYSTEM); this.acceptAndContinue = acceptAndContinue == null? new AcceptAllPredicate() : acceptAndContinue; }
public static Metronome parker(Duration period, Clock timeSystem) { return parker(period.toNanos(), TimeUnit.NANOSECONDS, timeSystem); } }
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; } } }
protected ServerInfo.ReplicationSlot readReplicationSlotInfo(String slotName, String pluginName) throws SQLException, InterruptedException { final String database = database(); final Metronome metronome = Metronome.parker(PAUSE_BETWEEN_REPLICATION_SLOT_RETRIEVAL_ATTEMPTS, Clock.SYSTEM);
/** * 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(); } }