public class AeronUdpTransport extends BaseTransport implements AutoCloseable
| Modifier and Type | Class and Description |
|---|---|
static class |
AeronUdpTransport.RemoteConnection |
BaseTransport.HeartbeatThread, BaseTransport.MessageFlow<T>| Modifier and Type | Field and Description |
|---|---|
protected io.aeron.Aeron |
aeron |
protected ReentrantLock |
aeronLock |
protected AtomicBoolean |
connectedFlag |
protected io.aeron.Aeron.Context |
context |
protected io.aeron.driver.MediaDriver |
driver |
protected Map<String,MessageCallable> |
interceptors |
protected int |
MESSAGE_THREADS |
protected io.aeron.FragmentAssembler |
messageHandler |
protected BlockingQueue<VoidMessage> |
messageQueue |
protected ExecutorService |
messagesExecutorService |
protected io.aeron.Subscription |
ownSubscription |
protected Map<String,MessageCallable> |
precursors |
protected BlockingQueue<INDArrayMessage> |
propagationQueue |
protected Map<String,AeronUdpTransport.RemoteConnection> |
remoteConnections |
protected int |
SENDER_THREADS |
protected AtomicBoolean |
shutdownFlag |
protected int |
SUBSCRIPTION_THREADS |
protected Thread |
subscriptionThread |
consumers, executorService, handshakeFlag, historyHolder, id, incomingFlow, masterMode, mesh, meshBuildMode, numerOfNodes, outgoingFlow, replies, restartCallback, rootId, splitter, voidConfiguration| Constructor and Description |
|---|
AeronUdpTransport(@NonNull String ownIp,
int ownPort,
@NonNull String rootIp,
int rootPort,
@NonNull VoidConfiguration configuration) |
AeronUdpTransport(@NonNull String rootIp,
int rootPort,
@NonNull VoidConfiguration configuration)
This constructor creates root transport instance
|
AeronUdpTransport(@NonNull String ownIp,
@NonNull String rootIp,
@NonNull VoidConfiguration configuration) |
| Modifier and Type | Method and Description |
|---|---|
protected void |
addConnection(@NonNull String ipAndPort) |
<T extends VoidMessage> |
addInterceptor(@NonNull Class<T> cls,
@NonNull MessageCallable<T> callable)
This method add interceptor for incoming messages.
|
<T extends VoidMessage> |
addPrecursor(@NonNull Class<T> cls,
@NonNull MessageCallable<T> callable)
This method add precursor for incoming messages.
|
void |
close() |
protected void |
createSubscription() |
void |
ensureConnection(String id)
This method checks connection to the given node ID, and if it's not connected - establishes connection
|
protected MeshOrganizer |
getMesh()
This method returns Mesh stored in this Transport instance
PLEASE NOTE: This method is suited for tests
|
String |
id()
This method returns id of the current transport
|
boolean |
isConnected()
This method checks if all connections required for work are established
|
protected void |
jointMessageHandler(org.agrona.DirectBuffer buffer,
int offset,
int length,
io.aeron.logbuffer.Header header)
This method converts aeron buffer into VoidMessage and puts into temp queue for further processing
|
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
|
void |
processMessage(@NonNull 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 |
redirectedPropagateArrayMessage(INDArrayMessage message) |
void |
sendMessage(@NonNull VoidMessage message,
@NonNull String id)
This method will send message to the node specified by Id
|
void |
shutdown()
This method shuts down this Transport instance
|
protected void |
shutdownSilent() |
addRequestConsumer, getRandomDownstreamFrom, getRootId, getUpstreamId, incomingPublisher, internalProcessMessage, isIntroduced, isLoopedNode, outgoingConsumer, propagateBroadcastableMessage, propagateMessage, propagateMessageDirect, sendMessageBlocking, sendMessageBlocking, setRestartCallback, totalNumberOfNodesprotected Map<String,MessageCallable> interceptors
protected Map<String,MessageCallable> precursors
protected Map<String,AeronUdpTransport.RemoteConnection> remoteConnections
protected final int SENDER_THREADS
protected final int MESSAGE_THREADS
protected final int SUBSCRIPTION_THREADS
protected io.aeron.Aeron aeron
protected io.aeron.Aeron.Context context
protected io.aeron.Subscription ownSubscription
protected io.aeron.FragmentAssembler messageHandler
protected Thread subscriptionThread
protected io.aeron.driver.MediaDriver driver
protected BlockingQueue<VoidMessage> messageQueue
protected BlockingQueue<INDArrayMessage> propagationQueue
protected ReentrantLock aeronLock
protected final AtomicBoolean shutdownFlag
protected final AtomicBoolean connectedFlag
protected ExecutorService messagesExecutorService
public AeronUdpTransport(@NonNull
@NonNull String ownIp,
@NonNull
@NonNull String rootIp,
@NonNull
@NonNull VoidConfiguration configuration)
public AeronUdpTransport(@NonNull
@NonNull String rootIp,
int rootPort,
@NonNull
@NonNull VoidConfiguration configuration)
rootIp - rootPort - configuration - public AeronUdpTransport(@NonNull
@NonNull String ownIp,
int ownPort,
@NonNull
@NonNull String rootIp,
int rootPort,
@NonNull
@NonNull VoidConfiguration configuration)
protected void createSubscription()
protected void propagateArrayMessage(INDArrayMessage message, PropagationMode mode) throws IOException
propagateArrayMessage in class BaseTransportIOExceptionprotected void redirectedPropagateArrayMessage(INDArrayMessage message) throws IOException
IOExceptionprotected void jointMessageHandler(org.agrona.DirectBuffer buffer,
int offset,
int length,
io.aeron.logbuffer.Header header)
buffer - offset - length - header - public void onRemap(String id)
TransportonRemap in interface TransportonRemap in class BaseTransportpublic void ensureConnection(String id)
TransportensureConnection in interface TransportensureConnection in class BaseTransportprotected void addConnection(@NonNull
@NonNull String ipAndPort)
public void close()
throws Exception
close in interface AutoCloseableExceptionpublic void launch()
Transportlaunch in interface Transportlaunch in class BaseTransportpublic void launchAsMaster()
TransportlaunchAsMaster in interface TransportlaunchAsMaster in class BaseTransportpublic String id()
Transportpublic boolean isConnected()
TransportisConnected in interface TransportisConnected in class BaseTransportpublic void sendMessage(@NonNull
@NonNull VoidMessage message,
@NonNull
@NonNull String id)
TransportsendMessage in interface Transportprotected void shutdownSilent()
public void shutdown()
Transportshutdown in interface Transportshutdown in class BaseTransportpublic void onMeshUpdate(MeshOrganizer mesh)
TransportonMeshUpdate in interface TransportonMeshUpdate in class BaseTransportpublic <T extends VoidMessage> void addInterceptor(@NonNull @NonNull Class<T> cls, @NonNull @NonNull MessageCallable<T> callable)
cls - callable - public <T extends VoidMessage> void addPrecursor(@NonNull @NonNull Class<T> cls, @NonNull @NonNull MessageCallable<T> callable)
cls - callable - public void processMessage(@NonNull
@NonNull VoidMessage message)
TransportprocessMessage in interface TransportprocessMessage in class BaseTransportprotected MeshOrganizer getMesh()
Copyright © 2021. All rights reserved.