You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by ap...@apache.org on 2019/07/24 14:37:14 UTC
[arrow] branch master updated: ARROW-6017: [FlightRPC] Enable
creating Flight Locations for unknown schemes
This is an automated email from the ASF dual-hosted git repository.
apitrou 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 c930839 ARROW-6017: [FlightRPC] Enable creating Flight Locations for unknown schemes
c930839 is described below
commit c930839f24486e0fb722181a35af940bd04030a7
Author: David Li <li...@gmail.com>
AuthorDate: Wed Jul 24 16:36:58 2019 +0200
ARROW-6017: [FlightRPC] Enable creating Flight Locations for unknown schemes
The motivation is to enable interop with future Flight versions that may support different transports, and to enable a Flight service to reference a non-Flight service.
Personal Travis: https://travis-ci.com/lihalite/arrow/builds/120257110
AppVeyor: https://ci.appveyor.com/project/lihalite/arrow/builds/26189055
Closes #4928 from lihalite/arrow-6017 and squashes the following commits:
99c020757 <David Li> Enable creating Flight Locations for unknown schemes
Authored-by: David Li <li...@gmail.com>
Signed-off-by: Antoine Pitrou <an...@python.org>
---
cpp/src/arrow/flight/flight-test.cc | 8 +++++
.../java/org/apache/arrow/flight/Location.java | 26 ++++++++---------
.../apache/arrow/flight/TestBasicOperation.java | 34 ++++++++++++++++++----
python/pyarrow/tests/test_flight.py | 7 +++++
4 files changed, 56 insertions(+), 19 deletions(-)
diff --git a/cpp/src/arrow/flight/flight-test.cc b/cpp/src/arrow/flight/flight-test.cc
index e37de8b..63c7546 100644
--- a/cpp/src/arrow/flight/flight-test.cc
+++ b/cpp/src/arrow/flight/flight-test.cc
@@ -153,6 +153,14 @@ TEST(TestFlight, DISABLED_StartStopTestServer) {
ASSERT_FALSE(server.IsRunning());
}
+// ARROW-6017: we should be able to construct locations for unknown
+// schemes
+TEST(TestFlight, UnknownLocationScheme) {
+ Location location;
+ ASSERT_OK(Location::Parse("s3://test", &location));
+ ASSERT_OK(Location::Parse("https://example.com/foo", &location));
+}
+
TEST(TestFlight, ConnectUri) {
TestServer server("flight-test-server");
server.Start();
diff --git a/java/flight/src/main/java/org/apache/arrow/flight/Location.java b/java/flight/src/main/java/org/apache/arrow/flight/Location.java
index b4169fc..32556a2 100644
--- a/java/flight/src/main/java/org/apache/arrow/flight/Location.java
+++ b/java/flight/src/main/java/org/apache/arrow/flight/Location.java
@@ -43,22 +43,10 @@ public class Location {
* Construct a new instance from an existing URI.
*
* @param uri the URI of the Flight service
- * @throws IllegalArgumentException if the URI scheme is unsupported
*/
public Location(URI uri) {
super();
this.uri = uri;
- // Validate the scheme
- switch (uri.getScheme()) {
- case LocationSchemes.GRPC:
- case LocationSchemes.GRPC_DOMAIN_SOCKET:
- case LocationSchemes.GRPC_INSECURE:
- case LocationSchemes.GRPC_TLS: {
- break;
- }
- default:
- throw new IllegalArgumentException("Scheme is not supported: " + this.uri);
- }
}
public URI getUri() {
@@ -103,7 +91,11 @@ public class Location {
return Flight.Location.newBuilder().setUri(uri.toString()).build();
}
- /** Construct a URI for a Flight+gRPC server without transport security. */
+ /**
+ * Construct a URI for a Flight+gRPC server without transport security.
+ *
+ * @throws IllegalArgumentException if the constructed URI is invalid.
+ */
public static Location forGrpcInsecure(String host, int port) {
try {
return new Location(new URI(LocationSchemes.GRPC_INSECURE, null, host, port, null, null, null));
@@ -112,7 +104,11 @@ public class Location {
}
}
- /** Construct a URI for a Flight+gRPC server with transport security. */
+ /**
+ * Construct a URI for a Flight+gRPC server with transport security.
+ *
+ * @throws IllegalArgumentException if the constructed URI is invalid.
+ */
public static Location forGrpcTls(String host, int port) {
try {
return new Location(new URI(LocationSchemes.GRPC_TLS, null, host, port, null, null, null));
@@ -123,6 +119,8 @@ public class Location {
/**
* Construct a URI for a Flight+gRPC server over a Unix domain socket.
+ *
+ * @throws IllegalArgumentException if the constructed URI is invalid.
*/
public static Location forGrpcDomainSocket(String path) {
try {
diff --git a/java/flight/src/test/java/org/apache/arrow/flight/TestBasicOperation.java b/java/flight/src/test/java/org/apache/arrow/flight/TestBasicOperation.java
index abc5a2c..9a2c5e3 100644
--- a/java/flight/src/test/java/org/apache/arrow/flight/TestBasicOperation.java
+++ b/java/flight/src/test/java/org/apache/arrow/flight/TestBasicOperation.java
@@ -17,6 +17,7 @@
package org.apache.arrow.flight;
+import java.net.URI;
import java.net.URISyntaxException;
import java.util.Iterator;
import java.util.function.BiConsumer;
@@ -40,6 +41,27 @@ import com.google.protobuf.ByteString;
*/
public class TestBasicOperation {
+ /**
+ * ARROW-6017: we should be able to construct locations for unknown schemes.
+ */
+ @Test
+ public void unknownScheme() throws URISyntaxException {
+ final Location location = new Location("s3://unknown");
+ Assert.assertEquals("s3", location.getUri().getScheme());
+ }
+
+ @Test
+ public void unknownSchemeRemote() throws Exception {
+ test(c -> {
+ try {
+ final FlightInfo info = c.getInfo(FlightDescriptor.path("test"));
+ Assert.assertEquals(new URI("https://example.com"), info.getEndpoints().get(0).getLocations().get(0).getUri());
+ } catch (URISyntaxException e) {
+ throw new RuntimeException(e);
+ }
+ });
+ }
+
@Test
public void getDescriptors() throws Exception {
test(c -> {
@@ -246,12 +268,14 @@ public class TestBasicOperation {
@Override
public FlightInfo getFlightInfo(CallContext context,
FlightDescriptor descriptor) {
- Flight.FlightInfo getInfo = Flight.FlightInfo.newBuilder()
- .setFlightDescriptor(Flight.FlightDescriptor.newBuilder()
- .setType(DescriptorType.CMD)
- .setCmd(ByteString.copyFrom("cool thing", Charsets.UTF_8)))
- .build();
try {
+ Flight.FlightInfo getInfo = Flight.FlightInfo.newBuilder()
+ .setFlightDescriptor(Flight.FlightDescriptor.newBuilder()
+ .setType(DescriptorType.CMD)
+ .setCmd(ByteString.copyFrom("cool thing", Charsets.UTF_8)))
+ .addEndpoint(
+ Flight.FlightEndpoint.newBuilder().addLocation(new Location("https://example.com").toProtocol()))
+ .build();
return new FlightInfo(getInfo);
} catch (URISyntaxException e) {
throw new RuntimeException(e);
diff --git a/python/pyarrow/tests/test_flight.py b/python/pyarrow/tests/test_flight.py
index 89b9a95..2912e29 100644
--- a/python/pyarrow/tests/test_flight.py
+++ b/python/pyarrow/tests/test_flight.py
@@ -636,6 +636,13 @@ def test_location_invalid():
server.init("%")
+def test_location_unknown_scheme():
+ """Test creating locations for unknown schemes."""
+ assert flight.Location("s3://foo").uri == b"s3://foo"
+ assert flight.Location("https://example.com/bar.parquet").uri == \
+ b"https://example.com/bar.parquet"
+
+
@pytest.mark.slow
@pytest.mark.requires_testing_data
def test_tls_fails():