Package com.tangosol.net.topic
Class Publisher.OrderBy<V>
- java.lang.Object
-
- com.tangosol.net.topic.Publisher.OrderBy<V>
-
- All Implemented Interfaces:
ExternalizableLite
,PortableObject
,Publisher.Option<V>
,Serializable
- Direct Known Subclasses:
Publisher.OrderById
,Publisher.OrderByNone
,Publisher.OrderByThread
,Publisher.OrderByValue
public abstract static class Publisher.OrderBy<V> extends Object implements Publisher.Option<V>, ExternalizableLite, PortableObject
The OrderBy option specifies the ordering of async operations with respect to one another. The default unit-of-order isthread()
which ensures that a sequence of async operations issued by a single thread will complete in order. This default ordering does not however guarantee ordering with respect to other threads or processes which are also issuing operations against the same topic. To ensure strict global ordering across threads or processes all parties mustspecify
the same unit-of-order id. Note that restricting the topic to a single unit-of-order naturally limits performance as it disallows full parallelism.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
OrderBy()
Default constructor for serialization.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract int
getOrderId(V value)
Return unit-of-order id.static Publisher.OrderBy<Object>
id(int nOrderId)
Return an OrderBy that will ensure ordering ofsent values
across all threads which share the same id.static Publisher.OrderBy<Object>
none()
Return an OrderBy that will enforce no specific ordering betweensent values
allowing for the greatest level of parallelism.static <V> Publisher.OrderBy<V>
roundRobin()
Return an OrderBy which will compute the unit-of-order such that each message is published to the next channel in a round robin order.static Publisher.OrderBy<Object>
thread()
Return an OrderBy that will ensure that allvalues sent
from the same thread are stored sequentially.static <V> Publisher.OrderBy<V>
value(Remote.ToIntFunction<? super V> supplierOrderId)
Return an OrderBy which will compute the unit-of-order based on thesent value
.static <V> Publisher.OrderBy<V>
value(ToIntFunction<? super V> supplierOrderId)
Return an OrderBy which will compute the unit-of-order based on thesent value
.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.tangosol.io.ExternalizableLite
readExternal, writeExternal
-
Methods inherited from interface com.tangosol.io.pof.PortableObject
readExternal, writeExternal
-
-
-
-
Method Detail
-
getOrderId
public abstract int getOrderId(V value)
Return unit-of-order id.- Returns:
- the unit-of-order id
-
thread
@Default public static Publisher.OrderBy<Object> thread()
Return an OrderBy that will ensure that allvalues sent
from the same thread are stored sequentially.- Returns:
- the default, thread-based ordering
-
none
public static Publisher.OrderBy<Object> none()
Return an OrderBy that will enforce no specific ordering betweensent values
allowing for the greatest level of parallelism.- Returns:
- the OrderBy which does not enforce ordering
-
id
public static Publisher.OrderBy<Object> id(int nOrderId)
Return an OrderBy that will ensure ordering ofsent values
across all threads which share the same id.This option effectively publishes all messages to a single channel, the exact channel used is the specified
nOrderId
modulo the number of channels in the topic. Therefore a channel number can be used as thenOrderId
parameter to ensure publishing to a specific channel.- Parameters:
nOrderId
- the unit-of-order- Returns:
- the order which will use specified
nOrderId
for all operations
-
value
public static <V> Publisher.OrderBy<V> value(Remote.ToIntFunction<? super V> supplierOrderId)
Return an OrderBy which will compute the unit-of-order based on thesent value
.- Parameters:
supplierOrderId
- the function that should be used to determine order id from the sent value.- Returns:
- the order which will use specified function to provide unit-of-order for each async operation
-
value
public static <V> Publisher.OrderBy<V> value(ToIntFunction<? super V> supplierOrderId)
Return an OrderBy which will compute the unit-of-order based on thesent value
.- Parameters:
supplierOrderId
- the function that should be used to determine order id from the sent value.- Returns:
- the order which will use specified function to provide unit-of-order for each async operation
-
roundRobin
public static <V> Publisher.OrderBy<V> roundRobin()
Return an OrderBy which will compute the unit-of-order such that each message is published to the next channel in a round robin order.- Returns:
- an OrderBy which will compute the unit-of-order such that each message is published to the next channel in a round robin order.
-
-