Search in sources :

Example 26 with InternalPartitionServiceImpl

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

the class BeforePromotionOperation method beforeRun.

@Override
public void beforeRun() throws Exception {
    sendMigrationEvent(STARTED);
    InternalPartitionServiceImpl service = getService();
    PartitionStateManager partitionStateManager = service.getPartitionStateManager();
    partitionStateManager.setMigratingFlag(getPartitionId());
}
Also used : InternalPartitionServiceImpl(com.hazelcast.internal.partition.impl.InternalPartitionServiceImpl) PartitionStateManager(com.hazelcast.internal.partition.impl.PartitionStateManager)

Example 27 with InternalPartitionServiceImpl

use of com.hazelcast.internal.partition.impl.InternalPartitionServiceImpl 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 28 with InternalPartitionServiceImpl

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

the class FetchPartitionStateOperation method run.

@Override
public void run() {
    final Address caller = getCallerAddress();
    final Address master = getNodeEngine().getMasterAddress();
    if (!caller.equals(master)) {
        final String msg = caller + " requested our partition table but it's not our known master. " + "Master: " + master;
        getLogger().warning(msg);
        throw new RetryableHazelcastException(msg);
    }
    InternalPartitionServiceImpl service = getService();
    partitionState = service.createPartitionStateInternal();
}
Also used : Address(com.hazelcast.nio.Address) RetryableHazelcastException(com.hazelcast.spi.exception.RetryableHazelcastException) InternalPartitionServiceImpl(com.hazelcast.internal.partition.impl.InternalPartitionServiceImpl)

Example 29 with InternalPartitionServiceImpl

use of com.hazelcast.internal.partition.impl.InternalPartitionServiceImpl 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 30 with InternalPartitionServiceImpl

use of com.hazelcast.internal.partition.impl.InternalPartitionServiceImpl 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)

Aggregations

InternalPartitionServiceImpl (com.hazelcast.internal.partition.impl.InternalPartitionServiceImpl)35 Address (com.hazelcast.nio.Address)11 ILogger (com.hazelcast.logging.ILogger)10 PartitionStateManager (com.hazelcast.internal.partition.impl.PartitionStateManager)7 NodeEngine (com.hazelcast.spi.NodeEngine)7 HazelcastInstance (com.hazelcast.core.HazelcastInstance)6 NodeEngineImpl (com.hazelcast.spi.impl.NodeEngineImpl)5 IPartitionLostEvent (com.hazelcast.spi.partition.IPartitionLostEvent)5 ParallelTest (com.hazelcast.test.annotation.ParallelTest)5 QuickTest (com.hazelcast.test.annotation.QuickTest)5 Test (org.junit.Test)5 InternalPartitionImpl (com.hazelcast.internal.partition.impl.InternalPartitionImpl)4 PartitionReplicaManager (com.hazelcast.internal.partition.impl.PartitionReplicaManager)4 EventCollectingPartitionLostListener (com.hazelcast.partition.PartitionLostListenerStressTest.EventCollectingPartitionLostListener)4 MigrationInfo (com.hazelcast.internal.partition.MigrationInfo)3 InternalMigrationListener (com.hazelcast.internal.partition.impl.InternalMigrationListener)3 InternalOperationService (com.hazelcast.spi.impl.operationservice.InternalOperationService)3 MigrationEndpoint (com.hazelcast.spi.partition.MigrationEndpoint)3 ClusterService (com.hazelcast.internal.cluster.ClusterService)2 Operation (com.hazelcast.spi.Operation)2