Search in sources :

Example 66 with MapService

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();
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) Config(com.hazelcast.config.Config) NearCacheConfig(com.hazelcast.config.NearCacheConfig) NearCacheConfig(com.hazelcast.config.NearCacheConfig) MapService(com.hazelcast.map.impl.MapService) MapServiceContext(com.hazelcast.map.impl.MapServiceContext)

Example 67 with MapService

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);
}
Also used : NodeEngineImpl(com.hazelcast.spi.impl.NodeEngineImpl) MapNearCacheManager(com.hazelcast.map.impl.nearcache.MapNearCacheManager) Invalidator(com.hazelcast.internal.nearcache.impl.invalidation.Invalidator) MapService(com.hazelcast.map.impl.MapService) MetaDataGenerator(com.hazelcast.internal.nearcache.impl.invalidation.MetaDataGenerator) MapServiceContext(com.hazelcast.map.impl.MapServiceContext)

Example 68 with MapService

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();
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) MapService(com.hazelcast.map.impl.MapService) TestHazelcastInstanceFactory(com.hazelcast.test.TestHazelcastInstanceFactory) MapContainer(com.hazelcast.map.impl.MapContainer) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 69 with MapService

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));
}
Also used : NodeEngineImpl(com.hazelcast.spi.impl.NodeEngineImpl) MapNearCacheManager(com.hazelcast.map.impl.nearcache.MapNearCacheManager) Invalidator(com.hazelcast.internal.nearcache.impl.invalidation.Invalidator) InternalPartitionService(com.hazelcast.internal.partition.InternalPartitionService) MapService(com.hazelcast.map.impl.MapService) MetaDataGenerator(com.hazelcast.internal.nearcache.impl.invalidation.MetaDataGenerator) MapServiceContext(com.hazelcast.map.impl.MapServiceContext)

Example 70 with MapService

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;
}
Also used : NodeEngineImpl(com.hazelcast.spi.impl.NodeEngineImpl) MapNearCacheManager(com.hazelcast.map.impl.nearcache.MapNearCacheManager) Invalidator(com.hazelcast.internal.nearcache.impl.invalidation.Invalidator) HashMap(java.util.HashMap) MapService(com.hazelcast.map.impl.MapService) MetaDataGenerator(com.hazelcast.internal.nearcache.impl.invalidation.MetaDataGenerator) MapServiceContext(com.hazelcast.map.impl.MapServiceContext)

Aggregations

MapService (com.hazelcast.map.impl.MapService)80 MapServiceContext (com.hazelcast.map.impl.MapServiceContext)44 NodeEngineImpl (com.hazelcast.spi.impl.NodeEngineImpl)20 HazelcastInstance (com.hazelcast.core.HazelcastInstance)13 MapNearCacheManager (com.hazelcast.map.impl.nearcache.MapNearCacheManager)13 MetaDataGenerator (com.hazelcast.internal.nearcache.impl.invalidation.MetaDataGenerator)12 Invalidator (com.hazelcast.internal.nearcache.impl.invalidation.Invalidator)11 MapContainer (com.hazelcast.map.impl.MapContainer)10 MapProxyImpl (com.hazelcast.map.impl.proxy.MapProxyImpl)10 ParallelTest (com.hazelcast.test.annotation.ParallelTest)9 QuickTest (com.hazelcast.test.annotation.QuickTest)9 Test (org.junit.Test)9 RecordStore (com.hazelcast.map.impl.recordstore.RecordStore)8 Config (com.hazelcast.config.Config)7 Before (org.junit.Before)7 Data (com.hazelcast.nio.serialization.Data)6 Map (java.util.Map)6 Address (com.hazelcast.nio.Address)5 IPartitionLostEvent (com.hazelcast.spi.partition.IPartitionLostEvent)5 PartitionContainer (com.hazelcast.map.impl.PartitionContainer)4