Skip to content

Commit 2214a26

Browse files
authored
Update to latest Deephaven version and remove dependency on dagger (#2)
This updates to the newer, recommended way of creating sessions. It removes the dependency on dagger and presents a ClientConfig object. See deephaven/deephaven-core#5386
1 parent 6ab103d commit 2214a26

File tree

3 files changed

+23
-19
lines changed

3 files changed

+23
-19
lines changed

build.gradle

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ repositories {
1212

1313
dependencies {
1414
implementation "io.deephaven:deephaven-java-client-barrage"
15-
implementation "io.deephaven:deephaven-java-client-barrage-dagger"
1615
implementation platform("io.deephaven:deephaven-bom:$dhcVersion")
1716

1817
runtimeOnly "io.deephaven:deephaven-log-to-slf4j"

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
dhcVersion=0.33.2
1+
dhcVersion=0.34.2

src/main/java/io/deephaven/examples/BasicJavaClientExample.java

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package io.deephaven.examples;
22

33
import io.deephaven.client.impl.*;
4+
import io.deephaven.client.impl.BarrageSessionFactoryConfig.Factory;
45
import io.deephaven.engine.table.Table;
56
import io.deephaven.engine.util.TableTools;
67
import io.deephaven.extensions.barrage.util.BarrageUtil;
@@ -10,11 +11,11 @@
1011
import io.deephaven.qst.table.NewTable;
1112
import io.deephaven.qst.table.TableHeader;
1213
import io.deephaven.qst.table.TableSpec;
13-
import io.grpc.ManagedChannel;
14-
import io.grpc.ManagedChannelBuilder;
14+
import io.deephaven.uri.DeephavenTarget;
1515
import org.apache.arrow.memory.BufferAllocator;
1616
import org.apache.arrow.memory.RootAllocator;
1717

18+
import java.net.URI;
1819
import java.util.concurrent.Executors;
1920
import java.util.concurrent.ScheduledExecutorService;
2021
import java.util.concurrent.TimeUnit;
@@ -47,28 +48,32 @@ public static void main(String[] args) throws Exception {
4748
// Create a BufferAllocator. (This is used by the underlying Flight implementation.)
4849
final BufferAllocator bufferAllocator = new RootAllocator();
4950

50-
// Create the ManagedChannel. This defines the underlying connection to the Deephaven server.
51-
final ManagedChannel managedChannel = ManagedChannelBuilder.forTarget("localhost:10000")
52-
.usePlaintext() // Use '.useTransportSecurity()' if TLS is enabled on the server
53-
.build();
54-
5551
// Create a scheduler thread pool. This is used by the Flight session.
5652
final ScheduledExecutorService threadPool = Executors.newScheduledThreadPool(4);
5753

54+
// ClientConfig describes the configuration to connect to the host
55+
final ClientConfig config = ClientConfig.builder()
56+
.target(DeephavenTarget.of(URI.create("dh+plain://localhost:10000")))
57+
.build();
58+
59+
// SessionConfig describes the configuration needed to create a session
60+
final SessionConfig sessionConfig = SessionConfig.builder()
61+
.authenticationTypeAndValue("io.deephaven.authentication.psk.PskAuthenticationHandler " + pskString)
62+
.build();
63+
5864
// Create a FlightSessionFactory. This stitches together the above components to create the real, live
5965
// API session with the server.
60-
final BarrageSessionFactory barrageSessionFactory =
61-
DaggerDeephavenBarrageRoot.create().factoryBuilder()
62-
.managedChannel(managedChannel)
63-
.scheduler(threadPool)
64-
.allocator(bufferAllocator)
65-
.authenticationTypeAndValue("io.deephaven.authentication.psk.PskAuthenticationHandler " + pskString)
66-
.build();
66+
final Factory factory = BarrageSessionFactoryConfig.builder()
67+
.clientConfig(config)
68+
.allocator(bufferAllocator)
69+
.scheduler(threadPool)
70+
.build()
71+
.factory();
6772

6873
// Create the Flight session and retrieve the underlying client API session.
69-
try (final BarrageSession barrageSession = barrageSessionFactory.newBarrageSession();
70-
final Session clientSession = barrageSession.session()
71-
) {
74+
try (
75+
final BarrageSession barrageSession = factory.newBarrageSession(sessionConfig);
76+
final Session clientSession = barrageSession.session()) {
7277

7378
// Define an append-only "InputTable" on the server. The client can send data to the server to append to this.
7479
final TableSpec inputTableSpec = InMemoryAppendOnlyInputTable.of(TableHeader.of(

0 commit comments

Comments
 (0)