Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@

public class EpochEntry extends RemotingSerializable {

public static final long LAST_EPOCH_END_OFFSET = Long.MAX_VALUE;
private int epoch;
private long startOffset;
private long endOffset = Long.MAX_VALUE;
private long endOffset = LAST_EPOCH_END_OFFSET;

public EpochEntry(EpochEntry entry) {
this.epoch = entry.getEpoch();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -593,6 +593,20 @@ private void transferToSlave() throws Exception {
return;
}

// Check and update currentTransferEpochEndOffset
if (AutoSwitchHAConnection.this.currentTransferEpochEndOffset == -1) {
EpochEntry currentEpochEntry = AutoSwitchHAConnection.this.epochCache.getEntry(AutoSwitchHAConnection.this.currentTransferEpoch);
if (currentEpochEntry != null) {
if (currentEpochEntry.getEndOffset() != EpochEntry.LAST_EPOCH_END_OFFSET) {
LOGGER.info("Update currentTransferEpochEndOffset from -1 to {}", currentEpochEntry.getEndOffset());
AutoSwitchHAConnection.this.currentTransferEpochEndOffset = currentEpochEntry.getEndOffset();
}
} else {
// we should never reach here
LOGGER.warn("[BUG]Can't find currentTransferEpoch [{}] from epoch cache", currentTransferEpoch);
}
}

// We must ensure that the transmitted logs are within the same epoch
// If currentEpochEndOffset == -1, means that currentTransferEpoch = last epoch, so the endOffset = Long.max
final long currentEpochEndOffset = AutoSwitchHAConnection.this.currentTransferEpochEndOffset;
Expand Down
Loading