HDFS-8911. NameNode Metric : Add Editlog counters as a JMX metric. (Contributed by Anu Engineer)

This commit is contained in:
Arpit Agarwal 2015-08-19 09:42:35 -07:00
parent 0824fa1c4f
commit 10a0ddbac3
6 changed files with 74 additions and 1 deletions

View File

@ -236,6 +236,8 @@ Each metrics record contains tags such as HAState and Hostname as additional inf
| `HAState` | (HA-only) Current state of the NameNode: initializing or active or standby or stopping state |
| `FSState` | Current state of the file system: Safemode or Operational |
| `LockQueueLength` | Number of threads waiting to acquire FSNameSystem lock |
| `TotalSyncCount` | Total number of sync operations performed by edit log |
| `TotalSyncTimes` | Total number of milliseconds spent by various edit logs in sync operation|
JournalNode
-----------

View File

@ -466,6 +466,9 @@ Release 2.8.0 - UNRELEASED
HDFS-8826. In Balancer, add an option to specify the source node list
so that balancer only selects blocks to move from those nodes. (szetszwo)
HDFS-8911. NameNode Metric : Add Editlog counters as a JMX metric.
(Anu Engineer via Arpit Agarwal)
OPTIMIZATIONS
HDFS-8026. Trace FSOutputSummer#writeChecksumChunks rather than

View File

@ -1647,4 +1647,11 @@ private JournalManager createJournal(URI uri) {
}
}
/**
+ * Return total number of syncs happened on this edit log.
+ * @return long - count
+ */
public long getTotalSyncCount() {
return editLogStream.getNumSync();
}
}

View File

@ -7273,5 +7273,24 @@ private static void enableAsyncAuditLog() {
}
}
/**
* Return total number of Sync Operations on FSEditLog.
*/
@Override
@Metric({"TotalSyncCount",
"Total number of sync operations performed on edit logs"})
public long getTotalSyncCount() {
return fsImage.editLog.getTotalSyncCount();
}
/**
* Return total time spent doing sync operations on FSEditLog.
*/
@Override
@Metric({"TotalSyncTimes",
"Total time spend in sync operation on various edit logs"})
public String getTotalSyncTimes() {
return fsImage.editLog.getJournalSet().getSyncTimes();
}
}

View File

@ -198,4 +198,14 @@ public interface FSNamesystemMBean {
* @return int - Number of Threads waiting to acquire FSNameSystemLock
*/
int getFsLockQueueLength();
/**
* Return total number of Sync Operations on FSEditLog.
*/
long getTotalSyncCount();
/**
* Return total time spent doing sync operations on FSEditLog.
*/
String getTotalSyncTimes();
}

View File

@ -30,6 +30,8 @@
import javax.management.MBeanServer;
import javax.management.ObjectName;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hdfs.MiniDFSCluster;
import org.junit.Test;
@ -159,4 +161,34 @@ public void testWithFSNamesystemWriteLock() throws Exception {
}
}
}
}
@Test(timeout = 120000)
public void testFsEditLogMetrics() throws Exception {
final Configuration conf = new Configuration();
MiniDFSCluster cluster = null;
try {
cluster = new MiniDFSCluster.Builder(conf).numDataNodes(0).build();
cluster.waitActive();
MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
ObjectName mxbeanNameFs =
new ObjectName("Hadoop:service=NameNode,name=FSNamesystemState");
FileSystem fs = cluster.getFileSystem();
final int NUM_OPS = 10;
for (int i = 0; i < NUM_OPS; i++) {
final Path path = new Path(String.format("/user%d", i));
fs.mkdirs(path);
}
long syncCount = (long) mbs.getAttribute(mxbeanNameFs, "TotalSyncCount");
String syncTimes =
(String) mbs.getAttribute(mxbeanNameFs, "TotalSyncTimes");
assertTrue(syncCount > 0);
assertNotNull(syncTimes);
} finally {
if (cluster != null) {
cluster.shutdown();
}
}
}
}