Skip to content
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

feat: Implement awaitTermination() for MangedHttpJsonChannel #1677

Merged
merged 14 commits into from Jun 2, 2023

Conversation

lqiu96
Copy link
Contributor

@lqiu96 lqiu96 commented May 12, 2023

Thank you for opening a Pull Request! For general contributing guidelines, please refer to contributing guide

Before submitting your PR, there are a few things you can do to make sure it goes smoothly:

  • Make sure to open an issue as a bug/issue before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea
  • Ensure the tests and linter pass
  • Code coverage does not decrease (if any source code was changed)
  • Appropriate docs were updated (if necessary)

Fixes: #1663

@product-auto-label product-auto-label bot added the size: m Pull request size is medium. label May 12, 2023
@lqiu96 lqiu96 marked this pull request as ready for review May 12, 2023 19:18
@lqiu96 lqiu96 requested a review from a team as a code owner May 12, 2023 19:18
@lqiu96 lqiu96 added the owlbot:run Add this label to trigger the Owlbot post processor. label May 12, 2023
@gcf-owl-bot gcf-owl-bot bot removed the owlbot:run Add this label to trigger the Owlbot post processor. label May 12, 2023
@lqiu96
Copy link
Contributor Author

lqiu96 commented May 18, 2023

Added additional comments to the PR. I'll add a section for our docs.

Copy link
Collaborator

@blakeli0 blakeli0 left a comment

Choose a reason for hiding this comment

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

Thanks Lawrence, the general approach makes sense if we can confirm that using a default executor from InstantiatingHttpJsonChannelProvider is fine. Also can you please add some tests to it? I know we didn't have any unit tests for it previously and it would be tricky to test executors.

@@ -54,6 +54,9 @@ public Thread newThread(Runnable runnable) {
return thread;
}
};
private static final int MIN_CPU_AMOUNT = 4;
Copy link
Collaborator

Choose a reason for hiding this comment

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

This should be MIN_THREAD_AMOUNT?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure. Updating.

public static Builder newBuilder() {
int numCpus = Runtime.getRuntime().availableProcessors();
int numThreads = Math.max(4, numCpus);
int numThreads = Math.max(MIN_CPU_AMOUNT, numCpus);
Copy link
Collaborator

Choose a reason for hiding this comment

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

I was expecting this change only in ManagedHttpJsonChannel, changing it here should be fine as well, but be aware that changing this in InstantiatingExecutorProvider would affect the current background tasks used for grpc.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Makes sense.I created a new builder: newIOBuilder that should only be used for HttpJson's async calls and wouldn't change the background executor.

@sonarcloud
Copy link

sonarcloud bot commented Jun 2, 2023

[gapic-generator-java-root] SonarCloud Quality Gate failed.    Quality Gate failed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 3 Code Smells

44.9% 44.9% Coverage
0.0% 0.0% Duplication

@sonarcloud
Copy link

sonarcloud bot commented Jun 2, 2023

[java_showcase_integration_tests] SonarCloud Quality Gate failed.    Quality Gate failed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 3 Code Smells

41.6% 41.6% Coverage
0.0% 0.0% Duplication

@sonarcloud
Copy link

sonarcloud bot commented Jun 2, 2023

[java_showcase_unit_tests] SonarCloud Quality Gate failed.    Quality Gate failed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 3 Code Smells

47.2% 47.2% Coverage
0.0% 0.0% Duplication

@lqiu96 lqiu96 merged commit dea8426 into main Jun 2, 2023
15 of 18 checks passed
@lqiu96 lqiu96 deleted the main-implement_await_termination branch June 2, 2023 21:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size: m Pull request size is medium.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement awaitTermination() for HttpJson's Channel
3 participants