hadoop-hdfs-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jgho...@apache.org
Subject svn commit: r1060656 - in /hadoop/hdfs/branches/branch-0.22: CHANGES.txt src/java/org/apache/hadoop/hdfs/server/namenode/Checkpointer.java
Date Wed, 19 Jan 2011 02:38:10 GMT
Author: jghoman
Date: Wed Jan 19 02:38:10 2011
New Revision: 1060656

URL: http://svn.apache.org/viewvc?rev=1060656&view=rev
Log:
HDFS-1572. Checkpointer should trigger checkpoint with specified period.

Modified:
    hadoop/hdfs/branches/branch-0.22/CHANGES.txt
    hadoop/hdfs/branches/branch-0.22/src/java/org/apache/hadoop/hdfs/server/namenode/Checkpointer.java

Modified: hadoop/hdfs/branches/branch-0.22/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/hdfs/branches/branch-0.22/CHANGES.txt?rev=1060656&r1=1060655&r2=1060656&view=diff
==============================================================================
--- hadoop/hdfs/branches/branch-0.22/CHANGES.txt (original)
+++ hadoop/hdfs/branches/branch-0.22/CHANGES.txt Wed Jan 19 02:38:10 2011
@@ -428,6 +428,9 @@ Release 0.22.0 - Unreleased
     HDFS-884. DataNode throws IOException if all data directories are 
     unavailable. (Steve Loughran and shv)
 
+    HDFS-1572. Checkpointer should trigger checkpoint with specified period.
+    (jghoman)
+
 Release 0.21.1 - Unreleased
 
   IMPROVEMENTS

Modified: hadoop/hdfs/branches/branch-0.22/src/java/org/apache/hadoop/hdfs/server/namenode/Checkpointer.java
URL: http://svn.apache.org/viewvc/hadoop/hdfs/branches/branch-0.22/src/java/org/apache/hadoop/hdfs/server/namenode/Checkpointer.java?rev=1060656&r1=1060655&r2=1060656&view=diff
==============================================================================
--- hadoop/hdfs/branches/branch-0.22/src/java/org/apache/hadoop/hdfs/server/namenode/Checkpointer.java
(original)
+++ hadoop/hdfs/branches/branch-0.22/src/java/org/apache/hadoop/hdfs/server/namenode/Checkpointer.java
Wed Jan 19 02:38:10 2011
@@ -126,30 +126,26 @@ class Checkpointer extends Daemon {
   // The main work loop
   //
   public void run() {
-    // Check the size of the edit log once every 5 minutes.
-    long periodMSec = 5 * 60;   // 5 minutes
-    if(checkpointPeriod < periodMSec) {
-      periodMSec = checkpointPeriod;
-    }
-    periodMSec *= 1000;
+    final long fiveMinMS = 5 * 60 * 1000; // How often to poll edits size
+    final long periodMS = checkpointPeriod * 1000; // How often to checkpoint, regardless
of edits' size
+    long lastCheckpointTimeMS = backupNode.shouldCheckpointAtStartup() ? 0 : now();
+    long lastSizeCheckMS = now();
 
-    long lastCheckpointTime = 0;
-    if(!backupNode.shouldCheckpointAtStartup())
-      lastCheckpointTime = now();
     while(shouldRun) {
       try {
         long now = now();
-        boolean shouldCheckpoint = false;
-        if(now >= lastCheckpointTime + periodMSec) {
-          shouldCheckpoint = true;
-        } else {
-          long size = getJournalSize();
-          if(size >= checkpointSize)
-            shouldCheckpoint = true;
+        boolean editsTooBig = false;
+        boolean periodExpired = now >= lastCheckpointTimeMS + periodMS;
+
+        if(now >= lastSizeCheckMS + fiveMinMS) {
+          editsTooBig = getJournalSize() > checkpointSize;
+          lastSizeCheckMS = now;
         }
-        if(shouldCheckpoint) {
+
+        if(periodExpired || editsTooBig) {
           doCheckpoint();
-          lastCheckpointTime = now;
+          lastCheckpointTimeMS = now;
+          lastSizeCheckMS = now;
         }
       } catch(IOException e) {
         LOG.error("Exception in doCheckpoint: ", e);
@@ -159,7 +155,7 @@ class Checkpointer extends Daemon {
         break;
       }
       try {
-        Thread.sleep(periodMSec);
+        Thread.sleep(Math.min(fiveMinMS, periodMS));
       } catch(InterruptedException ie) {
         // do nothing
       }



Mime
View raw message