use of com.hazelcast.map.impl.MapService in project hazelcast by hazelcast.
the class MemberMapMetaDataFetcherTest method getRepairingTask.
private RepairingTask getRepairingTask(String mapName, int partition, long givenSequence, UUID givenUuid) {
Config config = new Config();
config.getMapConfig(mapName).setNearCacheConfig(new NearCacheConfig());
HazelcastInstance member = factory.newHazelcastInstance(config);
MapService mapService = getNodeEngineImpl(member).getService(MapService.SERVICE_NAME);
MapServiceContext mapServiceContext = mapService.getMapServiceContext();
distortRandomPartitionSequence(mapName, partition, givenSequence, member);
distortRandomPartitionUuid(partition, givenUuid, member);
member.getMap(mapName);
return mapServiceContext.getMapNearCacheManager().getRepairingTask();
}
use of com.hazelcast.map.impl.MapService in project hazelcast by hazelcast.
the class MemberMapMetaDataFetcherTest method distortRandomPartitionSequence.
private void distortRandomPartitionSequence(String mapName, int partition, long sequence, HazelcastInstance member) {
NodeEngineImpl nodeEngineImpl = getNodeEngineImpl(member);
MapService mapService = nodeEngineImpl.getService(SERVICE_NAME);
MapServiceContext mapServiceContext = mapService.getMapServiceContext();
MapNearCacheManager mapNearCacheManager = mapServiceContext.getMapNearCacheManager();
Invalidator invalidator = mapNearCacheManager.getInvalidator();
MetaDataGenerator metaDataGenerator = invalidator.getMetaDataGenerator();
metaDataGenerator.setCurrentSequence(mapName, partition, sequence);
}
use of com.hazelcast.map.impl.MapService in project hazelcast by hazelcast.
the class PostJoinMapOperationTest method testPostJoinMapOperation_whenMapHasNoData.
@Test
public void testPostJoinMapOperation_whenMapHasNoData() {
TestHazelcastInstanceFactory hzFactory = createHazelcastInstanceFactory(2);
// given: a single node HazelcastInstance with a map configured with index and interceptor
HazelcastInstance hz1 = hzFactory.newHazelcastInstance();
IMap<String, Person> map = hz1.getMap("map");
map.addIndex("age", true);
map.addInterceptor(new FixedReturnInterceptor());
assertEquals(RETURNED_FROM_INTERCEPTOR, map.get("foo"));
// when: another member joins the cluster
HazelcastInstance hz2 = hzFactory.newHazelcastInstance();
waitAllForSafeState(hz1, hz2);
// then: index & interceptor exist on internal MapContainer on node that joined the cluster
MapService mapService = getNodeEngineImpl(hz2).getService(MapService.SERVICE_NAME);
MapContainer mapContainerOnNode2 = mapService.getMapServiceContext().getMapContainer("map");
assertEquals(1, mapContainerOnNode2.getIndexes().getIndexes().length);
assertEquals(1, mapContainerOnNode2.getInterceptorRegistry().getInterceptors().size());
assertEquals(Person.class, mapContainerOnNode2.getInterceptorRegistry().getInterceptors().get(0).interceptGet("anything").getClass());
assertEquals(RETURNED_FROM_INTERCEPTOR.getAge(), ((Person) mapContainerOnNode2.getInterceptorRegistry().getInterceptors().get(0).interceptGet("anything")).getAge());
// also verify via user API
IMap<String, Person> mapOnNode2 = hz2.getMap("map");
assertEquals(RETURNED_FROM_INTERCEPTOR, mapOnNode2.get("whatever"));
hzFactory.terminateAll();
}
use of com.hazelcast.map.impl.MapService in project hazelcast by hazelcast.
the class InvalidationMetadataDistortionTest method distortRandomPartitionSequence.
private void distortRandomPartitionSequence(String mapName, HazelcastInstance member) {
NodeEngineImpl nodeEngineImpl = getNodeEngineImpl(member);
MapService mapService = nodeEngineImpl.getService(SERVICE_NAME);
MapServiceContext mapServiceContext = mapService.getMapServiceContext();
MapNearCacheManager mapNearCacheManager = mapServiceContext.getMapNearCacheManager();
Invalidator invalidator = mapNearCacheManager.getInvalidator();
MetaDataGenerator metaDataGenerator = invalidator.getMetaDataGenerator();
InternalPartitionService partitionService = nodeEngineImpl.getPartitionService();
int partitionCount = partitionService.getPartitionCount();
metaDataGenerator.setCurrentSequence(mapName, getInt(partitionCount), getInt(MAX_VALUE));
}
use of com.hazelcast.map.impl.MapService 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;
}
Aggregations