@SPI
public interface ShardedWorkRegistry
Modifier and Type | Method and Description |
---|---|
java.util.Optional<ShardProcessingSession> |
pickUp(io.spine.server.delivery.ShardIndex index,
io.spine.server.NodeId node)
Picks up the shard at a given index to process.
|
java.lang.Iterable<io.spine.server.delivery.ShardIndex> |
releaseExpiredSessions(com.google.protobuf.Duration inactivityPeriod)
Clears up the recorded
NodeId s from the session records if there was no activity
for longer than passed inactivityPeriod . |
java.util.Optional<ShardProcessingSession> pickUp(io.spine.server.delivery.ShardIndex index, io.spine.server.NodeId node)
This action is intended to be exclusive, i.e. a single shard may be served by a single application node at a given moment of time.
In case of a successful operation, an instance of ShardProcessingSession
is returned. The node obtained the session should perform the desired actions with the
sharded messages and then complete
the session.
In case the shard at a given index is already picked up by some node,
an Optional.empty()
is returned.
index
- the index of the shard to pick up for processingnode
- the identifier of the node for which to pick the shardOptional.empty()
if the shard is not availablejava.lang.Iterable<io.spine.server.delivery.ShardIndex> releaseExpiredSessions(com.google.protobuf.Duration inactivityPeriod)
NodeId
s from the session records if there was no activity
for longer than passed inactivityPeriod
.
It may be handy if an application node hangs or gets killed — so that it is not able to complete the session in a conventional way.
inactivityPeriod
- the duration of the period after which the session is considered expired