use of com.hazelcast.instance.impl.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));
}
use of com.hazelcast.instance.impl.Node in project hazelcast by hazelcast.
the class HazelcastStarterTest method testHazelcastInstanceCompatibility.
private static void testHazelcastInstanceCompatibility(HazelcastInstance instance, TestHazelcastInstanceFactory factory) {
Node node = TestUtil.getNode(instance);
HazelcastInstanceImpl instanceImpl = TestUtil.getHazelcastInstanceImpl(instance);
if (factory != null) {
assertEquals("Expected one active HazelcastInstance in the factory", 1, factory.getAllHazelcastInstances().size());
}
assertNode(node, true);
assertHazelcastInstanceImpl(instanceImpl);
assertSafePartitionServiceState(instance);
instance.shutdown();
assertNode(node, false);
if (factory != null) {
assertEquals("Expected no active HazelcastInstances in the factory", 0, factory.getAllHazelcastInstances().size());
}
assertGetNodeFromShutdownInstance(instance);
assertGetHazelcastInstanceImplFromShutdownInstance(instance);
assertSafePartitionServiceState(instance);
}
use of com.hazelcast.instance.impl.Node in project hazelcast by hazelcast.
the class HazelcastStarterTest method testMemberWithConfig.
private void testMemberWithConfig(String version, boolean supportsFirewallingConnectionManager) {
Config config = new Config().setInstanceName("test-name");
hz = HazelcastStarter.newHazelcastInstance(version, config, false);
assertEquals(hz.getName(), "test-name");
Node node = HazelcastStarter.getNode(hz);
assertNotNull(node);
assertEquals("Expected the same address from HazelcastInstance and Node", hz.getCluster().getLocalMember().getAddress(), node.getThisAddress());
if (supportsFirewallingConnectionManager) {
assertInstanceOf(FirewallingServer.class, node.getServer());
} else {
assertInstanceOf(TcpServer.class, node.getServer());
}
}
use of com.hazelcast.instance.impl.Node in project hazelcast by hazelcast.
the class CacheManagerAnswer method answer.
@Override
Object answer(InvocationOnMock invocation, String methodName, Object[] arguments) throws Exception {
if (arguments.length == 1 && methodName.equals("getCacheByFullName")) {
String cacheName = (String) arguments[0];
Object original = getFieldValueReflectively(delegate, "original");
Object delegateNode = getFieldValueReflectively(original, "node");
Node node = mock(Node.class, new NodeAnswer(delegateNode));
NodeEngine nodeEngine = node.getNodeEngine();
CacheConfig cacheConfig = new CacheConfig(node.getConfig().getCacheConfig(cacheName));
CacheService cacheService = nodeEngine.getService(CacheService.SERVICE_NAME);
// we have to create the mock with useConstructor(), otherwise the
// calls to the AbstractDistributedObject (its base class) won't
// work properly, since the NodeEngine field is not set (final
// method calls are not mocked in the used Mockito version)
Object cacheProxy = invokeForMock(invocation, arguments);
return mock(CacheProxy.class, withSettings().useConstructor(cacheConfig, nodeEngine, cacheService).defaultAnswer(new CacheProxyAnswer(cacheProxy)));
} else if (arguments.length == 0) {
return invoke(invocation);
}
throw new UnsupportedOperationException("Method is not implemented in CacheManagerAnswer: " + methodName);
}
use of com.hazelcast.instance.impl.Node in project hazelcast by hazelcast.
the class MapIndexJsonTest method getIndexOfAttributeForMap.
protected static List<Index> getIndexOfAttributeForMap(HazelcastInstance instance, String mapName, String attribute) {
Node node = getNode(instance);
MapService service = node.nodeEngine.getService(MapService.SERVICE_NAME);
MapServiceContext mapServiceContext = service.getMapServiceContext();
MapContainer mapContainer = mapServiceContext.getMapContainer(mapName);
List<Index> result = new ArrayList<>();
for (int partitionId : mapServiceContext.getOrInitCachedMemberPartitions()) {
Indexes indexes = mapContainer.getIndexes(partitionId);
result.add(indexes.getIndex(attribute));
}
return result;
}
Aggregations