Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public void init(Class<?> protocol) {
return;
}
protocolCache.add(protocol);
for (Method method : protocol.getDeclaredMethods()) {
for (Method method : protocol.getMethods()) {
String name = method.getName();
LOG.debug(name);
addMetricIfNotExists(name);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;

import javax.management.AttributeNotFoundException;
import javax.management.MBeanServer;
import javax.management.ObjectName;

Expand Down Expand Up @@ -591,14 +592,24 @@ public Boolean get() {
}

@Test
public void testNNRpcMetricsWithNonHA() throws IOException {
public void testNNRpcMetricsWithNonHA() throws Exception {
Configuration conf = new HdfsConfiguration();
// setting heartbeat interval to 1 hour to prevent bpServiceActor sends
// heartbeat periodically to NN during running test case, and bpServiceActor
// only sends heartbeat once after startup
conf.setTimeDuration(DFS_HEARTBEAT_INTERVAL_KEY, 1, TimeUnit.HOURS);
MiniDFSCluster cluster = new MiniDFSCluster.Builder(conf).build();
cluster.waitActive();
final MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@zhangshuyan0 Thanks for your update. This unit test seems failed based on the yetus reports. Another side, this segment code located at TestNameNodeMetrics should be more proper? Thanks again.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed that this isn't the right place. Actually it seems like enhancing TestRPC#testRpcMetrics() might be the best place? Or if we can't get it to work there, then I agree TestNameNodeMetrics seems better.

final ObjectName mxbeanName =
new ObjectName("Hadoop:service=NameNode," +
"name=RpcDetailedActivityForPort" +
cluster.getNameNode().getNameNodeAddress().getPort());
try {
mbs.getAttribute(mxbeanName, "CommitBlockSynchronizationNumOps");
} catch (AttributeNotFoundException e) {
fail("Datanode protocol metrics have not been fully initialized.");
}
DataNode dn = cluster.getDataNodes().get(0);
MetricsRecordBuilder rb = getMetrics(dn.getMetrics().name());
assertCounter("HeartbeatsNumOps", 1L, rb);
Expand Down