@ThreadSafe public class RecordsSnapshotProducer extends RecordsProducer
source records from a database snapshot. Once completed,
this producer can optionally continue streaming records, using another RecordsStreamProducer instance.| Modifier and Type | Field and Description |
|---|---|
private static String |
CONTEXT_NAME |
private AtomicReference<org.apache.kafka.connect.source.SourceRecord> |
currentRecord |
private ExecutorService |
executorService |
private Optional<RecordsStreamProducer> |
streamProducer |
logger, sourceInfo, taskContext| Constructor and Description |
|---|
RecordsSnapshotProducer(PostgresTaskContext taskContext,
SourceInfo sourceInfo,
boolean continueStreamingAfterCompletion) |
| Modifier and Type | Method and Description |
|---|---|
private void |
cleanup() |
protected void |
commit()
Notification that offsets have been committed to Kafka.
|
protected void |
generateReadRecord(TableId tableId,
Object[] rowData) |
private Void |
handleException(Throwable t) |
private void |
readTable(TableId tableId,
ResultSet rs,
Consumer<org.apache.kafka.connect.source.SourceRecord> consumer,
AtomicInteger rowsCounter) |
private Statement |
readTableStatement(Connection conn) |
private void |
sendCurrentRecord(Consumer<org.apache.kafka.connect.source.SourceRecord> consumer) |
protected void |
start(Consumer<org.apache.kafka.connect.source.SourceRecord> recordConsumer)
Starts up this producer.
|
private void |
startStreaming(Consumer<org.apache.kafka.connect.source.SourceRecord> consumer) |
protected void |
stop()
Requests that this producer be stopped.
|
private void |
takeSnapshot(Consumer<org.apache.kafka.connect.source.SourceRecord> consumer) |
private Object |
valueForColumn(ResultSet rs,
int colIdx,
ResultSetMetaData metaData) |
clock, createEnvelope, schema, topicSelectorprivate static final String CONTEXT_NAME
private final ExecutorService executorService
private final Optional<RecordsStreamProducer> streamProducer
private AtomicReference<org.apache.kafka.connect.source.SourceRecord> currentRecord
public RecordsSnapshotProducer(PostgresTaskContext taskContext, SourceInfo sourceInfo, boolean continueStreamingAfterCompletion)
protected void start(Consumer<org.apache.kafka.connect.source.SourceRecord> recordConsumer)
RecordsProducerPostgresConnectorTask instance. Subclasses should start
enqueuing records via a separate thread at the end of this method.start in class RecordsProducerrecordConsumer - a consumer of SourceRecord instances, may not be nullprivate void startStreaming(Consumer<org.apache.kafka.connect.source.SourceRecord> consumer)
protected void commit()
RecordsProducercommit in class RecordsProducerprotected void stop()
RecordsProducerPostgresConnectorTask instancestop in class RecordsProducerprivate void cleanup()
private void takeSnapshot(Consumer<org.apache.kafka.connect.source.SourceRecord> consumer)
private Statement readTableStatement(Connection conn) throws SQLException
SQLExceptionprivate void readTable(TableId tableId, ResultSet rs, Consumer<org.apache.kafka.connect.source.SourceRecord> consumer, AtomicInteger rowsCounter) throws SQLException
SQLExceptionprivate Object valueForColumn(ResultSet rs, int colIdx, ResultSetMetaData metaData) throws SQLException
SQLExceptionprivate void sendCurrentRecord(Consumer<org.apache.kafka.connect.source.SourceRecord> consumer)
Copyright © 2017 JBoss by Red Hat. All rights reserved.