|
@@ -164,10 +164,13 @@ public class FileJournalManager implements JournalManager {
|
|
/**
|
|
/**
|
|
* Find all editlog segments starting at or above the given txid.
|
|
* Find all editlog segments starting at or above the given txid.
|
|
* @param fromTxId the txnid which to start looking
|
|
* @param fromTxId the txnid which to start looking
|
|
|
|
+ * @param forReading whether or not the caller intends to read from the edit
|
|
|
|
+ * logs
|
|
* @return a list of remote edit logs
|
|
* @return a list of remote edit logs
|
|
* @throws IOException if edit logs cannot be listed.
|
|
* @throws IOException if edit logs cannot be listed.
|
|
*/
|
|
*/
|
|
- public List<RemoteEditLog> getRemoteEditLogs(long firstTxId) throws IOException {
|
|
|
|
|
|
+ public List<RemoteEditLog> getRemoteEditLogs(long firstTxId,
|
|
|
|
+ boolean forReading) throws IOException {
|
|
File currentDir = sd.getCurrentDir();
|
|
File currentDir = sd.getCurrentDir();
|
|
List<EditLogFile> allLogFiles = matchEditLogs(currentDir);
|
|
List<EditLogFile> allLogFiles = matchEditLogs(currentDir);
|
|
List<RemoteEditLog> ret = Lists.newArrayListWithCapacity(
|
|
List<RemoteEditLog> ret = Lists.newArrayListWithCapacity(
|
|
@@ -177,11 +180,15 @@ public class FileJournalManager implements JournalManager {
|
|
if (elf.hasCorruptHeader() || elf.isInProgress()) continue;
|
|
if (elf.hasCorruptHeader() || elf.isInProgress()) continue;
|
|
if (elf.getFirstTxId() >= firstTxId) {
|
|
if (elf.getFirstTxId() >= firstTxId) {
|
|
ret.add(new RemoteEditLog(elf.firstTxId, elf.lastTxId));
|
|
ret.add(new RemoteEditLog(elf.firstTxId, elf.lastTxId));
|
|
- } else if ((firstTxId > elf.getFirstTxId()) &&
|
|
|
|
- (firstTxId <= elf.getLastTxId())) {
|
|
|
|
- // Note that this behavior is different from getLogFiles below.
|
|
|
|
- throw new IllegalStateException("Asked for firstTxId " + firstTxId
|
|
|
|
- + " which is in the middle of file " + elf.file);
|
|
|
|
|
|
+ } else if (elf.getFirstTxId() < firstTxId && firstTxId <= elf.getLastTxId()) {
|
|
|
|
+ // If the firstTxId is in the middle of an edit log segment
|
|
|
|
+ if (forReading) {
|
|
|
|
+ // Note that this behavior is different from getLogFiles below.
|
|
|
|
+ throw new IllegalStateException("Asked for firstTxId " + firstTxId
|
|
|
|
+ + " which is in the middle of file " + elf.file);
|
|
|
|
+ } else {
|
|
|
|
+ ret.add(new RemoteEditLog(elf.firstTxId, elf.lastTxId));
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -242,7 +249,7 @@ public class FileJournalManager implements JournalManager {
|
|
@Override
|
|
@Override
|
|
synchronized public void selectInputStreams(
|
|
synchronized public void selectInputStreams(
|
|
Collection<EditLogInputStream> streams, long fromTxId,
|
|
Collection<EditLogInputStream> streams, long fromTxId,
|
|
- boolean inProgressOk) throws IOException {
|
|
|
|
|
|
+ boolean inProgressOk, boolean forReading) throws IOException {
|
|
List<EditLogFile> elfs = matchEditLogs(sd.getCurrentDir());
|
|
List<EditLogFile> elfs = matchEditLogs(sd.getCurrentDir());
|
|
LOG.debug(this + ": selecting input streams starting at " + fromTxId +
|
|
LOG.debug(this + ": selecting input streams starting at " + fromTxId +
|
|
(inProgressOk ? " (inProgress ok) " : " (excluding inProgress) ") +
|
|
(inProgressOk ? " (inProgress ok) " : " (excluding inProgress) ") +
|