Skip to content

Commit

Permalink
HDFS-8214. Secondary NN Web UI shows wrong date for Last Checkpoint. …
Browse files Browse the repository at this point in the history
…Contributed by Charles Lamb.
  • Loading branch information
umbrant committed Apr 30, 2015
1 parent 4c1af15 commit aa22450
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 12 deletions.
2 changes: 2 additions & 0 deletions hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt
Expand Up @@ -582,6 +582,8 @@ Release 2.8.0 - UNRELEASED
HDFS-8232. Missing datanode counters when using Metrics2 sink interface. HDFS-8232. Missing datanode counters when using Metrics2 sink interface.
(Anu Engineer via cnauroth) (Anu Engineer via cnauroth)


HDFS-8214. Secondary NN Web UI shows wrong date for Last Checkpoint. (clamb via wang)

Release 2.7.1 - UNRELEASED Release 2.7.1 - UNRELEASED


INCOMPATIBLE CHANGES INCOMPATIBLE CHANGES
Expand Down
Expand Up @@ -108,6 +108,7 @@ public class SecondaryNameNode implements Runnable,


private final long starttime = Time.now(); private final long starttime = Time.now();
private volatile long lastCheckpointTime = 0; private volatile long lastCheckpointTime = 0;
private volatile long lastCheckpointWallclockTime = 0;


