public final class TestOutbox extends Object implements Outbox
Outbox
with an array of ArrayDeque
s.Modifier and Type | Class and Description |
---|---|
static class |
TestOutbox.MockData
Javadoc pending
|
static class |
TestOutbox.MockSerializationService
Javadoc pending
|
Constructor and Description |
---|
TestOutbox(int... capacities) |
TestOutbox(int[] edgeCapacities,
int snapshotCapacity) |
Modifier and Type | Method and Description |
---|---|
int |
bucketCount()
Returns the number of buckets in this outbox.
|
boolean |
offer(int[] ordinals,
Object item)
Offers the item to all supplied edge ordinals.
|
boolean |
offer(int ordinal,
Object item)
Offers the supplied item to the bucket with the supplied ordinal.
|
boolean |
offer(Object item)
Offers the item to all edges.
|
boolean |
offerToSnapshot(Object key,
Object value)
Offers the given key and value pair to the processor's snapshot
storage.
|
Queue<Object> |
queueWithOrdinal(int ordinal)
Exposes individual buckets to the testing code.
|
Queue<Map.Entry<TestOutbox.MockData,TestOutbox.MockData>> |
snapshotQueue()
Returns the queue to which snapshot is written.
|
String |
toString() |
public TestOutbox(int... capacities)
capacities
- Capacities of individual buckets. Number of buckets
is determined by the number of provided capacities.
There is no snapshot bucket.public TestOutbox(int[] edgeCapacities, int snapshotCapacity)
edgeCapacities
- Capacities of individual buckets. Number of buckets
is determined by the number of provided capacities.snapshotCapacity
- Capacity of snapshot bucket. If 0, snapshot queue
is not present.public int bucketCount()
Outbox
bucketCount
in interface Outbox
public boolean offer(int ordinal, @Nonnull Object item)
Outbox
ordinal == -1
, offers the supplied item to all buckets (behaves
the same as Outbox.offer(Object)
).
Items offered to outbox should not be subsequently mutated because the same instance might be used by a downstream processor in different thread, causing concurrent access.
public boolean offer(int[] ordinals, @Nonnull Object item)
Outbox
Outbox.offer(int,
Object)
for more details.public boolean offer(@Nonnull Object item)
Outbox
Outbox.offer(int, Object)
for more
details.public boolean offerToSnapshot(Object key, Object value)
Outbox
The type of the offered key determines which processors receive the key
and value pair when it is restored. If the key is of type BroadcastKey
, the entry will be restored to all processor instances.
Otherwise the key will be distributed according to default partitioning
and only a single processor instance will receive the key.
This method may only be called from the Processor.saveToSnapshot()
method.
Keys and values offered to snapshot are serialized and can be further mutated as soon as this method returns.
offerToSnapshot
in interface Outbox
true
if the outbox accepted the itempublic Queue<Object> queueWithOrdinal(int ordinal)
ordinal
- ordinal of the bucketpublic Queue<Map.Entry<TestOutbox.MockData,TestOutbox.MockData>> snapshotQueue()
Copyright © 2017 Hazelcast, Inc.. All Rights Reserved.