Search in sources :

Example 1 with PartitionReplicaManager

use of com.hazelcast.internal.partition.impl.PartitionReplicaManager in project hazelcast by hazelcast.

the class ReplicaSyncResponse method postProcessReplicaSync.

private void postProcessReplicaSync(InternalPartitionServiceImpl partitionService, int currentReplicaIndex) {
    int partitionId = getPartitionId();
    int replicaIndex = getReplicaIndex();
    PartitionReplicaManager replicaManager = partitionService.getReplicaManager();
    if (replicaIndex == currentReplicaIndex) {
        replicaManager.finalizeReplicaSync(partitionId, replicaIndex, replicaVersions);
    } else {
        replicaManager.clearReplicaSyncRequest(partitionId, replicaIndex);
        if (currentReplicaIndex < 0) {
            replicaManager.clearPartitionReplicaVersions(partitionId);
        } else if (currentReplicaIndex > 0) {
            replicaManager.triggerPartitionReplicaSync(partitionId, currentReplicaIndex, 0);
        }
    }
}
Also used : PartitionReplicaManager(com.hazelcast.internal.partition.impl.PartitionReplicaManager)

Example 2 with PartitionReplicaManager

use of com.hazelcast.internal.partition.impl.PartitionReplicaManager in project hazelcast by hazelcast.

the class CheckReplicaVersion method run.

@Override
public void run() throws Exception {
    InternalPartitionServiceImpl partitionService = getService();
    int partitionId = getPartitionId();
    int replicaIndex = getReplicaIndex();
    PartitionReplicaManager replicaManager = partitionService.getReplicaManager();
    long[] currentVersions = replicaManager.getPartitionReplicaVersions(partitionId);
    long currentVersion = currentVersions[replicaIndex - 1];
    if (replicaManager.isPartitionReplicaVersionDirty(partitionId) || currentVersion != version) {
        logBackupVersionMismatch(currentVersion);
        replicaManager.triggerPartitionReplicaSync(partitionId, replicaIndex, 0L);
        response = false;
    } else {
        response = true;
    }
}
Also used : InternalPartitionServiceImpl(com.hazelcast.internal.partition.impl.InternalPartitionServiceImpl) PartitionReplicaManager(com.hazelcast.internal.partition.impl.PartitionReplicaManager)

Example 3 with PartitionReplicaManager

use of com.hazelcast.internal.partition.impl.PartitionReplicaManager in project hazelcast by hazelcast.

the class FinalizeMigrationOperation method rollbackDestination.

private void rollbackDestination() {
    int partitionId = getPartitionId();
    InternalPartitionServiceImpl partitionService = getService();
    PartitionReplicaManager replicaManager = partitionService.getReplicaManager();
    ILogger logger = getLogger();
    int destinationCurrentReplicaIndex = migrationInfo.getDestinationCurrentReplicaIndex();
    if (destinationCurrentReplicaIndex == -1) {
        replicaManager.clearPartitionReplicaVersions(partitionId);
        if (logger.isFinestEnabled()) {
            logger.finest("Replica versions are cleared in destination after failed migration. partitionId=" + partitionId);
        }
    } else {
        int replicaOffset = migrationInfo.getDestinationCurrentReplicaIndex() <= 1 ? 1 : migrationInfo.getDestinationCurrentReplicaIndex();
        long[] versions = updatePartitionReplicaVersions(replicaManager, partitionId, replicaOffset - 1);
        if (logger.isFinestEnabled()) {
            logger.finest("Replica versions are rolled back in destination after failed migration. partitionId=" + partitionId + " replica versions=" + Arrays.toString(versions));
        }
    }
}
Also used : InternalPartitionServiceImpl(com.hazelcast.internal.partition.impl.InternalPartitionServiceImpl) PartitionReplicaManager(com.hazelcast.internal.partition.impl.PartitionReplicaManager) ILogger(com.hazelcast.logging.ILogger) MigrationEndpoint(com.hazelcast.spi.partition.MigrationEndpoint)

Example 4 with PartitionReplicaManager

use of com.hazelcast.internal.partition.impl.PartitionReplicaManager in project hazelcast by hazelcast.

the class FinalizeMigrationOperation method commitSource.

private void commitSource() {
    int partitionId = getPartitionId();
    InternalPartitionServiceImpl partitionService = getService();
    PartitionReplicaManager replicaManager = partitionService.getReplicaManager();
    ILogger logger = getLogger();
    int sourceNewReplicaIndex = migrationInfo.getSourceNewReplicaIndex();
    if (sourceNewReplicaIndex < 0) {
        replicaManager.clearPartitionReplicaVersions(partitionId);
        if (logger.isFinestEnabled()) {
            logger.finest("Replica versions are cleared in source after migration. partitionId=" + partitionId);
        }
    } else if (migrationInfo.getSourceCurrentReplicaIndex() != sourceNewReplicaIndex && sourceNewReplicaIndex > 1) {
        long[] versions = updatePartitionReplicaVersions(replicaManager, partitionId, sourceNewReplicaIndex - 1);
        if (logger.isFinestEnabled()) {
            logger.finest("Replica versions are set after SHIFT DOWN migration. partitionId=" + partitionId + " replica versions=" + Arrays.toString(versions));
        }
    }
}
Also used : InternalPartitionServiceImpl(com.hazelcast.internal.partition.impl.InternalPartitionServiceImpl) PartitionReplicaManager(com.hazelcast.internal.partition.impl.PartitionReplicaManager) ILogger(com.hazelcast.logging.ILogger) MigrationEndpoint(com.hazelcast.spi.partition.MigrationEndpoint)

Example 5 with PartitionReplicaManager

use of com.hazelcast.internal.partition.impl.PartitionReplicaManager in project hazelcast by hazelcast.

the class MigrationOperation method afterMigrate.

private void afterMigrate() {
    if (success) {
        InternalPartitionServiceImpl partitionService = getService();
        PartitionReplicaManager replicaManager = partitionService.getReplicaManager();
        int destinationNewReplicaIndex = migrationInfo.getDestinationNewReplicaIndex();
        int replicaOffset = destinationNewReplicaIndex <= 1 ? 1 : destinationNewReplicaIndex;
        replicaManager.setPartitionReplicaVersions(migrationInfo.getPartitionId(), replicaVersions, replicaOffset);
        if (getLogger().isFinestEnabled()) {
            getLogger().finest("ReplicaVersions are set after migration. partitionId=" + migrationInfo.getPartitionId() + " replicaVersions=" + Arrays.toString(replicaVersions));
        }
    } else if (getLogger().isFinestEnabled()) {
        getLogger().finest("ReplicaVersions are not set since migration failed. partitionId=" + migrationInfo.getPartitionId());
    }
    migrationInfo.doneProcessing();
}
Also used : InternalPartitionServiceImpl(com.hazelcast.internal.partition.impl.InternalPartitionServiceImpl) PartitionReplicaManager(com.hazelcast.internal.partition.impl.PartitionReplicaManager) MigrationEndpoint(com.hazelcast.spi.partition.MigrationEndpoint)

Aggregations

PartitionReplicaManager (com.hazelcast.internal.partition.impl.PartitionReplicaManager)5 InternalPartitionServiceImpl (com.hazelcast.internal.partition.impl.InternalPartitionServiceImpl)4 MigrationEndpoint (com.hazelcast.spi.partition.MigrationEndpoint)3 ILogger (com.hazelcast.logging.ILogger)2