Class PartitionHandlingManagerImpl
- java.lang.Object
-
- org.infinispan.partitionhandling.impl.PartitionHandlingManagerImpl
-
- All Implemented Interfaces:
PartitionHandlingManager
- Direct Known Subclasses:
ScatteredPartitionHandlingManagerImpl
public class PartitionHandlingManagerImpl extends Object implements PartitionHandlingManager
-
-
Field Summary
Fields Modifier and Type Field Description protected DistributionManagerdistributionManager
-
Constructor Summary
Constructors Constructor Description PartitionHandlingManagerImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanaddPartialCommit1PCTransaction(GlobalTransaction globalTransaction, Collection<Address> affectedNodes, Collection<Object> lockedKeys, List<WriteCommand> modifications)Adds a partially committed transaction.booleanaddPartialCommit2PCTransaction(GlobalTransaction globalTransaction, Collection<Address> affectedNodes, Collection<Object> lockedKeys, Map<Object,IncrementableEntryVersion> newVersions)Adds a partially committed transaction.booleanaddPartialRollbackTransaction(GlobalTransaction globalTransaction, Collection<Address> affectedNodes, Collection<Object> lockedKeys)Adds a partially aborted transaction.booleancanRollbackTransactionAfterOriginatorLeave(GlobalTransaction globalTransaction)It checks if the transaction can be aborted when the originator leaves the cluster.voidcheckBulkRead()voidcheckClear()voidcheckRead(Object key, long flagBitSet)voidcheckWrite(Object key)protected voiddoCheck(Object key, boolean isWrite, long flagBitSet)AvailabilityModegetAvailabilityMode()CacheTopologygetLastStableTopology()Collection<GlobalTransaction>getPartialTransactions()protected PartitionHandlinggetPartitionHandling()protected booleanisBulkOperationAllowed(boolean isWrite)protected booleanisKeyOperationAllowed(boolean isWrite, long flagBitSet, LocalizedCacheTopology cacheTopology, Object key)Check if a read/write operation is allowed with the actual membersbooleanisTransactionPartiallyCommitted(GlobalTransaction globalTransaction)It checks if the transaction resources (for example locks) can be released.voidonTopologyUpdate(CacheTopology cacheTopology)Notifies thePartitionHandlingManagerthat the cache topology was update.CompletionStage<Void>setAvailabilityMode(AvailabilityMode availabilityMode)voidstart()
-
-
-
Field Detail
-
distributionManager
protected DistributionManager distributionManager
-
-
Method Detail
-
start
public void start()
-
getAvailabilityMode
public AvailabilityMode getAvailabilityMode()
- Specified by:
getAvailabilityModein interfacePartitionHandlingManager
-
setAvailabilityMode
public CompletionStage<Void> setAvailabilityMode(AvailabilityMode availabilityMode)
- Specified by:
setAvailabilityModein interfacePartitionHandlingManager
-
checkWrite
public void checkWrite(Object key)
- Specified by:
checkWritein interfacePartitionHandlingManager
-
checkRead
public void checkRead(Object key, long flagBitSet)
- Specified by:
checkReadin interfacePartitionHandlingManager
-
checkClear
public void checkClear()
- Specified by:
checkClearin interfacePartitionHandlingManager
-
checkBulkRead
public void checkBulkRead()
- Specified by:
checkBulkReadin interfacePartitionHandlingManager
-
getLastStableTopology
public CacheTopology getLastStableTopology()
- Specified by:
getLastStableTopologyin interfacePartitionHandlingManager
-
addPartialRollbackTransaction
public boolean addPartialRollbackTransaction(GlobalTransaction globalTransaction, Collection<Address> affectedNodes, Collection<Object> lockedKeys)
Description copied from interface:PartitionHandlingManagerAdds a partially aborted transaction. The transaction should be registered when it is not sure if the abort happens successfully in all the affected nodes.- Specified by:
addPartialRollbackTransactionin interfacePartitionHandlingManager- Parameters:
globalTransaction- the global transaction.affectedNodes- the nodes involved in the transaction and they must abort the transaction.lockedKeys- the keys locally locked.- Returns:
trueif thePartitionHandlingManagerwill handle it,falseotherwise.
-
addPartialCommit2PCTransaction
public boolean addPartialCommit2PCTransaction(GlobalTransaction globalTransaction, Collection<Address> affectedNodes, Collection<Object> lockedKeys, Map<Object,IncrementableEntryVersion> newVersions)
Description copied from interface:PartitionHandlingManagerAdds a partially committed transaction. The transaction is committed in the second phase and it is register if it is not sure that the transaction was committed successfully in all the affected nodes.- Specified by:
addPartialCommit2PCTransactionin interfacePartitionHandlingManager- Parameters:
globalTransaction- the global transaction.affectedNodes- the nodes involved in the transaction and they must commit it.lockedKeys- the keys locally locked.newVersions- the updated versions. Only used when versioning is enabled.- Returns:
trueif thePartitionHandlingManagerwill handle it,falseotherwise.
-
addPartialCommit1PCTransaction
public boolean addPartialCommit1PCTransaction(GlobalTransaction globalTransaction, Collection<Address> affectedNodes, Collection<Object> lockedKeys, List<WriteCommand> modifications)
Description copied from interface:PartitionHandlingManagerAdds a partially committed transaction. The transaction is committed in one phase and it is register if it is not sure that the transaction was committed successfully in all the affected nodes.- Specified by:
addPartialCommit1PCTransactionin interfacePartitionHandlingManager- Parameters:
globalTransaction- the global transaction.affectedNodes- the nodes involved in the transaction and they must commit it.lockedKeys- the keys locally locked.modifications- the transaction's modification log.- Returns:
trueif thePartitionHandlingManagerwill handle it,falseotherwise.
-
isTransactionPartiallyCommitted
public boolean isTransactionPartiallyCommitted(GlobalTransaction globalTransaction)
Description copied from interface:PartitionHandlingManagerIt checks if the transaction resources (for example locks) can be released. The transaction resource can't be released when the transaction is partially committed.- Specified by:
isTransactionPartiallyCommittedin interfacePartitionHandlingManager- Parameters:
globalTransaction- the transaction.- Returns:
trueif the resources can be released,falseotherwise.
-
getPartialTransactions
public Collection<GlobalTransaction> getPartialTransactions()
- Specified by:
getPartialTransactionsin interfacePartitionHandlingManager- Returns:
- a collection of partial committed or aborted transactions.
-
canRollbackTransactionAfterOriginatorLeave
public boolean canRollbackTransactionAfterOriginatorLeave(GlobalTransaction globalTransaction)
Description copied from interface:PartitionHandlingManagerIt checks if the transaction can be aborted when the originator leaves the cluster. The only case in which it is not possible to abort is when partition handling is enabled and the originator didn't leave gracefully. The transaction will complete when the partition heals.- Specified by:
canRollbackTransactionAfterOriginatorLeavein interfacePartitionHandlingManager- Parameters:
globalTransaction- the global transaction.- Returns:
trueif the transaction can be aborted,falseotherwise.
-
onTopologyUpdate
public void onTopologyUpdate(CacheTopology cacheTopology)
Description copied from interface:PartitionHandlingManagerNotifies thePartitionHandlingManagerthat the cache topology was update. It detects when the partition is merged and tries to complete all the partially completed transactions.- Specified by:
onTopologyUpdatein interfacePartitionHandlingManager- Parameters:
cacheTopology- the new cache topology.
-
doCheck
protected void doCheck(Object key, boolean isWrite, long flagBitSet)
-
isKeyOperationAllowed
protected boolean isKeyOperationAllowed(boolean isWrite, long flagBitSet, LocalizedCacheTopology cacheTopology, Object key)Check if a read/write operation is allowed with the actual members- Parameters:
isWrite-falsefor reads,truefor writesflagBitSet- reads with theFlag.FORCE_WRITE_LOCKare treated as writescacheTopology- actual members, ornullfor bulk operationskey- key owners, ornullfor bulk operations- Returns:
-
isBulkOperationAllowed
protected boolean isBulkOperationAllowed(boolean isWrite)
-
getPartitionHandling
protected PartitionHandling getPartitionHandling()
-
-