Skip to content

Commit

Permalink
Incorporated comment and add equals method
Browse files Browse the repository at this point in the history
Signed-off-by: Dhwanil Patel <dhwanip@amazon.com>
  • Loading branch information
dhwanilpatel committed Jan 16, 2023
1 parent da4303b commit 07c0d87
Showing 1 changed file with 23 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import java.io.IOException;
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.ConcurrentHashMap;

/**
Expand Down Expand Up @@ -73,7 +74,7 @@ public ClusterManagerThrottlingStats(StreamInput in) throws IOException {
@Override
public XContentBuilder toXContent(XContentBuilder builder, ToXContent.Params params) throws IOException {
builder.startObject("cluster_manager_throttling");
builder.startObject("cluster_manager_stats");
builder.startObject("stats");
builder.field("total_throttled_tasks", getTotalThrottledTaskCount());
builder.startObject("throttled_tasks_per_task_type");
for (Map.Entry<String, CounterMetric> entry : throttledTasksCount.entrySet()) {
Expand All @@ -84,4 +85,25 @@ public XContentBuilder toXContent(XContentBuilder builder, ToXContent.Params par
return builder.endObject();
}

public boolean equals(Object o) {
if (this == o) {
return true;
} else if (o != null && this.getClass() == o.getClass()) {
ClusterManagerThrottlingStats that = (ClusterManagerThrottlingStats) o;

if (this.throttledTasksCount.size() == that.throttledTasksCount.size()) {
for (Map.Entry<String, CounterMetric> entry : this.throttledTasksCount.entrySet()) {
if (!that.throttledTasksCount.get(entry.getKey()).equals(entry.getValue())) {
return false;
}
}
return true;
}
}
return false;
}

public int hashCode() {
return Objects.hash(new Object[] { this.throttledTasksCount });
}
}

0 comments on commit 07c0d87

Please sign in to comment.