Package io.grpc.netty
Class NettyChannelBuilder.NettyTransportFactory
- java.lang.Object
-
- io.grpc.netty.NettyChannelBuilder.NettyTransportFactory
-
- All Implemented Interfaces:
ClientTransportFactory
,java.io.Closeable
,java.lang.AutoCloseable
- Enclosing class:
- NettyChannelBuilder
private static final class NettyChannelBuilder.NettyTransportFactory extends java.lang.Object implements ClientTransportFactory
Creates Netty transports. Exposed for internal use, as it should be private.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface io.grpc.internal.ClientTransportFactory
ClientTransportFactory.ClientTransportOptions, ClientTransportFactory.SwapChannelCredentialsResult
-
-
Field Summary
Fields Modifier and Type Field Description private boolean
autoFlowControl
private io.netty.channel.ChannelFactory<? extends io.netty.channel.Channel>
channelFactory
private java.util.Map<io.netty.channel.ChannelOption<?>,?>
channelOptions
private boolean
closed
private int
flowControlWindow
private io.netty.channel.EventLoopGroup
group
private ObjectPool<? extends io.netty.channel.EventLoopGroup>
groupPool
private AtomicBackoff
keepAliveBackoff
private long
keepAliveTimeNanos
private long
keepAliveTimeoutNanos
private boolean
keepAliveWithoutCalls
private NettyChannelBuilder.LocalSocketPicker
localSocketPicker
private int
maxHeaderListSize
private int
maxMessageSize
private ProtocolNegotiator
protocolNegotiator
private java.lang.Class<? extends java.net.SocketAddress>
transportSocketType
private TransportTracer.Factory
transportTracerFactory
private boolean
useGetForSafeMethods
-
Constructor Summary
Constructors Constructor Description NettyTransportFactory(ProtocolNegotiator protocolNegotiator, io.netty.channel.ChannelFactory<? extends io.netty.channel.Channel> channelFactory, java.util.Map<io.netty.channel.ChannelOption<?>,?> channelOptions, ObjectPool<? extends io.netty.channel.EventLoopGroup> groupPool, boolean autoFlowControl, int flowControlWindow, int maxMessageSize, int maxHeaderListSize, long keepAliveTimeNanos, long keepAliveTimeoutNanos, boolean keepAliveWithoutCalls, TransportTracer.Factory transportTracerFactory, NettyChannelBuilder.LocalSocketPicker localSocketPicker, boolean useGetForSafeMethods, java.lang.Class<? extends java.net.SocketAddress> transportSocketType)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
Releases any resources.java.util.concurrent.ScheduledExecutorService
getScheduledExecutorService()
Returns an executor for scheduling provided by the transport.java.util.Collection<java.lang.Class<? extends java.net.SocketAddress>>
getSupportedSocketAddressTypes()
Returns theSocketAddress
types this transport supports.ConnectionClientTransport
newClientTransport(java.net.SocketAddress serverAddress, ClientTransportFactory.ClientTransportOptions options, ChannelLogger channelLogger)
Creates an unstarted transport for exclusive use.ClientTransportFactory.SwapChannelCredentialsResult
swapChannelCredentials(ChannelCredentials channelCreds)
Swaps to a new ChannelCredentials with all other settings unchanged.
-
-
-
Field Detail
-
protocolNegotiator
private final ProtocolNegotiator protocolNegotiator
-
channelFactory
private final io.netty.channel.ChannelFactory<? extends io.netty.channel.Channel> channelFactory
-
channelOptions
private final java.util.Map<io.netty.channel.ChannelOption<?>,?> channelOptions
-
groupPool
private final ObjectPool<? extends io.netty.channel.EventLoopGroup> groupPool
-
group
private final io.netty.channel.EventLoopGroup group
-
autoFlowControl
private final boolean autoFlowControl
-
flowControlWindow
private final int flowControlWindow
-
maxMessageSize
private final int maxMessageSize
-
maxHeaderListSize
private final int maxHeaderListSize
-
keepAliveTimeNanos
private final long keepAliveTimeNanos
-
keepAliveBackoff
private final AtomicBackoff keepAliveBackoff
-
keepAliveTimeoutNanos
private final long keepAliveTimeoutNanos
-
keepAliveWithoutCalls
private final boolean keepAliveWithoutCalls
-
transportTracerFactory
private final TransportTracer.Factory transportTracerFactory
-
localSocketPicker
private final NettyChannelBuilder.LocalSocketPicker localSocketPicker
-
useGetForSafeMethods
private final boolean useGetForSafeMethods
-
closed
private boolean closed
-
transportSocketType
private final java.lang.Class<? extends java.net.SocketAddress> transportSocketType
-
-
Constructor Detail
-
NettyTransportFactory
NettyTransportFactory(ProtocolNegotiator protocolNegotiator, io.netty.channel.ChannelFactory<? extends io.netty.channel.Channel> channelFactory, java.util.Map<io.netty.channel.ChannelOption<?>,?> channelOptions, ObjectPool<? extends io.netty.channel.EventLoopGroup> groupPool, boolean autoFlowControl, int flowControlWindow, int maxMessageSize, int maxHeaderListSize, long keepAliveTimeNanos, long keepAliveTimeoutNanos, boolean keepAliveWithoutCalls, TransportTracer.Factory transportTracerFactory, NettyChannelBuilder.LocalSocketPicker localSocketPicker, boolean useGetForSafeMethods, java.lang.Class<? extends java.net.SocketAddress> transportSocketType)
-
-
Method Detail
-
newClientTransport
public ConnectionClientTransport newClientTransport(java.net.SocketAddress serverAddress, ClientTransportFactory.ClientTransportOptions options, ChannelLogger channelLogger)
Description copied from interface:ClientTransportFactory
Creates an unstarted transport for exclusive use. Ownership ofoptions
is passed to the callee; the caller should not reuse or read from the options after this method is called.- Specified by:
newClientTransport
in interfaceClientTransportFactory
- Parameters:
serverAddress
- the address that the transport is connected tooptions
- additional configurationchannelLogger
- logger for the transport.
-
getScheduledExecutorService
public java.util.concurrent.ScheduledExecutorService getScheduledExecutorService()
Description copied from interface:ClientTransportFactory
Returns an executor for scheduling provided by the transport. The service should be configured to allow cancelled scheduled runnables to be GCed.The executor should not be used after the factory has been closed. The caller should ensure any outstanding tasks are cancelled before the factory is closed. However, it is a known issue that ClientCallImpl may use this executor after close, so implementations should not go out of their way to prevent usage.
- Specified by:
getScheduledExecutorService
in interfaceClientTransportFactory
-
swapChannelCredentials
public ClientTransportFactory.SwapChannelCredentialsResult swapChannelCredentials(ChannelCredentials channelCreds)
Description copied from interface:ClientTransportFactory
Swaps to a new ChannelCredentials with all other settings unchanged. Returns null if the ChannelCredentials is not supported by the current ClientTransportFactory settings.- Specified by:
swapChannelCredentials
in interfaceClientTransportFactory
-
close
public void close()
Description copied from interface:ClientTransportFactory
Releases any resources.After this method has been called, it's no longer valid to call
ClientTransportFactory.newClientTransport(java.net.SocketAddress, io.grpc.internal.ClientTransportFactory.ClientTransportOptions, io.grpc.ChannelLogger)
. No guarantees about thread-safety are made.- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfaceClientTransportFactory
- Specified by:
close
in interfacejava.io.Closeable
-
getSupportedSocketAddressTypes
public java.util.Collection<java.lang.Class<? extends java.net.SocketAddress>> getSupportedSocketAddressTypes()
Description copied from interface:ClientTransportFactory
Returns theSocketAddress
types this transport supports.- Specified by:
getSupportedSocketAddressTypes
in interfaceClientTransportFactory
-
-