Class NettyTransportClient
- java.lang.Object
-
- org.apache.hugegraph.computer.core.network.netty.NettyTransportClient
-
- All Implemented Interfaces:
TransportClient
public class NettyTransportClient extends java.lang.Object implements TransportClient
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedNettyTransportClient(io.netty.channel.Channel channel, ConnectionId connectionId, NettyClientFactory clientFactory, ClientHandler clientHandler)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanactive()To check whether the connection is active to useio.netty.channel.Channelchannel()protected voidcheckAndNotifySendAvailable()protected booleancheckSendAvailable()ClientHandlerclientHandler()protected ClientSessionclientSession()voidclose()Close the client.ConnectionIdconnectionId()Get theConnectionIdvoidfinishSession()This method is called after an iteration.java.util.concurrent.CompletableFuture<java.lang.Void>finishSessionAsync()This method is the asynchronous version ofTransportClient.finishSession().java.net.InetSocketAddressremoteAddress()Get the remote SocketAddressbooleansend(MessageType messageType, int partition, java.nio.ByteBuffer buffer)Send the buffer to the server.booleansessionActive()To check whether the session is active to usevoidstartSession()This method is called before an iteration of sending buffers.java.util.concurrent.CompletableFuture<java.lang.Void>startSessionAsync()This method is the asynchronous version ofTransportClient.startSession().
-
-
-
Constructor Detail
-
NettyTransportClient
protected NettyTransportClient(io.netty.channel.Channel channel, ConnectionId connectionId, NettyClientFactory clientFactory, ClientHandler clientHandler)
-
-
Method Detail
-
channel
public io.netty.channel.Channel channel()
-
connectionId
public ConnectionId connectionId()
Description copied from interface:TransportClientGet theConnectionId- Specified by:
connectionIdin interfaceTransportClient
-
remoteAddress
public java.net.InetSocketAddress remoteAddress()
Description copied from interface:TransportClientGet the remote SocketAddress- Specified by:
remoteAddressin interfaceTransportClient
-
active
public boolean active()
Description copied from interface:TransportClientTo check whether the connection is active to use- Specified by:
activein interfaceTransportClient- Returns:
- true if connection is active
-
sessionActive
public boolean sessionActive()
Description copied from interface:TransportClientTo check whether the session is active to use- Specified by:
sessionActivein interfaceTransportClient- Returns:
- true if session is active
-
clientSession
protected ClientSession clientSession()
-
clientHandler
public ClientHandler clientHandler()
-
startSessionAsync
public java.util.concurrent.CompletableFuture<java.lang.Void> startSessionAsync()
Description copied from interface:TransportClientThis method is the asynchronous version ofTransportClient.startSession().- Specified by:
startSessionAsyncin interfaceTransportClient
-
startSession
public void startSession() throws TransportExceptionDescription copied from interface:TransportClientThis method is called before an iteration of sending buffers.- Specified by:
startSessionin interfaceTransportClient- Throws:
TransportException
-
send
public boolean send(MessageType messageType, int partition, java.nio.ByteBuffer buffer) throws TransportException
Description copied from interface:TransportClientSend the buffer to the server. Return false if unable send data immediately. This method is called zero or many times in iteration.- Specified by:
sendin interfaceTransportClient- Throws:
TransportException- if failed, the job will fail.
-
finishSessionAsync
public java.util.concurrent.CompletableFuture<java.lang.Void> finishSessionAsync()
Description copied from interface:TransportClientThis method is the asynchronous version ofTransportClient.finishSession().- Specified by:
finishSessionAsyncin interfaceTransportClient
-
finishSession
public void finishSession() throws TransportExceptionDescription copied from interface:TransportClientThis method is called after an iteration. It will block the caller to make sure the buffers sent be received by target workers.- Specified by:
finishSessionin interfaceTransportClient- Throws:
TransportException
-
checkSendAvailable
protected boolean checkSendAvailable()
-
checkAndNotifySendAvailable
protected void checkAndNotifySendAvailable()
-
close
public void close()
Description copied from interface:TransportClientClose the client. NOTE: If the client is created withConnectionManager, need to useConnectionManager.closeClient(ConnectionId)to close it, otherwise there will be unsafe risks.- Specified by:
closein interfaceTransportClient
-
-