Search in sources :

Example 61 with MapService

use of com.hazelcast.map.impl.MapService in project hazelcast by hazelcast.

the class MapProxyImpl method submitToKey.

@Override
public ICompletableFuture submitToKey(K key, EntryProcessor entryProcessor) {
    checkNotNull(key, NULL_KEY_IS_NOT_ALLOWED);
    MapService service = getService();
    Data keyData = toData(key, partitionStrategy);
    InternalCompletableFuture f = executeOnKeyInternal(keyData, entryProcessor, null);
    return new DelegatingFuture(f, service.getMapServiceContext().getNodeEngine().getSerializationService());
}
Also used : InternalCompletableFuture(com.hazelcast.spi.InternalCompletableFuture) Data(com.hazelcast.nio.serialization.Data) MapService(com.hazelcast.map.impl.MapService) DelegatingFuture(com.hazelcast.util.executor.DelegatingFuture)

Example 62 with MapService

use of com.hazelcast.map.impl.MapService in project hazelcast by hazelcast.

the class ClientMapPartitionLostListenerTest method test_mapPartitionLostListener_invoked_fromOtherNode.

@Test
public void test_mapPartitionLostListener_invoked_fromOtherNode() {
    final String mapName = randomMapName();
    final Config config = new Config();
    config.getMapConfig(mapName).setBackupCount(0);
    final HazelcastInstance instance1 = hazelcastFactory.newHazelcastInstance(config);
    final HazelcastInstance instance2 = hazelcastFactory.newHazelcastInstance(config);
    final ClientConfig clientConfig = new ClientConfig();
    clientConfig.getNetworkConfig().setSmartRouting(false);
    final HazelcastInstance client = hazelcastFactory.newHazelcastClient(clientConfig);
    final HazelcastClientInstanceImpl clientInstanceImpl = getHazelcastClientInstanceImpl(client);
    final Address clientOwnerAddress = clientInstanceImpl.getClientClusterService().getOwnerConnectionAddress();
    final HazelcastInstance other = getAddress(instance1).equals(clientOwnerAddress) ? instance2 : instance1;
    final TestEventCollectingMapPartitionLostListener listener = new TestEventCollectingMapPartitionLostListener(0);
    client.getMap(mapName).addPartitionLostListener(listener);
    assertRegistrationEventually(instance1, mapName, true);
    assertRegistrationEventually(instance2, mapName, true);
    assertProxyExistsEventually(instance1, mapName);
    assertProxyExistsEventually(instance2, mapName);
    final MapService mapService = getNode(other).getNodeEngine().getService(SERVICE_NAME);
    final int partitionId = 5;
    mapService.onPartitionLost(new IPartitionLostEvent(partitionId, 0, null));
    assertMapPartitionLostEventEventually(listener, partitionId);
}
Also used : TestEventCollectingMapPartitionLostListener(com.hazelcast.map.TestEventCollectingMapPartitionLostListener) HazelcastInstance(com.hazelcast.core.HazelcastInstance) Address(com.hazelcast.nio.Address) HazelcastTestSupport.getAddress(com.hazelcast.test.HazelcastTestSupport.getAddress) ClientConfig(com.hazelcast.client.config.ClientConfig) Config(com.hazelcast.config.Config) ClientTestUtil.getHazelcastClientInstanceImpl(com.hazelcast.client.impl.ClientTestUtil.getHazelcastClientInstanceImpl) HazelcastClientInstanceImpl(com.hazelcast.client.impl.HazelcastClientInstanceImpl) ClientConfig(com.hazelcast.client.config.ClientConfig) MapService(com.hazelcast.map.impl.MapService) IPartitionLostEvent(com.hazelcast.spi.partition.IPartitionLostEvent) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 63 with MapService

use of com.hazelcast.map.impl.MapService in project hazelcast by hazelcast.

the class ClientMapPartitionLostListenerTest method test_mapPartitionLostListener_invoked.

@Test
public void test_mapPartitionLostListener_invoked() {
    final String mapName = randomMapName();
    final Config config = new Config();
    config.getMapConfig(mapName).setBackupCount(0);
    final HazelcastInstance instance = hazelcastFactory.newHazelcastInstance(config);
    final HazelcastInstance client = hazelcastFactory.newHazelcastClient();
    warmUpPartitions(instance, client);
    final TestEventCollectingMapPartitionLostListener listener = new TestEventCollectingMapPartitionLostListener(0);
    client.getMap(mapName).addPartitionLostListener(listener);
    final MapService mapService = getNode(instance).getNodeEngine().getService(MapService.SERVICE_NAME);
    final int partitionId = 5;
    mapService.onPartitionLost(new IPartitionLostEvent(partitionId, 0, null));
    assertMapPartitionLostEventEventually(listener, partitionId);
}
Also used : TestEventCollectingMapPartitionLostListener(com.hazelcast.map.TestEventCollectingMapPartitionLostListener) HazelcastInstance(com.hazelcast.core.HazelcastInstance) ClientConfig(com.hazelcast.client.config.ClientConfig) Config(com.hazelcast.config.Config) MapService(com.hazelcast.map.impl.MapService) IPartitionLostEvent(com.hazelcast.spi.partition.IPartitionLostEvent) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 64 with MapService

use of com.hazelcast.map.impl.MapService in project hazelcast by hazelcast.

the class ClearExpiredOperation method run.

@Override
public void run() throws Exception {
    final MapService mapService = getService();
    MapServiceContext mapServiceContext = mapService.getMapServiceContext();
    final PartitionContainer partitionContainer = mapServiceContext.getPartitionContainer(getPartitionId());
    final ConcurrentMap<String, RecordStore> recordStores = partitionContainer.getMaps();
    final boolean backup = !isOwner();
    for (final RecordStore recordStore : recordStores.values()) {
        if (recordStore.size() > 0 && recordStore.isExpirable()) {
            recordStore.evictExpiredEntries(expirationPercentage, backup);
            recordStore.disposeDeferredBlocks();
        }
    }
}
Also used : PartitionContainer(com.hazelcast.map.impl.PartitionContainer) RecordStore(com.hazelcast.map.impl.recordstore.RecordStore) MapService(com.hazelcast.map.impl.MapService) MapServiceContext(com.hazelcast.map.impl.MapServiceContext)

Example 65 with MapService

use of com.hazelcast.map.impl.MapService in project hazelcast by hazelcast.

the class MemberMapMetaDataFetcherTest method distortRandomPartitionUuid.

private void distortRandomPartitionUuid(int partition, UUID uuid, 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.setUuid(partition, uuid);
}
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)

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