HDFS-14537. Journaled Edits Cache is not cleared when formatting the JN. Contributed by Ranith Sardar.
This commit is contained in:
parent
a1c3868c4f
commit
48e564f7e2
|
@ -138,12 +138,14 @@ public class Journal implements Closeable {
|
||||||
|
|
||||||
private final FileJournalManager fjm;
|
private final FileJournalManager fjm;
|
||||||
|
|
||||||
private final JournaledEditsCache cache;
|
private JournaledEditsCache cache;
|
||||||
|
|
||||||
private final JournalMetrics metrics;
|
private final JournalMetrics metrics;
|
||||||
|
|
||||||
private long lastJournalTimestamp = 0;
|
private long lastJournalTimestamp = 0;
|
||||||
|
|
||||||
|
private Configuration conf = null;
|
||||||
|
|
||||||
// This variable tracks, have we tried to start journalsyncer
|
// This variable tracks, have we tried to start journalsyncer
|
||||||
// with nameServiceId. This will help not to start the journalsyncer
|
// with nameServiceId. This will help not to start the journalsyncer
|
||||||
// on each rpc call, if it has failed to start
|
// on each rpc call, if it has failed to start
|
||||||
|
@ -157,6 +159,7 @@ public class Journal implements Closeable {
|
||||||
Journal(Configuration conf, File logDir, String journalId,
|
Journal(Configuration conf, File logDir, String journalId,
|
||||||
StartupOption startOpt, StorageErrorReporter errorReporter)
|
StartupOption startOpt, StorageErrorReporter errorReporter)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
|
this.conf = conf;
|
||||||
storage = new JNStorage(conf, logDir, startOpt, errorReporter);
|
storage = new JNStorage(conf, logDir, startOpt, errorReporter);
|
||||||
this.journalId = journalId;
|
this.journalId = journalId;
|
||||||
|
|
||||||
|
@ -164,12 +167,7 @@ public class Journal implements Closeable {
|
||||||
|
|
||||||
this.fjm = storage.getJournalManager();
|
this.fjm = storage.getJournalManager();
|
||||||
|
|
||||||
if (conf.getBoolean(DFSConfigKeys.DFS_HA_TAILEDITS_INPROGRESS_KEY,
|
this.cache = createCache();
|
||||||
DFSConfigKeys.DFS_HA_TAILEDITS_INPROGRESS_DEFAULT)) {
|
|
||||||
this.cache = new JournaledEditsCache(conf);
|
|
||||||
} else {
|
|
||||||
this.cache = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.metrics = JournalMetrics.create(this);
|
this.metrics = JournalMetrics.create(this);
|
||||||
|
|
||||||
|
@ -179,6 +177,15 @@ public class Journal implements Closeable {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private JournaledEditsCache createCache() {
|
||||||
|
if (conf.getBoolean(DFSConfigKeys.DFS_HA_TAILEDITS_INPROGRESS_KEY,
|
||||||
|
DFSConfigKeys.DFS_HA_TAILEDITS_INPROGRESS_DEFAULT)) {
|
||||||
|
return new JournaledEditsCache(conf);
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void setTriedJournalSyncerStartedwithnsId(boolean started) {
|
public void setTriedJournalSyncerStartedwithnsId(boolean started) {
|
||||||
this.triedJournalSyncerStartedwithnsId = started;
|
this.triedJournalSyncerStartedwithnsId = started;
|
||||||
}
|
}
|
||||||
|
@ -248,6 +255,7 @@ public class Journal implements Closeable {
|
||||||
LOG.info("Formatting journal id : " + journalId + " with namespace info: " +
|
LOG.info("Formatting journal id : " + journalId + " with namespace info: " +
|
||||||
nsInfo + " and force: " + force);
|
nsInfo + " and force: " + force);
|
||||||
storage.format(nsInfo, force);
|
storage.format(nsInfo, force);
|
||||||
|
this.cache = createCache();
|
||||||
refreshCachedData();
|
refreshCachedData();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue