forked from debezium/debezium
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DBZ-7698 Add ordered transaction metadata
- Loading branch information
Showing
23 changed files
with
608 additions
and
183 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 0 additions & 59 deletions
59
...java/io/debezium/connector/postgresql/pipeline/txmetadata/PostgresTransactionMonitor.java
This file was deleted.
Oops, something went wrong.
49 changes: 49 additions & 0 deletions
49
.../io/debezium/connector/postgresql/pipeline/txmetadata/PostgresTransactionStructMaker.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* | ||
* Copyright Debezium Authors. | ||
* | ||
* Licensed under the Apache Software License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0 | ||
*/ | ||
package io.debezium.connector.postgresql.pipeline.txmetadata; | ||
|
||
import java.time.Instant; | ||
|
||
import org.apache.kafka.connect.data.Struct; | ||
|
||
import io.debezium.config.Configuration; | ||
import io.debezium.connector.postgresql.PostgresOffsetContext; | ||
import io.debezium.pipeline.spi.OffsetContext; | ||
import io.debezium.pipeline.txmetadata.BasicTransactionStructMaker; | ||
import io.debezium.spi.schema.DataCollectionId; | ||
|
||
public class PostgresTransactionStructMaker extends BasicTransactionStructMaker { | ||
public PostgresTransactionStructMaker(Configuration configuration) { | ||
super(configuration); | ||
} | ||
|
||
@Override | ||
public Struct prepareTxKey(OffsetContext offsetContext) { | ||
return adjustTxId(new Struct(transactionKeySchema), offsetContext); | ||
} | ||
|
||
@Override | ||
public Struct prepareTxBeginValue(OffsetContext offsetContext, Instant timestamp) { | ||
return adjustTxId(super.prepareTxBeginValue(offsetContext, timestamp), offsetContext); | ||
} | ||
|
||
@Override | ||
public Struct prepareTxEndValue(OffsetContext offsetContext, Instant timestamp) { | ||
return adjustTxId(super.prepareTxEndValue(offsetContext, timestamp), offsetContext); | ||
} | ||
|
||
@Override | ||
public Struct prepareTxStruct(OffsetContext offsetContext, DataCollectionId source) { | ||
return adjustTxId(super.prepareTxStruct(offsetContext, source), offsetContext); | ||
} | ||
|
||
private Struct adjustTxId(Struct txStruct, OffsetContext offsetContext) { | ||
final String lsn = Long.toString(((PostgresOffsetContext) offsetContext).asOffsetState().lastSeenLsn().asLong()); | ||
final String txId = offsetContext.getTransactionContext().getTransactionId(); | ||
txStruct.put(DEBEZIUM_TRANSACTION_ID_KEY, String.format("%s:%s", txId, lsn)); | ||
return txStruct; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.