Search in sources :

Example 81 with Node

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

the class ServiceManagerImpl method registerCoreServices.

private void registerCoreServices() {
    logger.finest("Registering core services...");
    Node node = nodeEngine.getNode();
    registerService(ClusterServiceImpl.SERVICE_NAME, node.getClusterService());
    registerService(InternalPartitionService.SERVICE_NAME, node.getPartitionService());
    registerService(ProxyServiceImpl.SERVICE_NAME, nodeEngine.getProxyService());
    registerService(TransactionManagerServiceImpl.SERVICE_NAME, nodeEngine.getTransactionManagerService());
    registerService(ClientEngineImpl.SERVICE_NAME, node.clientEngine);
    registerService(SplitBrainProtectionServiceImpl.SERVICE_NAME, nodeEngine.getSplitBrainProtectionService());
    registerService(WanReplicationService.SERVICE_NAME, nodeEngine.getWanReplicationService());
    registerService(EventServiceImpl.SERVICE_NAME, nodeEngine.getEventService());
}
Also used : Node(com.hazelcast.instance.impl.Node)

Example 82 with Node

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

the class ServiceManagerImpl method createService.

private <T> T createService(Class<T> service) {
    Node node = nodeEngine.getNode();
    NodeExtension nodeExtension = node.getNodeExtension();
    return nodeExtension.createService(service);
}
Also used : Node(com.hazelcast.instance.impl.Node) NodeExtension(com.hazelcast.instance.impl.NodeExtension)

Example 83 with Node

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

the class CacheClearTest method testClear.

@Test
public void testClear() {
    ICache<String, String> cache = createCache();
    String cacheName = cache.getName();
    Map<String, String> entries = createAndFillEntries();
    for (Map.Entry<String, String> entry : entries.entrySet()) {
        cache.put(entry.getKey(), entry.getValue());
    }
    // Verify that put works
    for (Map.Entry<String, String> entry : entries.entrySet()) {
        String key = entry.getKey();
        String expectedValue = entries.get(key);
        String actualValue = cache.get(key);
        assertEquals(expectedValue, actualValue);
    }
    Node node = getNode(hazelcastInstance);
    InternalPartitionService partitionService = node.getPartitionService();
    SerializationService serializationService = node.getSerializationService();
    // Verify that backup of put works
    for (Map.Entry<String, String> entry : entries.entrySet()) {
        String key = entry.getKey();
        String expectedValue = entries.get(key);
        Data keyData = serializationService.toData(key);
        int keyPartitionId = partitionService.getPartitionId(keyData);
        for (int i = 0; i < INSTANCE_COUNT; i++) {
            Node n = getNode(hazelcastInstances[i]);
            ICacheService cacheService = n.getNodeEngine().getService(ICacheService.SERVICE_NAME);
            ICacheRecordStore recordStore = cacheService.getRecordStore("/hz/" + cacheName, keyPartitionId);
            assertNotNull(recordStore);
            String actualValue = serializationService.toObject(recordStore.get(keyData, null));
            assertEquals(expectedValue, actualValue);
        }
    }
    cache.clear();
    // Verify that clear works
    for (Map.Entry<String, String> entry : entries.entrySet()) {
        String key = entry.getKey();
        String actualValue = cache.get(key);
        assertNull(actualValue);
    }
    // Verify that backup of clear works
    for (Map.Entry<String, String> entry : entries.entrySet()) {
        String key = entry.getKey();
        Data keyData = serializationService.toData(key);
        int keyPartitionId = partitionService.getPartitionId(keyData);
        for (int i = 0; i < INSTANCE_COUNT; i++) {
            Node n = getNode(hazelcastInstances[i]);
            ICacheService cacheService = n.getNodeEngine().getService(ICacheService.SERVICE_NAME);
            ICacheRecordStore recordStore = cacheService.getRecordStore("/hz/" + cacheName, keyPartitionId);
            assertNotNull(recordStore);
            String actualValue = serializationService.toObject(recordStore.get(keyData, null));
            assertNull(actualValue);
        }
    }
}
Also used : InternalPartitionService(com.hazelcast.internal.partition.InternalPartitionService) ICacheService(com.hazelcast.cache.impl.ICacheService) Accessors.getNode(com.hazelcast.test.Accessors.getNode) Node(com.hazelcast.instance.impl.Node) SerializationService(com.hazelcast.internal.serialization.SerializationService) Data(com.hazelcast.internal.serialization.Data) ICacheRecordStore(com.hazelcast.cache.impl.ICacheRecordStore) HashMap(java.util.HashMap) Map(java.util.Map) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 84 with Node

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

