use of com.hazelcast.internal.partition.PartitionReplicaVersionManager in project hazelcast by hazelcast.
the class Backup method beforeRun.
@Override
public void beforeRun() {
NodeEngineImpl nodeEngine = (NodeEngineImpl) getNodeEngine();
int partitionId = getPartitionId();
InternalPartitionService partitionService = nodeEngine.getPartitionService();
ILogger logger = getLogger();
ensureBackupOperationInitialized();
PartitionReplicaVersionManager versionManager = partitionService.getPartitionReplicaVersionManager();
namespace = versionManager.getServiceNamespace(backupOp);
if (!nodeEngine.getNode().getNodeExtension().isStartCompleted()) {
validationFailure = new IllegalStateException("Ignoring backup! " + "Backup operation is received before startup is completed.");
if (logger.isFinestEnabled()) {
logger.finest(validationFailure.getMessage());
}
return;
}
InternalPartition partition = partitionService.getPartition(partitionId);
PartitionReplica owner = partition.getReplica(getReplicaIndex());
if (owner == null || !owner.isIdentical(nodeEngine.getLocalMember())) {
validationFailure = new IllegalStateException("Wrong target! " + toString() + " cannot be processed! Target should be: " + owner);
if (logger.isFinestEnabled()) {
logger.finest(validationFailure.getMessage());
}
return;
}
if (versionManager.isPartitionReplicaVersionStale(getPartitionId(), namespace, replicaVersions, getReplicaIndex())) {
validationFailure = new IllegalStateException("Ignoring stale backup with namespace: " + namespace + ", versions: " + Arrays.toString(replicaVersions));
if (logger.isFineEnabled()) {
long[] currentVersions = versionManager.getPartitionReplicaVersions(partitionId, namespace);
logger.fine("Ignoring stale backup! namespace: " + namespace + ", Current-versions: " + Arrays.toString(currentVersions) + ", Backup-versions: " + Arrays.toString(replicaVersions));
}
return;
}
}
use of com.hazelcast.internal.partition.PartitionReplicaVersionManager in project hazelcast by hazelcast.
the class MigrationRequestOperation method createReplicaFragmentMigrationState.
private ReplicaFragmentMigrationState createReplicaFragmentMigrationState(Collection<ServiceNamespace> namespaces, Collection<Operation> operations, Collection<ChunkSupplier> suppliers, int maxTotalChunkedDataInBytes) {
InternalPartitionService partitionService = getService();
PartitionReplicaVersionManager versionManager = partitionService.getPartitionReplicaVersionManager();
Map<ServiceNamespace, long[]> versions = new HashMap<>(namespaces.size());
for (ServiceNamespace namespace : namespaces) {
long[] v = versionManager.getPartitionReplicaVersions(getPartitionId(), namespace);
versions.put(namespace, v);
}
return new ReplicaFragmentMigrationState(versions, operations, suppliers, chunkedMigrationEnabled, maxTotalChunkedDataInBytes, getLogger(), getPartitionId());
}
Aggregations