Search in sources :

Example 1 with Node

use of com.hazelcast.instance.Node in project orientdb by orientechnologies.

the class ServerRun method terminateServer.

public void terminateServer() {
    if (server != null) {
        try {
            HazelcastInstance hz = ((OHazelcastPlugin) server.getDistributedManager()).getHazelcastInstance();
            final Node node = getHazelcastNode(hz);
            node.getConnectionManager().shutdown();
            node.shutdown(true);
            hz.getLifecycleService().terminate();
        } catch (Exception e) {
        // IGNORE IT
        }
        try {
            server.shutdown();
        } catch (Exception e) {
        // IGNORE IT
        }
    }
    closeStorages();
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) Node(com.hazelcast.instance.Node) OHazelcastPlugin(com.orientechnologies.orient.server.hazelcast.OHazelcastPlugin) IOException(java.io.IOException)

Example 2 with Node

use of com.hazelcast.instance.Node in project orientdb by orientechnologies.

the class ServerRun method rejoin.

public void rejoin(final ServerRun... serverIds) {
    final Node currentNode = getHazelcastNode(((OHazelcastPlugin) server.getDistributedManager()).getHazelcastInstance());
    for (ServerRun s : serverIds) {
        final Node otherNode = getHazelcastNode(((OHazelcastPlugin) s.server.getDistributedManager()).getHazelcastInstance());
        final ClusterServiceImpl clusterService = currentNode.getClusterService();
        clusterService.merge(otherNode.address);
    }
}
Also used : Node(com.hazelcast.instance.Node) ClusterServiceImpl(com.hazelcast.cluster.impl.ClusterServiceImpl)

Example 3 with Node

use of com.hazelcast.instance.Node in project hazelcast by hazelcast.

the class ConnectedClientOperationTest method testGetConnectedClientsOperation_WhenMoreThanZeroClientConnects.

@Test
public void testGetConnectedClientsOperation_WhenMoreThanZeroClientConnects() throws Exception {
    HazelcastInstance instance = factory.newHazelcastInstance();
    factory.newHazelcastClient();
    factory.newHazelcastClient();
    Node node = TestUtil.getNode(instance);
    Operation operation = new GetConnectedClientsOperation();
    OperationService operationService = node.nodeEngine.getOperationService();
    Future<Map<String, ClientType>> future = operationService.invokeOnTarget(ClientEngineImpl.SERVICE_NAME, operation, node.address);
    Map<String, ClientType> clients = future.get();
    assertEquals(2, clients.size());
}
Also used : ClientType(com.hazelcast.core.ClientType) HazelcastInstance(com.hazelcast.core.HazelcastInstance) Node(com.hazelcast.instance.Node) Operation(com.hazelcast.spi.Operation) GetConnectedClientsOperation(com.hazelcast.client.impl.operations.GetConnectedClientsOperation) GetConnectedClientsOperation(com.hazelcast.client.impl.operations.GetConnectedClientsOperation) OperationService(com.hazelcast.spi.OperationService) Map(java.util.Map) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 4 with Node

use of com.hazelcast.instance.Node in project hazelcast by hazelcast.

the class ListenerLeakTestSmartRouting method testTopicMessageListener.

@Test
public void testTopicMessageListener() {
    Collection<Node> nodes = createNodes();
    HazelcastInstance client = hazelcastFactory.newHazelcastClient();
    ITopic<Object> topic = client.getTopic(randomString());
    String id = topic.addMessageListener(mock(MessageListener.class));
    Collection<ClientEventRegistration> registrations = getClientEventRegistrations(client, id);
    assertTrue(topic.removeMessageListener(id));
    assertNoLeftOver(nodes, client, id, registrations);
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) ClientEventRegistration(com.hazelcast.client.spi.impl.listener.ClientEventRegistration) Node(com.hazelcast.instance.Node) MessageListener(com.hazelcast.core.MessageListener) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 5 with Node

use of com.hazelcast.instance.Node in project hazelcast by hazelcast.

the class ListenerLeakTestSmartRouting method testDistributedObjectListeners.

@Test
public void testDistributedObjectListeners() {
    Collection<Node> nodes = createNodes();
    HazelcastInstance client = hazelcastFactory.newHazelcastClient();
    String id = client.addDistributedObjectListener(mock(DistributedObjectListener.class));
    Collection<ClientEventRegistration> registrations = getClientEventRegistrations(client, id);
    assertTrue(client.removeDistributedObjectListener(id));
    assertNoLeftOver(nodes, client, id, registrations);
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) ClientEventRegistration(com.hazelcast.client.spi.impl.listener.ClientEventRegistration) Node(com.hazelcast.instance.Node) DistributedObjectListener(com.hazelcast.core.DistributedObjectListener) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Aggregations

Node (com.hazelcast.instance.Node)131 HazelcastInstance (com.hazelcast.core.HazelcastInstance)60 Test (org.junit.Test)50 QuickTest (com.hazelcast.test.annotation.QuickTest)45 ParallelTest (com.hazelcast.test.annotation.ParallelTest)42 NodeEngineImpl (com.hazelcast.spi.impl.NodeEngineImpl)21 ClientEventRegistration (com.hazelcast.client.spi.impl.listener.ClientEventRegistration)18 Address (com.hazelcast.nio.Address)17 Config (com.hazelcast.config.Config)14 ClusterServiceImpl (com.hazelcast.internal.cluster.impl.ClusterServiceImpl)13 ILogger (com.hazelcast.logging.ILogger)10 Data (com.hazelcast.nio.serialization.Data)10 TestHazelcastInstanceFactory (com.hazelcast.test.TestHazelcastInstanceFactory)10 InternalPartitionService (com.hazelcast.internal.partition.InternalPartitionService)9 StringUtil.bytesToString (com.hazelcast.util.StringUtil.bytesToString)8 CountDownLatch (java.util.concurrent.CountDownLatch)8 ClusterService (com.hazelcast.internal.cluster.ClusterService)7 SerializationService (com.hazelcast.spi.serialization.SerializationService)7 ItemListener (com.hazelcast.core.ItemListener)6 Operation (com.hazelcast.spi.Operation)6