the class ClientListenersTest method testEntryMergeListener_withPortableNotRegisteredInNode.

@Test
public void testEntryMergeListener_withPortableNotRegisteredInNode() throws Exception {
    final IMap<Object, Object> map = client.getMap(randomMapName());
    final CountDownLatch latch = new CountDownLatch(1);
    map.addEntryListener(new EntryMergedListener<Object, Object>() {

        @Override
        public void entryMerged(EntryEvent<Object, Object> event) {
            latch.countDown();
        }
    }, true);
    Node node = getNode(server);
    NodeEngineImpl nodeEngine = node.nodeEngine;
    OperationServiceImpl operationService = nodeEngine.getOperationService();
    SerializationService serializationService = getSerializationService(server);
    Data key = serializationService.toData(1);
    Data value = serializationService.toData(new ClientRegressionWithMockNetworkTest.SamplePortable(1));
    SplitBrainMergeTypes.MapMergeTypes mergingEntry = createMergingEntry(serializationService, key, value, Mockito.mock(Record.class), ExpiryMetadata.NULL);
    Operation op = new MergeOperation(map.getName(), Collections.singletonList(mergingEntry), new PassThroughMergePolicy<>(), false);
    int partitionId = nodeEngine.getPartitionService().getPartitionId(key);
    operationService.invokeOnPartition(MapService.SERVICE_NAME, op, partitionId);
    assertOpenEventually(latch);
}
Also used : NodeEngineImpl(com.hazelcast.spi.impl.NodeEngineImpl) MergeOperation(com.hazelcast.map.impl.operation.MergeOperation) Node(com.hazelcast.instance.impl.Node) Accessors.getNode(com.hazelcast.test.Accessors.getNode) SerializationService(com.hazelcast.internal.serialization.SerializationService) Accessors.getSerializationService(com.hazelcast.test.Accessors.getSerializationService) Data(com.hazelcast.internal.serialization.Data) Operation(com.hazelcast.spi.impl.operationservice.Operation) MergeOperation(com.hazelcast.map.impl.operation.MergeOperation) CountDownLatch(java.util.concurrent.CountDownLatch) Record(com.hazelcast.map.impl.record.Record) SplitBrainMergeTypes(com.hazelcast.spi.merge.SplitBrainMergeTypes) OperationServiceImpl(com.hazelcast.spi.impl.operationservice.impl.OperationServiceImpl) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 85 with Node

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

the class HttpGetCommandProcessor method handleGetClusterVersion.

private void handleGetClusterVersion(HttpGetCommand command) {
    Node node = textCommandService.getNode();
    ClusterService clusterService = node.getClusterService();
    JsonObject response = new JsonObject().add("status", "success").add("version", clusterService.getClusterVersion().toString());
    prepareResponse(command, response);
}
Also used : ClusterService(com.hazelcast.internal.cluster.ClusterService) Node(com.hazelcast.instance.impl.Node) JsonObject(com.hazelcast.internal.json.JsonObject)

Aggregations

Node (com.hazelcast.instance.impl.Node)144 Accessors.getNode (com.hazelcast.test.Accessors.getNode)84 HazelcastInstance (com.hazelcast.core.HazelcastInstance)68 Test (org.junit.Test)60 QuickTest (com.hazelcast.test.annotation.QuickTest)57 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)44 Config (com.hazelcast.config.Config)22 Address (com.hazelcast.cluster.Address)20 NodeEngineImpl (com.hazelcast.spi.impl.NodeEngineImpl)19 ClusterServiceImpl (com.hazelcast.internal.cluster.impl.ClusterServiceImpl)13 UUID (java.util.UUID)13 InternalPartitionService (com.hazelcast.internal.partition.InternalPartitionService)12 SerializationService (com.hazelcast.internal.serialization.SerializationService)12 ILogger (com.hazelcast.logging.ILogger)10 MapService (com.hazelcast.map.impl.MapService)10 ClientConnectionRegistration (com.hazelcast.client.impl.spi.impl.listener.ClientConnectionRegistration)9 Operation (com.hazelcast.spi.impl.operationservice.Operation)9 HashMap (java.util.HashMap)9 Data (com.hazelcast.internal.serialization.Data)8 MapServiceContext (com.hazelcast.map.impl.MapServiceContext)8