Package org.infinispan.util.concurrent
Class CommandAckCollector
- java.lang.Object
-
- org.infinispan.util.concurrent.CommandAckCollector
-
public class CommandAckCollector extends java.lang.Object
An acknowledge collector for Triangle algorithm used in non-transactional caches for write operations.Acknowledges are used between the owners and the originator. They signal the completion of a write operation. The operation can complete successfully or not.
The acknowledges are valid on the same cache topology id. So, each acknowledge is tagged with the command topology id. Acknowledges from previous topology id are discarded.
The acknowledges from the primary owner carry the return value of the operation.
- Since:
- 9.0
- Author:
- Pedro Ruivo
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
CommandAckCollector.MultiTargetCollector
-
Constructor Summary
Constructors Constructor Description CommandAckCollector()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
backupAck(long id, Address from, int topologyId)
Acknowledges a write operation completion in the backup owner.void
completeExceptionally(long id, java.lang.Throwable throwable, int topologyId)
Acknowledges an exception during the operation execution.<T> Collector<T>
create(long id, java.util.Collection<Address> backupOwners, int topologyId)
Creates a collector for a single key write operation.BiasedCollector
createBiased(long id, int topologyId)
CommandAckCollector.MultiTargetCollector
createMultiTargetCollector(long id, int primaries, int topologyId)
<T> Collector<T>
createSegmentBasedCollector(long id, java.util.Map<Address,java.util.Collection<java.lang.Integer>> backups, int topologyId)
Creates a collector forPutMapCommand
.java.util.List<java.lang.Long>
getPendingCommands()
boolean
hasPendingBackupAcks(long id)
void
multiKeyBackupAck(long id, Address from, int segment, int topologyId)
Acknowledges aPutMapCommand
completion in the backup owner.void
onMembersChange(java.util.Collection<Address> members)
Notifies a change in member list.void
start()
-
-
-
Method Detail
-
start
public void start()
-
create
public <T> Collector<T> create(long id, java.util.Collection<Address> backupOwners, int topologyId)
Creates a collector for a single key write operation.- Parameters:
id
- the id fromCommandInvocationId
.backupOwners
- the backup owners of the key.topologyId
- the current topology id.
-
createBiased
public BiasedCollector createBiased(long id, int topologyId)
-
createMultiTargetCollector
public CommandAckCollector.MultiTargetCollector createMultiTargetCollector(long id, int primaries, int topologyId)
-
createSegmentBasedCollector
public <T> Collector<T> createSegmentBasedCollector(long id, java.util.Map<Address,java.util.Collection<java.lang.Integer>> backups, int topologyId)
Creates a collector forPutMapCommand
.- Parameters:
id
- the id fromCommandInvocationId.getId()
.backups
- a map between a backup owner and its segments affected.topologyId
- the current topology id.
-
multiKeyBackupAck
public void multiKeyBackupAck(long id, Address from, int segment, int topologyId)
Acknowledges aPutMapCommand
completion in the backup owner.- Parameters:
id
- the id fromCommandInvocationId.getId()
.from
- the backup owner.segment
- the segments affected and acknowledged.topologyId
- the topology id.
-
backupAck
public void backupAck(long id, Address from, int topologyId)
Acknowledges a write operation completion in the backup owner.- Parameters:
id
- the id fromCommandInvocationId.getId()
.from
- the backup owner.topologyId
- the topology id.
-
completeExceptionally
public void completeExceptionally(long id, java.lang.Throwable throwable, int topologyId)
Acknowledges an exception during the operation execution.The collector is completed without waiting any further acknowledges.
- Parameters:
id
- the id fromCommandInvocationId.getId()
.throwable
- theThrowable
.topologyId
- the topology id.
-
getPendingCommands
public java.util.List<java.lang.Long> getPendingCommands()
- Returns:
- the pending ids from
CommandInvocationId.getId()
(testing purposes only)
-
hasPendingBackupAcks
public boolean hasPendingBackupAcks(long id)
- Parameters:
id
- the id fromCommandInvocationId.getId()
.- Returns:
true
if there are acknowledges pending from the backup owners,false
otherwise. (testing purposes only)
-
onMembersChange
public void onMembersChange(java.util.Collection<Address> members)
Notifies a change in member list.- Parameters:
members
- the new cluster members.
-
-