Search in sources :

Example 16 with Operation

use of com.hazelcast.spi.impl.operationservice.Operation in project hazelcast by hazelcast.

the class MigrationRequestOperation method createReplicaFragmentMigrationStateFor.

private ReplicaFragmentMigrationState createReplicaFragmentMigrationStateFor(ServiceNamespace ns) {
    PartitionReplicationEvent event = getPartitionReplicationEvent();
    Collection<String> serviceNames = namespacesContext.getServiceNames(ns);
    Collection<Operation> operations = createFragmentReplicationOperationsOffload(event, ns, serviceNames);
    return createReplicaFragmentMigrationState(singleton(ns), operations, emptyList(), maxTotalChunkedDataInBytes);
}
Also used : UrgentSystemOperation(com.hazelcast.spi.impl.operationservice.UrgentSystemOperation) Operation(com.hazelcast.spi.impl.operationservice.Operation) PartitionReplicationEvent(com.hazelcast.internal.partition.PartitionReplicationEvent)

Example 17 with Operation

use of com.hazelcast.spi.impl.operationservice.Operation in project hazelcast by hazelcast.

the class PartitionReplicaSyncRequest method sendOperationsForNamespaces.

/**
 * Send responses for first number of {@code permits} namespaces and remove them from the list.
 */
protected void sendOperationsForNamespaces(int permits) {
    InternalPartitionServiceImpl partitionService = getService();
    try {
        PartitionReplicationEvent event = new PartitionReplicationEvent(getCallerAddress(), partitionId(), getReplicaIndex());
        Iterator<ServiceNamespace> iterator = namespaces.iterator();
        for (int i = 0; i < permits; i++) {
            ServiceNamespace namespace = iterator.next();
            Collection<Operation> operations = Collections.emptyList();
            Collection<ChunkSupplier> chunkSuppliers = Collections.emptyList();
            if (NonFragmentedServiceNamespace.INSTANCE.equals(namespace)) {
                operations = createNonFragmentedReplicationOperations(event);
            } else {
                chunkSuppliers = isChunkedMigrationEnabled() ? collectChunkSuppliers(event, namespace) : chunkSuppliers;
                if (isEmpty(chunkSuppliers)) {
                    operations = createFragmentReplicationOperations(event, namespace);
                }
            }
            sendOperations(operations, chunkSuppliers, namespace);
            while (hasRemainingChunksToSend(chunkSuppliers)) {
                sendOperations(operations, chunkSuppliers, namespace);
            }
            iterator.remove();
        }
    } finally {
        partitionService.getReplicaManager().releaseReplicaSyncPermits(permits);
    }
}
Also used : ChunkSupplier(com.hazelcast.internal.partition.ChunkSupplier) InternalPartitionServiceImpl(com.hazelcast.internal.partition.impl.InternalPartitionServiceImpl) NonFragmentedServiceNamespace(com.hazelcast.internal.partition.NonFragmentedServiceNamespace) ServiceNamespace(com.hazelcast.internal.services.ServiceNamespace) Operation(com.hazelcast.spi.impl.operationservice.Operation) MigrationCycleOperation(com.hazelcast.internal.partition.MigrationCycleOperation) PartitionAwareOperation(com.hazelcast.spi.impl.operationservice.PartitionAwareOperation) PartitionReplicationEvent(com.hazelcast.internal.partition.PartitionReplicationEvent)

Example 18 with Operation

use of com.hazelcast.spi.impl.operationservice.Operation in project hazelcast by hazelcast.

the class AbstractPartitionOperation method prepareReplicationOperation.

private Operation prepareReplicationOperation(PartitionReplicationEvent event, ServiceNamespace ns, FragmentedMigrationAwareService service, String serviceName) {
    Operation op = service.prepareReplicationOperation(event, singleton(ns));
    if (op == null) {
        return null;
    }
    op.setServiceName(serviceName);
    return op;
}
Also used : Operation(com.hazelcast.spi.impl.operationservice.Operation)

Example 19 with Operation

use of com.hazelcast.spi.impl.operationservice.Operation in project hazelcast by hazelcast.

