use of com.hazelcast.spi.impl.NodeEngineImpl in project hazelcast by hazelcast.
the class MapInvalidationMetaDataMigrationTest method getPartitionToSequenceMap.
private Map<Integer, Long> getPartitionToSequenceMap(String mapName, HazelcastInstance instance) {
NodeEngineImpl nodeEngineImpl = getNodeEngineImpl(instance);
int partitionCount = nodeEngineImpl.getPartitionService().getPartitionCount();
HashMap<Integer, Long> partitionToSequenceMap = new HashMap<Integer, Long>(partitionCount);
MapService mapService = nodeEngineImpl.getService(SERVICE_NAME);
MapServiceContext mapServiceContext = mapService.getMapServiceContext();
MapNearCacheManager mapNearCacheManager = mapServiceContext.getMapNearCacheManager();
Invalidator invalidator = mapNearCacheManager.getInvalidator();
MetaDataGenerator metaDataGenerator = invalidator.getMetaDataGenerator();
for (int i = 0; i < partitionCount; i++) {
partitionToSequenceMap.put(i, metaDataGenerator.currentSequence(mapName, i));
}
return partitionToSequenceMap;
}
use of com.hazelcast.spi.impl.NodeEngineImpl in project hazelcast by hazelcast.
the class MapInvalidationMetaDataMigrationTest method getPartitionToUuidMap.
private Map<Integer, UUID> getPartitionToUuidMap(HazelcastInstance instance) {
NodeEngineImpl nodeEngineImpl = getNodeEngineImpl(instance);
int partitionCount = nodeEngineImpl.getPartitionService().getPartitionCount();
HashMap<Integer, UUID> partitionToSequenceMap = new HashMap<Integer, UUID>(partitionCount);
MapService mapService = nodeEngineImpl.getService(SERVICE_NAME);
MapServiceContext mapServiceContext = mapService.getMapServiceContext();
MapNearCacheManager mapNearCacheManager = mapServiceContext.getMapNearCacheManager();
Invalidator invalidator = mapNearCacheManager.getInvalidator();
MetaDataGenerator metaDataGenerator = invalidator.getMetaDataGenerator();
for (int i = 0; i < partitionCount; i++) {
partitionToSequenceMap.put(i, metaDataGenerator.getUuidOrNull(i));
}
return partitionToSequenceMap;
}
use of com.hazelcast.spi.impl.NodeEngineImpl in project hazelcast by hazelcast.
the class ReplicatedMapReorderedReplicationTest method testNonConvergingReplicatedMaps.
@Test
public void testNonConvergingReplicatedMaps() throws Exception {
final int nodeCount = 4;
final int keyCount = 10000;
final int threadCount = 2;
updateFactory();
TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory();
final Config config = new Config();
final HazelcastInstance[] instances = factory.newInstances(config, nodeCount);
warmUpPartitions(instances);
final int partitionId = randomPartitionOwnedBy(instances[0]).getPartitionId();
final String mapName = randomMapName();
final NodeEngineImpl nodeEngine = getNodeEngineImpl(instances[0]);
final Thread[] threads = new Thread[threadCount];
for (int i = 0; i < threadCount; i++) {
final int startIndex = i;
threads[i] = new Thread(new Runnable() {
@Override
public void run() {
for (int j = startIndex; j < keyCount; j += threadCount) {
put(nodeEngine, mapName, partitionId, j, j);
}
}
});
}
for (Thread thread : threads) {
thread.start();
}
for (Thread thread : threads) {
thread.join();
}
final ReplicatedRecordStore[] stores = new ReplicatedRecordStore[nodeCount];
for (int i = 0; i < nodeCount; i++) {
ReplicatedMapService service = getNodeEngineImpl(instances[i]).getService(ReplicatedMapService.SERVICE_NAME);
service.triggerAntiEntropy();
stores[i] = service.getReplicatedRecordStore(mapName, false, partitionId);
}
assertTrueEventually(new AssertTask() {
@Override
public void run() throws Exception {
long version = stores[0].getVersion();
for (ReplicatedRecordStore store : stores) {
assertEquals(version, store.getVersion());
assertFalse(store.isStale(version));
}
}
});
for (int i = 0; i < keyCount; i++) {
for (ReplicatedRecordStore store : stores) {
assertTrue(store.containsKey(i));
}
}
}
use of com.hazelcast.spi.impl.NodeEngineImpl in project hazelcast by hazelcast.
the class AbstractBaseReplicatedRecordStoreTest method setUp.
@Before
public void setUp() {
HazelcastInstance instance = createHazelcastInstance();
NodeEngineImpl nodeEngine = getNodeEngineImpl(instance);
ReplicatedMapService service = new ReplicatedMapService(nodeEngine);
recordStore = new TestReplicatedRecordStore("recordStore", service, 0);
recordStoreSameAttributes = new TestReplicatedRecordStore("recordStore", service, 0);
recordStoreSameAttributes.storageRef.set(recordStore.storageRef.get());
recordStoreOtherStorage = new TestReplicatedRecordStore("recordStore", service, 0);
recordStoreOtherName = new TestReplicatedRecordStore("otherRecordStore", service, 0);
}
use of com.hazelcast.spi.impl.NodeEngineImpl in project hazelcast by hazelcast.
the class MockConnection method close.
public void close(String msg, Throwable cause) {
if (!alive.compareAndSet(true, false)) {
return;
}
if (localConnection != null) {
//this is a member-to-member connection
NodeEngineImpl localNodeEngine = localConnection.nodeEngine;
Node localNode = localNodeEngine.getNode();
MockConnectionManager connectionManager = (MockConnectionManager) localNode.connectionManager;
connectionManager.onClose(this);
} else {
//this is a client-member connection. we need to notify NodeEngine about a client connection being closed.
MockConnectionManager connectionManager = (MockConnectionManager) nodeEngine.getNode().connectionManager;
connectionManager.onClose(this);
}
}
Aggregations