Search in sources :

Example 1 with ServiceInfo

use of com.hazelcast.spi.impl.servicemanager.ServiceInfo 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 2 with ServiceInfo

use of com.hazelcast.spi.impl.servicemanager.ServiceInfo in project hazelcast by hazelcast.

the class ServiceManagerImplTest method getServiceInfo_notExisting.

@Test
public void getServiceInfo_notExisting() {
    ServiceInfo result = serviceManager.getServiceInfo("notexisting");
    assertNull(result);
}
Also used : ServiceInfo(com.hazelcast.spi.impl.servicemanager.ServiceInfo) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 3 with ServiceInfo

use of com.hazelcast.spi.impl.servicemanager.ServiceInfo in project hazelcast by hazelcast.

the class ServiceManagerImplTest method getServiceInfo.

// ===================== getServiceInfo ================================
@Test
public void getServiceInfo() {
    ServiceInfo result = serviceManager.getServiceInfo(MapService.SERVICE_NAME);
    assertNotNull(result);
    assertEquals(MapService.SERVICE_NAME, result.getName());
    assertInstanceOf(MapService.class, result.getService());
}
Also used : ServiceInfo(com.hazelcast.spi.impl.servicemanager.ServiceInfo) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 4 with ServiceInfo

use of com.hazelcast.spi.impl.servicemanager.ServiceInfo 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 5 with ServiceInfo

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

Aggregations

ServiceInfo (com.hazelcast.spi.impl.servicemanager.ServiceInfo)15 NodeEngineImpl (com.hazelcast.spi.impl.NodeEngineImpl)6 QuickTest (com.hazelcast.test.annotation.QuickTest)6 Test (org.junit.Test)6 FragmentedMigrationAwareService (com.hazelcast.internal.partition.FragmentedMigrationAwareService)3 Operation (com.hazelcast.spi.impl.operationservice.Operation)3 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)3 ParallelTest (com.hazelcast.test.annotation.ParallelTest)3 ArrayList (java.util.ArrayList)3 NonFragmentedServiceNamespace (com.hazelcast.internal.partition.NonFragmentedServiceNamespace)2 MigrationAwareService (com.hazelcast.spi.MigrationAwareService)2 Operation (com.hazelcast.spi.Operation)2 PartitionReplicationEvent (com.hazelcast.spi.PartitionReplicationEvent)2 LinkedList (java.util.LinkedList)2 HazelcastException (com.hazelcast.core.HazelcastException)1 CPGroupDestroyedException (com.hazelcast.cp.exception.CPGroupDestroyedException)1 RaftManagedService (com.hazelcast.cp.internal.datastructures.spi.RaftManagedService)1 CannotRemoveCPMemberException (com.hazelcast.cp.internal.exception.CannotRemoveCPMemberException)1 SnapshotAwareService (com.hazelcast.cp.internal.raft.SnapshotAwareService)1 RaftNode (com.hazelcast.cp.internal.raft.impl.RaftNode)1