[hadoop] 50/50: HDFS-14537. Journaled Edits Cache is not cleared when formatting the JN. Contributed by Ranith Sardar.

2019-07-25 Thread cliang
This is an automated email from the ASF dual-hosted git repository.

cliang pushed a commit to branch branch-3.0
in repository https://gitbox.apache.org/repos/asf/hadoop.git

commit b5303012a0c0e839b4bdc1a9b5640425a44a831c
Author: Wei-Chiu Chuang 
AuthorDate: Tue Jun 18 22:28:21 2019 -0700

HDFS-14537. Journaled Edits Cache is not cleared when formatting the JN. 
Contributed by Ranith Sardar.
---
 .../hadoop/hdfs/qjournal/server/Journal.java   | 24 ++
 1 file changed, 16 insertions(+), 8 deletions(-)

diff --git 
a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/qjournal/server/Journal.java
 
b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/qjournal/server/Journal.java
index 5fb4fc3..02e2a7e 100644
--- 
a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/qjournal/server/Journal.java
+++ 
b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/qjournal/server/Journal.java
@@ -139,12 +139,14 @@ public class Journal implements Closeable {
   
   private final FileJournalManager fjm;
 
-  private final JournaledEditsCache cache;
+  private JournaledEditsCache cache;
 
   private final JournalMetrics metrics;
 
   private long lastJournalTimestamp = 0;
 
+  private Configuration conf = null;
+
   // This variable tracks, have we tried to start journalsyncer
   // with nameServiceId. This will help not to start the journalsyncer
   // on each rpc call, if it has failed to start
@@ -158,6 +160,7 @@ public class Journal implements Closeable {
   Journal(Configuration conf, File logDir, String journalId,
   StartupOption startOpt, StorageErrorReporter errorReporter)
   throws IOException {
+this.conf = conf;
 storage = new JNStorage(conf, logDir, startOpt, errorReporter);
 this.journalId = journalId;
 
@@ -165,13 +168,8 @@ public class Journal implements Closeable {
 
 this.fjm = storage.getJournalManager();
 
-if (conf.getBoolean(DFSConfigKeys.DFS_HA_TAILEDITS_INPROGRESS_KEY,
-DFSConfigKeys.DFS_HA_TAILEDITS_INPROGRESS_DEFAULT)) {
-  this.cache = new JournaledEditsCache(conf);
-} else {
-  this.cache = null;
-}
-
+this.cache = createCache();
+
 this.metrics = JournalMetrics.create(this);
 
 EditLogFile latest = scanStorageForLatestEdits();
@@ -180,6 +178,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) {
 this.triedJournalSyncerStartedwithnsId = started;
   }
@@ -249,6 +256,7 @@ public class Journal implements Closeable {
 LOG.info("Formatting journal id : " + journalId + " with namespace info: " 
+
 nsInfo);
 storage.format(nsInfo);
+this.cache = createCache();
 refreshCachedData();
   }
 


-
To unsubscribe, e-mail: common-commits-unsubscr...@hadoop.apache.org
For additional commands, e-mail: common-commits-h...@hadoop.apache.org



[hadoop] 50/50: HDFS-14537. Journaled Edits Cache is not cleared when formatting the JN. Contributed by Ranith Sardar.

2019-06-28 Thread cliang
This is an automated email from the ASF dual-hosted git repository.

cliang pushed a commit to branch branch-3.2
in repository https://gitbox.apache.org/repos/asf/hadoop.git

commit 66920e6d377275aa42844eeaa2b18b1c956c5e6d
Author: Wei-Chiu Chuang 
AuthorDate: Tue Jun 18 22:28:21 2019 -0700

HDFS-14537. Journaled Edits Cache is not cleared when formatting the JN. 
Contributed by Ranith Sardar.
---
 .../hadoop/hdfs/qjournal/server/Journal.java   | 24 ++
 1 file changed, 16 insertions(+), 8 deletions(-)

diff --git 
a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/qjournal/server/Journal.java
 
b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/qjournal/server/Journal.java
index ffbb682..a886b7c 100644
--- 
a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/qjournal/server/Journal.java
+++ 
b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/qjournal/server/Journal.java
@@ -139,12 +139,14 @@ public class Journal implements Closeable {
   
   private final FileJournalManager fjm;
 
-  private final JournaledEditsCache cache;
+  private JournaledEditsCache cache;
 
   private final JournalMetrics metrics;
 
   private long lastJournalTimestamp = 0;
 
+  private Configuration conf = null;
+
   // This variable tracks, have we tried to start journalsyncer
   // with nameServiceId. This will help not to start the journalsyncer
   // on each rpc call, if it has failed to start
@@ -158,6 +160,7 @@ public class Journal implements Closeable {
   Journal(Configuration conf, File logDir, String journalId,
   StartupOption startOpt, StorageErrorReporter errorReporter)
   throws IOException {
+this.conf = conf;
 storage = new JNStorage(conf, logDir, startOpt, errorReporter);
 this.journalId = journalId;
 
@@ -165,13 +168,8 @@ public class Journal implements Closeable {
 
 this.fjm = storage.getJournalManager();
 
-if (conf.getBoolean(DFSConfigKeys.DFS_HA_TAILEDITS_INPROGRESS_KEY,
-DFSConfigKeys.DFS_HA_TAILEDITS_INPROGRESS_DEFAULT)) {
-  this.cache = new JournaledEditsCache(conf);
-} else {
-  this.cache = null;
-}
-
+this.cache = createCache();
+
 this.metrics = JournalMetrics.create(this);
 
 EditLogFile latest = scanStorageForLatestEdits();
@@ -180,6 +178,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) {
 this.triedJournalSyncerStartedwithnsId = started;
   }
@@ -249,6 +256,7 @@ public class Journal implements Closeable {
 LOG.info("Formatting journal id : " + journalId + " with namespace info: " 
+
 nsInfo + " and force: " + force);
 storage.format(nsInfo, force);
+this.cache = createCache();
 refreshCachedData();
   }
 


-
To unsubscribe, e-mail: common-commits-unsubscr...@hadoop.apache.org
For additional commands, e-mail: common-commits-h...@hadoop.apache.org