HDFS-11879. Fix JN sync interval in case of exception. Contributed by Hanisha Koneru.
This commit is contained in:
parent
29b7df960f
commit
1161563136
@ -172,7 +172,6 @@ private void startSyncJournalsDaemon() {
|
||||
} else {
|
||||
syncJournals();
|
||||
}
|
||||
Thread.sleep(journalSyncInterval);
|
||||
} catch (Throwable t) {
|
||||
if (!shouldSync) {
|
||||
if (t instanceof InterruptedException) {
|
||||
@ -194,6 +193,17 @@ private void startSyncJournalsDaemon() {
|
||||
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 @@ private List<RemoteEditLog> getMissingLogList(
|
||||
|
||||
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
Block a user