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/trunk@1583926 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Andrew Wang 2014-04-02 08:33:25 +00:00
parent f93d99990a
commit 64c50d9dfb
4 changed files with 15 additions and 9 deletions

View File

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

View File

@ -129,7 +129,9 @@ public class SecondaryNameNode implements Runnable {
return getClass().getSimpleName() + " Status"
+ "\nName Node Address : " + nameNodeAddr
+ "\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 Size : " + StringUtils.byteDesc(checkpointConf.getTxnCount())
+ " (= " + checkpointConf.getTxnCount() + " bytes)"
@ -376,7 +378,7 @@ public class SecondaryNameNode implements Runnable {
if(UserGroupInformation.isSecurityEnabled())
UserGroupInformation.getCurrentUser().checkTGTAndReloginFromKeytab();
long now = Time.now();
final long now = Time.monotonicNow();
if (shouldCheckpointBasedOnCount() ||
now >= lastCheckpointTime + 1000 * checkpointConf.getPeriod()) {

View File

@ -17,7 +17,7 @@
*/
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.net.URI;
@ -277,14 +277,14 @@ public class StandbyCheckpointer {
* prevented
*/
private void preventCheckpointsFor(long delayMs) {
preventCheckpointsUntil = now() + delayMs;
preventCheckpointsUntil = monotonicNow() + delayMs;
}
private void doWork() {
final long checkPeriod = 1000 * checkpointConf.getCheckPeriod();
// Reset checkpoint time so that we don't always checkpoint
// on startup.
lastCheckpointTime = now();
lastCheckpointTime = monotonicNow();
while (shouldRun) {
boolean needRollbackCheckpoint = namesystem.isNeedRollbackFsImage();
if (!needRollbackCheckpoint) {
@ -302,9 +302,9 @@ public class StandbyCheckpointer {
UserGroupInformation.getCurrentUser().checkTGTAndReloginFromKeytab();
}
long now = now();
long uncheckpointed = countUncheckpointedTxns();
long secsSinceLast = (now - lastCheckpointTime)/1000;
final long now = monotonicNow();
final long uncheckpointed = countUncheckpointedTxns();
final long secsSinceLast = (now - lastCheckpointTime) / 1000;
boolean needCheckpoint = needRollbackCheckpoint;
if (needCheckpoint) {

View File

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