public interface ReplicableLogEntry extends LogEntry
LogEntry that must be implemented by all log
entries that can be replicated. Replicable log entries are all those
entries for which the associated LogEntryType's LogEntryType.isReplicationPossible() method returns true. These are
the log entries that can be included in the replication stream distributed
from feeders to replicas during replication. See [#22336].
Starting with the release using log version 9, as specified by LogEntryType.LOG_VERSION_REPLICATE_OLDER, all replicable log entries
need to support writing themselves in earlier log formats, to support
replication during an upgrade when the master is replicated first. Any
loggable objects that they reference should also implement VersionedWriteLoggable for the same reason.
The getLastFormatChange() method identifies the log version for
which the entry's log format has most recently changed. This information is
used to determine if the current log format is compatible with a
non-upgraded replica.
The getSize(int, boolean) method overloading is used when
creating the buffer that will be used to transmit the log entry data in the
earlier format.
The writeEntry(ByteBuffer, int, boolean) method overloading is
used to convert the in-memory format of the log entry into the log data in
the earlier format.
To simplify the implementation of writing log entries in multiple log version formats, a log entry that needs to be written in a previous format will first be read into its in-memory format in the current version, and then written from there to the previous format.
| Modifier and Type | Method and Description |
|---|---|
Collection<VersionedWriteLoggable> |
getEmbeddedLoggables()
Returns all possible
VersionedWriteLoggable objects that may be
embedded in the binary data of this log entry. |
int |
getLastFormatChange()
Returns the log version of the most recent format change for this log
entry.
|
int |
getSize(int logVersion,
boolean forReplication)
Returns the number of bytes needed to store this entry in the format for
the specified log version.
|
boolean |
hasReplicationFormat()
Returns whether this format has a variant that is optimized for
replication.
|
boolean |
isReplicationFormatWorthwhile(ByteBuffer logBuffer,
int srcVersion,
int destVersion)
Returns whether it is worthwhile to materialize and then re-serialize a
log entry in a format optimized for replication.
|
void |
writeEntry(ByteBuffer logBuffer,
int logVersion,
boolean forReplication)
Serializes this object into the specified buffer in the format for the
the specified log version.
|
clone, dumpEntry, dumpRep, getDbId, getLogType, getMainItem, getResolvedItem, getSize, getTransactionId, isDeleted, isImmediatelyObsolete, logicalEquals, postLogWork, readEntry, setLogType, writeEntryint getLastFormatChange()
Collection<VersionedWriteLoggable> getEmbeddedLoggables()
VersionedWriteLoggable objects that may be
embedded in the binary data of this log entry.
This is used by tests to ensure that for each X:Y pair, where X is a ReplicableLogEntry and Y is a VersionedWriteLoggable, and X embeds Y either directly or indirectly, X.getLastFormatChange is greater than or equal to Y.getLastFormatChange.
Each ReplicableLogEntry and VersionedWriteLoggable class typically has a LAST_FORMAT_CHANGE constant that is returned by its getLastFormatChange method. When bumping this constant for an object X embedded by an log entry Y, Y.LAST_FORMAT_CHANGE should also be set to the minimum of its current value and X.LAST_FORMAT_CHANGE.
Enforcing this rule in a general way is made possible by the getEmbeddedLoggables method of each ReplicableLogEntry and VersionedWriteLoggable. Note that this method is not intended to be called outside of tests.
int getSize(int logVersion,
boolean forReplication)
LogEntryType.LOG_VERSION_REPLICATE_OLDER or greater.logVersion - the log versionforReplication - whether the entry will be sent over the wire,
and not written to the log.void writeEntry(ByteBuffer logBuffer, int logVersion, boolean forReplication)
LogEntryType.LOG_VERSION_REPLICATE_OLDER or greater.logBuffer - the destination bufferforReplication - whether the entry will be sent over the wire,
and not written to the log.logVersion - the log versionboolean hasReplicationFormat()
boolean isReplicationFormatWorthwhile(ByteBuffer logBuffer, int srcVersion, int destVersion)
WARNING: The logBuffer position must not be changed by this method.
WARNING: The shared LogEntry object is used for calling this method, and this method must not change any of the fields in the object.
logBuffer - contains the entry that would be re-serialized.srcVersion - the log version of entry in logBuffer.destVersion - the version that would be used for re-serialization.Copyright © 2024. All rights reserved.