Search in sources :

Example 1 with MapProxyImpl

use of com.hazelcast.map.impl.proxy.MapProxyImpl in project hazelcast by hazelcast.

the class MapFlushMessageTask method call.

@Override
protected Object call() throws Exception {
    MapService mapService = getService(SERVICE_NAME);
    MapServiceContext mapServiceContext = mapService.getMapServiceContext();
    NodeEngine nodeEngine = mapServiceContext.getNodeEngine();
    ProxyService proxyService = nodeEngine.getProxyService();
    DistributedObject distributedObject = proxyService.getDistributedObject(SERVICE_NAME, parameters.name);
    MapProxyImpl mapProxy = (MapProxyImpl) distributedObject;
    mapProxy.flush();
    return null;
}
Also used : NodeEngine(com.hazelcast.spi.NodeEngine) DistributedObject(com.hazelcast.core.DistributedObject) ProxyService(com.hazelcast.spi.ProxyService) MapProxyImpl(com.hazelcast.map.impl.proxy.MapProxyImpl) MapService(com.hazelcast.map.impl.MapService) MapServiceContext(com.hazelcast.map.impl.MapServiceContext)

Example 2 with MapProxyImpl

use of com.hazelcast.map.impl.proxy.MapProxyImpl in project hazelcast by hazelcast.

the class MapLoadAllMessageTask method call.

@Override
protected Object call() {
    final MapService mapService = getService(MapService.SERVICE_NAME);
    final DistributedObject distributedObject = mapService.getMapServiceContext().getNodeEngine().getProxyService().getDistributedObject(MapService.SERVICE_NAME, parameters.name);
    final MapProxyImpl mapProxy = (MapProxyImpl) distributedObject;
    mapProxy.loadAll(parameters.replaceExistingValues);
    return null;
}
Also used : DistributedObject(com.hazelcast.core.DistributedObject) MapProxyImpl(com.hazelcast.map.impl.proxy.MapProxyImpl) MapService(com.hazelcast.map.impl.MapService)

Example 3 with MapProxyImpl

use of com.hazelcast.map.impl.proxy.MapProxyImpl in project hazelcast by hazelcast.

the class MapRemoteService method createDistributedObject.

@Override
public DistributedObject createDistributedObject(String name) {
    MapConfig mapConfig = nodeEngine.getConfig().findMapConfig(name);
    checkMapConfig(mapConfig);
    if (mapConfig.isNearCacheEnabled()) {
        checkNearCacheConfig(name, mapConfig.getNearCacheConfig(), false);
        return new NearCachedMapProxyImpl(name, mapServiceContext.getService(), nodeEngine, mapConfig);
    } else {
        return new MapProxyImpl(name, mapServiceContext.getService(), nodeEngine, mapConfig);
    }
}
Also used : MapProxyImpl(com.hazelcast.map.impl.proxy.MapProxyImpl) NearCachedMapProxyImpl(com.hazelcast.map.impl.proxy.NearCachedMapProxyImpl) NearCachedMapProxyImpl(com.hazelcast.map.impl.proxy.NearCachedMapProxyImpl) MapConfig(com.hazelcast.config.MapConfig) ConfigValidator.checkMapConfig(com.hazelcast.internal.config.ConfigValidator.checkMapConfig)

Example 4 with MapProxyImpl

use of com.hazelcast.map.impl.proxy.MapProxyImpl in project hazelcast by hazelcast.

the class MapContainerCreationUponDestroyStressTest method getMapServiceContext.

private MapServiceContext getMapServiceContext(IMap map) {
    MapProxyImpl mapProxy = (MapProxyImpl) map;
    RemoteService service = mapProxy.getService();
    MapService mapService = (MapService) service;
    return mapService.getMapServiceContext();
}
Also used : RemoteService(com.hazelcast.spi.RemoteService) MapProxyImpl(com.hazelcast.map.impl.proxy.MapProxyImpl) MapService(com.hazelcast.map.impl.MapService)

