You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by we...@apache.org on 2019/04/04 19:54:00 UTC
[arrow] branch master updated: ARROW-4625: [Flight][Java] Add
method to await Flight server termination in Java
This is an automated email from the ASF dual-hosted git repository.
wesm pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/arrow.git
The following commit(s) were added to refs/heads/master by this push:
new e20dc90 ARROW-4625: [Flight][Java] Add method to await Flight server termination in Java
e20dc90 is described below
commit e20dc90a5c8b408695740d4eaa142d74f473ee44
Author: David Li <Da...@twosigma.com>
AuthorDate: Thu Apr 4 14:53:53 2019 -0500
ARROW-4625: [Flight][Java] Add method to await Flight server termination in Java
Apologies for all the tiny PRs...trying to clean up some small API things we've run into.
Author: David Li <Da...@twosigma.com>
Closes #4110 from lihalite/arrow-4625 and squashes the following commits:
1e0d67f3b <David Li> Add method to await Flight server termination in Java
---
.../src/main/java/org/apache/arrow/flight/FlightServer.java | 5 +++++
.../java/org/apache/arrow/flight/example/ExampleFlightServer.java | 8 +++++---
.../arrow/flight/example/integration/IntegrationTestServer.java | 4 +---
.../src/test/java/org/apache/arrow/flight/perf/TestPerf.java | 5 +----
4 files changed, 12 insertions(+), 10 deletions(-)
diff --git a/java/flight/src/main/java/org/apache/arrow/flight/FlightServer.java b/java/flight/src/main/java/org/apache/arrow/flight/FlightServer.java
index 80c1624..9aaffb8 100644
--- a/java/flight/src/main/java/org/apache/arrow/flight/FlightServer.java
+++ b/java/flight/src/main/java/org/apache/arrow/flight/FlightServer.java
@@ -62,6 +62,11 @@ public class FlightServer implements AutoCloseable {
return server.getPort();
}
+ /** Block until the server shuts down. */
+ public void awaitTermination() throws InterruptedException {
+ server.awaitTermination();
+ }
+
public void close() throws InterruptedException {
server.shutdown();
final boolean terminated = server.awaitTermination(3000, TimeUnit.MILLISECONDS);
diff --git a/java/flight/src/main/java/org/apache/arrow/flight/example/ExampleFlightServer.java b/java/flight/src/main/java/org/apache/arrow/flight/example/ExampleFlightServer.java
index 2a73269..7bb1fb5 100644
--- a/java/flight/src/main/java/org/apache/arrow/flight/example/ExampleFlightServer.java
+++ b/java/flight/src/main/java/org/apache/arrow/flight/example/ExampleFlightServer.java
@@ -53,6 +53,10 @@ public class ExampleFlightServer implements AutoCloseable {
flightServer.start();
}
+ public void awaitTermination() throws InterruptedException {
+ flightServer.awaitTermination();
+ }
+
public InMemoryStore getStore() {
return mem;
}
@@ -74,8 +78,6 @@ public class ExampleFlightServer implements AutoCloseable {
e.printStackTrace();
}
}));
- while (true) {
- Thread.sleep(30000);
- }
+ efs.awaitTermination();
}
}
diff --git a/java/flight/src/main/java/org/apache/arrow/flight/example/integration/IntegrationTestServer.java b/java/flight/src/main/java/org/apache/arrow/flight/example/integration/IntegrationTestServer.java
index eff2f5d..fdad5d1 100644
--- a/java/flight/src/main/java/org/apache/arrow/flight/example/integration/IntegrationTestServer.java
+++ b/java/flight/src/main/java/org/apache/arrow/flight/example/integration/IntegrationTestServer.java
@@ -57,9 +57,7 @@ class IntegrationTestServer {
}
}));
- while (true) {
- Thread.sleep(30000);
- }
+ efs.awaitTermination();
}
public static void main(String[] args) {
diff --git a/java/flight/src/test/java/org/apache/arrow/flight/perf/TestPerf.java b/java/flight/src/test/java/org/apache/arrow/flight/perf/TestPerf.java
index 1047c97..d580fe2 100644
--- a/java/flight/src/test/java/org/apache/arrow/flight/perf/TestPerf.java
+++ b/java/flight/src/test/java/org/apache/arrow/flight/perf/TestPerf.java
@@ -85,9 +85,6 @@ public class TestPerf {
new Location(FlightTestUtil.LOCALHOST, port)));
final FlightClient client = new FlightClient(a, server.getLocation());
) {
-
- server.start();
-
final FlightInfo info = client.getInfo(getPerfFlightDescriptor(50_000_000L, 4095, 2));
ListeningExecutorService pool = MoreExecutors.listeningDecorator(Executors.newFixedThreadPool(4));
List<ListenableFuture<Result>> results = info.getEndpoints()
@@ -104,7 +101,7 @@ public class TestPerf {
double seconds = r.nanos * 1.0d / 1000 / 1000 / 1000;
System.out.println(String.format(
- "Transferred %d records totaling %s bytes at %f mb/s. %f record/s. %f batch/s.",
+ "Transferred %d records totaling %s bytes at %f MiB/s. %f record/s. %f batch/s.",
r.rows,
r.bytes,
(r.bytes * 1.0d / 1024 / 1024) / seconds,