Interface TransportClient
-
- All Known Implementing Classes:
NettyTransportClient
public interface TransportClientThis is used for worker to send buffer to other worker. The whole process contains several iteration. In one iterationstartSession()is called only once.send(org.apache.hugegraph.computer.core.network.message.MessageType, int, java.nio.ByteBuffer)is called zero or more times.finishSession()is called only once.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description booleanactive()To check whether the connection is active to usevoidclose()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 offinishSession().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 ofstartSession().
-
-
-
Method Detail
-
startSession
void startSession() throws TransportExceptionThis method is called before an iteration of sending buffers.- Throws:
TransportException
-
startSessionAsync
java.util.concurrent.CompletableFuture<java.lang.Void> startSessionAsync() throws TransportExceptionThis method is the asynchronous version ofstartSession().- Throws:
TransportException
-
send
boolean send(MessageType messageType, int partition, java.nio.ByteBuffer buffer) throws TransportException
Send the buffer to the server. Return false if unable send data immediately. This method is called zero or many times in iteration.- Throws:
TransportException- if failed, the job will fail.
-
finishSession
void finishSession() throws TransportExceptionThis method is called after an iteration. It will block the caller to make sure the buffers sent be received by target workers.- Throws:
TransportException
-
finishSessionAsync
java.util.concurrent.CompletableFuture<java.lang.Void> finishSessionAsync() throws TransportExceptionThis method is the asynchronous version offinishSession().- Throws:
TransportException
-
connectionId
ConnectionId connectionId()
Get theConnectionId
-
remoteAddress
java.net.InetSocketAddress remoteAddress()
Get the remote SocketAddress
-
active
boolean active()
To check whether the connection is active to use- Returns:
- true if connection is active
-
sessionActive
boolean sessionActive()
To check whether the session is active to use- Returns:
- true if session is active
-
close
void close()
Close the client. NOTE: If the client is created withConnectionManager, need to useConnectionManager.closeClient(ConnectionId)to close it, otherwise there will be unsafe risks.
-
-