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, totalNumberOfNodes
protected 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 BaseTransport
IOException
protected void redirectedPropagateArrayMessage(INDArrayMessage message) throws IOException
IOException
protected void jointMessageHandler(org.agrona.DirectBuffer buffer, int offset, int length, io.aeron.logbuffer.Header header)
buffer
- offset
- length
- header
- public void onRemap(String id)
Transport
onRemap
in interface Transport
onRemap
in class BaseTransport
public void ensureConnection(String id)
Transport
ensureConnection
in interface Transport
ensureConnection
in class BaseTransport
protected void addConnection(@NonNull @NonNull String ipAndPort)
public void close() throws Exception
close
in interface AutoCloseable
Exception
public void launch()
Transport
launch
in interface Transport
launch
in class BaseTransport
public void launchAsMaster()
Transport
launchAsMaster
in interface Transport
launchAsMaster
in class BaseTransport
public String id()
Transport
public boolean isConnected()
Transport
isConnected
in interface Transport
isConnected
in class BaseTransport
public void sendMessage(@NonNull @NonNull VoidMessage message, @NonNull @NonNull String id)
Transport
sendMessage
in interface Transport
protected void shutdownSilent()
public void shutdown()
Transport
shutdown
in interface Transport
shutdown
in class BaseTransport
public void onMeshUpdate(MeshOrganizer mesh)
Transport
onMeshUpdate
in interface Transport
onMeshUpdate
in class BaseTransport
public <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)
Transport
processMessage
in interface Transport
processMessage
in class BaseTransport
protected MeshOrganizer getMesh()
Copyright © 2020. All rights reserved.