HDFS-11879. Fix JN sync interval in case of exception. Contributed by Hanisha Koneru.
This commit is contained in:
parent
46bad64684
commit
ad32d5f4ef
|
@ -172,7 +172,6 @@ public class JournalNodeSyncer {
|
|||
} else {
|
||||
syncJournals();
|
||||
}
|
||||
Thread.sleep(journalSyncInterval);
|
||||
} catch (Throwable t) {
|
||||
if (!shouldSync) {
|
||||
if (t instanceof InterruptedException) {
|
||||
|
@ -194,6 +193,17 @@ public class JournalNodeSyncer {
|
|||
LOG.error(
|
||||
"JournalNodeSyncer daemon received Runtime exception. ", t);
|
||||
}
|
||||
try {
|
||||
Thread.sleep(journalSyncInterval);
|
||||
} catch (InterruptedException e) {
|
||||
if (!shouldSync) {
|
||||
LOG.info("Stopping JournalNode Sync.");
|
||||
} else {
|
||||
LOG.warn("JournalNodeSyncer interrupted", e);
|
||||
}
|
||||
Thread.currentThread().interrupt();
|
||||
return;
|
||||
}
|
||||
}
|
||||
});
|
||||
syncJournalDaemon.start();
|
||||
|
@ -320,30 +330,30 @@ public class JournalNodeSyncer {
|
|||
|
||||
List<RemoteEditLog> missingEditLogs = Lists.newArrayList();
|
||||
|
||||
int thisJnIndex = 0, otherJnIndex = 0;
|
||||
int thisJnNumLogs = thisJournalEditLogs.size();
|
||||
int otherJnNumLogs = otherJournalEditLogs.size();
|
||||
int localJnIndex = 0, remoteJnIndex = 0;
|
||||
int localJnNumLogs = thisJournalEditLogs.size();
|
||||
int remoteJnNumLogs = otherJournalEditLogs.size();
|
||||
|
||||
while (thisJnIndex < thisJnNumLogs && otherJnIndex < otherJnNumLogs) {
|
||||
long localJNstartTxId = thisJournalEditLogs.get(thisJnIndex)
|
||||
while (localJnIndex < localJnNumLogs && remoteJnIndex < remoteJnNumLogs) {
|
||||
long localJNstartTxId = thisJournalEditLogs.get(localJnIndex)
|
||||
.getStartTxId();
|
||||
long remoteJNstartTxId = otherJournalEditLogs.get(otherJnIndex)
|
||||
long remoteJNstartTxId = otherJournalEditLogs.get(remoteJnIndex)
|
||||
.getStartTxId();
|
||||
|
||||
if (localJNstartTxId == remoteJNstartTxId) {
|
||||
thisJnIndex++;
|
||||
otherJnIndex++;
|
||||
localJnIndex++;
|
||||
remoteJnIndex++;
|
||||
} else if (localJNstartTxId > remoteJNstartTxId) {
|
||||
missingEditLogs.add(otherJournalEditLogs.get(otherJnIndex));
|
||||
otherJnIndex++;
|
||||
missingEditLogs.add(otherJournalEditLogs.get(remoteJnIndex));
|
||||
remoteJnIndex++;
|
||||
} else {
|
||||
thisJnIndex++;
|
||||
localJnIndex++;
|
||||
}
|
||||
}
|
||||
|
||||
if (otherJnIndex < otherJnNumLogs) {
|
||||
for (; otherJnIndex < otherJnNumLogs; otherJnIndex++) {
|
||||
missingEditLogs.add(otherJournalEditLogs.get(otherJnIndex));
|
||||
if (remoteJnIndex < remoteJnNumLogs) {
|
||||
for (; remoteJnIndex < remoteJnNumLogs; remoteJnIndex++) {
|
||||
missingEditLogs.add(otherJournalEditLogs.get(remoteJnIndex));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue