ChenSammi commented on code in PR #10426:
URL: https://github.com/apache/ozone/pull/10426#discussion_r3411408670
##########
hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/api/DataNodeMetricsService.java:
##########
@@ -301,27 +302,40 @@ private void resetState() {
totalNodesFailed = 0;
}
- public DataNodeMetricsServiceResponse getCollectedMetrics(Integer limit) {
+ /**
+ * Returns either {@link DataNodeMetricsCompleteResponse} when collection is
+ * finished, or {@link DataNodeMetricsProgressResponse} otherwise.
+ */
+ public Object getCollectedMetrics(Integer limit) {
startTask();
if (currentStatus == MetricCollectionStatus.FINISHED) {
- DataNodeMetricsServiceResponse.Builder dnMetricsBuilder =
DataNodeMetricsServiceResponse.newBuilder();
- dnMetricsBuilder
- .setStatus(currentStatus)
- .setTotalPendingDeletionSize(totalPendingDeletion)
- .setTotalNodesQueried(totalNodesQueried)
- .setTotalNodeQueryFailures(totalNodesFailed);
+ List<DatanodePendingDeletionMetrics> list =
+ (limit == null) ? pendingDeletionList :
+ pendingDeletionList.subList(0, Math.min(limit,
pendingDeletionList.size()));
+ return new DataNodeMetricsCompleteResponse(
+ currentStatus,
+ totalNodesQueried,
+ totalNodesFailed,
+ totalPendingDeletion,
+ list);
+ }
- if (null == limit) {
- return
dnMetricsBuilder.setPendingDeletion(pendingDeletionList).build();
- } else {
- return dnMetricsBuilder.setPendingDeletion(
- pendingDeletionList.subList(0, Math.min(limit,
pendingDeletionList.size())
- )).build();
- }
+ return new DataNodeMetricsProgressResponse(
+ currentStatus,
+ buildProgressMessage(currentStatus));
+ }
+
+ private static String buildProgressMessage(MetricCollectionStatus status) {
+ switch (status) {
+ case IN_PROGRESS:
+ return "Metrics collection task is currently running. Please wait for
task to finish.";
+ case FAILED:
Review Comment:
Will the metrics collection task auto retry itself? If no, then it's
doesn't make sense to category FAILED as in progress state.
Do we reply the failure reason to API caller?
--
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]