Skip to content

Commit

Permalink
feat(java/driver/flight-sql): add basic auth (#1487)
Browse files Browse the repository at this point in the history
- Removed unused FlightClient from `FlightSqlDatabase`
- FlightClient creation moved from `FlightSqlDatabase` to
`FlightSqlConnection`.
- Use separate allocators for each FlightClient.
- Add HTTP basic auth (username/password).
- Add support for arbitrary headers.
- Add support for TLS and mTLS
- Add the arrow-testing library as a submodule for TLS certificates.
- Update CI for arrow-testing library.

---------

Co-authored-by: tokoko <togurg14@freeuni.edu.ge>
  • Loading branch information
jduo and tokoko committed Feb 2, 2024
1 parent 1d7dbfe commit 5e21134
Show file tree
Hide file tree
Showing 19 changed files with 1,226 additions and 70 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/java.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ jobs:
with:
fetch-depth: 0
persist-credentials: false
submodules: recursive
- uses: actions/setup-java@v4
with:
cache: "maven"
Expand Down Expand Up @@ -81,6 +82,7 @@ jobs:
with:
fetch-depth: 0
persist-credentials: false
submodules: recursive
- uses: actions/setup-java@v4
with:
cache: "maven"
Expand Down
20 changes: 20 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

[submodule "testing"]
path = testing
url = https://github.com/apache/arrow-testing.git
1 change: 0 additions & 1 deletion java/driver-manager/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
<dependency>
<groupId>org.apache.arrow</groupId>
<artifactId>arrow-memory-unsafe</artifactId>
<version>${dep.arrow.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
Expand Down
38 changes: 38 additions & 0 deletions java/driver/flight-sql/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -78,5 +78,43 @@
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
<scope>test</scope>
</dependency>
<!-- To use FlightSeverTestRule from arrow-flight-sql-jdbc-core -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.arrow</groupId>
<artifactId>flight-sql-jdbc-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.arrow</groupId>
<artifactId>flight-sql-jdbc-core</artifactId>
<version>${dep.arrow.version}</version>
<scope>test</scope>
<classifier>tests</classifier>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration combine.self="append">
<systemPropertyVariables>
<arrow.test.dataRoot>${project.basedir}/../../../testing/data</arrow.test.dataRoot>
</systemPropertyVariables>
</configuration>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,10 @@
import java.util.Objects;
import org.apache.arrow.adbc.core.AdbcException;
import org.apache.arrow.adbc.core.AdbcStatusCode;
import org.apache.arrow.flight.FlightClient;
import org.apache.arrow.flight.FlightEndpoint;
import org.apache.arrow.flight.FlightRuntimeException;
import org.apache.arrow.flight.FlightStream;
import org.apache.arrow.flight.Location;
import org.apache.arrow.flight.sql.FlightSqlClient;
import org.apache.arrow.memory.BufferAllocator;
import org.apache.arrow.vector.VectorSchemaRoot;
import org.apache.arrow.vector.VectorUnloader;
Expand All @@ -40,17 +38,17 @@
/** An ArrowReader that wraps a FlightInfo. */
public class FlightInfoReader extends ArrowReader {
private final Schema schema;
private final FlightSqlClient client;
private final LoadingCache<Location, FlightClient> clientCache;
private final FlightSqlClientWithCallOptions client;
private final LoadingCache<Location, FlightSqlClientWithCallOptions> clientCache;
private final List<FlightEndpoint> flightEndpoints;
private int nextEndpointIndex;
private FlightStream currentStream;
private long bytesRead;

FlightInfoReader(
BufferAllocator allocator,
FlightSqlClient client,
LoadingCache<Location, FlightClient> clientCache,
FlightSqlClientWithCallOptions client,
LoadingCache<Location, FlightSqlClientWithCallOptions> clientCache,
List<FlightEndpoint> flightEndpoints)
throws AdbcException {
super(allocator);
Expand Down
Loading

0 comments on commit 5e21134

Please sign in to comment.