You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by aa...@apache.org on 2019/02/04 04:52:06 UTC

[hadoop] branch trunk updated: HDFS-14158. Checkpointer ignores configured time period > 5 minutes

This is an automated email from the ASF dual-hosted git repository.

aajisaka pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/hadoop.git


The following commit(s) were added to refs/heads/trunk by this push:
     new 9aa3dc8  HDFS-14158. Checkpointer ignores configured time period > 5 minutes
9aa3dc8 is described below

commit 9aa3dc872ca9a528cb98ef56d9a33ab9d4531aa1
Author: tiwalter <wa...@gmail.com>
AuthorDate: Tue Dec 18 14:21:19 2018 +0100

    HDFS-14158. Checkpointer ignores configured time period > 5 minutes
    
    This closes #449
    
    Signed-off-by: Akira Ajisaka <aa...@apache.org>
---
 .../hadoop/hdfs/server/namenode/Checkpointer.java  | 22 ++++++++++++----------
 1 file changed, 12 insertions(+), 10 deletions(-)

diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/Checkpointer.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/Checkpointer.java
index 14749d0..ab07efa 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/Checkpointer.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/Checkpointer.java
@@ -28,6 +28,7 @@ import java.net.MalformedURLException;
 import java.net.URL;
 import java.util.List;
 
+import com.google.common.math.LongMath;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.apache.hadoop.conf.Configuration;
@@ -51,7 +52,7 @@ import com.google.common.collect.Lists;
  * The Checkpointer is a daemon that periodically wakes up
  * up (determined by the schedule specified in the configuration),
  * triggers a periodic checkpoint and then goes back to sleep.
- * 
+ *
  * The start of a checkpoint is triggered by one of the two factors:
  * (1) time or (2) the size of the edits file.
  */
@@ -126,14 +127,13 @@ class Checkpointer extends Daemon {
   //
   @Override
   public void run() {
-    // Check the size of the edit log once every 5 minutes.
-    long periodMSec = 5 * 60;   // 5 minutes
-    if(checkpointConf.getPeriod() < periodMSec) {
-      periodMSec = checkpointConf.getPeriod();
-    }
-    periodMSec *= 1000;
+    // How often to check the size of the edit log (min of checkpointCheckPeriod and checkpointPeriod)
+    long periodMSec = checkpointConf.getCheckPeriod() * 1000;
+    // How often to checkpoint regardless of number of txns
+    long checkpointPeriodMSec = checkpointConf.getPeriod() * 1000;
 
     long lastCheckpointTime = 0;
+    long lastEditLogCheckTime =0;
     if (!backupNode.shouldCheckpointAtStartup()) {
       lastCheckpointTime = monotonicNow();
     }
@@ -141,16 +141,18 @@ class Checkpointer extends Daemon {
       try {
         long now = monotonicNow();
         boolean shouldCheckpoint = false;
-        if(now >= lastCheckpointTime + periodMSec) {
+        if(now >= lastCheckpointTime + checkpointPeriodMSec) {
           shouldCheckpoint = true;
-        } else {
+        } else if(now >= lastEditLogCheckTime + periodMSec) {
           long txns = countUncheckpointedTxns();
+          lastEditLogCheckTime = now;
           if(txns >= checkpointConf.getTxnCount())
             shouldCheckpoint = true;
         }
         if(shouldCheckpoint) {
           doCheckpoint();
           lastCheckpointTime = now;
+          lastEditLogCheckTime = now;
         }
       } catch(IOException e) {
         LOG.error("Exception in doCheckpoint: ", e);
@@ -160,7 +162,7 @@ class Checkpointer extends Daemon {
         break;
       }
       try {
-        Thread.sleep(periodMSec);
+        Thread.sleep(LongMath.gcd(periodMSec, checkpointPeriodMSec));
       } catch(InterruptedException ie) {
         // do nothing
       }


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