Skip to content

Conversation

@beliefer
Copy link
Contributor

What is the purpose of the change

This PR aims to improve the comments and variable names for TaskMailbox.
There are some improvement points show below.

  • message -> mail. mail is a more suitable name in the context of TaskMailbox.

  • Adds comments to increasing the readability of tryTake and take. These comments show below.
    Note that the priority is given to retrieving email from the head of batch, and when email cannot be retrieved from the batch, it is retrieved from the head of queue. This also means that emails in batch are older than emails in queue.

  • Supplement the missing exception into comments.

  • The default batch is empty. -> By default, the batch is empty.. The latter is more accurate.

  • (head of queue) -> (head of batch). We only fetch the head mail from the batch not the queue with tryTakeFromBatch.

  • head -> headEmail. The latter is a better variable name. Some code uses headEmail and other uses head before this PR. We should unify the name.

  • Move the size() in TaskMailboxImpl so that it follows the order of the declaration in the interface TaskMailbox.

Brief change log

Improve the comments and variable names for TaskMailbox.

Verifying this change

This change is a trivial rework / code cleanup without any test coverage.

Does this pull request potentially affect one of the following parts:

  • Dependencies (does it add or upgrade a dependency): (no)
  • The public API, i.e., is any changed class annotated with @Public(Evolving): (no)
  • The serializers: (no)
  • The runtime per-record code paths (performance sensitive): (no)
  • Anything that affects deployment or recovery: JobManager (and its components), Checkpointing, Kubernetes/Yarn, ZooKeeper: (no)
  • The S3 file system connector: (no)

Documentation

  • Does this pull request introduce a new feature? (no)


/**
* The maximal priority for mails. This priority indicates that the message should be performed
* The maximal priority for mails. This priority indicates that the mail should be performed
Copy link
Contributor Author

Choose a reason for hiding this comment

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

message -> mail. mail is a more suitable name in the context of TaskMailbox.

* Returns an optional with either the oldest mail from the mailbox if the mailbox is not empty
* or an empty optional otherwise. Note that the priority is given to retrieving email from the
* head of batch, and when email cannot be retrieved from the batch, it is retrieved from the
* head of queue. This also means that emails in batch are older than emails in queue.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Adds comments to increasing the readability of tryTake and take. These comments show below.
Note that the priority is given to retrieving email from the head of batch, and when email cannot be retrieved from the batch, it is retrieved from the head of queue. This also means that emails in batch are older than emails in queue.

* @return an optional with either the oldest mail from the mailbox (head of queue) if the
* mailbox is not empty or an empty optional otherwise.
* @throws IllegalStateException if mailbox is already closed.
* @throws MailboxClosedException if mailbox is already closed.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Supplement the missing exception into comments.

* even if no batch had been created.
*
* <p>The default batch is empty. Thus, this method must be invoked once before {@link
* <p>By default, the batch is empty. Thus, this method must be invoked once before {@link
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The default batch is empty. -> By default, the batch is empty.. The latter is more accurate.


/**
* Returns an optional with either the oldest mail from the batch (head of queue) if the batch
* Returns an optional with either the oldest mail from the batch (head of batch) if the batch
Copy link
Contributor Author

Choose a reason for hiding this comment

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

(head of queue) -> (head of batch). We only fetch the head mail from the batch not the queue with tryTakeFromBatch.

lock.unlock();
}
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Move the size() in TaskMailboxImpl so that it follows the order of the declaration in the interface TaskMailbox.

return Optional.of(head);
Mail headEmail = takeOrNull(batch, priority);
if (headEmail != null) {
return Optional.of(headEmail);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

head -> headEmail. The latter is a better variable name. Some code uses headEmail and other uses head before this PR. We should unify the name.

@flinkbot
Copy link
Collaborator

flinkbot commented Apr 16, 2025

CI report:

Bot commands The @flinkbot bot supports the following commands:
  • @flinkbot run azure re-run the last Azure build

@beliefer
Copy link
Contributor Author

@github-actions github-actions bot added community-reviewed PR has been reviewed by the community. and removed component=Runtime/Task community-reviewed PR has been reviewed by the community. labels Jun 30, 2025
@github-actions github-actions bot added community-reviewed PR has been reviewed by the community. and removed community-reviewed PR has been reviewed by the community. labels Aug 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

community-reviewed PR has been reviewed by the community.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants