-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Allow Reset of ThreadResourceUsageAccountant in Tracing.java #16360
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
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
999bd69
Allow reset of ThreadResourceUsageAccountant
vrajat d40c174
Bug fixes
vrajat b012b80
Revert call startWatcherTask
vrajat 01357c2
Improves interface
vrajat 1169b68
Also set Holder._accountant
vrajat 3ee247b
Initialize thread accountant in tests.
vrajat c03a08b
Revert how default thread accountant is created.
vrajat cc537d8
Add unregister
vrajat b411cc7
Stop the watcher task between tests
vrajat 7a15306
Checkstyle
vrajat e755950
Fix unit tests
vrajat 0974837
Reset ThreadAccountant
vrajat 58130ca
Dont set accountant to null if not registered
vrajat File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -54,7 +54,7 @@ public static class ResourceUsageAccountant implements ThreadResourceUsageAccoun | |
| private static final String ACCOUNTANT_TASK_NAME = "ResourceUsageAccountant"; | ||
| private static final int ACCOUNTANT_PRIORITY = 4; | ||
|
|
||
| private static final ExecutorService EXECUTOR_SERVICE = Executors.newFixedThreadPool(1, r -> { | ||
| private final ExecutorService _executorService = Executors.newFixedThreadPool(1, r -> { | ||
| Thread thread = new Thread(r); | ||
| thread.setPriority(ACCOUNTANT_PRIORITY); | ||
| thread.setDaemon(true); | ||
|
|
@@ -286,7 +286,12 @@ public void clear() { | |
|
|
||
| @Override | ||
| public void startWatcherTask() { | ||
| EXECUTOR_SERVICE.submit(_watcherTask); | ||
| _executorService.submit(_watcherTask); | ||
| } | ||
|
|
||
| @Override | ||
| public void stopWatcherTask() { | ||
| _executorService.shutdownNow(); | ||
| } | ||
|
|
||
| @Override | ||
|
|
@@ -315,7 +320,7 @@ class WatcherTask implements Runnable { | |
| @Override | ||
| public void run() { | ||
| LOGGER.debug("Running timed task for {}", this.getClass().getName()); | ||
| while (true) { | ||
| while (!Thread.currentThread().isInterrupted()) { | ||
|
||
| try { | ||
| // Preaggregation. | ||
| runPreAggregation(); | ||
|
|
||
This file contains hidden or 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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The while loop should also check the interrupted flag at the beginning of each iteration to ensure prompt response to interruption. Consider adding Thread.interrupted() check after the sleep/wait operations.