|
1 | 1 | package io.deephaven.examples; |
2 | 2 |
|
3 | 3 | import io.deephaven.client.impl.*; |
| 4 | +import io.deephaven.client.impl.BarrageSessionFactoryConfig.Factory; |
4 | 5 | import io.deephaven.engine.table.Table; |
5 | 6 | import io.deephaven.engine.util.TableTools; |
6 | 7 | import io.deephaven.extensions.barrage.util.BarrageUtil; |
|
10 | 11 | import io.deephaven.qst.table.NewTable; |
11 | 12 | import io.deephaven.qst.table.TableHeader; |
12 | 13 | import io.deephaven.qst.table.TableSpec; |
13 | | -import io.grpc.ManagedChannel; |
14 | | -import io.grpc.ManagedChannelBuilder; |
| 14 | +import io.deephaven.uri.DeephavenTarget; |
15 | 15 | import org.apache.arrow.memory.BufferAllocator; |
16 | 16 | import org.apache.arrow.memory.RootAllocator; |
17 | 17 |
|
| 18 | +import java.net.URI; |
18 | 19 | import java.util.concurrent.Executors; |
19 | 20 | import java.util.concurrent.ScheduledExecutorService; |
20 | 21 | import java.util.concurrent.TimeUnit; |
@@ -47,28 +48,32 @@ public static void main(String[] args) throws Exception { |
47 | 48 | // Create a BufferAllocator. (This is used by the underlying Flight implementation.) |
48 | 49 | final BufferAllocator bufferAllocator = new RootAllocator(); |
49 | 50 |
|
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 | | - |
55 | 51 | // Create a scheduler thread pool. This is used by the Flight session. |
56 | 52 | final ScheduledExecutorService threadPool = Executors.newScheduledThreadPool(4); |
57 | 53 |
|
| 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 | + |
58 | 64 | // Create a FlightSessionFactory. This stitches together the above components to create the real, live |
59 | 65 | // 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(); |
67 | 72 |
|
68 | 73 | // 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()) { |
72 | 77 |
|
73 | 78 | // Define an append-only "InputTable" on the server. The client can send data to the server to append to this. |
74 | 79 | final TableSpec inputTableSpec = InMemoryAppendOnlyInputTable.of(TableHeader.of( |
|
0 commit comments