private URL fsName; private URL fsName;
private CheckpointStorage checkpointImage; private CheckpointStorage checkpointImage;
Expand All @@ -134,8 +135,9 @@ public String toString() {
+ "\nName Node Address : " + nameNodeAddr + "\nName Node Address : " + nameNodeAddr
+ "\nStart Time : " + new Date(starttime) + "\nStart Time : " + new Date(starttime)
+ "\nLast Checkpoint : " + (lastCheckpointTime == 0? "--": + "\nLast Checkpoint : " + (lastCheckpointTime == 0? "--":
((Time.monotonicNow() - lastCheckpointTime) / 1000)) new Date(lastCheckpointWallclockTime))
+ " seconds ago" + " (" + ((Time.monotonicNow() - lastCheckpointTime) / 1000)
+ " seconds ago)"
+ "\nCheckpoint Period : " + checkpointConf.getPeriod() + " seconds" + "\nCheckpoint Period : " + checkpointConf.getPeriod() + " seconds"
+ "\nCheckpoint Transactions: " + checkpointConf.getTxnCount() + "\nCheckpoint Transactions: " + checkpointConf.getTxnCount()
+ "\nCheckpoint Dirs : " + checkpointDirs + "\nCheckpoint Dirs : " + checkpointDirs
Expand Down Expand Up @@ -388,12 +390,14 @@ public void doWork() {
if(UserGroupInformation.isSecurityEnabled()) if(UserGroupInformation.isSecurityEnabled())
UserGroupInformation.getCurrentUser().checkTGTAndReloginFromKeytab(); UserGroupInformation.getCurrentUser().checkTGTAndReloginFromKeytab();


final long now = Time.monotonicNow(); final long monotonicNow = Time.monotonicNow();
final long now = Time.now();


if (shouldCheckpointBasedOnCount() || if (shouldCheckpointBasedOnCount() ||
now >= lastCheckpointTime + 1000 * checkpointConf.getPeriod()) { monotonicNow >= lastCheckpointTime + 1000 * checkpointConf.getPeriod()) {
doCheckpoint(); doCheckpoint();
lastCheckpointTime = now; lastCheckpointTime = monotonicNow;
lastCheckpointWallclockTime = now;
} }
} catch (IOException e) { } catch (IOException e) {
LOG.error("Exception in doCheckpoint", e); LOG.error("Exception in doCheckpoint", e);
Expand Down Expand Up @@ -695,22 +699,31 @@ public void startCheckpointThread() {
checkpointThread.start(); checkpointThread.start();
} }


@Override // SecondaryNameNodeInfoMXXBean @Override // SecondaryNameNodeInfoMXBean
public String getHostAndPort() { public String getHostAndPort() {
return NetUtils.getHostPortString(nameNodeAddr); return NetUtils.getHostPortString(nameNodeAddr);
} }


@Override // SecondaryNameNodeInfoMXXBean @Override // SecondaryNameNodeInfoMXBean
public long getStartTime() { public long getStartTime() {
return starttime; return starttime;
} }


@Override // SecondaryNameNodeInfoMXXBean @Override // SecondaryNameNodeInfoMXBean
public long getLastCheckpointTime() { public long getLastCheckpointTime() {
return lastCheckpointTime; return lastCheckpointWallclockTime;
} }


@Override // SecondaryNameNodeInfoMXXBean @Override // SecondaryNameNodeInfoMXBean
public long getLastCheckpointDeltaMs() {
if (lastCheckpointTime == 0) {
return -1;
} else {
return (Time.monotonicNow() - lastCheckpointTime);
}
}

@Override // SecondaryNameNodeInfoMXBean
public String[] getCheckpointDirectories() { public String[] getCheckpointDirectories() {
ArrayList<String> r = Lists.newArrayListWithCapacity(checkpointDirs.size()); ArrayList<String> r = Lists.newArrayListWithCapacity(checkpointDirs.size());
for (URI d : checkpointDirs) { for (URI d : checkpointDirs) {
Expand All @@ -719,7 +732,7 @@ public String[] getCheckpointDirectories() {
return r.toArray(new String[r.size()]); return r.toArray(new String[r.size()]);
} }


@Override // SecondaryNameNodeInfoMXXBean @Override // SecondaryNameNodeInfoMXBean
public String[] getCheckpointEditlogDirectories() { public String[] getCheckpointEditlogDirectories() {
ArrayList<String> r = Lists.newArrayListWithCapacity(checkpointEditsDirs.size()); ArrayList<String> r = Lists.newArrayListWithCapacity(checkpointEditsDirs.size());
for (URI d : checkpointEditsDirs) { for (URI d : checkpointEditsDirs) {
Expand Down
Expand Up @@ -41,6 +41,12 @@ public interface SecondaryNameNodeInfoMXBean extends VersionInfoMXBean {
*/ */
public long getLastCheckpointTime(); public long getLastCheckpointTime();


/**
* @return the number of msec since the last checkpoint, or -1 if no
* checkpoint has been done yet.
*/
public long getLastCheckpointDeltaMs();

/** /**
* @return the directories that store the checkpoint images * @return the directories that store the checkpoint images
*/ */
Expand Down
Expand Up @@ -65,7 +65,7 @@
<tr><th>Compiled</th><td>{CompileInfo}</td></tr> <tr><th>Compiled</th><td>{CompileInfo}</td></tr>
<tr><th>NameNode Address</th><td>{HostAndPort}</td></tr> <tr><th>NameNode Address</th><td>{HostAndPort}</td></tr>
<tr><th>Started</th><td>{StartTime|date_tostring}</td></tr> <tr><th>Started</th><td>{StartTime|date_tostring}</td></tr>
<tr><th>Last Checkpoint</th><td>{@if cond="{LastCheckpointTime} === 0"}Never{:else}{LastCheckpointTime|date_tostring}{/if}</td></tr> <tr><th>Last Checkpoint</th><td>{@if cond="{LastCheckpointTime} === 0"}Never{:else}{LastCheckpointTime|date_tostring} ({LastCheckpointDeltaMs|fmt_time} ago){/if}</td></tr>
<tr><th>Checkpoint Period</th><td>{CheckpointPeriod} seconds</td></tr> <tr><th>Checkpoint Period</th><td>{CheckpointPeriod} seconds</td></tr>
<tr><th>Checkpoint Transactions</th><td>{TxnCount}</td></tr> <tr><th>Checkpoint Transactions</th><td>{TxnCount}</td></tr>
</table> </table>
Expand Down
Expand Up @@ -40,6 +40,9 @@
}, },


'fmt_time': function (v) { 'fmt_time': function (v) {
if (v < 0) {
return "unknown";
}
var s = Math.floor(v / 1000), h = Math.floor(s / 3600); var s = Math.floor(v / 1000), h = Math.floor(s / 3600);
s -= h * 3600; s -= h * 3600;
var m = Math.floor(s / 60); var m = Math.floor(s / 60);
Expand Down

0 comments on commit aa22450

Please sign in to comment.