-
Notifications
You must be signed in to change notification settings - Fork 4k
ARROW-6867: [FlightRPC][Java] clean up default executor #5634
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,6 +18,8 @@ | |
| package org.apache.arrow.flight; | ||
|
|
||
| import java.io.File; | ||
| import java.util.concurrent.ExecutorService; | ||
| import java.util.concurrent.Executors; | ||
| import java.util.concurrent.atomic.AtomicBoolean; | ||
| import java.util.function.Consumer; | ||
|
|
||
|
|
@@ -54,6 +56,48 @@ public void builderConsumer() throws Exception { | |
| } | ||
| } | ||
|
|
||
| /** | ||
| * Make sure that if Flight supplies a default executor to gRPC, then it is closed along with the server. | ||
| */ | ||
| @Test | ||
| public void defaultExecutorClosed() throws Exception { | ||
| final ExecutorService executor; | ||
| try ( | ||
| BufferAllocator a = new RootAllocator(Long.MAX_VALUE); | ||
| FlightServer server = | ||
| FlightTestUtil.getStartedServer( | ||
| (location) -> FlightServer.builder(a, location, new NoOpFlightProducer()) | ||
| .build() | ||
| )) { | ||
| Assert.assertNotNull(server.grpcExecutor); | ||
| executor = server.grpcExecutor; | ||
| } | ||
|
||
| Assert.assertTrue(executor.isShutdown()); | ||
| } | ||
|
|
||
| /** | ||
| * Make sure that if the user provides an executor to gRPC, then Flight does not close it. | ||
| */ | ||
| @Test | ||
| public void suppliedExecutorNotClosed() throws Exception { | ||
| final ExecutorService executor = Executors.newSingleThreadExecutor(); | ||
| try { | ||
| try ( | ||
| BufferAllocator a = new RootAllocator(Long.MAX_VALUE); | ||
| FlightServer server = | ||
| FlightTestUtil.getStartedServer( | ||
| (location) -> FlightServer.builder(a, location, new NoOpFlightProducer()) | ||
| .executor(executor) | ||
| .build() | ||
| )) { | ||
| Assert.assertNull(server.grpcExecutor); | ||
| } | ||
| Assert.assertFalse(executor.isShutdown()); | ||
| } finally { | ||
| executor.shutdown(); | ||
| } | ||
| } | ||
|
|
||
| @Test | ||
| public void domainSocket() throws Exception { | ||
| Assume.assumeTrue("We have a native transport available", FlightTestUtil.isNativeTransportAvailable()); | ||
|
|
||
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.
I think you could avoid exposing this if you added this to awaitTermination as well (but that is a little tricky to do correctly). I'm OK if you don't want to do it.
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.
Hmm, how would that work in the test? We'd shut down the executor in awaitTermination and wait?
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.
I would have thought we shutdown the executorservice in shutdown
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.
Er, right. I can do that, but I still don't see how that'd let us avoid exposing it in test.
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.
i think it tests the behavior implicitly vs explicitly as the way you have it now. Like I said I'm fine with either approach.