Search in sources :

Example 6 with InternalPartitionServiceImpl

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

the class ReplicaSyncRequest method run.

@Override
public void run() throws Exception {
    NodeEngineImpl nodeEngine = (NodeEngineImpl) getNodeEngine();
    InternalPartitionServiceImpl partitionService = (InternalPartitionServiceImpl) nodeEngine.getPartitionService();
    int partitionId = getPartitionId();
    int replicaIndex = getReplicaIndex();
    if (!partitionService.isReplicaSyncAllowed()) {
        ILogger logger = getLogger();
        if (logger.isFinestEnabled()) {
            logger.finest("Migration is paused! Cannot run replica sync -> " + toString());
        }
        sendRetryResponse();
        return;
    }
    if (!preCheckReplicaSync(nodeEngine, partitionId, replicaIndex)) {
        return;
    }
    try {
        List<Operation> tasks = createReplicationOperations();
        if (tasks.isEmpty()) {
            logNoReplicaDataFound(partitionId, replicaIndex);
            sendEmptyResponse();
        } else {
            sendResponse(tasks);
        }
    } finally {
        partitionService.getReplicaManager().releaseReplicaSyncPermit();
    }
}
Also used : NodeEngineImpl(com.hazelcast.spi.impl.NodeEngineImpl) InternalPartitionServiceImpl(com.hazelcast.internal.partition.impl.InternalPartitionServiceImpl) ILogger(com.hazelcast.logging.ILogger) PartitionAwareOperation(com.hazelcast.spi.PartitionAwareOperation) MigrationCycleOperation(com.hazelcast.internal.partition.MigrationCycleOperation) Operation(com.hazelcast.spi.Operation)

Example 7 with InternalPartitionServiceImpl

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

the class MigrationCommitOperation method run.

@Override
public void run() {
    NodeEngine nodeEngine = getNodeEngine();
    final Member localMember = nodeEngine.getLocalMember();
    if (!localMember.getUuid().equals(expectedMemberUuid)) {
        throw new IllegalStateException("This " + localMember + " is migration commit destination but most probably it's restarted " + "and not the expected target.");
    }
    partitionState.setEndpoint(getCallerAddress());
    InternalPartitionServiceImpl partitionService = getService();
    success = partitionService.processPartitionRuntimeState(partitionState);
}
Also used : NodeEngine(com.hazelcast.spi.NodeEngine) InternalPartitionServiceImpl(com.hazelcast.internal.partition.impl.InternalPartitionServiceImpl) Member(com.hazelcast.core.Member)

Example 8 with InternalPartitionServiceImpl

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

the class MigrationRequestOperation method invokeMigrationOperation.

private void invokeMigrationOperation(Address destination, long[] replicaVersions, Collection<Operation> tasks) throws IOException {
    MigrationOperation operation = new MigrationOperation(migrationInfo, replicaVersions, tasks, partitionStateVersion);
    NodeEngine nodeEngine = getNodeEngine();
    InternalPartitionServiceImpl partitionService = getService();
    nodeEngine.getOperationService().createInvocationBuilder(InternalPartitionService.SERVICE_NAME, operation, destination).setExecutionCallback(new MigrationCallback(migrationInfo, this)).setResultDeserialized(true).setCallTimeout(partitionService.getPartitionMigrationTimeout()).setTryCount(InternalPartitionService.MIGRATION_RETRY_COUNT).setTryPauseMillis(InternalPartitionService.MIGRATION_RETRY_PAUSE).setReplicaIndex(getReplicaIndex()).invoke();
}
Also used : NodeEngine(com.hazelcast.spi.NodeEngine) InternalPartitionServiceImpl(com.hazelcast.internal.partition.impl.InternalPartitionServiceImpl)

Example 9 with InternalPartitionServiceImpl

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

the class MigrationRequestOperation method run.

@Override
public void run() {
    NodeEngine nodeEngine = getNodeEngine();
    verifyGoodMaster(nodeEngine);
    Address source = migrationInfo.getSource();
    Address destination = migrationInfo.getDestination();
    verifyExistingTarget(nodeEngine, destination);
    if (destination.equals(source)) {
        getLogger().warning("Source and destination addresses are the same! => " + toString());
        setFailed();
        return;
    }
    InternalPartition partition = getPartition();
    verifySource(nodeEngine.getThisAddress(), partition);
    setActiveMigration();
    if (!migrationInfo.startProcessing()) {
        getLogger().warning("Migration is cancelled -> " + migrationInfo);
        setFailed();
        return;
    }
    try {
        executeBeforeMigrations();
        Collection<Operation> tasks = prepareMigrationOperations();
        InternalPartitionServiceImpl partitionService = getService();
        long[] replicaVersions = partitionService.getPartitionReplicaVersions(migrationInfo.getPartitionId());
        invokeMigrationOperation(destination, replicaVersions, tasks);
        returnResponse = false;
    } catch (Throwable e) {
        logThrowable(e);
        setFailed();
    } finally {
        migrationInfo.doneProcessing();
    }
}
Also used : NodeEngine(com.hazelcast.spi.NodeEngine) Address(com.hazelcast.nio.Address) InternalPartitionServiceImpl(com.hazelcast.internal.partition.impl.InternalPartitionServiceImpl) InternalPartition(com.hazelcast.internal.partition.InternalPartition) Operation(com.hazelcast.spi.Operation)

Example 10 with InternalPartitionServiceImpl

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

the class FinalizeMigrationOperation method run.

@Override
public void run() {
    NodeEngineImpl nodeEngine = (NodeEngineImpl) getNodeEngine();
    notifyServices(nodeEngine);
    if (endpoint == MigrationEndpoint.SOURCE && success) {
        commitSource();
    } else if (endpoint == MigrationEndpoint.DESTINATION && !success) {
        rollbackDestination();
    }
    InternalPartitionServiceImpl partitionService = getService();
    PartitionStateManager partitionStateManager = partitionService.getPartitionStateManager();
    partitionStateManager.clearMigratingFlag(migrationInfo.getPartitionId());
    if (success) {
        nodeEngine.onPartitionMigrate(migrationInfo);
    }
}
Also used : NodeEngineImpl(com.hazelcast.spi.impl.NodeEngineImpl) InternalPartitionServiceImpl(com.hazelcast.internal.partition.impl.InternalPartitionServiceImpl) PartitionStateManager(com.hazelcast.internal.partition.impl.PartitionStateManager)

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