hemantk-12 commented on code in PR #5760:
URL: https://github.com/apache/ozone/pull/5760#discussion_r1422416036
##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/safemode/ContainerSafeModeRule.java:
##########
@@ -139,11 +141,28 @@ protected synchronized void cleanup() {
@Override
public String getStatusText() {
- return String
- .format(
- "%% of containers with at least one reported replica (=%1.2f) >= "
- + "safeModeCutoff (=%1.2f)",
- getCurrentContainerThreshold(), this.safeModeCutoff);
+ List<Long> sampleContainers = new ArrayList<>();
+ if (!containerMap.isEmpty()) {
Review Comment:
nit: I think this `if` check is not needed. `containerMap.keySet()` will be
empty set if `containerMap` is empty.
```suggestion
int count = 0;
for (long cId : containerMap.keySet()) {
if (count < SAMPLE_CONTAINER_DISPLAY_LIMIT) {
sampleContainers.add(cId);
count++;
}
}
```
To make it nicer you can use stream:
```
List<String> sampleContainers = containerMap.keySet()
.stream()
.limit(SAMPLE_CONTAINER_DISPLAY_LIMIT)
.collect(Collectors.toList());
```
or guava library:
```
List<String> sampleContainers =
ImmutableList.copyOf(Iterables.limit(containerMap.keySet(),
SAMPLE_CONTAINER_DISPLAY_LIMIT));
```
--
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]