use of com.hazelcast.instance.impl.Node in project hazelcast by hazelcast.
the class InternalCacheRecordStoreTest method batchEventMapShouldBeCleanedAfterRemoveAll.
/**
* Test for issue: https://github.com/hazelcast/hazelcast/issues/6618
*/
@Test
public void batchEventMapShouldBeCleanedAfterRemoveAll() {
String cacheName = randomString();
CacheConfig<Integer, String> config = createCacheConfig();
CacheFromDifferentNodesTest.SimpleEntryListener<Integer, String> listener = new CacheFromDifferentNodesTest.SimpleEntryListener<Integer, String>();
MutableCacheEntryListenerConfiguration<Integer, String> listenerConfiguration = new MutableCacheEntryListenerConfiguration<Integer, String>(FactoryBuilder.factoryOf(listener), null, true, true);
config.addCacheEntryListenerConfiguration(listenerConfiguration);
Cache<Integer, String> cache = cacheManager.createCache(cacheName, config);
assertNotNull(cache);
Integer key = 1;
String value = "value";
cache.put(key, value);
HazelcastInstance instance = ((HazelcastCacheManager) cacheManager).getHazelcastInstance();
int partitionId = instance.getPartitionService().getPartition(key).getPartitionId();
cache.removeAll();
Node node = getNode(instance);
assertNotNull(node);
ICacheService cacheService = node.getNodeEngine().getService(ICacheService.SERVICE_NAME);
AbstractCacheRecordStore recordStore = (AbstractCacheRecordStore) cacheService.getRecordStore("/hz/" + cacheName, partitionId);
assertEquals(0, recordStore.batchEvent.size());
}
use of com.hazelcast.instance.impl.Node in project hazelcast by hazelcast.
the class InternalCacheRecordStoreTest method ownerStateShouldBeUpdatedAfterMigration.
/**
* Test for issue: https://github.com/hazelcast/hazelcast/issues/6983
*/
@Test
public void ownerStateShouldBeUpdatedAfterMigration() throws Exception {
HazelcastCacheManager hzCacheManager = (HazelcastCacheManager) cacheManager;
HazelcastInstance instance1 = hzCacheManager.getHazelcastInstance();
Node node1 = getNode(instance1);
NodeEngineImpl nodeEngine1 = node1.getNodeEngine();
InternalPartitionService partitionService1 = nodeEngine1.getPartitionService();
int partitionCount = partitionService1.getPartitionCount();
String cacheName = randomName();
CacheConfig cacheConfig = new CacheConfig().setName(cacheName);
Cache<String, String> cache = cacheManager.createCache(cacheName, cacheConfig);
String fullCacheName = hzCacheManager.getCacheNameWithPrefix(cacheName);
for (int i = 0; i < partitionCount; i++) {
String key = generateKeyForPartition(instance1, i);
cache.put(key, "Value");
}
for (int i = 0; i < partitionCount; i++) {
verifyPrimaryState(node1, fullCacheName, i, true);
}
HazelcastInstance instance2 = getHazelcastInstance();
Node node2 = getNode(instance2);
warmUpPartitions(instance1, instance2);
waitAllForSafeState(instance1, instance2);
for (int i = 0; i < partitionCount; i++) {
boolean ownedByNode1 = partitionService1.isPartitionOwner(i);
if (ownedByNode1) {
verifyPrimaryState(node1, fullCacheName, i, true);
verifyPrimaryState(node2, fullCacheName, i, false);
} else {
verifyPrimaryState(node1, fullCacheName, i, false);
verifyPrimaryState(node2, fullCacheName, i, true);
}
}
}
use of com.hazelcast.instance.impl.Node in project hazelcast by hazelcast.
the class ConnectedClientOperationTest method testNumberOfConnectedClients.
@Test
public void testNumberOfConnectedClients() throws Exception {
HazelcastInstance h1 = factory.newHazelcastInstance();
HazelcastInstance h2 = factory.newHazelcastInstance();
assertClusterSize(2, h1, h2);
int numberOfClients = 6;
for (int i = 0; i < numberOfClients; i++) {
factory.newHazelcastClient();
}
Node node = getNode(h1);
Map<String, Long> clientStats = node.clientEngine.getActiveClientsInCluster();
assertEquals(numberOfClients, clientStats.get(ConnectionType.JAVA_CLIENT).intValue());
assertNull(clientStats.get(ConnectionType.CPP_CLIENT));
assertNull(clientStats.get(ConnectionType.CSHARP_CLIENT));
assertNull(clientStats.get(ConnectionType.NODEJS_CLIENT));
assertNull(clientStats.get(ConnectionType.PYTHON_CLIENT));
assertNull(clientStats.get(ConnectionType.GO_CLIENT));
}
use of com.hazelcast.instance.impl.Node in project hazelcast by hazelcast.
the class ConnectedClientOperationTest method testGetConnectedClientsOperation_WhenZeroClientConnects.
@Test
public void testGetConnectedClientsOperation_WhenZeroClientConnects() throws Exception {
HazelcastInstance instance = factory.newHazelcastInstance();
Node node = getNode(instance);
Operation operation = new GetConnectedClientsOperation();
OperationService operationService = node.nodeEngine.getOperationService();
Future<Map<String, String>> future = operationService.invokeOnTarget(ClientEngineImpl.SERVICE_NAME, operation, node.address);
Map<String, String> clients = future.get();
assertEquals(0, clients.size());
}
use of com.hazelcast.instance.impl.Node in project hazelcast by hazelcast.
the class ListenerLeakTest method testMultiMapEntryListeners.
@Test
public void testMultiMapEntryListeners() {
Collection<Node> nodes = createNodes();
HazelcastInstance client = newHazelcastClient();
MultiMap multiMap = client.getMultiMap(randomString());
UUID id = multiMap.addEntryListener(mock(EntryListener.class), false);
Collection<ClientConnectionRegistration> registrations = getClientEventRegistrations(client, id);
assertTrue(multiMap.removeEntryListener(id));
assertNoLeftOver(nodes, client, id, registrations);
}
Aggregations