Example 5 with MapProxyImpl

use of com.hazelcast.map.impl.proxy.MapProxyImpl in project hazelcast by hazelcast.

the class EvictionMaxSizePolicyTest method setTestSizeEstimator.

public static void setTestSizeEstimator(IMap map, final long oneEntryHeapCostInBytes) {
    final MapProxyImpl mapProxy = (MapProxyImpl) map;
    final MapService mapService = (MapService) mapProxy.getService();
    final MapServiceContext mapServiceContext = mapService.getMapServiceContext();
    final NodeEngine nodeEngine = mapServiceContext.getNodeEngine();
    final IPartitionService partitionService = nodeEngine.getPartitionService();
    for (int i = 0; i < partitionService.getPartitionCount(); i++) {
        final Address owner = partitionService.getPartitionOwner(i);
        if (nodeEngine.getThisAddress().equals(owner)) {
            final PartitionContainer container = mapServiceContext.getPartitionContainer(i);
            if (container == null) {
                continue;
            }
            final RecordStore recordStore = container.getRecordStore(map.getName());
            final DefaultRecordStore defaultRecordStore = (DefaultRecordStore) recordStore;
            defaultRecordStore.setSizeEstimator(new EntryCostEstimator() {

                long size;

                @Override
                public long getEstimate() {
                    return size;
                }

                @Override
                public void adjustEstimateBy(long size) {
                    this.size += size;
                }

                @Override
                public long calculateValueCost(Object record) {
                    if (record == null) {
                        return 0L;
                    }
                    return oneEntryHeapCostInBytes;
                }

                @Override
                public long calculateEntryCost(Object key, Object record) {
                    if (record == null) {
                        return 0L;
                    }
                    return 2 * oneEntryHeapCostInBytes;
                }

                @Override
                public void reset() {
                    size = 0;
                }
            });
        }
    }
}
Also used : Address(com.hazelcast.nio.Address) PartitionContainer(com.hazelcast.map.impl.PartitionContainer) IPartitionService(com.hazelcast.spi.partition.IPartitionService) EntryCostEstimator(com.hazelcast.map.impl.EntryCostEstimator) MapServiceContext(com.hazelcast.map.impl.MapServiceContext) NodeEngine(com.hazelcast.spi.NodeEngine) MapProxyImpl(com.hazelcast.map.impl.proxy.MapProxyImpl) DefaultRecordStore(com.hazelcast.map.impl.recordstore.DefaultRecordStore) RecordStore(com.hazelcast.map.impl.recordstore.RecordStore) MapService(com.hazelcast.map.impl.MapService) DefaultRecordStore(com.hazelcast.map.impl.recordstore.DefaultRecordStore)

Aggregations

MapProxyImpl (com.hazelcast.map.impl.proxy.MapProxyImpl)24 HazelcastInstance (com.hazelcast.core.HazelcastInstance)13 ParallelTest (com.hazelcast.test.annotation.ParallelTest)12 QuickTest (com.hazelcast.test.annotation.QuickTest)12 Test (org.junit.Test)12 MapService (com.hazelcast.map.impl.MapService)10 MapServiceContext (com.hazelcast.map.impl.MapServiceContext)7 Config (com.hazelcast.config.Config)3 DistributedObject (com.hazelcast.core.DistributedObject)3 MapContainer (com.hazelcast.map.impl.MapContainer)3 Map (java.util.Map)3 MapConfig (com.hazelcast.config.MapConfig)2 PartitionContainer (com.hazelcast.map.impl.PartitionContainer)2 RecordStore (com.hazelcast.map.impl.recordstore.RecordStore)2 Address (com.hazelcast.nio.Address)2 NodeEngine (com.hazelcast.spi.NodeEngine)2 IPartitionService (com.hazelcast.spi.partition.IPartitionService)2 TestHazelcastInstanceFactory (com.hazelcast.test.TestHazelcastInstanceFactory)2 HashSet (java.util.HashSet)2 Ignore (org.junit.Ignore)2