Skip to content

Commit 5844e12

Browse files
committed
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
1 parent f773d71 commit 5844e12

File tree

4 files changed

+15
-9
lines changed

4 files changed

+15
-9
lines changed

hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,9 @@ Release 2.5.0 - UNRELEASED
299299
HDFS-6173. Move the default processor from Ls to Web in OfflineImageViewer.
300300
(Akira Ajisaka via wheat9)
301301

302+
HDFS-5591. Checkpointing should use monotonic time when calculating period.
303+
(Charles Lamb via wang)
304+
302305
Release 2.4.1 - UNRELEASED
303306

304307
INCOMPATIBLE CHANGES

hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/SecondaryNameNode.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,9 @@ public String toString() {
129129
return getClass().getSimpleName() + " Status"
130130
+ "\nName Node Address : " + nameNodeAddr
131131
+ "\nStart Time : " + new Date(starttime)
132-
+ "\nLast Checkpoint Time : " + (lastCheckpointTime == 0? "--": new Date(lastCheckpointTime))
132+
+ "\nLast Checkpoint : " + (lastCheckpointTime == 0? "--":
133+
((Time.monotonicNow() - lastCheckpointTime) / 1000))
134+
+ " seconds ago"
133135
+ "\nCheckpoint Period : " + checkpointConf.getPeriod() + " seconds"
134136
+ "\nCheckpoint Size : " + StringUtils.byteDesc(checkpointConf.getTxnCount())
135137
+ " (= " + checkpointConf.getTxnCount() + " bytes)"
@@ -376,7 +378,7 @@ public void doWork() {
376378
if(UserGroupInformation.isSecurityEnabled())
377379
UserGroupInformation.getCurrentUser().checkTGTAndReloginFromKeytab();
378380

379-
long now = Time.now();
381+
final long now = Time.monotonicNow();
380382

381383
if (shouldCheckpointBasedOnCount() ||
382384
now >= lastCheckpointTime + 1000 * checkpointConf.getPeriod()) {

hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/ha/StandbyCheckpointer.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
*/
1818
package org.apache.hadoop.hdfs.server.namenode.ha;
1919

20-
import static org.apache.hadoop.util.Time.now;
20+
import static org.apache.hadoop.util.Time.monotonicNow;
2121

2222
import java.io.IOException;
2323
import java.net.URI;
@@ -277,14 +277,14 @@ public Object run() {
277277
* prevented
278278
*/
279279
private void preventCheckpointsFor(long delayMs) {
280-
preventCheckpointsUntil = now() + delayMs;
280+
preventCheckpointsUntil = monotonicNow() + delayMs;
281281
}
282282

283283
private void doWork() {
284284
final long checkPeriod = 1000 * checkpointConf.getCheckPeriod();
285285
// Reset checkpoint time so that we don't always checkpoint
286286
// on startup.
287-
lastCheckpointTime = now();
287+
lastCheckpointTime = monotonicNow();
288288
while (shouldRun) {
289289
boolean needRollbackCheckpoint = namesystem.isNeedRollbackFsImage();
290290
if (!needRollbackCheckpoint) {
@@ -302,9 +302,9 @@ private void doWork() {
302302
UserGroupInformation.getCurrentUser().checkTGTAndReloginFromKeytab();
303303
}
304304

305-
long now = now();
306-
long uncheckpointed = countUncheckpointedTxns();
307-
long secsSinceLast = (now - lastCheckpointTime)/1000;
305+
final long now = monotonicNow();
306+
final long uncheckpointed = countUncheckpointedTxns();
307+
final long secsSinceLast = (now - lastCheckpointTime) / 1000;
308308

309309
boolean needCheckpoint = needRollbackCheckpoint;
310310
if (needCheckpoint) {

hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestSecondaryWebUi.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@ public static void shutDownCluster() {
6262
public void testSecondaryWebUi() throws IOException {
6363
String pageContents = DFSTestUtil.urlGet(new URL("http://localhost:" +
6464
SecondaryNameNode.getHttpAddress(conf).getPort() + "/status.jsp"));
65-
assertTrue(pageContents.contains("Last Checkpoint Time"));
65+
assertTrue("Didn't find \"Last Checkpoint\"",
66+
pageContents.contains("Last Checkpoint"));
6667
}
6768

6869
@Test

0 commit comments

Comments
 (0)