Search in sources :

Example 1 with FragmentedMigrationAwareService

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

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

Example 3 with FragmentedMigrationAwareService

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

the class AbstractPartitionOperation method createFragmentReplicationOperations.

final Collection<Operation> createFragmentReplicationOperations(PartitionReplicationEvent event, ServiceNamespace ns) {
    assert !(ns instanceof NonFragmentedServiceNamespace) : ns + " should be used only for fragmented services!";
    assertRunningOnPartitionThread();
    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 = prepareAndAppendReplicationOperation(event, ns, service, serviceInfo.getName(), operations);
    }
    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 4 with FragmentedMigrationAwareService

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

Example 5 with FragmentedMigrationAwareService

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

the class OperationBackupHandler method checkServiceNamespaces.

private void checkServiceNamespaces(BackupAwareOperation backupAwareOp, Operation backupOp) {
    Operation op = (Operation) backupAwareOp;
    Object service;
    try {
        service = op.getService();
    } catch (Exception ignored) {
        // operation doesn't know its service name
        return;
    }
    if (service instanceof FragmentedMigrationAwareService) {
        assert backupAwareOp instanceof ServiceNamespaceAware : service + " is instance of FragmentedMigrationAwareService, " + backupAwareOp + " should implement ServiceNamespaceAware!";
        assert backupOp instanceof ServiceNamespaceAware : service + " is instance of FragmentedMigrationAwareService, " + backupOp + " should implement ServiceNamespaceAware!";
    } else {
        assert !(backupAwareOp instanceof ServiceNamespaceAware) : service + " is NOT instance of FragmentedMigrationAwareService, " + backupAwareOp + " should NOT implement ServiceNamespaceAware!";
        assert !(backupOp instanceof ServiceNamespaceAware) : service + " is NOT instance of FragmentedMigrationAwareService, " + backupOp + " should NOT implement ServiceNamespaceAware!";
    }
}
Also used : ServiceNamespaceAware(com.hazelcast.internal.services.ServiceNamespaceAware) BackupAwareOperation(com.hazelcast.spi.impl.operationservice.BackupAwareOperation) Operation(com.hazelcast.spi.impl.operationservice.Operation) FragmentedMigrationAwareService(com.hazelcast.internal.partition.FragmentedMigrationAwareService)

Aggregations

FragmentedMigrationAwareService (com.hazelcast.internal.partition.FragmentedMigrationAwareService)6 Operation (com.hazelcast.spi.impl.operationservice.Operation)5 NonFragmentedServiceNamespace (com.hazelcast.internal.partition.NonFragmentedServiceNamespace)4 NodeEngineImpl (com.hazelcast.spi.impl.NodeEngineImpl)4 ServiceInfo (com.hazelcast.spi.impl.servicemanager.ServiceInfo)3 ChunkedMigrationAwareService (com.hazelcast.internal.partition.ChunkedMigrationAwareService)1 MigrationAwareService (com.hazelcast.internal.partition.MigrationAwareService)1 PartitionReplicationEvent (com.hazelcast.internal.partition.PartitionReplicationEvent)1 ServiceNamespace (com.hazelcast.internal.services.ServiceNamespace)1 ServiceNamespaceAware (com.hazelcast.internal.services.ServiceNamespaceAware)1 ILogger (com.hazelcast.logging.ILogger)1 BackupAwareOperation (com.hazelcast.spi.impl.operationservice.BackupAwareOperation)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1