Skip to content

[CELEBORN-2376] Filter empty ResourceConsumption entries in WorkerInfo toString output#3754

Open
gaoyajun02 wants to merge 1 commit into
apache:mainfrom
gaoyajun02:CELEBORN-2376
Open

[CELEBORN-2376] Filter empty ResourceConsumption entries in WorkerInfo toString output#3754
gaoyajun02 wants to merge 1 commit into
apache:mainfrom
gaoyajun02:CELEBORN-2376

Conversation

@gaoyajun02

Copy link
Copy Markdown

What changes were proposed in this pull request?

Added an isEmpty() method to ResourceConsumption that returns true when all four counters (diskBytesWritten, diskFileCount, hdfsBytesWritten, hdfsFileCount) are zero and subResourceConsumptions is empty.

WorkerInfo.toString now uses this method to skip users with no active resource consumption, so that only entries with non-zero usage are included in the output. An additional guard handles the edge case where all entries are filtered out, falling back to "empty" rather than producing a blank string.

Why are the changes needed?

In clusters with many registered users, WorkerInfo.toString — surfaced in both HTTP API responses and log output — can include a large number of entries like:

UserIdentifier: tenant1.user1, ResourceConsumption(diskBytesWritten: 0 B, diskFileCount: 0, hdfsBytesWritten: 0 B, hdfsFileCount: 0, subResourceConsumptions: empty)

These zero-value entries carry no operational information and add noise that makes it harder to identify active workloads at a glance. Filtering them out keeps the output focused on users with actual resource usage.

Does this PR resolve a correctness bug?

  • Yes

Does this PR introduce any user-facing change?

  • Yes

WorkerInfo.toString output (returned by GET /api/v1/workers and visible in Worker logs) will no longer include users whose resource consumption is entirely zero.

How was this patch tested?

Covered by existing unit tests.

…ng output

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

Comment on lines 269 to +273
val userResourceConsumptionString =
if (userResourceConsumption == null || userResourceConsumption.isEmpty) {
"empty"
} else if (userResourceConsumption != null) {
userResourceConsumption.asScala.map { case (userIdentifier, resourceConsumption) =>
s"\n UserIdentifier: ${userIdentifier}, ResourceConsumption: ${resourceConsumption}"
}.mkString("")
val nonEmpty = userResourceConsumption.asScala.filterNot(_._2.isEmpty)
Comment on lines +273 to +277
val nonEmpty = userResourceConsumption.asScala.filterNot(_._2.isEmpty)
if (nonEmpty.isEmpty) {
"empty"
} else {
nonEmpty.map { case (userIdentifier, resourceConsumption) =>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants