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.Channel
channel
protected RequestFutureManager
requestManager
protected TarantoolVersionHolder
versionHolder
-
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 void
addConnectionCloseListener(TarantoolConnectionCloseListener listener)
Add a listener which is invoked when the connection is closed.void
addConnectionFailureListener(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).void
close()
io.netty.channel.Channel
getChannel()
Get the Netty channel baking this connectionInetSocketAddress
getRemoteAddress()
Get the Tarantool server address for this connectionTarantoolVersion
getVersion()
Get the Tarantool server versionboolean
isConnected()
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:TarantoolConnection
Get the Tarantool server address for this connection- Specified by:
getRemoteAddress
in interfaceTarantoolConnection
- Returns:
- server address
- Throws:
TarantoolClientException
- if the client is not connected
-
getVersion
public TarantoolVersion getVersion() throws TarantoolClientException
Description copied from interface:TarantoolConnection
Get the Tarantool server version- Specified by:
getVersion
in interfaceTarantoolConnection
- Returns:
TarantoolVersion
- Throws:
TarantoolClientException
- if the client is not connected
-
isConnected
public boolean isConnected()
Description copied from interface:TarantoolConnection
Get the connection status- Specified by:
isConnected
in interfaceTarantoolConnection
- Returns:
- true, if the connection is alive
-
sendRequest
public <T> CompletableFuture<T> sendRequest(TarantoolRequest request, MessagePackValueMapper resultMapper)
Description copied from interface:TarantoolConnection
Send a prepared request to the Tarantool server and flush the buffer- Specified by:
sendRequest
in 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:TarantoolConnection
Get the Netty channel baking this connection- Specified by:
getChannel
in interfaceTarantoolConnection
- Returns:
- channel
-
addConnectionFailureListener
public void addConnectionFailureListener(TarantoolConnectionFailureListener listener)
Description copied from interface:TarantoolConnection
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).- Specified by:
addConnectionFailureListener
in interfaceTarantoolConnection
- Parameters:
listener
- aTarantoolConnectionFailureListener
instance
-
addConnectionCloseListener
public void addConnectionCloseListener(TarantoolConnectionCloseListener listener)
Description copied from interface:TarantoolConnection
Add 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:
addConnectionCloseListener
in interfaceTarantoolConnection
- Parameters:
listener
- aTarantoolConnectionCloseListener
instance
-
close
public void close()
- Specified by:
close
in interfaceAutoCloseable
-
-