Search in sources :

Example 51 with Node

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

the class ListenerLeakTestNonSmartRouting method testTopicMessageListener.

@Test
public void testTopicMessageListener() {
    Collection<Node> nodes = createNodes();
    HazelcastInstance client = 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 52 with Node

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

the class ListenerLeakTestNonSmartRouting method testMapPartitionLostListeners.

@Test
public void testMapPartitionLostListeners() {
    Collection<Node> nodes = createNodes();
    HazelcastInstance client = newHazelcastClient();
    IMap map = client.getMap(randomString());
    String id = map.addPartitionLostListener(mock(MapPartitionLostListener.class));
    Collection<ClientEventRegistration> registrations = getClientEventRegistrations(client, id);
    assertTrue(map.removePartitionLostListener(id));
    assertNoLeftOver(nodes, client, id, registrations);
}
Also used : IMap(com.hazelcast.core.IMap) HazelcastInstance(com.hazelcast.core.HazelcastInstance) MapPartitionLostListener(com.hazelcast.map.listener.MapPartitionLostListener) ClientEventRegistration(com.hazelcast.client.spi.impl.listener.ClientEventRegistration) Node(com.hazelcast.instance.Node) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 53 with Node

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

the class QueryCacheEventLostListenerTest method setTestSequencer.

private void setTestSequencer(HazelcastInstance instance, int eventCount) {
    Node node = getNode(instance);
    MapService service = node.getNodeEngine().getService(MapService.SERVICE_NAME);
    MapServiceContext mapServiceContext = service.getMapServiceContext();
    QueryCacheContext queryCacheContext = mapServiceContext.getQueryCacheContext();
    queryCacheContext.setSubscriberContext(new TestSubscriberContext(queryCacheContext, eventCount, true));
}
Also used : TestSubscriberContext(com.hazelcast.map.impl.querycache.subscriber.TestSubscriberContext) Node(com.hazelcast.instance.Node) MapService(com.hazelcast.map.impl.MapService) MapServiceContext(com.hazelcast.map.impl.MapServiceContext)

Example 54 with Node

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

the class QueryCacheIMapEventHandlingTest method executeMergeOperation.

private void executeMergeOperation(HazelcastInstance member, String mapName, int key, int mergedValue) throws Exception {
    Node node = getNode(member);
    NodeEngineImpl nodeEngine = node.nodeEngine;
    OperationServiceImpl operationService = (OperationServiceImpl) nodeEngine.getOperationService();
    SerializationService serializationService = getSerializationService(member);
    Data keyData = serializationService.toData(key);
    Data valueData = serializationService.toData(mergedValue);
    EntryView<Data, Data> entryView = createSimpleEntryView(keyData, valueData, Mockito.mock(Record.class));
    MergeOperation mergeOperation = new MergeOperation(mapName, keyData, entryView, new PassThroughMergePolicy());
    int partitionId = nodeEngine.getPartitionService().getPartitionId(key);
    Future<Object> future = operationService.invokeOnPartition(SERVICE_NAME, mergeOperation, partitionId);
    future.get();
}
Also used : NodeEngineImpl(com.hazelcast.spi.impl.NodeEngineImpl) MergeOperation(com.hazelcast.map.impl.operation.MergeOperation) PassThroughMergePolicy(com.hazelcast.map.merge.PassThroughMergePolicy) Node(com.hazelcast.instance.Node) SerializationService(com.hazelcast.spi.serialization.SerializationService) Data(com.hazelcast.nio.serialization.Data) Record(com.hazelcast.map.impl.record.Record) OperationServiceImpl(com.hazelcast.spi.impl.operationservice.impl.OperationServiceImpl)

Example 55 with Node

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

the class QueryCacheRecoveryUponEventLossTest method setTestSequencer.

private void setTestSequencer(HazelcastInstance instance, int eventCount) {
    Node node = getNode(instance);
    MapService service = node.getNodeEngine().getService(MapService.SERVICE_NAME);
    MapServiceContext mapServiceContext = service.getMapServiceContext();
    QueryCacheContext queryCacheContext = mapServiceContext.getQueryCacheContext();
    queryCacheContext.setSubscriberContext(new TestSubscriberContext(queryCacheContext, eventCount, true));
}
Also used : TestSubscriberContext(com.hazelcast.map.impl.querycache.subscriber.TestSubscriberContext) Node(com.hazelcast.instance.Node) MapService(com.hazelcast.map.impl.MapService) MapServiceContext(com.hazelcast.map.impl.MapServiceContext)

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