priyeshkaratha commented on code in PR #9326:
URL: https://github.com/apache/ozone/pull/9326#discussion_r2543000004
##########
hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/ReconUtils.java:
##########
@@ -847,4 +899,53 @@ public static String constructObjectPathWithPrefix(long...
ids) {
}
return pathBuilder.toString();
}
+
+ public static long getMetricsFromDatanode(DatanodeDetails datanode, String
service, String name, String keyName)
+ throws IOException {
+ // Construct metrics URL for DataNode JMX endpoint
+ String metricsUrl =
String.format("http://%s:%d/jmx?qry=Hadoop:service=%s,name=%s",
+ datanode.getIpAddress(),
+ datanode.getPort(DatanodeDetails.Port.Name.HTTP).getValue(),
+ service,
+ name);
+ HttpGet request = new HttpGet(metricsUrl);
+ try (CloseableHttpResponse response = httpClient.execute(request)) {
+ if (response.getStatusLine().getStatusCode() != 200) {
+ throw new IOException("HTTP request failed with status: " +
+ response.getStatusLine().getStatusCode());
+ }
+
+ String jsonResponse = EntityUtils.toString(response.getEntity());
+ return parseMetrics(jsonResponse, name, keyName);
+ } catch (IOException e) {
+ log.error("Error getting metrics from datanode: {}",
datanode.getIpAddress(), e);
+ }
+ return 0;
Review Comment:
Handled
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]