HDFS-8911. NameNode Metric : Add Editlog counters as a JMX metric. (Contributed by Anu Engineer)
This commit is contained in:
parent
2da5aaab33
commit
9c3571ea60
|
@ -237,6 +237,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
|
||||
-----------
|
||||
|
|
|
@ -811,6 +811,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
|
||||
|
|
|
@ -1691,4 +1691,11 @@ public class FSEditLog implements LogsPurgeable {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
+ * Return total number of syncs happened on this edit log.
|
||||
+ * @return long - count
|
||||
+ */
|
||||
public long getTotalSyncCount() {
|
||||
return editLogStream.getNumSync();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7277,5 +7277,24 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -30,6 +30,8 @@ import javax.management.MBeanInfo;
|
|||
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 class TestFSNamesystemMBean {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
@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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue