Search in sources :

Example 11 with NodeEngineImpl

use of com.hazelcast.spi.impl.NodeEngineImpl 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 12 with NodeEngineImpl

use of com.hazelcast.spi.impl.NodeEngineImpl in project hazelcast by hazelcast.

the class MigrationRequestOperation method prepareMigrationOperations.

private Collection<Operation> prepareMigrationOperations() {
    NodeEngineImpl nodeEngine = (NodeEngineImpl) getNodeEngine();
    PartitionReplicationEvent replicationEvent = new PartitionReplicationEvent(migrationInfo.getPartitionId(), migrationInfo.getDestinationNewReplicaIndex());
    Collection<Operation> tasks = new LinkedList<Operation>();
    for (ServiceInfo serviceInfo : nodeEngine.getServiceInfos(MigrationAwareService.class)) {
        MigrationAwareService service = (MigrationAwareService) serviceInfo.getService();
        Operation op = service.prepareReplicationOperation(replicationEvent);
        if (op != null) {
            op.setServiceName(serviceInfo.getName());
            tasks.add(op);
        }
    }
    return tasks;
}
Also used : NodeEngineImpl(com.hazelcast.spi.impl.NodeEngineImpl) ServiceInfo(com.hazelcast.spi.impl.servicemanager.ServiceInfo) MigrationAwareService(com.hazelcast.spi.MigrationAwareService) Operation(com.hazelcast.spi.Operation) PartitionReplicationEvent(com.hazelcast.spi.PartitionReplicationEvent) LinkedList(java.util.LinkedList)

Example 13 with NodeEngineImpl

use of com.hazelcast.spi.impl.NodeEngineImpl in project hazelcast by hazelcast.

the class BaseMigrationOperation method verifyClusterState.

private void verifyClusterState() {
    final NodeEngineImpl nodeEngine = (NodeEngineImpl) getNodeEngine();
    ClusterState clusterState = nodeEngine.getClusterService().getClusterState();
    if (clusterState != ClusterState.ACTIVE) {
        throw new IllegalStateException("Cluster state is not active! " + clusterState);
    }
    final Node node = nodeEngine.getNode();
    if (!node.getNodeExtension().isStartCompleted()) {
        throw new IllegalStateException("Migration operation is received before startup is completed. " + "Caller: " + getCallerAddress());
    }
}
Also used : NodeEngineImpl(com.hazelcast.spi.impl.NodeEngineImpl) ClusterState(com.hazelcast.cluster.ClusterState) Node(com.hazelcast.instance.Node)

Example 14 with NodeEngineImpl

use of com.hazelcast.spi.impl.NodeEngineImpl 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)

Example 15 with NodeEngineImpl

use of com.hazelcast.spi.impl.NodeEngineImpl in project hazelcast by hazelcast.

the class MapDestroyTest method getMapServiceContext.

private MapServiceContext getMapServiceContext(HazelcastInstance instance) {
    NodeEngineImpl nodeEngine1 = getNodeEngineImpl(instance);
    MapService mapService = nodeEngine1.getService(MapService.SERVICE_NAME);
    return mapService.getMapServiceContext();
}
Also used : NodeEngineImpl(com.hazelcast.spi.impl.NodeEngineImpl) MapService(com.hazelcast.map.impl.MapService)

Aggregations

NodeEngineImpl (com.hazelcast.spi.impl.NodeEngineImpl)112 HazelcastInstance (com.hazelcast.core.HazelcastInstance)39 Test (org.junit.Test)32 ParallelTest (com.hazelcast.test.annotation.ParallelTest)31 QuickTest (com.hazelcast.test.annotation.QuickTest)31 Node (com.hazelcast.instance.Node)21 MapService (com.hazelcast.map.impl.MapService)20 Config (com.hazelcast.config.Config)19 TestHazelcastInstanceFactory (com.hazelcast.test.TestHazelcastInstanceFactory)19 InternalOperationService (com.hazelcast.spi.impl.operationservice.InternalOperationService)16 MetaDataGenerator (com.hazelcast.internal.nearcache.impl.invalidation.MetaDataGenerator)14 MapServiceContext (com.hazelcast.map.impl.MapServiceContext)14 ILogger (com.hazelcast.logging.ILogger)11 AssertTask (com.hazelcast.test.AssertTask)11 Invalidator (com.hazelcast.internal.nearcache.impl.invalidation.Invalidator)10 MapNearCacheManager (com.hazelcast.map.impl.nearcache.MapNearCacheManager)10 Address (com.hazelcast.nio.Address)10 Data (com.hazelcast.nio.serialization.Data)10 Before (org.junit.Before)10 Operation (com.hazelcast.spi.Operation)9