Search in sources :

Example 6 with ServiceInfo

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

the class RaftService method resetLocalRaftState.

private void resetLocalRaftState() {
    // node.forceSetTerminatedStatus() will trigger RaftNodeLifecycleAwareService.onRaftGroupDestroyed()
    // which will attempt to acquire the read lock on nodeLock. In order to prevent it, we first
    // add group ids into destroyedGroupIds to short-cut RaftNodeLifecycleAwareService.onRaftGroupDestroyed()
    List<InternalCompletableFuture> futures = new ArrayList<>(nodes.size());
    destroyedGroupIds.addAll(nodes.keySet());
    for (RaftNode node : nodes.values()) {
        InternalCompletableFuture f = node.forceSetTerminatedStatus();
        futures.add(f);
    }
    for (InternalCompletableFuture future : futures) {
        try {
            future.get();
        } catch (Exception e) {
            logger.warning(e);
        }
    }
    nodes.clear();
    for (ServiceInfo serviceInfo : nodeEngine.getServiceInfos(RaftRemoteService.class)) {
        if (serviceInfo.getService() instanceof RaftManagedService) {
            ((RaftManagedService) serviceInfo.getService()).onCPSubsystemRestart();
        }
    }
    nodeMetrics.clear();
    missingMembers.clear();
    invocationManager.reset();
}
Also used : ServiceInfo(com.hazelcast.spi.impl.servicemanager.ServiceInfo) InternalCompletableFuture(com.hazelcast.spi.impl.InternalCompletableFuture) ArrayList(java.util.ArrayList) RaftManagedService(com.hazelcast.cp.internal.datastructures.spi.RaftManagedService) RaftNode(com.hazelcast.cp.internal.raft.impl.RaftNode) RaftNodeImpl.newRaftNode(com.hazelcast.cp.internal.raft.impl.RaftNodeImpl.newRaftNode) PartitionMigratingException(com.hazelcast.spi.exception.PartitionMigratingException) CPGroupDestroyedException(com.hazelcast.cp.exception.CPGroupDestroyedException) ExecutionException(java.util.concurrent.ExecutionException) CannotRemoveCPMemberException(com.hazelcast.cp.internal.exception.CannotRemoveCPMemberException) ResponseAlreadySentException(com.hazelcast.spi.exception.ResponseAlreadySentException)

Example 7 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) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 8 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) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 9 with ServiceInfo

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

the class TimedMemberStateFactory method isCacheServiceEnabled.

private boolean isCacheServiceEnabled() {
    NodeEngineImpl nodeEngine = instance.node.nodeEngine;
    Collection<ServiceInfo> serviceInfos = nodeEngine.getServiceInfos(CacheService.class);
    return !serviceInfos.isEmpty();
}
Also used : NodeEngineImpl(com.hazelcast.spi.impl.NodeEngineImpl) ServiceInfo(com.hazelcast.spi.impl.servicemanager.ServiceInfo)

Example 10 with ServiceInfo

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

the class ReplicaSyncRequest method createReplicationOperations.

private List<Operation> createReplicationOperations() {
    NodeEngineImpl nodeEngine = (NodeEngineImpl) getNodeEngine();
    Collection<ServiceInfo> services = nodeEngine.getServiceInfos(MigrationAwareService.class);
    PartitionReplicationEvent event = new PartitionReplicationEvent(getPartitionId(), getReplicaIndex());
    List<Operation> tasks = new LinkedList<Operation>();
    for (ServiceInfo serviceInfo : services) {
        MigrationAwareService service = (MigrationAwareService) serviceInfo.getService();
        Operation op = service.prepareReplicationOperation(event);
        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) PartitionAwareOperation(com.hazelcast.spi.PartitionAwareOperation) MigrationCycleOperation(com.hazelcast.internal.partition.MigrationCycleOperation) Operation(com.hazelcast.spi.Operation) PartitionReplicationEvent(com.hazelcast.spi.PartitionReplicationEvent) LinkedList(java.util.LinkedList)

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