Class TarantoolConnectionImpl
- java.lang.Object
-
- io.tarantool.driver.core.connection.TarantoolConnectionImpl
-
- All Implemented Interfaces:
TarantoolConnection,AutoCloseable
public class TarantoolConnectionImpl extends Object implements TarantoolConnection
-
-
Field Summary
Fields Modifier and Type Field Description protected io.netty.channel.Channelchannelprotected RequestFutureManagerrequestManagerprotected TarantoolVersionHolderversionHolder
-
Constructor Summary
Constructors Constructor Description TarantoolConnectionImpl(RequestFutureManager requestManager, TarantoolVersionHolder versionHolder, io.netty.channel.Channel channel)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddConnectionCloseListener(TarantoolConnectionCloseListener listener)Add a listener which is invoked when the connection is closed.voidaddConnectionFailureListener(TarantoolConnectionFailureListener listener)Add a listener which is invoked when the connection is broken from the server side (e.g. server closed the connection or a network failure has occurred).voidclose()io.netty.channel.ChannelgetChannel()Get the Netty channel baking this connectionInetSocketAddressgetRemoteAddress()Get the Tarantool server address for this connectionTarantoolVersiongetVersion()Get the Tarantool server versionbooleanisConnected()Get the connection status<T> CompletableFuture<T>sendRequest(TarantoolRequest request, MessagePackValueMapper resultMapper)Send a prepared request to the Tarantool server and flush the buffer
-
-
-
Field Detail
-
versionHolder
protected final TarantoolVersionHolder versionHolder
-
requestManager
protected final RequestFutureManager requestManager
-
channel
protected final io.netty.channel.Channel channel
-
-
Constructor Detail
-
TarantoolConnectionImpl
public TarantoolConnectionImpl(RequestFutureManager requestManager, TarantoolVersionHolder versionHolder, io.netty.channel.Channel channel)
-
-
Method Detail
-
getRemoteAddress
public InetSocketAddress getRemoteAddress() throws TarantoolClientException
Description copied from interface:TarantoolConnectionGet the Tarantool server address for this connection- Specified by:
getRemoteAddressin interfaceTarantoolConnection- Returns:
- server address
- Throws:
TarantoolClientException- if the client is not connected
-
getVersion
public TarantoolVersion getVersion() throws TarantoolClientException
Description copied from interface:TarantoolConnectionGet the Tarantool server version- Specified by:
getVersionin interfaceTarantoolConnection- Returns:
TarantoolVersion- Throws:
TarantoolClientException- if the client is not connected
-
isConnected
public boolean isConnected()
Description copied from interface:TarantoolConnectionGet the connection status- Specified by:
isConnectedin interfaceTarantoolConnection- Returns:
- true, if the connection is alive
-
sendRequest
public <T> CompletableFuture<T> sendRequest(TarantoolRequest request, MessagePackValueMapper resultMapper)
Description copied from interface:TarantoolConnectionSend a prepared request to the Tarantool server and flush the buffer- Specified by:
sendRequestin interfaceTarantoolConnection- Type Parameters:
T- result type- Parameters:
request- the requestresultMapper- the mapper for response body- Returns:
- result future
-
getChannel
public io.netty.channel.Channel getChannel()
Description copied from interface:TarantoolConnectionGet the Netty channel baking this connection- Specified by:
getChannelin interfaceTarantoolConnection- Returns:
- channel
-
addConnectionFailureListener
public void addConnectionFailureListener(TarantoolConnectionFailureListener listener)
Description copied from interface:TarantoolConnectionAdd a listener which is invoked when the connection is broken from the server side (e.g. server closed the connection or a network failure has occurred).- Specified by:
addConnectionFailureListenerin interfaceTarantoolConnection- Parameters:
listener- aTarantoolConnectionFailureListenerinstance
-
addConnectionCloseListener
public void addConnectionCloseListener(TarantoolConnectionCloseListener listener)
Description copied from interface:TarantoolConnectionAdd a listener which is invoked when the connection is closed. The internal channel may probably be in an invalid state at this moment.- Specified by:
addConnectionCloseListenerin interfaceTarantoolConnection- Parameters:
listener- aTarantoolConnectionCloseListenerinstance
-
close
public void close()
- Specified by:
closein interfaceAutoCloseable
-
-