forked from deephaven/deephaven-core
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added SessionFactoryCreator and related helpers (deephaven#5386)
This is the java client related changes to support deephaven#5374. Note, that we may need to prioritize deephaven/web-client-ui#1947 as follow-up.
- Loading branch information
1 parent
8becc41
commit 66cede6
Showing
48 changed files
with
1,035 additions
and
240 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
Util/immutables/src/main/java/io/deephaven/annotations/CopyableStyle.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// | ||
// Copyright (c) 2016-2024 Deephaven Data Labs and Patent Pending | ||
// | ||
package io.deephaven.annotations; | ||
|
||
import org.immutables.value.Value; | ||
import org.immutables.value.Value.Style.ImplementationVisibility; | ||
|
||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import java.lang.annotation.Target; | ||
|
||
/** | ||
* A style for objects that should declare a builder interface to use for construction and allows copy. Recommended for | ||
* objects with more than two fields, or default fields. If copy is not needed, prefer {@link BuildableStyle}. | ||
*/ | ||
@Target({ElementType.TYPE, ElementType.PACKAGE}) | ||
@Retention(RetentionPolicy.CLASS) | ||
@Value.Style(visibility = ImplementationVisibility.PACKAGE, | ||
defaults = @Value.Immutable(copy = true), | ||
strictBuilder = true, | ||
weakInterning = true, | ||
jdkOnly = true, | ||
includeHashCode = "getClass().hashCode()") | ||
public @interface CopyableStyle { | ||
// Note: this produces ImmutableX.builder()s for the implementation classes | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 0 additions & 16 deletions
16
...nt/barrage-dagger/src/main/java/io/deephaven/client/impl/BarrageFactoryBuilderModule.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 0 additions & 22 deletions
22
java-client/barrage/src/main/java/io/deephaven/client/impl/BarrageSessionFactoryBuilder.java
This file was deleted.
Oops, something went wrong.
118 changes: 118 additions & 0 deletions
118
java-client/barrage/src/main/java/io/deephaven/client/impl/BarrageSessionFactoryConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
// | ||
// Copyright (c) 2016-2024 Deephaven Data Labs and Patent Pending | ||
// | ||
package io.deephaven.client.impl; | ||
|
||
import io.deephaven.annotations.BuildableStyle; | ||
import io.grpc.ManagedChannel; | ||
import org.apache.arrow.memory.BufferAllocator; | ||
import org.immutables.value.Value.Default; | ||
import org.immutables.value.Value.Immutable; | ||
|
||
import java.util.Objects; | ||
import java.util.concurrent.ScheduledExecutorService; | ||
|
||
@Immutable | ||
@BuildableStyle | ||
public abstract class BarrageSessionFactoryConfig { | ||
private static final SessionConfig SESSION_CONFIG_EMPTY = SessionConfig.builder().build(); | ||
|
||
public static Builder builder() { | ||
return ImmutableBarrageSessionFactoryConfig.builder(); | ||
} | ||
|
||
/** | ||
* The client configuration. | ||
*/ | ||
public abstract ClientConfig clientConfig(); | ||
|
||
/** | ||
* The client channel factory. By default is {@link ClientChannelFactory#defaultInstance()}. | ||
*/ | ||
@Default | ||
public ClientChannelFactory clientChannelFactory() { | ||
return ClientChannelFactory.defaultInstance(); | ||
} | ||
|
||
/** | ||
* The default session config, used by the factory when {@link SessionConfig} is not provided. By default is | ||
* {@code SessionConfig.builder().build()}. | ||
*/ | ||
@Default | ||
public SessionConfig sessionConfig() { | ||
return SESSION_CONFIG_EMPTY; | ||
} | ||
|
||
/** | ||
* The scheduler, used by the factory when {@link SessionConfig#scheduler()} is not set. | ||
*/ | ||
public abstract ScheduledExecutorService scheduler(); | ||
|
||
/** | ||
* The allocator. | ||
*/ | ||
public abstract BufferAllocator allocator(); | ||
|
||
/** | ||
* Creates a new factory with a new {@link ManagedChannel}. | ||
* | ||
* @return the factory | ||
*/ | ||
public final Factory factory() { | ||
return new Factory(SessionFactoryConfig.builder() | ||
.clientConfig(clientConfig()) | ||
.clientChannelFactory(clientChannelFactory()) | ||
.sessionConfig(sessionConfig()) | ||
.scheduler(scheduler()) | ||
.build() | ||
.factory()); | ||
} | ||
|
||
public final class Factory implements BarrageSessionFactory { | ||
private final SessionFactoryConfig.Factory factory; | ||
|
||
private Factory(SessionFactoryConfig.Factory factory) { | ||
this.factory = Objects.requireNonNull(factory); | ||
} | ||
|
||
@Override | ||
public BarrageSession newBarrageSession() { | ||
final Session session = factory.newSession(); | ||
return BarrageSession.of((SessionImpl) session, allocator(), factory.managedChannel()); | ||
} | ||
|
||
/** | ||
* Creates a new {@link BarrageSession} with {@code sessionConfig}. Closing the session does <b>not</b> close | ||
* the {@link #managedChannel()}. | ||
* | ||
* @param sessionConfig the session config | ||
* @return the new barrage session | ||
*/ | ||
public BarrageSession newBarrageSession(SessionConfig sessionConfig) { | ||
final Session session = factory.newSession(sessionConfig); | ||
return BarrageSession.of((SessionImpl) session, allocator(), factory.managedChannel()); | ||
} | ||
|
||
@Override | ||
public ManagedChannel managedChannel() { | ||
return factory.managedChannel(); | ||
} | ||
} | ||
|
||
// ------------------------------------------------ | ||
|
||
public interface Builder { | ||
|
||
Builder clientConfig(ClientConfig clientConfig); | ||
|
||
Builder clientChannelFactory(ClientChannelFactory clientChannelFactory); | ||
|
||
Builder sessionConfig(SessionConfig sessionConfig); | ||
|
||
Builder scheduler(ScheduledExecutorService scheduler); | ||
|
||
Builder allocator(BufferAllocator allocator); | ||
|
||
BarrageSessionFactoryConfig build(); | ||
} | ||
} |
Oops, something went wrong.