New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dynamically change the processor thread name when consuming event #359
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jiajunwang
reviewed
Jul 24, 2019
helix-core/src/main/java/org/apache/helix/controller/GenericHelixController.java
Outdated
Show resolved
Hide resolved
helix-core/src/main/java/org/apache/helix/controller/GenericHelixController.java
Outdated
Show resolved
Hide resolved
helix-core/src/main/java/org/apache/helix/controller/GenericHelixController.java
Show resolved
Hide resolved
Could we format the PR per the guidelines? :)
…On Jul 24, 2019, 07:17, at 07:17, jiajunwang ***@***.***> wrote:
jiajunwang commented on this pull request.
> @@ -1165,7 +1164,11 @@ public void run() {
+ _processorName);
while (!isInterrupted()) {
try {
- handleEvent(_eventBlockingQueue.take(), _cache);
+ ClusterEvent newClusterEvent = _eventBlockingQueue.take();
+ // rename the current processor's thread name to include
event id
+ String currentThreadName = this.getName().split("_")[0];
The thread name shall be fixed, You can just regenerate the name
according to our name convention.
> @@ -1165,7 +1164,11 @@ public void run() {
+ _processorName);
while (!isInterrupted()) {
try {
- handleEvent(_eventBlockingQueue.take(), _cache);
+ ClusterEvent newClusterEvent = _eventBlockingQueue.take();
+ // rename the current processor's thread name to include
event id
+ String currentThreadName = this.getName().split("_")[0];
+ this.setName(currentThreadName + "_" +
newClusterEvent.getEventId());
Can we use "()" to wrap the event? I feel it's easier to identify which
part is the default thread name, and which part is the event name.
> @@ -1165,7 +1164,11 @@ public void run() {
+ _processorName);
while (!isInterrupted()) {
try {
- handleEvent(_eventBlockingQueue.take(), _cache);
+ ClusterEvent newClusterEvent = _eventBlockingQueue.take();
+ // rename the current processor's thread name to include
event id
+ String currentThreadName = this.getName().split("_")[0];
+ this.setName(currentThreadName + "_" +
newClusterEvent.getEventId());
+ handleEvent(newClusterEvent, _cache);
Would it be better to set the event id inside handleEvent()? Logic will
be more concise.
And remember that we'd better recover the thread name after the
handling logic. Probably in some final block.
--
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
#359 (review)
|
Please verify this in your local deployment to make sure it works as expected |
It's working as expected while running controller locally. What I did is to print the thread name, it's something like |
huizhilu
reviewed
Jul 26, 2019
helix-core/src/main/java/org/apache/helix/controller/GenericHelixController.java
Outdated
Show resolved
Hide resolved
lei-xia
reviewed
Jul 31, 2019
helix-core/src/main/java/org/apache/helix/controller/GenericHelixController.java
Show resolved
Hide resolved
narendly
reviewed
Jul 31, 2019
helix-core/src/main/java/org/apache/helix/controller/GenericHelixController.java
Show resolved
Hide resolved
lei-xia
approved these changes
Aug 1, 2019
This PR is ready to be merged, approved by @lei-xia |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Here are some details about my PR, including screenshots of any UI changes:
(Write a concise description including what, why, how)
What
Change the thread name at run time for processing every event.
Why?
It tries to solve the pain point when developers need to grep the entire log history of a single event based on its event id. We do add the event id in some of our pipeline stages, but it's not convenient and incomplete.
Modifying the running thread at run time whenever an event is consumed is much more convenient.
Example:
Tests
N/A
Manually tested, verified in the above example. It doesn't change any functionality of Helix.
Code Quality
My diff has been formatted using helix-style.xml