public abstract class BaseTransport extends Object implements Transport
| Modifier and Type | Class and Description |
|---|---|
protected static class |
BaseTransport.HeartbeatThread |
static class |
BaseTransport.MessageFlow<T>
Generic Publisher/Consumer implementation for interconnect
|
| Modifier and Type | Field and Description |
|---|---|
protected Map<String,io.reactivex.functions.Consumer> |
consumers |
protected ThreadPoolExecutor |
executorService |
protected org.nd4j.common.primitives.AtomicBoolean |
handshakeFlag |
protected MessagesHistoryHolder<String> |
historyHolder |
protected String |
id |
protected BaseTransport.MessageFlow<INDArrayMessage> |
incomingFlow |
protected boolean |
masterMode |
protected org.nd4j.common.primitives.Atomic<MeshOrganizer> |
mesh |
protected MeshBuildMode |
meshBuildMode |
protected TransferQueue<VoidMessage> |
messageQueue |
protected AtomicInteger |
numerOfNodes |
protected BaseTransport.MessageFlow<VoidMessage> |
outgoingFlow |
protected Map<String,ResponseMessage> |
replies |
protected RestartCallback |
restartCallback |
protected String |
rootId |
protected MessageSplitter |
splitter |
protected VoidConfiguration |
voidConfiguration |
| Modifier | Constructor and Description |
|---|---|
protected |
BaseTransport() |
protected |
BaseTransport(@NonNull String rootId) |
protected |
BaseTransport(@NonNull String ownId,
@NonNull String rootId,
@NonNull VoidConfiguration voidConfiguration) |
protected |
BaseTransport(@NonNull String rootId,
@NonNull VoidConfiguration voidConfiguration) |
| Modifier and Type | Method and Description |
|---|---|
<T extends RequestMessage> |
addRequestConsumer(@NonNull Class<T> cls,
io.reactivex.functions.Consumer<T> consumer)
This methd allows to set callback instance for various
|
void |
ensureConnection(String id)
This method checks connection to the given node ID, and if it's not connected - establishes connection
|
String |
getRandomDownstreamFrom(@NonNull String id,
String exclude)
This method returns random
|
String |
getRootId()
This method returns ID of the root node
|
String |
getUpstreamId()
This methos returns Id of the upstream node
|
org.reactivestreams.Publisher<INDArrayMessage> |
incomingPublisher()
This method returns flow of messages for parameter server
|
protected void |
internalProcessMessage(VoidMessage message) |
boolean |
isConnected()
This method checks if all connections required for work are established
|
boolean |
isIntroduced()
This method checks if this node was properly introduced to driver
|
protected boolean |
isLoopedNode(MeshOrganizer.Node node,
@NonNull String originatorId,
@NonNull String relayId) |
void |
launch()
This method starts this Transport instance
|
void |
launchAsMaster()
This method will start this Transport instance
|
void |
onMeshUpdate(MeshOrganizer mesh)
This method will be called if mesh update was received
PLEASE NOTE: This method will be called ONLY if new mesh differs from current one
|
void |
onRemap(String id)
This method will be called upon remap request
|
io.reactivex.functions.Consumer<VoidMessage> |
outgoingConsumer()
This method returns consumer that accepts messages for delivery
|
void |
processMessage(VoidMessage message)
This method will be invoked for all incoming messages
PLEASE NOTE: this method is mostly suited for tests
|
protected void |
propagateArrayMessage(INDArrayMessage message,
PropagationMode mode) |
protected void |
propagateBroadcastableMessage(@NonNull BroadcastableMessage voidMessage,
PropagationMode mode) |
void |
propagateMessage(@NonNull VoidMessage voidMessage,
PropagationMode mode)
This method will send message to the network, using tree structure
|
void |
propagateMessageDirect(@NonNull BroadcastableMessage message) |
<T extends ResponseMessage> |
sendMessageBlocking(@NonNull RequestMessage message,
@NonNull String id)
This method will send message to specified node, and will return its response
|
<T extends ResponseMessage> |
sendMessageBlocking(@NonNull RequestMessage message,
@NonNull String id,
long timeWait,
@NonNull TimeUnit timeUnit)
This method will send message to specified node, and will return its response
|
void |
setRestartCallback(RestartCallback callback)
This method allows to set callback instance, which will be called upon restart event
|
void |
shutdown()
This method shuts down this Transport instance
|
int |
totalNumberOfNodes()
This method returns total number of nodes known to this Transport
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitid, sendMessageprotected final BaseTransport.MessageFlow<VoidMessage> outgoingFlow
protected final BaseTransport.MessageFlow<INDArrayMessage> incomingFlow
protected final org.nd4j.common.primitives.Atomic<MeshOrganizer> mesh
protected String id
protected String rootId
protected boolean masterMode
protected final Map<String,ResponseMessage> replies
protected RestartCallback restartCallback
protected final VoidConfiguration voidConfiguration
protected final MeshBuildMode meshBuildMode
protected final AtomicInteger numerOfNodes
protected final TransferQueue<VoidMessage> messageQueue
protected MessageSplitter splitter
protected MessagesHistoryHolder<String> historyHolder
protected org.nd4j.common.primitives.AtomicBoolean handshakeFlag
protected final ThreadPoolExecutor executorService
protected BaseTransport()
protected BaseTransport(@NonNull
@NonNull String rootId)
protected BaseTransport(@NonNull
@NonNull String rootId,
@NonNull
@NonNull VoidConfiguration voidConfiguration)
protected BaseTransport(@NonNull
@NonNull String ownId,
@NonNull
@NonNull String rootId,
@NonNull
@NonNull VoidConfiguration voidConfiguration)
public io.reactivex.functions.Consumer<VoidMessage> outgoingConsumer()
TransportoutgoingConsumer in interface Transportpublic org.reactivestreams.Publisher<INDArrayMessage> incomingPublisher()
TransportincomingPublisher in interface Transportpublic String getUpstreamId()
TransportgetUpstreamId in interface Transportpublic void launch()
Transportpublic void launchAsMaster()
TransportlaunchAsMaster in interface Transportpublic void shutdown()
Transportprotected void propagateArrayMessage(INDArrayMessage message, PropagationMode mode) throws IOException
IOExceptionpublic void propagateMessage(@NonNull
@NonNull VoidMessage voidMessage,
PropagationMode mode)
throws IOException
TransportpropagateMessage in interface TransportIOExceptionprotected void propagateBroadcastableMessage(@NonNull
@NonNull BroadcastableMessage voidMessage,
PropagationMode mode)
protected boolean isLoopedNode(@NonNull
MeshOrganizer.Node node,
@NonNull
@NonNull String originatorId,
@NonNull
@NonNull String relayId)
protected void internalProcessMessage(VoidMessage message)
public void propagateMessageDirect(@NonNull
@NonNull BroadcastableMessage message)
public void processMessage(VoidMessage message)
TransportprocessMessage in interface Transportpublic String getRandomDownstreamFrom(@NonNull @NonNull String id, String exclude)
TransportgetRandomDownstreamFrom in interface Transportpublic <T extends ResponseMessage> T sendMessageBlocking(@NonNull @NonNull RequestMessage message, @NonNull @NonNull String id) throws InterruptedException
TransportsendMessageBlocking in interface TransportInterruptedExceptionpublic <T extends ResponseMessage> T sendMessageBlocking(@NonNull @NonNull RequestMessage message, @NonNull @NonNull String id, long timeWait, @NonNull @NonNull TimeUnit timeUnit) throws InterruptedException
TransportsendMessageBlocking in interface TransportInterruptedExceptionpublic void setRestartCallback(RestartCallback callback)
TransportsetRestartCallback in interface Transportpublic <T extends RequestMessage> void addRequestConsumer(@NonNull @NonNull Class<T> cls, io.reactivex.functions.Consumer<T> consumer)
TransportaddRequestConsumer in interface Transportpublic void onMeshUpdate(MeshOrganizer mesh)
TransportonMeshUpdate in interface Transportpublic void onRemap(String id)
Transportpublic String getRootId()
Transportpublic int totalNumberOfNodes()
TransporttotalNumberOfNodes in interface Transportpublic boolean isConnected()
TransportisConnected in interface Transportpublic boolean isIntroduced()
TransportisIntroduced in interface Transportpublic void ensureConnection(String id)
TransportensureConnection in interface TransportCopyright © 2021. All rights reserved.