Search in sources :

Example 6 with PartitionReplicaVersionManager

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;
    }
}
Also used : NodeEngineImpl(com.hazelcast.spi.impl.NodeEngineImpl) InternalPartitionService(com.hazelcast.internal.partition.InternalPartitionService) PartitionReplica(com.hazelcast.internal.partition.PartitionReplica) ILogger(com.hazelcast.logging.ILogger) InternalPartition(com.hazelcast.internal.partition.InternalPartition) PartitionReplicaVersionManager(com.hazelcast.internal.partition.PartitionReplicaVersionManager)

Example 7 with PartitionReplicaVersionManager

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());
}
Also used : ReplicaFragmentMigrationState(com.hazelcast.internal.partition.ReplicaFragmentMigrationState) InternalPartitionService(com.hazelcast.internal.partition.InternalPartitionService) HashMap(java.util.HashMap) NonFragmentedServiceNamespace(com.hazelcast.internal.partition.NonFragmentedServiceNamespace) ServiceNamespace(com.hazelcast.internal.services.ServiceNamespace) PartitionReplicaVersionManager(com.hazelcast.internal.partition.PartitionReplicaVersionManager)

Aggregations

PartitionReplicaVersionManager (com.hazelcast.internal.partition.PartitionReplicaVersionManager)7 ServiceNamespace (com.hazelcast.internal.services.ServiceNamespace)4 InternalPartitionServiceImpl (com.hazelcast.internal.partition.impl.InternalPartitionServiceImpl)3 InternalPartitionService (com.hazelcast.internal.partition.InternalPartitionService)2 NonFragmentedServiceNamespace (com.hazelcast.internal.partition.NonFragmentedServiceNamespace)2 NodeEngineImpl (com.hazelcast.spi.impl.NodeEngineImpl)2 InternalPartition (com.hazelcast.internal.partition.InternalPartition)1 PartitionReplica (com.hazelcast.internal.partition.PartitionReplica)1 ReplicaFragmentMigrationState (com.hazelcast.internal.partition.ReplicaFragmentMigrationState)1 PartitionEventManager (com.hazelcast.internal.partition.impl.PartitionEventManager)1 ILogger (com.hazelcast.logging.ILogger)1 BackupAwareOperation (com.hazelcast.spi.impl.operationservice.BackupAwareOperation)1 Operation (com.hazelcast.spi.impl.operationservice.Operation)1 OperationService (com.hazelcast.spi.impl.operationservice.OperationService)1 HashMap (java.util.HashMap)1