Class EmbeddedEngine
- All Implemented Interfaces:
EmbeddedEngineConfig,io.debezium.engine.DebeziumEngine<org.apache.kafka.connect.source.SourceRecord>,Closeable,AutoCloseable,Runnable
SourceConnector within an application's process. An embedded connector
is entirely standalone and only talks with the source system; no Kafka, Kafka Connect, or Zookeeper processes are needed.
Applications using an embedded connector simply set one up and supply a consumer function to which the
connector will pass all SourceRecords containing database change events.
With an embedded connector, the application that runs the connector assumes all responsibility for fault tolerance, scalability, and durability. Additionally, applications must specify how the connector can store its relational database schema history and offsets. By default, this information will be stored in memory and will thus be lost upon application restart.
Embedded connectors are designed to be submitted to an Executor or ExecutorService for execution by a single
thread, and a running connector can be stopped either by calling stop() from another thread or by interrupting
the running thread (e.g., as is the case with ExecutorService.shutdownNow()).
- Author:
- Randall Hauch
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classDeprecated.A callback function to be notified when the connector completes.private static classDeprecated.static final classDeprecated.private classDeprecated.protected classDeprecated.Implementation ofDebeziumEngine.Offsetswhich can be used to construct aSourceRecordwith its offsets.Nested classes/interfaces inherited from interface io.debezium.engine.DebeziumEngine
io.debezium.engine.DebeziumEngine.Builder<R>, io.debezium.engine.DebeziumEngine.BuilderFactory, io.debezium.engine.DebeziumEngine.ChangeConsumer<R>, io.debezium.engine.DebeziumEngine.CompletionCallback, io.debezium.engine.DebeziumEngine.ConnectorCallback, io.debezium.engine.DebeziumEngine.Offsets, io.debezium.engine.DebeziumEngine.RecordCommitter<R> -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final ClassLoaderDeprecated.private final ClockDeprecated.private final io.debezium.engine.DebeziumEngine.CompletionCallbackDeprecated.private final EmbeddedEngine.CompletionResultDeprecated.private final ConfigurationDeprecated.private final io.debezium.engine.DebeziumEngine.ConnectorCallbackDeprecated.private final io.debezium.engine.DebeziumEngine.ChangeConsumer<org.apache.kafka.connect.source.SourceRecord> Deprecated.private final org.apache.kafka.connect.storage.ConverterDeprecated.private final VariableLatchDeprecated.private static final org.slf4j.LoggerDeprecated.private io.debezium.engine.spi.OffsetCommitPolicyDeprecated.private longDeprecated.private final AtomicReference<Thread> Deprecated.private org.apache.kafka.connect.source.SourceTaskDeprecated.private longDeprecated.private final TransformationsDeprecated.private final org.apache.kafka.connect.storage.ConverterDeprecated.private final org.apache.kafka.connect.runtime.WorkerConfigDeprecated.Fields inherited from interface io.debezium.engine.DebeziumEngine
OFFSET_FLUSH_INTERVAL_MS_PROPFields inherited from interface io.debezium.embedded.EmbeddedEngineConfig
ALL_FIELDS, CONNECTOR_CLASS, CONNECTOR_FIELDS, DEFAULT_ERROR_MAX_RETRIES, ENGINE_NAME, ERRORS_MAX_RETRIES, ERRORS_RETRY_DELAY_INITIAL_MS, ERRORS_RETRY_DELAY_MAX_MS, OFFSET_COMMIT_POLICY, OFFSET_COMMIT_TIMEOUT_MS, OFFSET_FLUSH_INTERVAL_MS, OFFSET_STORAGE, OFFSET_STORAGE_FILE_FILENAME, OFFSET_STORAGE_KAFKA_PARTITIONS, OFFSET_STORAGE_KAFKA_REPLICATION_FACTOR, OFFSET_STORAGE_KAFKA_TOPIC, PREDICATES, TRANSFORMS, WAIT_FOR_COMPLETION_BEFORE_INTERRUPT_MS -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateEmbeddedEngine(Configuration config, ClassLoader classLoader, Clock clock, io.debezium.engine.DebeziumEngine.ChangeConsumer<org.apache.kafka.connect.source.SourceRecord> handler, io.debezium.engine.DebeziumEngine.CompletionCallback completionCallback, io.debezium.engine.DebeziumEngine.ConnectorCallback connectorCallback, io.debezium.engine.spi.OffsetCommitPolicy offsetCommitPolicy) Deprecated. -
Method Summary
Modifier and TypeMethodDescriptionbooleanDeprecated.Wait for the connector to complete processing.private static io.debezium.engine.DebeziumEngine.ChangeConsumer<org.apache.kafka.connect.source.SourceRecord> buildDefaultChangeConsumer(Consumer<org.apache.kafka.connect.source.SourceRecord> consumer) Deprecated.protected io.debezium.engine.DebeziumEngine.RecordCommitterbuildRecordCommitter(org.apache.kafka.connect.storage.OffsetStorageWriter offsetWriter, org.apache.kafka.connect.source.SourceTask task, Duration commitTimeout) Deprecated.Creates a new RecordCommitter that is responsible for informing the engine about the updates to the given batchvoidclose()Deprecated.protected voidcommitOffsets(org.apache.kafka.connect.storage.OffsetStorageWriter offsetWriter, Duration commitTimeout, org.apache.kafka.connect.source.SourceTask task) Deprecated.Flush offsets to storage.protected voidcompletedFlush(Throwable error, Void result) Deprecated.private org.apache.kafka.connect.source.SourceTaskcreateSourceTask(List<Map<String, String>> taskConfigs, Class<? extends org.apache.kafka.connect.connector.Task> taskClass) Deprecated.private DelayStrategydelayStrategy(Configuration config) Deprecated.private voidDeprecated.private voidDeprecated.private voidfailAndThrow(String msg, Throwable error) Deprecated.getConnectorConfig(org.apache.kafka.connect.source.SourceConnector connector, String connectorClassName) Deprecated.private intDeprecated.private ThrowablehandleRetries(org.apache.kafka.connect.errors.RetriableException e, List<Map<String, String>> taskConfigs) Deprecated.private voidinitializeConnector(org.apache.kafka.connect.source.SourceConnector connector, org.apache.kafka.connect.storage.OffsetStorageReader offsetReader) Deprecated.private org.apache.kafka.connect.storage.OffsetBackingStoreinitializeOffsetStore(Map<String, String> connectorConfig) Deprecated.Determines, which offset backing store should be used, instantiate it and start the offset store.private org.apache.kafka.connect.source.SourceConnectorinstantiateConnector(String connectorClassName) Deprecated.booleanDeprecated.Determine if this embedded connector is currently running.protected voidmaybeFlush(org.apache.kafka.connect.storage.OffsetStorageWriter offsetWriter, io.debezium.engine.spi.OffsetCommitPolicy policy, Duration commitTimeout, org.apache.kafka.connect.source.SourceTask task) Deprecated.Determine if we should flush offsets to storage, and if so then attempt to flush offsets.private voidpollRecords(List<Map<String, String>> taskConfigs, io.debezium.engine.DebeziumEngine.RecordCommitter committer, EmbeddedEngine.HandlerErrors errors) Deprecated.voidrun()Deprecated.Run this embedded connector and deliver database changes to the registeredConsumer.voidrunWithTask(Consumer<org.apache.kafka.connect.source.SourceTask> consumer) Deprecated.private voidsetCompletionResult(String connectorClassName, EmbeddedEngine.HandlerErrors errors) Deprecated.private voidDeprecated.private voidstartSourceTask(List<Map<String, String>> taskConfigs, org.apache.kafka.connect.storage.OffsetStorageReader offsetReader) Deprecated.booleanstop()Deprecated.Stop the execution of this embedded connector.private voidstopOffsetStoreAndConnector(org.apache.kafka.connect.source.SourceConnector connector, String connectorClassName, org.apache.kafka.connect.storage.OffsetBackingStore offsetStore, Optional<io.debezium.engine.DebeziumEngine.ConnectorCallback> connectorCallback) Deprecated.private voidDeprecated.private voidstopTaskAndCommitOffset(org.apache.kafka.connect.storage.OffsetStorageWriter offsetWriter, Duration commitTimeout, Optional<io.debezium.engine.DebeziumEngine.ConnectorCallback> connectorCallback) Deprecated.private voidDeprecated.toString()Deprecated.
-
Field Details
-
LOGGER
private static final org.slf4j.Logger LOGGERDeprecated. -
config
Deprecated. -
clock
Deprecated. -
classLoader
Deprecated. -
handler
private final io.debezium.engine.DebeziumEngine.ChangeConsumer<org.apache.kafka.connect.source.SourceRecord> handlerDeprecated. -
completionCallback
private final io.debezium.engine.DebeziumEngine.CompletionCallback completionCallbackDeprecated. -
connectorCallback
private final io.debezium.engine.DebeziumEngine.ConnectorCallback connectorCallbackDeprecated. -
runningThread
Deprecated. -
latch
Deprecated. -
keyConverter
private final org.apache.kafka.connect.storage.Converter keyConverterDeprecated. -
valueConverter
private final org.apache.kafka.connect.storage.Converter valueConverterDeprecated. -
workerConfig
private final org.apache.kafka.connect.runtime.WorkerConfig workerConfigDeprecated. -
completionResult
Deprecated. -
recordsSinceLastCommit
private long recordsSinceLastCommitDeprecated. -
timeOfLastCommitMillis
private long timeOfLastCommitMillisDeprecated. -
offsetCommitPolicy
private io.debezium.engine.spi.OffsetCommitPolicy offsetCommitPolicyDeprecated. -
task
private org.apache.kafka.connect.source.SourceTask taskDeprecated. -
transformations
Deprecated.
-
-
Constructor Details
-
EmbeddedEngine
private EmbeddedEngine(Configuration config, ClassLoader classLoader, Clock clock, io.debezium.engine.DebeziumEngine.ChangeConsumer<org.apache.kafka.connect.source.SourceRecord> handler, io.debezium.engine.DebeziumEngine.CompletionCallback completionCallback, io.debezium.engine.DebeziumEngine.ConnectorCallback connectorCallback, io.debezium.engine.spi.OffsetCommitPolicy offsetCommitPolicy) Deprecated.
-
-
Method Details
-
buildDefaultChangeConsumer
private static io.debezium.engine.DebeziumEngine.ChangeConsumer<org.apache.kafka.connect.source.SourceRecord> buildDefaultChangeConsumer(Consumer<org.apache.kafka.connect.source.SourceRecord> consumer) Deprecated. -
isRunning
public boolean isRunning()Deprecated.Determine if this embedded connector is currently running.- Returns:
trueif running, orfalseotherwise
-
fail
Deprecated. -
fail
Deprecated. -
failAndThrow
private void failAndThrow(String msg, Throwable error) throws EmbeddedEngine.EmbeddedEngineRuntimeException Deprecated. -
succeed
Deprecated. -
run
public void run()Deprecated.Run this embedded connector and deliver database changes to the registeredConsumer. This method blocks until the connector is stopped.First, the method checks to see if this instance is currently
running, and if so immediately returns.If the configuration is valid, this method starts the connector and starts polling the connector for change events. All messages are delivered in batches to the
Consumerregistered with this embedded connector. The batch size, polling frequency, and other parameters are controlled via configuration settings. This continues until this connector isstopped.Note that there are two ways to stop a connector running on a thread: calling
stop()from another thread, or interrupting the thread (e.g., viaExecutorService.shutdownNow()).This method can be called repeatedly as needed.
-
instantiateConnector
private org.apache.kafka.connect.source.SourceConnector instantiateConnector(String connectorClassName) throws EmbeddedEngine.EmbeddedEngineRuntimeException Deprecated. -
getConnectorConfig
private Map<String,String> getConnectorConfig(org.apache.kafka.connect.source.SourceConnector connector, String connectorClassName) throws EmbeddedEngine.EmbeddedEngineRuntimeException Deprecated. -
initializeOffsetStore
private org.apache.kafka.connect.storage.OffsetBackingStore initializeOffsetStore(Map<String, String> connectorConfig) throws EmbeddedEngine.EmbeddedEngineRuntimeExceptionDeprecated.Determines, which offset backing store should be used, instantiate it and start the offset store. -
setOffsetCommitPolicy
Deprecated. -
initializeConnector
private void initializeConnector(org.apache.kafka.connect.source.SourceConnector connector, org.apache.kafka.connect.storage.OffsetStorageReader offsetReader) Deprecated. -
createSourceTask
private org.apache.kafka.connect.source.SourceTask createSourceTask(List<Map<String, String>> taskConfigs, Class<? extends org.apache.kafka.connect.connector.Task> taskClass) throws EmbeddedEngine.EmbeddedEngineRuntimeException, NoSuchMethodException, InvocationTargetExceptionDeprecated. -
startSourceTask
private void startSourceTask(List<Map<String, String>> taskConfigs, org.apache.kafka.connect.storage.OffsetStorageReader offsetReader) Deprecated. -
stopSourceTask
private void stopSourceTask()Deprecated. -
handleRetries
private Throwable handleRetries(org.apache.kafka.connect.errors.RetriableException e, List<Map<String, String>> taskConfigs) Deprecated. -
pollRecords
private void pollRecords(List<Map<String, String>> taskConfigs, io.debezium.engine.DebeziumEngine.RecordCommitter committer, EmbeddedEngine.HandlerErrors errors) throws ThrowableDeprecated.- Throws:
Throwable
-
setCompletionResult
Deprecated. -
stopTaskAndCommitOffset
private void stopTaskAndCommitOffset(org.apache.kafka.connect.storage.OffsetStorageWriter offsetWriter, Duration commitTimeout, Optional<io.debezium.engine.DebeziumEngine.ConnectorCallback> connectorCallback) Deprecated. -
stopOffsetStoreAndConnector
private void stopOffsetStoreAndConnector(org.apache.kafka.connect.source.SourceConnector connector, String connectorClassName, org.apache.kafka.connect.storage.OffsetBackingStore offsetStore, Optional<io.debezium.engine.DebeziumEngine.ConnectorCallback> connectorCallback) Deprecated. -
getErrorsMaxRetries
private int getErrorsMaxRetries()Deprecated. -
buildRecordCommitter
protected io.debezium.engine.DebeziumEngine.RecordCommitter buildRecordCommitter(org.apache.kafka.connect.storage.OffsetStorageWriter offsetWriter, org.apache.kafka.connect.source.SourceTask task, Duration commitTimeout) Deprecated.Creates a new RecordCommitter that is responsible for informing the engine about the updates to the given batch- Parameters:
offsetWriter- the offsetWriter current in usetask- the sourcetaskcommitTimeout- the time in ms until a commit times out- Returns:
- the new recordCommitter to be used for a given batch
-
maybeFlush
protected void maybeFlush(org.apache.kafka.connect.storage.OffsetStorageWriter offsetWriter, io.debezium.engine.spi.OffsetCommitPolicy policy, Duration commitTimeout, org.apache.kafka.connect.source.SourceTask task) throws InterruptedException Deprecated.Determine if we should flush offsets to storage, and if so then attempt to flush offsets.- Parameters:
offsetWriter- the offset storage writer; may not be nullpolicy- the offset commit policy; may not be nullcommitTimeout- the timeout to wait for commit resultstask- the task which produced the records for which the offsets have been committed- Throws:
InterruptedException
-
commitOffsets
protected void commitOffsets(org.apache.kafka.connect.storage.OffsetStorageWriter offsetWriter, Duration commitTimeout, org.apache.kafka.connect.source.SourceTask task) throws InterruptedException Deprecated.Flush offsets to storage.- Parameters:
offsetWriter- the offset storage writer; may not be nullcommitTimeout- the timeout to wait for commit resultstask- the task which produced the records for which the offsets have been committed- Throws:
InterruptedException
-
completedFlush
Deprecated. -
stop
public boolean stop()Deprecated.Stop the execution of this embedded connector. This method does not block until the connector is stopped; useawait(long, TimeUnit)for this purpose.- Returns:
trueif the connector wasrunningand will eventually stop, orfalseif it was not running when this method is called- See Also:
-
close
Deprecated.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-
await
Deprecated.Wait for the connector to complete processing. If the processor is not running, this method returns immediately; however, if the processor isstoppedand restarted before this method is called, this method will return only when it completes the second time.- Parameters:
timeout- the maximum amount of time to wait before returningunit- the unit of time; may not be null- Returns:
trueif the connector completed within the timeout (or was not running), orfalseif it is still running when the timeout occurred- Throws:
InterruptedException- if this thread is interrupted while waiting for the completion of the connector
-
toString
Deprecated. -
runWithTask
Deprecated. -
delayStrategy
Deprecated.
-
AsyncEmbeddedEngineinstead.