Skip to content

Commit d1c9608

Browse files
author
Haohui Mai
committed
HDFS-6270. Secondary namenode status page shows transaction count in bytes. Contributed by Benoy Antony.
git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1590197 13f79535-47bb-0310-9956-ffa450edef68
1 parent 53de58b commit d1c9608

File tree

4 files changed

+30
-10
lines changed

4 files changed

+30
-10
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -406,6 +406,9 @@ Release 2.5.0 - UNRELEASED
406406

407407
HDFS-5865. Update OfflineImageViewer document. (Akira Ajisaka via wheat9)
408408

409+
HDFS-6270. Secondary namenode status page shows transaction count in bytes.
410+
(Benoy Antony via wheat9)
411+
409412
Release 2.4.1 - UNRELEASED
410413

411414
INCOMPATIBLE CHANGES

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

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@
7878

7979
import com.google.common.annotations.VisibleForTesting;
8080
import com.google.common.base.Preconditions;
81-
import com.google.common.collect.ImmutableList;
8281
import org.apache.hadoop.util.VersionInfo;
8382

8483
import javax.management.ObjectName;
@@ -130,16 +129,15 @@ public class SecondaryNameNode implements Runnable,
130129
@Override
131130
public String toString() {
132131
return getClass().getSimpleName() + " Status"
133-
+ "\nName Node Address : " + nameNodeAddr
134-
+ "\nStart Time : " + new Date(starttime)
135-
+ "\nLast Checkpoint : " + (lastCheckpointTime == 0? "--":
132+
+ "\nName Node Address : " + nameNodeAddr
133+
+ "\nStart Time : " + new Date(starttime)
134+
+ "\nLast Checkpoint : " + (lastCheckpointTime == 0? "--":
136135
((Time.monotonicNow() - lastCheckpointTime) / 1000))
137136
+ " seconds ago"
138-
+ "\nCheckpoint Period : " + checkpointConf.getPeriod() + " seconds"
139-
+ "\nCheckpoint Size : " + StringUtils.byteDesc(checkpointConf.getTxnCount())
140-
+ " (= " + checkpointConf.getTxnCount() + " bytes)"
141-
+ "\nCheckpoint Dirs : " + checkpointDirs
142-
+ "\nCheckpoint Edits Dirs: " + checkpointEditsDirs;
137+
+ "\nCheckpoint Period : " + checkpointConf.getPeriod() + " seconds"
138+
+ "\nCheckpoint Transactions: " + checkpointConf.getTxnCount()
139+
+ "\nCheckpoint Dirs : " + checkpointDirs
140+
+ "\nCheckpoint Edits Dirs : " + checkpointEditsDirs;
143141
}
144142

145143
@VisibleForTesting

hadoop-hdfs-project/hadoop-hdfs/src/main/webapps/secondary/status.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666
<tr><th>Started</th><td>{StartTime|date_tostring}</td></tr>
6767
<tr><th>Last Checkpoint</th><td>{@if cond="{LastCheckpointTime} === 0"}Never{:else}{LastCheckpointTime|date_tostring}{/if}</td></tr>
6868
<tr><th>Checkpoint Period</th><td>{CheckpointPeriod} seconds</td></tr>
69-
<tr><th>Checkpoint Size</th><td>{TxnCount|fmt_bytes}</td></tr>
69+
<tr><th>Checkpoint Transactions</th><td>{TxnCount}</td></tr>
7070
</table>
7171

7272
<div class="page-header"><h2><small>Checkpoint Image URI</small></h2></div>

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

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

20+
import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_NAMENODE_CHECKPOINT_TXNS_KEY;
21+
2022
import org.apache.hadoop.conf.Configuration;
2123
import org.apache.hadoop.hdfs.DFSConfigKeys;
24+
import org.apache.hadoop.hdfs.DFSTestUtil;
2225
import org.apache.hadoop.hdfs.MiniDFSCluster;
2326
import org.junit.AfterClass;
2427
import org.junit.Assert;
@@ -28,6 +31,7 @@
2831
import javax.management.*;
2932
import java.io.IOException;
3033
import java.lang.management.ManagementFactory;
34+
import java.net.URL;
3135

3236
public class TestSecondaryWebUi {
3337

@@ -39,6 +43,7 @@ public class TestSecondaryWebUi {
3943
public static void setUpCluster() throws IOException {
4044
conf.set(DFSConfigKeys.DFS_NAMENODE_SECONDARY_HTTP_ADDRESS_KEY,
4145
"0.0.0.0:0");
46+
conf.setLong(DFS_NAMENODE_CHECKPOINT_TXNS_KEY, 500);
4247
cluster = new MiniDFSCluster.Builder(conf).numDataNodes(0)
4348
.build();
4449
cluster.waitActive();
@@ -73,4 +78,18 @@ public void testSecondaryWebUi()
7378
Assert.assertArrayEquals(checkpointEditlogDir,
7479
snn.getCheckpointEditlogDirectories());
7580
}
81+
82+
@Test
83+
public void testSecondaryWebUiJsp()
84+
throws IOException, MalformedObjectNameException,
85+
AttributeNotFoundException, MBeanException,
86+
ReflectionException, InstanceNotFoundException {
87+
String pageContents = DFSTestUtil.urlGet(new URL("http://localhost:" +
88+
SecondaryNameNode.getHttpAddress(conf).getPort() + "/status.jsp"));
89+
Assert.assertTrue("Didn't find \"Last Checkpoint\"",
90+
pageContents.contains("Last Checkpoint"));
91+
Assert.assertTrue("Didn't find Checkpoint Transactions: 500",
92+
pageContents.contains("Checkpoint Transactions: 500"));
93+
94+
}
7695
}

0 commit comments

Comments
 (0)