public class PartitionReplicaManager extends Object implements PartitionReplicaVersionManager
Modifier and Type | Method and Description |
---|---|
int |
availableReplicaSyncPermits()
Returns the number of available permits.
|
void |
clearPartitionReplicaVersions(int partitionId,
ServiceNamespace namespace) |
void |
clearReplicaSyncRequest(int partitionId,
ServiceNamespace namespace,
int replicaIndex)
Resets the state of the replica synchronization request for the given partition and replica.
|
void |
finalizeReplicaSync(int partitionId,
int replicaIndex,
ServiceNamespace namespace,
long[] versions)
Set the new replica versions for the partition with the
partitionId and reset any ongoing replica
synchronization request for this partition and replica index. |
Collection<ServiceNamespace> |
getNamespaces(int partitionId)
Returns all registered namespaces for given partition ID
|
long[] |
getPartitionReplicaVersions(int partitionId,
ServiceNamespace namespace)
Returns replica versions for given partition and namespace.
|
ServiceNamespace |
getServiceNamespace(Operation operation)
Returns
ServiceNamespace for given operation. |
long[] |
incrementPartitionReplicaVersions(int partitionId,
ServiceNamespace namespace,
int backupCount)
Increments replica versions for given partition and namespace by the number of backup count.
|
boolean |
isPartitionReplicaVersionDirty(int partitionId,
ServiceNamespace namespace) |
boolean |
isPartitionReplicaVersionStale(int partitionId,
ServiceNamespace namespace,
long[] versions,
int replicaIndex)
Returns whether given replica version is behind the current version or not.
|
void |
releaseReplicaSyncPermits(int permits)
Releases the previously acquired permits.
|
void |
retainNamespaces(int partitionId,
Set<ServiceNamespace> namespaces) |
void |
setPartitionReplicaVersions(int partitionId,
ServiceNamespace namespace,
long[] versions,
int replicaOffset) |
void |
triggerPartitionReplicaSync(int partitionId,
Collection<ServiceNamespace> namespaces,
int replicaIndex)
This method is called on a backup node (replica).
|
int |
tryAcquireReplicaSyncPermits(int requestedPermits)
Tries to acquire requested permits.
|
void |
updatePartitionReplicaVersions(int partitionId,
ServiceNamespace namespace,
long[] versions,
int replicaIndex)
Updates the partition replica version and triggers replica sync if the replica is dirty (e.g.
|
public void triggerPartitionReplicaSync(int partitionId, Collection<ServiceNamespace> namespaces, int replicaIndex)
delayMillis
is greater than 0partitionId
- the partition which is being synchronizednamespaces
- namespaces of partition replica fragmentsreplicaIndex
- the index of the replica which is being synchronizedIllegalArgumentException
- if the replica index is not between 0 and InternalPartition.MAX_REPLICA_COUNT
public ServiceNamespace getServiceNamespace(Operation operation)
PartitionReplicaVersionManager
ServiceNamespace
for given operation. If operation is instance of
ServiceNamespaceAware
then ServiceNamespaceAware.getServiceNamespace()
will be used. Otherwise NonFragmentedServiceNamespace
will be returned.getServiceNamespace
in interface PartitionReplicaVersionManager
operation
- operationpublic long[] incrementPartitionReplicaVersions(int partitionId, ServiceNamespace namespace, int backupCount)
PartitionReplicaVersionManager
incrementPartitionReplicaVersions
in interface PartitionReplicaVersionManager
partitionId
- partition IDnamespace
- replica namespacebackupCount
- number of desired backupspublic void updatePartitionReplicaVersions(int partitionId, ServiceNamespace namespace, long[] versions, int replicaIndex)
PartitionReplicaVersionManager
updatePartitionReplicaVersions
in interface PartitionReplicaVersionManager
partitionId
- the ID of the partition for which we received a new versionnamespace
- replica namespaceversions
- the received replica versionsreplicaIndex
- the index of this replicapublic boolean isPartitionReplicaVersionStale(int partitionId, ServiceNamespace namespace, long[] versions, int replicaIndex)
PartitionReplicaVersionManager
isPartitionReplicaVersionStale
in interface PartitionReplicaVersionManager
partitionId
- partition IDnamespace
- replica namespaceversions
- replica versionsreplicaIndex
- specific replica indexpublic boolean isPartitionReplicaVersionDirty(int partitionId, ServiceNamespace namespace)
public long[] getPartitionReplicaVersions(int partitionId, ServiceNamespace namespace)
PartitionReplicaVersionManager
getPartitionReplicaVersions
in interface PartitionReplicaVersionManager
partitionId
- partition IDnamespace
- replica namespacepublic void setPartitionReplicaVersions(int partitionId, ServiceNamespace namespace, long[] versions, int replicaOffset)
public void clearPartitionReplicaVersions(int partitionId, ServiceNamespace namespace)
public void finalizeReplicaSync(int partitionId, int replicaIndex, ServiceNamespace namespace, long[] versions)
partitionId
and reset any ongoing replica
synchronization request for this partition and replica index.partitionId
- the partition IDreplicaIndex
- the index of the replicaversions
- the new replica versions for the partitionpublic void clearReplicaSyncRequest(int partitionId, ServiceNamespace namespace, int replicaIndex)
partitionId
- the partition being synchronizednamespace
- namespacereplicaIndex
- the index of the replica being synchronizedpublic int tryAcquireReplicaSyncPermits(int requestedPermits)
[0, requestedPermits]
.requestedPermits
- number of requested permitspublic void releaseReplicaSyncPermits(int permits)
permits
- number of permitspublic int availableReplicaSyncPermits()
public Collection<ServiceNamespace> getNamespaces(int partitionId)
PartitionReplicaVersionManager
getNamespaces
in interface PartitionReplicaVersionManager
partitionId
- partition IDpublic void retainNamespaces(int partitionId, Set<ServiceNamespace> namespaces)
Copyright © 2021 Hazelcast, Inc.. All Rights Reserved.