Search in sources :

Example 1 with PartitionReplicationEvent

use of com.hazelcast.internal.partition.PartitionReplicationEvent in project hazelcast by hazelcast.

the class MigrationRequestOperation method createNonFragmentedReplicaFragmentMigrationState.

private ReplicaFragmentMigrationState createNonFragmentedReplicaFragmentMigrationState() {
    PartitionReplicationEvent event = getPartitionReplicationEvent();
    Collection<Operation> operations = createNonFragmentedReplicationOperations(event);
    Collection<ServiceNamespace> namespaces = Collections.singleton(NonFragmentedServiceNamespace.INSTANCE);
    return createReplicaFragmentMigrationState(namespaces, operations, emptyList(), maxTotalChunkedDataInBytes);
}
Also used : NonFragmentedServiceNamespace(com.hazelcast.internal.partition.NonFragmentedServiceNamespace) ServiceNamespace(com.hazelcast.internal.services.ServiceNamespace) UrgentSystemOperation(com.hazelcast.spi.impl.operationservice.UrgentSystemOperation) Operation(com.hazelcast.spi.impl.operationservice.Operation) PartitionReplicationEvent(com.hazelcast.internal.partition.PartitionReplicationEvent)

Example 2 with PartitionReplicationEvent

use of com.hazelcast.internal.partition.PartitionReplicationEvent in project hazelcast by hazelcast.

the class MigrationRequestOperation method createAllReplicaFragmentsMigrationState.

private ReplicaFragmentMigrationState createAllReplicaFragmentsMigrationState() {
    PartitionReplicationEvent event = getPartitionReplicationEvent();
    Collection<Operation> operations = createAllReplicationOperations(event);
    return createReplicaFragmentMigrationState(namespacesContext.allNamespaces, 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 3 with PartitionReplicationEvent

use of com.hazelcast.internal.partition.PartitionReplicationEvent 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 4 with PartitionReplicationEvent

use of com.hazelcast.internal.partition.PartitionReplicationEvent 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 5 with PartitionReplicationEvent

use of com.hazelcast.internal.partition.PartitionReplicationEvent in project hazelcast by hazelcast.

the class AbstractPartitionPrimaryReplicaAntiEntropyTask method retainAndGetNamespaces.

// works only on primary. backups are retained
// in PartitionBackupReplicaAntiEntropyTask
final Collection<ServiceNamespace> retainAndGetNamespaces() {
    PartitionReplicationEvent event = new PartitionReplicationEvent(null, partitionId, 0);
    Collection<FragmentedMigrationAwareService> services = nodeEngine.getServices(FragmentedMigrationAwareService.class);
    Collection<ServiceNamespace> namespaces = new HashSet<>();
    for (FragmentedMigrationAwareService service : services) {
        Collection<ServiceNamespace> serviceNamespaces = service.getAllServiceNamespaces(event);
        if (serviceNamespaces != null) {
            namespaces.addAll(serviceNamespaces);
        }
    }
    namespaces.add(NonFragmentedServiceNamespace.INSTANCE);
    PartitionReplicaManager replicaManager = partitionService.getReplicaManager();
    replicaManager.retainNamespaces(partitionId, namespaces);
    ILogger logger = nodeEngine.getLogger(getClass());
    if (logger.isFinestEnabled()) {
        logger.finest("Retained namespaces for partitionId=" + partitionId + ". Service namespaces=" + namespaces + ", retained namespaces=" + replicaManager.getNamespaces(partitionId));
    }
    return replicaManager.getNamespaces(partitionId);
}
Also used : NonFragmentedServiceNamespace(com.hazelcast.internal.partition.NonFragmentedServiceNamespace) ServiceNamespace(com.hazelcast.internal.services.ServiceNamespace) ILogger(com.hazelcast.logging.ILogger) FragmentedMigrationAwareService(com.hazelcast.internal.partition.FragmentedMigrationAwareService) PartitionReplicationEvent(com.hazelcast.internal.partition.PartitionReplicationEvent) HashSet(java.util.HashSet)

Aggregations

PartitionReplicationEvent (com.hazelcast.internal.partition.PartitionReplicationEvent)6 Operation (com.hazelcast.spi.impl.operationservice.Operation)5 NonFragmentedServiceNamespace (com.hazelcast.internal.partition.NonFragmentedServiceNamespace)4 ServiceNamespace (com.hazelcast.internal.services.ServiceNamespace)4 UrgentSystemOperation (com.hazelcast.spi.impl.operationservice.UrgentSystemOperation)3 ChunkSupplier (com.hazelcast.internal.partition.ChunkSupplier)2 InternalPartitionServiceImpl (com.hazelcast.internal.partition.impl.InternalPartitionServiceImpl)2 FragmentedMigrationAwareService (com.hazelcast.internal.partition.FragmentedMigrationAwareService)1 MigrationCycleOperation (com.hazelcast.internal.partition.MigrationCycleOperation)1 ILogger (com.hazelcast.logging.ILogger)1 PartitionAwareOperation (com.hazelcast.spi.impl.operationservice.PartitionAwareOperation)1 HashSet (java.util.HashSet)1