Constructor and Description |
---|
TestOutbox(int... capacities) |
TestOutbox(int[] edgeCapacities,
int snapshotCapacity) |
Modifier and Type | Method and Description |
---|---|
void |
block()
Blocks the outbox so it allows the caller only to offer the current
unfinished item.
|
int |
bucketCount()
Returns the number of buckets in this outbox.
|
<T> void |
drainQueueAndReset(int queueOrdinal,
Collection<T> target,
boolean logItems)
Move all items from the queue to the
target collection and make
the outbox available to accept more items. |
<T> void |
drainQueuesAndReset(List<? extends Collection<T>> target,
boolean logItems)
Move all items from all queues (except the snapshot queue) to the
target list of collections. |
<K,V> void |
drainSnapshotQueueAndReset(Collection<? super Map.Entry<K,V>> target,
boolean logItems)
Deserialize and move all items from the snapshot queue to the
target collection and make the outbox available to accept more items. |
boolean |
hasUnfinishedItem()
Returns true if this outbox has an unfinished item and the same item
must be offered again.
|
long |
lastForwardedWm(byte key)
Returns the timestamp of the last forwarded watermark for the given key.
|
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.
|
<T> Queue<T> |
queue(int ordinal)
Exposes individual output queues to the testing code.
|
void |
reset()
Resets the counter that prevents adding more than
batchSize
items until this method is called again. |
Queue<Map.Entry<Object,Object>> |
snapshotQueue()
Returns the queue to which snapshot is written.
|
String |
toString() |
void |
unblock()
Removes the effect of a previous
OutboxInternal.block() call (if any). |
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
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.
Outbox is not thread safe, see Thread safety
in its class
javadoc.
public boolean offer(@Nonnull Object item)
Outbox
Outbox.offer(int, Object)
for more
details.
Outbox is not thread safe, see Thread safety
in its class
javadoc.
public boolean offer(@Nonnull int[] ordinals, @Nonnull Object item)
Outbox
Outbox.offer(int,
Object)
for more details.
Outbox is not thread safe, see Thread safety
in its class
javadoc.
public boolean offerToSnapshot(@Nonnull Object key, @Nonnull 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 must only be called from the Processor.saveToSnapshot()
or Processor.snapshotCommitPrepare()
methods.
Keys and values offered to snapshot are serialized and can be further mutated as soon as this method returns.
Outbox is not thread safe, see Thread safety
in its class
javadoc.
offerToSnapshot
in interface Outbox
true
if the outbox accepted the itempublic <T> Queue<T> queue(int ordinal)
ordinal
- ordinal of the bucketpublic Queue<Map.Entry<Object,Object>> snapshotQueue()
drainSnapshotQueueAndReset(java.util.Collection<? super java.util.Map.Entry<K, V>>, boolean)
.public <T> void drainQueueAndReset(int queueOrdinal, Collection<T> target, boolean logItems)
target
collection and make
the outbox available to accept more items. Also calls reset()
. If you have a limited capacity outbox, you need to call
this method regularly.queueOrdinal
- the queue from Outbox to draintarget
- target collectionlogItems
- whether to log drained items to System.out
public <T> void drainQueuesAndReset(List<? extends Collection<T>> target, boolean logItems)
target
list of collections. Queue N is moved to collection at target N
etc. Also calls reset()
. If you have a limited capacity outbox,
you need to call this method regularly.target
- list of target collectionslogItems
- whether to log drained items to System.out
public <K,V> void drainSnapshotQueueAndReset(Collection<? super Map.Entry<K,V>> target, boolean logItems)
target
collection and make the outbox available to accept more items.
Also calls reset()
. If you have a limited capacity outbox, you
need to call this method regularly.target
- target listlogItems
- whether to log drained items to System.out
public void reset()
com.hazelcast.jet.impl.execution.OutboxInternal
batchSize
items until this method is called again. Note that the counter may
jump to the "full" state even before the outbox accepted that many items.reset
in interface com.hazelcast.jet.impl.execution.OutboxInternal
public boolean hasUnfinishedItem()
Outbox
Outbox is not thread safe, see Thread safety
in its class
javadoc.
hasUnfinishedItem
in interface Outbox
public void block()
com.hazelcast.jet.impl.execution.OutboxInternal
OutboxInternal.unblock()
.block
in interface com.hazelcast.jet.impl.execution.OutboxInternal
public void unblock()
com.hazelcast.jet.impl.execution.OutboxInternal
OutboxInternal.block()
call (if any).unblock
in interface com.hazelcast.jet.impl.execution.OutboxInternal
public long lastForwardedWm(byte key)
com.hazelcast.jet.impl.execution.OutboxInternal
If there was no watermark added, it returns Long.MIN_VALUE
. Can
be called from a concurrent thread.
lastForwardedWm
in interface com.hazelcast.jet.impl.execution.OutboxInternal
Copyright © 2023 Hazelcast, Inc.. All rights reserved.