the class AbstractPartitionOperation method createFragmentReplicationOperationsOffload.

/**
 * Used for partition replica sync, supporting
 * offloaded replication-operation preparation
 */
final Collection<Operation> createFragmentReplicationOperationsOffload(PartitionReplicationEvent event, ServiceNamespace ns) {
    assert !(ns instanceof NonFragmentedServiceNamespace) : ns + " should be used only for fragmented services!";
    Collection<Operation> operations = emptySet();
    NodeEngineImpl nodeEngine = (NodeEngineImpl) getNodeEngine();
    Collection<ServiceInfo> services = nodeEngine.getServiceInfos(FragmentedMigrationAwareService.class);
    for (ServiceInfo serviceInfo : services) {
        FragmentedMigrationAwareService service = serviceInfo.getService();
        if (!service.isKnownServiceNamespace(ns)) {
            continue;
        }
        operations = collectReplicationOperations(event, ns, isRunningOnPartitionThread(), operations, serviceInfo.getName(), service);
    }
    return operations;
}
Also used : NodeEngineImpl(com.hazelcast.spi.impl.NodeEngineImpl) ServiceInfo(com.hazelcast.spi.impl.servicemanager.ServiceInfo) Operation(com.hazelcast.spi.impl.operationservice.Operation) FragmentedMigrationAwareService(com.hazelcast.internal.partition.FragmentedMigrationAwareService) NonFragmentedServiceNamespace(com.hazelcast.internal.partition.NonFragmentedServiceNamespace)

Example 20 with Operation

use of com.hazelcast.spi.impl.operationservice.Operation in project hazelcast by hazelcast.

the class AbstractPartitionOperation method createFragmentReplicationOperationsOffload.

/**
 * Used for offloaded replication-operation
 * preparation while executing a migration request
 */
final Collection<Operation> createFragmentReplicationOperationsOffload(PartitionReplicationEvent event, ServiceNamespace ns, Collection<String> serviceNames) {
    assert !(ns instanceof NonFragmentedServiceNamespace) : ns + " should be used only for fragmented services!";
    Collection<Operation> operations = emptySet();
    NodeEngineImpl nodeEngine = (NodeEngineImpl) getNodeEngine();
    for (String serviceName : serviceNames) {
        FragmentedMigrationAwareService service = nodeEngine.getService(serviceName);
        assert service.isKnownServiceNamespace(ns) : ns + " should be known by " + service;
        operations = collectReplicationOperations(event, ns, isRunningOnPartitionThread(), operations, serviceName, service);
    }
    return operations;
}
Also used : NodeEngineImpl(com.hazelcast.spi.impl.NodeEngineImpl) Operation(com.hazelcast.spi.impl.operationservice.Operation) FragmentedMigrationAwareService(com.hazelcast.internal.partition.FragmentedMigrationAwareService) NonFragmentedServiceNamespace(com.hazelcast.internal.partition.NonFragmentedServiceNamespace)

Aggregations

Operation (com.hazelcast.spi.impl.operationservice.Operation)271 Test (org.junit.Test)80 QuickTest (com.hazelcast.test.annotation.QuickTest)79 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)59 OperationService (com.hazelcast.spi.impl.operationservice.OperationService)56 Address (com.hazelcast.cluster.Address)31 HazelcastInstance (com.hazelcast.core.HazelcastInstance)25 Data (com.hazelcast.internal.serialization.Data)24 Future (java.util.concurrent.Future)24 Member (com.hazelcast.cluster.Member)22 ArrayList (java.util.ArrayList)21 NodeEngine (com.hazelcast.spi.impl.NodeEngine)18 NodeEngineImpl (com.hazelcast.spi.impl.NodeEngineImpl)17 TestHazelcastInstanceFactory (com.hazelcast.test.TestHazelcastInstanceFactory)17 AssertTask (com.hazelcast.test.AssertTask)15 ILogger (com.hazelcast.logging.ILogger)14 UrgentSystemOperation (com.hazelcast.spi.impl.operationservice.UrgentSystemOperation)13 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)13 Config (com.hazelcast.config.Config)12 CompletableFuture (java.util.concurrent.CompletableFuture)12