Class IgniteMessagingImpl
- java.lang.Object
-
- org.apache.ignite.internal.AsyncSupportAdapter<IgniteMessaging>
-
- org.apache.ignite.internal.IgniteMessagingImpl
-
- All Implemented Interfaces:
Externalizable,Serializable,IgniteMessaging,IgniteAsyncSupport
public class IgniteMessagingImpl extends AsyncSupportAdapter<IgniteMessaging> implements IgniteMessaging, Externalizable
IgniteMessagingimplementation.- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from class org.apache.ignite.internal.AsyncSupportAdapter
curFut
-
-
Constructor Summary
Constructors Constructor Description IgniteMessagingImpl()Required byExternalizable.IgniteMessagingImpl(GridKernalContext ctx, ClusterGroupAdapter prj, boolean async)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ClusterGroupclusterGroup()Gets the cluster group to which thisGridMessaginginstance belongs.protected IgniteMessagingcreateAsyncInstance()Creates component with asynchronous mode enabled.voidlocalListen(@Nullable Object topic, IgniteBiPredicate<UUID,?> p)Adds local listener for given topic on local node only.voidreadExternal(ObjectInput in)protected ObjectreadResolve()Reconstructs object on unmarshalling.UUIDremoteListen(@Nullable Object topic, IgniteBiPredicate<UUID,?> p)Adds a message listener for a given topic to all nodes in the cluster group (possibly including this node if it belongs to the cluster group as well).IgniteFuture<UUID>remoteListenAsync(@Nullable Object topic, IgniteBiPredicate<UUID,?> p)Asynchronously adds a message listener for a given topic to all nodes in the cluster group (possibly including this node if it belongs to the cluster group as well).voidsend(@Nullable Object topic, Object msg)Sends given message with specified topic to the nodes in the underlying cluster group.voidsend(@Nullable Object topic, Collection<?> msgs)Sends given messages with the specified topic to the nodes in the underlying cluster group.voidsendOrdered(@Nullable Object topic, Object msg, long timeout)Sends given message with specified topic to the nodes in the underlying cluster group.voidstopLocalListen(@Nullable Object topic, IgniteBiPredicate<UUID,?> p)Unregisters local listener for given topic on local node only.voidstopRemoteListen(UUID opId)Unregisters all listeners identified with provided operation ID on all nodes in the cluster group.IgniteFuture<Void>stopRemoteListenAsync(UUID opId)Asynchronously unregisters all listeners identified with provided operation ID on all nodes in the cluster group.voidwriteExternal(ObjectOutput out)-
Methods inherited from class org.apache.ignite.internal.AsyncSupportAdapter
createFuture, future, future, isAsync, saveOrGet, withAsync
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.ignite.lang.IgniteAsyncSupport
future, isAsync
-
Methods inherited from interface org.apache.ignite.IgniteMessaging
withAsync
-
-
-
-
Constructor Detail
-
IgniteMessagingImpl
public IgniteMessagingImpl()
Required byExternalizable.
-
IgniteMessagingImpl
public IgniteMessagingImpl(GridKernalContext ctx, ClusterGroupAdapter prj, boolean async)
- Parameters:
ctx- Kernal context.prj- Projection.async- Async support flag.
-
-
Method Detail
-
clusterGroup
public ClusterGroup clusterGroup()
Gets the cluster group to which thisGridMessaginginstance belongs.- Specified by:
clusterGroupin interfaceIgniteMessaging- Returns:
- Cluster group to which this
GridMessaginginstance belongs.
-
send
public void send(@Nullable @Nullable Object topic, Object msg)Sends given message with specified topic to the nodes in the underlying cluster group.By default all local listeners will be executed in the calling thread, or if you use
IgniteMessaging.withAsync(), listeners will execute in public thread pool (in this case it is user's responsibility to implement back-pressure and limit number of concurrently executed async messages).- Specified by:
sendin interfaceIgniteMessaging- Parameters:
topic- Topic to send to,nullfor default topic.msg- Message to send.
-
send
public void send(@Nullable @Nullable Object topic, Collection<?> msgs)Sends given messages with the specified topic to the nodes in the underlying cluster group.By default all local listeners will be executed in the calling thread, or if you use
IgniteMessaging.withAsync(), listeners will execute in public thread pool (in this case it is user's responsibility to implement back-pressure and limit number of concurrently executed async messages).- Specified by:
sendin interfaceIgniteMessaging- Parameters:
topic- Topic to send to,nullfor default topic.msgs- Messages to send. Order of the sending is undefined. If the method produces the exception none or some messages could have been sent already.
-
sendOrdered
public void sendOrdered(@Nullable @Nullable Object topic, Object msg, long timeout)Sends given message with specified topic to the nodes in the underlying cluster group. Messages sent with this method will arrive in the same order they were sent. Note that if a topic is used for ordered messages, then it cannot be reused for non-ordered messages. Note that local listeners are always executed in public thread pool, no matter default orIgniteMessaging.withAsync()mode is used.The
timeoutparameter specifies how long an out-of-order message will stay in a queue, waiting for messages that are ordered ahead of it to arrive. If timeout expires, then all ordered messages that have not arrived before this message will be skipped. When (and if) expired messages actually do arrive, they will be ignored.- Specified by:
sendOrderedin interfaceIgniteMessaging- Parameters:
topic- Topic to send to,nullfor default topic.msg- Message to send.timeout- Message timeout in milliseconds,0for default which isIgniteConfiguration.getNetworkTimeout().
-
localListen
public void localListen(@Nullable @Nullable Object topic, IgniteBiPredicate<UUID,?> p)Adds local listener for given topic on local node only. This listener will be notified whenever any node within the cluster group will send a message for a given topic to this node. Local listen subscription will happen regardless of whether local node belongs to this cluster group or not.- Specified by:
localListenin interfaceIgniteMessaging- Parameters:
topic- Topic to subscribe to.p- Predicate that is called on each received message. If predicate returnsfalse, then it will be unsubscribed from any further notifications.
-
stopLocalListen
public void stopLocalListen(@Nullable @Nullable Object topic, IgniteBiPredicate<UUID,?> p)Unregisters local listener for given topic on local node only.- Specified by:
stopLocalListenin interfaceIgniteMessaging- Parameters:
topic- Topic to unsubscribe from.p- Listener predicate.
-
remoteListen
public UUID remoteListen(@Nullable @Nullable Object topic, IgniteBiPredicate<UUID,?> p)
Adds a message listener for a given topic to all nodes in the cluster group (possibly including this node if it belongs to the cluster group as well). This means that any node within this cluster group can send a message for a given topic and all nodes within the cluster group will receive listener notifications.- Specified by:
remoteListenin interfaceIgniteMessaging- Parameters:
topic- Topic to subscribe to,nullmeans default topic.p- Predicate that is called on each node for each received message. If predicate returnsfalse, then it will be unsubscribed from any further notifications.- Returns:
Operation IDthat can be passed toIgniteMessaging.stopRemoteListen(UUID)method to stop listening.
-
remoteListenAsync
public IgniteFuture<UUID> remoteListenAsync(@Nullable @Nullable Object topic, IgniteBiPredicate<UUID,?> p) throws IgniteException
Asynchronously adds a message listener for a given topic to all nodes in the cluster group (possibly including this node if it belongs to the cluster group as well). This means that any node within this cluster group can send a message for a given topic and all nodes within the cluster group will receive listener notifications.- Specified by:
remoteListenAsyncin interfaceIgniteMessaging- Parameters:
topic- Topic to subscribe to,nullmeans default topic.p- Predicate that is called on each node for each received message. If predicate returnsfalse, then it will be unsubscribed from any further notifications.- Returns:
- a Future representing pending completion of the operation. The completed future contains
Operation IDthat can be passed toIgniteMessaging.stopRemoteListen(UUID)method to stop listening. - Throws:
IgniteException- If failed to add listener.
-
stopRemoteListen
public void stopRemoteListen(UUID opId)
Unregisters all listeners identified with provided operation ID on all nodes in the cluster group.Supports asynchronous execution (see
IgniteAsyncSupport).- Specified by:
stopRemoteListenin interfaceIgniteMessaging- Parameters:
opId- Listen ID that was returned fromIgniteMessaging.remoteListen(Object, IgniteBiPredicate)method.
-
stopRemoteListenAsync
public IgniteFuture<Void> stopRemoteListenAsync(UUID opId) throws IgniteException
Asynchronously unregisters all listeners identified with provided operation ID on all nodes in the cluster group.- Specified by:
stopRemoteListenAsyncin interfaceIgniteMessaging- Parameters:
opId- Listen ID that was returned fromIgniteMessaging.remoteListen(Object, IgniteBiPredicate)method.- Returns:
- a Future representing pending completion of the operation.
- Throws:
IgniteException- If failed to unregister listeners.
-
createAsyncInstance
protected IgniteMessaging createAsyncInstance()
Creates component with asynchronous mode enabled.- Overrides:
createAsyncInstancein classAsyncSupportAdapter<IgniteMessaging>- Returns:
- Component with asynchronous mode enabled.
-
writeExternal
public void writeExternal(ObjectOutput out) throws IOException
- Specified by:
writeExternalin interfaceExternalizable- Throws:
IOException
-
readExternal
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
- Specified by:
readExternalin interfaceExternalizable- Throws:
IOExceptionClassNotFoundException
-
readResolve
protected Object readResolve() throws ObjectStreamException
Reconstructs object on unmarshalling.- Returns:
- Reconstructed object.
- Throws:
ObjectStreamException- Thrown in case of unmarshalling error.
-
-