Updated on 2024-05-07 GMT+08:00

PGReplicationStream

PGReplicationStream is an API class provided by the GaussDB JDBC driver. It is used to operate logical replication streams.

Inheritance Relationship of PGReplicationStream

PGReplicationStream is a logical replication API. Its implementation class is V3PGReplicationStream, which is in the org.postgresql.core.v3.replication package. The declaration of the class is as follows:

public class V3PGReplicationStream implements PGReplicationStream

Constructor Method

public V3PGReplicationStream(CopyDual copyDual, LogSequenceNumber startLSN, long updateIntervalMs, ReplicationType replicationType)

Common Methods

Table 1 Common methods of PGReplicationConnection

Return Value

Method

Description

throws

void

close()

Ends the logical replication and releases resources.

SQLException

void

forceUpdateStatus()

Forcibly sends the LSN status received, flushed, and applied last time to the backend.

SQLException

LogSequenceNumber

getLastAppliedLSN()

Obtains the LSN when the primary node replays logs last time.

-

LogSequenceNumber

getLastFlushedLSN()

Obtains the LSN flushed by the primary node last time, that is, the LSN pushed by the current logical decoding.

-

LogSequenceNumber

getLastReceiveLSN()

Obtains the last received LSN (for LSN-based replication slots) or CSN (for CSN-based replication slots).

-

boolean

isClosed()

Determines whether the replication stream is disabled.

-

ByteBuffer

read()

Reads the next WAL record from the backend. If the data cannot be read, this method blocks the I/O read.

SQLException

ByteBuffer

readPending()

Reads the next WAL record from the backend. If the data cannot be read, this method does not block the I/O read.

SQLException

void

setAppliedLSN(LogSequenceNumber applied)

Sets the applied LSN.

-

void

setFlushedLSN(LogSequenceNumber flushed)

Updates the LSN (for LSN-based replication slots) or CSN (for CSN-based replication slots), which is sent to the backend at the next update to update the LSN (for LSN-based replication slots) or CSN (for CSN-based replication slots) on the server.

-