Skip to content

Commit

Permalink
add metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
lgh committed Dec 26, 2023
1 parent 977035a commit 02d21e1
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -3194,6 +3194,7 @@ public void run() {
*/
if (rpcStableEnable && startTimeNanos - call.timestampNanos > rpcStableInterval) {
call.setStable(true);
rpcMetrics.incrStableCalls();
} else {
// Re-queue the call and continue
requeueCall(call);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,8 @@ public static RpcMetrics create(Server server, Configuration conf) {
MutableCounterLong rpcRequeueCalls;
@Metric("Number of successful RPC calls")
MutableCounterLong rpcCallSuccesses;
@Metric("Number of stable calls")
MutableCounterLong rpcStableCalls;

@Metric("Number of open connections") public int numOpenConnections() {
return server.getNumOpenConnections();
Expand Down Expand Up @@ -363,6 +365,13 @@ public void incrRpcCallSuccesses() {
rpcCallSuccesses.incr();
}

/**
* Increments the stable calls counter.
*/
public void incrStableCalls() {
rpcStableCalls.incr();
}

/**
* Returns a MutableRate Counter.
* @return Mutable Rate
Expand Down Expand Up @@ -412,6 +421,15 @@ public long getRpcRequeueCalls() {
return rpcRequeueCalls.value();
}

/**
* Returns the number of stable calls.
* @return long
*/
@VisibleForTesting
public long getRpcStableCalls() {
return rpcStableCalls.value();
}

public MutableRate getDeferredRpcProcessingTime() {
return deferredRpcProcessingTime;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@
import org.apache.hadoop.hdfs.protocol.Block;
import org.apache.hadoop.hdfs.protocol.DatanodeInfo;
import org.apache.hadoop.hdfs.protocol.ExtendedBlock;
import org.apache.hadoop.hdfs.protocol.HdfsFileStatus;
import org.apache.hadoop.hdfs.protocol.LocatedBlock;
import org.apache.hadoop.hdfs.protocol.LocatedBlocks;
import org.apache.hadoop.hdfs.qjournal.MiniQJMHACluster;
Expand Down Expand Up @@ -181,6 +180,8 @@ public void testObserverRequeue() throws Exception {
@Test
public void testObserverStableRpc() throws Exception {
FSNamesystem observerFsNS = dfsCluster.getNamesystem(2);
RpcMetrics obRpcMetrics = ((NameNodeRpcServer)dfsCluster
.getNameNodeRpc(2)).getClientRpcServer().getRpcMetrics();
try {
// Stop EditlogTailer of Observer NameNode.
observerFsNS.getEditLogTailer().stop();
Expand All @@ -194,11 +195,13 @@ public void testObserverStableRpc() throws Exception {
FileStatus fileStatus = dfs.getFileStatus(tmpTestPath);
assertSentTo(0);
assertNotNull(fileStatus);
assertEquals(1, obRpcMetrics.getRpcStableCalls());

observerFsNS.getEditLogTailer().doTailEdits();
fileStatus = dfs.getFileStatus(tmpTestPath);
assertSentTo(2);
assertNotNull(fileStatus);
assertEquals(1, obRpcMetrics.getRpcStableCalls());
} finally {
EditLogTailer editLogTailer = new EditLogTailer(observerFsNS, conf);
observerFsNS.setEditLogTailerForTests(editLogTailer);
Expand Down

0 comments on commit 02d21e1

Please sign in to comment.