| Modifier and Type | Field and Description |
|---|---|
| private boolean | |
| private final CopyDual | |
| private volatile LogSequenceNumber | |
| private volatile LogSequenceNumber | |
| private volatile LogSequenceNumber | |
| private volatile LogSequenceNumber | lastReceiveLSN
Last receive LSN + payload size. |
| private LogSequenceNumber | |
| private long | |
| private static final Logger | |
| private static final long | |
| public static final long | |
| private final ReplicationType | |
| private volatile LogSequenceNumber | |
| private final long |
| Access | Constructor and Description |
|---|---|
| public | V3PGReplicationStream(CopyDual
bidirectional copy protocol copyDual, LogSequenceNumber the position in the WAL that we want to initiate replication from
usually the currentLSN returned by calling pg_current_wal_lsn()for v10
above or pg_current_xlog_location() depending on the version of the
server startLSN, long the number of millisecond between status packets sent back to the
server. A value of zero disables the periodic status updates
completely, although an update will still be sent when requested by the
server, to avoid timeout disconnect. updateIntervalMs, ReplicationType LOGICAL or PHYSICAL replicationType)
|
| Modifier and Type | Method and Description |
|---|---|
| private void | |
| public void | close()
Implements org. Stop replication changes from server and free resources. |
| public void | forceUpdateStatus()
Implements org. Force send last received, flushed and applied LSN status to backend. |
| public LogSequenceNumber | getLastAppliedLSN()
Implements org. Last applied lsn sent in update message to backed. |
| public LogSequenceNumber | getLastFlushedLSN()
Implements org. Last flushed LSN sent in update message to backend. |
| public LogSequenceNumber | getLastReceiveLSN()
Implements org. Parameter updates by execute |
| public boolean | |
| private boolean | |
| private byte[] | prepareUpdateStatus(LogSequenceNumber received, LogSequenceNumber flushed, LogSequenceNumber applied, boolean replyRequired)
|
| private boolean | |
| private ByteBuffer | |
| public @Nullable ByteBuffer | read()
Implements org. Read next wal record from backend. |
| private @Nullable ByteBuffer | |
| public @Nullable ByteBuffer | readPending()
Implements org. Read next WAL record from backend. |
| private @Nullable ByteBuffer | |
| public void | setAppliedLSN(LogSequenceNumber
NOT NULL location of the last WAL applied in the standby. applied)Implements org. Inform backend which LSN has been applied on standby. |
| public void | setFlushedLSN(LogSequenceNumber
NOT NULL location of the last WAL flushed to disk in the standby. flushed)Implements org. Set flushed LSN. |
| private void | |
| private void | updateStatusInternal(LogSequenceNumber received, LogSequenceNumber flushed, LogSequenceNumber applied, boolean replyRequired)
|
| closeFlag | back to summary |
|---|---|
| private boolean closeFlag | |
| copyDual | back to summary |
|---|---|
| private final CopyDual copyDual | |
| explicitlyFlushedLSN | back to summary |
|---|---|
| private volatile LogSequenceNumber explicitlyFlushedLSN | |
| lastAppliedLSN | back to summary |
|---|---|
| private volatile LogSequenceNumber lastAppliedLSN | |
| lastFlushedLSN | back to summary |
|---|---|
| private volatile LogSequenceNumber lastFlushedLSN | |
| lastReceiveLSN | back to summary |
|---|---|
| private volatile LogSequenceNumber lastReceiveLSN Last receive LSN + payload size. | |
| lastServerLSN | back to summary |
|---|---|
| private LogSequenceNumber lastServerLSN | |
| lastStatusUpdate | back to summary |
|---|---|
| private long lastStatusUpdate | |
| LOGGER | back to summary |
|---|---|
| private static final Logger LOGGER | |
| NANOS_PER_MILLISECOND | back to summary |
|---|---|
| private static final long NANOS_PER_MILLISECOND | |
| POSTGRES_EPOCH_2000_01_01 | back to summary |
|---|---|
| public static final long POSTGRES_EPOCH_2000_01_01 | |
| replicationType | back to summary |
|---|---|
| private final ReplicationType replicationType | |
| startOfLastMessageLSN | back to summary |
|---|---|
| private volatile LogSequenceNumber startOfLastMessageLSN | |
| updateInterval | back to summary |
|---|---|
| private final long updateInterval | |
| V3PGReplicationStream | back to summary |
|---|---|
public V3PGReplicationStream(CopyDual copyDual, LogSequenceNumber startLSN, long updateIntervalMs, ReplicationType replicationType)
| |
| checkClose | back to summary |
|---|---|
| private void checkClose() throws PSQLException | |
| close | back to summary |
|---|---|
| public void close() throws SQLException Implements org. Doc from org. Stop replication changes from server and free resources. After that connection can be reuse to another queries. Also after close current stream they cannot be used anymore. Note This method can spend much time for logical replication stream on postgresql version 9.6 and lower, because postgresql have bug - during decode big transaction to logical form and during wait new changes postgresql ignore messages from client. As workaround you can close replication connection instead of close replication stream. For more information about it problem see mailing list thread Stopping logical replication protocol
| |
| forceUpdateStatus | back to summary |
|---|---|
| public void forceUpdateStatus() throws SQLException Implements org. Doc from org. Force send last received, flushed and applied LSN status to backend. You cannot send LSN status
explicitly because
| |
| getLastAppliedLSN | back to summary |
|---|---|
| public LogSequenceNumber getLastAppliedLSN() Implements org. Doc from org. Last applied lsn sent in update message to backed. Parameter updates only via It is safe to call this method in a thread different than the main thread.
| |
| getLastFlushedLSN | back to summary |
|---|---|
| public LogSequenceNumber getLastFlushedLSN() Implements org. Doc from org. Last flushed LSN sent in update message to backend. Parameter updates only via It is safe to call this method in a thread different than the main thread.
| |
| getLastReceiveLSN | back to summary |
|---|---|
| public LogSequenceNumber getLastReceiveLSN() Implements org. Doc from org. Parameter updates by execute It is safe to call this method in a thread different than the main thread. However, usually this
method is called in the main thread after a successful
| |
| isClosed | back to summary |
|---|---|
| public boolean isClosed() Implements org.
| |
| isTimeUpdate | back to summary |
|---|---|
| private boolean isTimeUpdate() | |
| prepareUpdateStatus | back to summary |
|---|---|
| private byte[] prepareUpdateStatus(LogSequenceNumber received, LogSequenceNumber flushed, LogSequenceNumber applied, boolean replyRequired) | |
| processKeepAliveMessage | back to summary |
|---|---|
| private boolean processKeepAliveMessage(ByteBuffer buffer) | |
| processXLogData | back to summary |
|---|---|
| private ByteBuffer processXLogData(ByteBuffer buffer) | |
| read | back to summary |
|---|---|
| public @Nullable ByteBuffer read() throws SQLException Implements org. Doc from org. Read next wal record from backend. It method can be block until new message will not get from server. A single WAL record is never split across two XLogData messages. When a WAL record crosses a WAL page boundary, and is therefore already split using continuation records, it can be split at the page boundary. In other words, the first main WAL record and its continuation records can be sent in different XLogData messages.
| |
| readInternal | back to summary |
|---|---|
| private @Nullable ByteBuffer readInternal(boolean block) throws SQLException | |
| readPending | back to summary |
|---|---|
| public @Nullable ByteBuffer readPending() throws SQLException Implements org. Doc from org. Read next WAL record from backend. This method does not block and in contrast to A single WAL record is never split across two XLogData messages. When a WAL record crosses a WAL page boundary, and is therefore already split using continuation records, it can be split at the page boundary. In other words, the first main WAL record and its continuation records can be sent in different XLogData messages.
| |
| receiveNextData | back to summary |
|---|---|
| private @Nullable ByteBuffer receiveNextData(boolean block) throws SQLException | |
| setAppliedLSN | back to summary |
|---|---|
| public void setAppliedLSN(LogSequenceNumber applied) Implements org. Doc from org. Inform backend which LSN has been applied on standby. Feedback will send to backend on next update status iteration. It is safe to call this method in a thread different than the main thread. The updated value will be sent to the backend in the next status update run.
| |
| setFlushedLSN | back to summary |
|---|---|
| public void setFlushedLSN(LogSequenceNumber flushed) Implements org. Doc from org. Set flushed LSN. This parameter will be sent to backend on next update status iteration. Flushed LSN position help backend define which WAL can be recycled. It is safe to call this method in a thread different than the main thread. The updated value will be sent to the backend in the next status update run.
| |
| timeUpdateStatus | back to summary |
|---|---|
| private void timeUpdateStatus() throws SQLException | |
| updateStatusInternal | back to summary |
|---|---|
| private void updateStatusInternal(LogSequenceNumber received, LogSequenceNumber flushed, LogSequenceNumber applied, boolean replyRequired) throws SQLException | |