HDFS-5591. Checkpointing should use monotonic time when calculating period. Contributed by Charles Lamb.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-2@1583927 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Andrew Wang 2014-04-02 08:36:13 +00:00
parent cd982702b2
commit 76b097c187
4 changed files with 15 additions and 9 deletions

View File

@ -51,6 +51,9 @@ Release 2.5.0 - UNRELEASED
HDFS-6173. Move the default processor from Ls to Web in OfflineImageViewer. HDFS-6173. Move the default processor from Ls to Web in OfflineImageViewer.
(Akira Ajisaka via wheat9) (Akira Ajisaka via wheat9)
HDFS-5591. Checkpointing should use monotonic time when calculating period.
(Charles Lamb via wang)
Release 2.4.1 - UNRELEASED Release 2.4.1 - UNRELEASED
INCOMPATIBLE CHANGES INCOMPATIBLE CHANGES

View File

@ -129,7 +129,9 @@ public class SecondaryNameNode implements Runnable {
return getClass().getSimpleName() + " Status" return getClass().getSimpleName() + " Status"
+ "\nName Node Address : " + nameNodeAddr + "\nName Node Address : " + nameNodeAddr
+ "\nStart Time : " + new Date(starttime) + "\nStart Time : " + new Date(starttime)
+ "\nLast Checkpoint Time : " + (lastCheckpointTime == 0? "--": new Date(lastCheckpointTime)) + "\nLast Checkpoint : " + (lastCheckpointTime == 0? "--":
((Time.monotonicNow() - lastCheckpointTime) / 1000))
+ " seconds ago"
+ "\nCheckpoint Period : " + checkpointConf.getPeriod() + " seconds" + "\nCheckpoint Period : " + checkpointConf.getPeriod() + " seconds"
+ "\nCheckpoint Size : " + StringUtils.byteDesc(checkpointConf.getTxnCount()) + "\nCheckpoint Size : " + StringUtils.byteDesc(checkpointConf.getTxnCount())
+ " (= " + checkpointConf.getTxnCount() + " bytes)" + " (= " + checkpointConf.getTxnCount() + " bytes)"
@ -376,7 +378,7 @@ public class SecondaryNameNode implements Runnable {
if(UserGroupInformation.isSecurityEnabled()) if(UserGroupInformation.isSecurityEnabled())
UserGroupInformation.getCurrentUser().checkTGTAndReloginFromKeytab(); UserGroupInformation.getCurrentUser().checkTGTAndReloginFromKeytab();
long now = Time.now(); final long now = Time.monotonicNow();
if (shouldCheckpointBasedOnCount() || if (shouldCheckpointBasedOnCount() ||
now >= lastCheckpointTime + 1000 * checkpointConf.getPeriod()) { now >= lastCheckpointTime + 1000 * checkpointConf.getPeriod()) {

View File

@ -17,7 +17,7 @@
*/ */
package org.apache.hadoop.hdfs.server.namenode.ha; package org.apache.hadoop.hdfs.server.namenode.ha;
import static org.apache.hadoop.util.Time.now; import static org.apache.hadoop.util.Time.monotonicNow;
import java.io.IOException; import java.io.IOException;
import java.net.URI; import java.net.URI;
@ -277,14 +277,14 @@ public class StandbyCheckpointer {
* prevented * prevented
*/ */
private void preventCheckpointsFor(long delayMs) { private void preventCheckpointsFor(long delayMs) {
preventCheckpointsUntil = now() + delayMs; preventCheckpointsUntil = monotonicNow() + delayMs;
} }
private void doWork() { private void doWork() {
final long checkPeriod = 1000 * checkpointConf.getCheckPeriod(); final long checkPeriod = 1000 * checkpointConf.getCheckPeriod();
// Reset checkpoint time so that we don't always checkpoint // Reset checkpoint time so that we don't always checkpoint
// on startup. // on startup.
lastCheckpointTime = now(); lastCheckpointTime = monotonicNow();
while (shouldRun) { while (shouldRun) {
boolean needRollbackCheckpoint = namesystem.isNeedRollbackFsImage(); boolean needRollbackCheckpoint = namesystem.isNeedRollbackFsImage();
if (!needRollbackCheckpoint) { if (!needRollbackCheckpoint) {
@ -302,9 +302,9 @@ public class StandbyCheckpointer {
UserGroupInformation.getCurrentUser().checkTGTAndReloginFromKeytab(); UserGroupInformation.getCurrentUser().checkTGTAndReloginFromKeytab();
} }
long now = now(); final long now = monotonicNow();
long uncheckpointed = countUncheckpointedTxns(); final long uncheckpointed = countUncheckpointedTxns();
long secsSinceLast = (now - lastCheckpointTime)/1000; final long secsSinceLast = (now - lastCheckpointTime) / 1000;
boolean needCheckpoint = needRollbackCheckpoint; boolean needCheckpoint = needRollbackCheckpoint;
if (needCheckpoint) { if (needCheckpoint) {

View File

@ -62,7 +62,8 @@ public class TestSecondaryWebUi {
public void testSecondaryWebUi() throws IOException { public void testSecondaryWebUi() throws IOException {
String pageContents = DFSTestUtil.urlGet(new URL("http://localhost:" + String pageContents = DFSTestUtil.urlGet(new URL("http://localhost:" +
SecondaryNameNode.getHttpAddress(conf).getPort() + "/status.jsp")); SecondaryNameNode.getHttpAddress(conf).getPort() + "/status.jsp"));
assertTrue(pageContents.contains("Last Checkpoint Time")); assertTrue("Didn't find \"Last Checkpoint\"",
pageContents.contains("Last Checkpoint"));
} }
@Test @Test