Search in sources :

Example 1 with IMapDataStructureAdapter

use of com.hazelcast.internal.adapter.IMapDataStructureAdapter in project hazelcast by hazelcast.

the class NearCachedClientMapProxy method onInitialize.

@Override
protected void onInitialize() {
    super.onInitialize();
    ClientContext context = getContext();
    logger = context.getLoggingService().getLogger(getClass());
    NearCacheConfig nearCacheConfig = context.getClientConfig().getNearCacheConfig(name);
    NearCacheManager nearCacheManager = context.getNearCacheManager();
    IMapDataStructureAdapter<K, V> adapter = new IMapDataStructureAdapter<K, V>(this);
    nearCache = nearCacheManager.getOrCreateNearCache(name, nearCacheConfig, adapter);
    invalidateOnChange = nearCache.isInvalidatedOnChange();
    if (invalidateOnChange) {
        addNearCacheInvalidationListener(new ConnectedServerVersionAwareNearCacheEventHandler());
    }
}
Also used : NearCacheManager(com.hazelcast.internal.nearcache.NearCacheManager) ClientContext(com.hazelcast.client.spi.ClientContext) IMapDataStructureAdapter(com.hazelcast.internal.adapter.IMapDataStructureAdapter) NearCacheConfig(com.hazelcast.config.NearCacheConfig)

Example 2 with IMapDataStructureAdapter

use of com.hazelcast.internal.adapter.IMapDataStructureAdapter in project hazelcast by hazelcast.

the class MapNearCacheBasicTest method createContext.

@Override
protected <K, V> NearCacheTestContext<K, V, Data, String> createContext(boolean loaderEnabled) {
    IMapMapStore mapStore = loaderEnabled ? new IMapMapStore() : null;
    Config config = createConfig(mapStore, false);
    HazelcastInstance dataInstance = hazelcastFactory.newHazelcastInstance(config);
    IMap<K, V> dataMap = dataInstance.getMap(DEFAULT_NEAR_CACHE_NAME);
    IMapDataStructureAdapter<K, V> dataAdapter = new IMapDataStructureAdapter<K, V>(dataMap);
    // wait until the initial load is done
    dataAdapter.waitUntilLoaded();
    NearCacheTestContextBuilder<K, V, Data, String> builder = createNearCacheContextBuilder(mapStore);
    return builder.setDataInstance(dataInstance).setDataAdapter(dataAdapter).build();
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) MapConfig(com.hazelcast.config.MapConfig) Config(com.hazelcast.config.Config) NearCacheTestUtils.createNearCacheConfig(com.hazelcast.internal.nearcache.impl.NearCacheTestUtils.createNearCacheConfig) NearCacheTestUtils.getBaseConfig(com.hazelcast.internal.nearcache.impl.NearCacheTestUtils.getBaseConfig) MapStoreConfig(com.hazelcast.config.MapStoreConfig) IMapDataStructureAdapter(com.hazelcast.internal.adapter.IMapDataStructureAdapter) Data(com.hazelcast.internal.serialization.Data) IMapMapStore(com.hazelcast.internal.adapter.IMapMapStore)

Example 3 with IMapDataStructureAdapter

use of com.hazelcast.internal.adapter.IMapDataStructureAdapter in project hazelcast by hazelcast.

the class LiteMemberMapNearCacheBasicTest method createNearCacheContextBuilder.

private <K, V> NearCacheTestContextBuilder<K, V, Data, String> createNearCacheContextBuilder(IMapMapStore mapStore) {
    Config configWithNearCache = getConfig(mapStore, true);
    HazelcastInstance liteMember = hazelcastFactory.newHazelcastInstance(configWithNearCache);
    IMap<K, V> liteMemberMap = liteMember.getMap(DEFAULT_NEAR_CACHE_NAME);
    NearCacheManager nearCacheManager = getMapNearCacheManager(liteMember);
    NearCache<Data, String> nearCache = nearCacheManager.getNearCache(DEFAULT_NEAR_CACHE_NAME);
    return new NearCacheTestContextBuilder<K, V, Data, String>(nearCacheConfig, getSerializationService(liteMember)).setNearCacheInstance(liteMember).setNearCacheAdapter(new IMapDataStructureAdapter<K, V>(liteMemberMap)).setNearCache(nearCache).setNearCacheManager(nearCacheManager).setLoader(mapStore);
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) NearCacheTestUtils.getMapNearCacheManager(com.hazelcast.internal.nearcache.impl.NearCacheTestUtils.getMapNearCacheManager) NearCacheManager(com.hazelcast.internal.nearcache.NearCacheManager) MapNearCacheBasicTest.addMapStoreConfig(com.hazelcast.map.impl.nearcache.MapNearCacheBasicTest.addMapStoreConfig) MapConfig(com.hazelcast.config.MapConfig) Config(com.hazelcast.config.Config) NearCacheTestUtils.createNearCacheConfig(com.hazelcast.internal.nearcache.impl.NearCacheTestUtils.createNearCacheConfig) NearCacheTestUtils.getBaseConfig(com.hazelcast.internal.nearcache.impl.NearCacheTestUtils.getBaseConfig) IMapDataStructureAdapter(com.hazelcast.internal.adapter.IMapDataStructureAdapter) Data(com.hazelcast.internal.serialization.Data)

Example 4 with IMapDataStructureAdapter

use of com.hazelcast.internal.adapter.IMapDataStructureAdapter in project hazelcast by hazelcast.

the class LiteMemberMapNearCacheLeakTest method createNearCacheContextBuilder.

private <K, V> NearCacheTestContextBuilder<K, V, Data, String> createNearCacheContextBuilder() {
    Config configWithNearCache = getConfig(true);
    HazelcastInstance liteMember = hazelcastFactory.newHazelcastInstance(configWithNearCache);
    IMap<K, V> liteMemberMap = liteMember.getMap(DEFAULT_NEAR_CACHE_NAME);
    NearCacheManager nearCacheManager = getMapNearCacheManager(liteMember);
    NearCache<Data, String> nearCache = nearCacheManager.getNearCache(DEFAULT_NEAR_CACHE_NAME);
    RepairingTask repairingTask = ((MapNearCacheManager) nearCacheManager).getRepairingTask();
    return new NearCacheTestContextBuilder<K, V, Data, String>(nearCacheConfig, getSerializationService(liteMember)).setNearCacheInstance(liteMember).setNearCacheAdapter(new IMapDataStructureAdapter<K, V>(liteMemberMap)).setNearCache(nearCache).setNearCacheManager(nearCacheManager).setRepairingTask(repairingTask);
}
Also used : NearCacheTestUtils.getMapNearCacheManager(com.hazelcast.internal.nearcache.impl.NearCacheTestUtils.getMapNearCacheManager) NearCacheTestUtils.getMapNearCacheManager(com.hazelcast.internal.nearcache.impl.NearCacheTestUtils.getMapNearCacheManager) NearCacheManager(com.hazelcast.internal.nearcache.NearCacheManager) RepairingTask(com.hazelcast.internal.nearcache.impl.invalidation.RepairingTask) MapConfig(com.hazelcast.config.MapConfig) Config(com.hazelcast.config.Config) NearCacheTestUtils.createNearCacheConfig(com.hazelcast.internal.nearcache.impl.NearCacheTestUtils.createNearCacheConfig) NearCacheTestUtils.getBaseConfig(com.hazelcast.internal.nearcache.impl.NearCacheTestUtils.getBaseConfig) Data(com.hazelcast.internal.serialization.Data) HazelcastInstance(com.hazelcast.core.HazelcastInstance) IMapDataStructureAdapter(com.hazelcast.internal.adapter.IMapDataStructureAdapter)

Example 5 with IMapDataStructureAdapter

use of com.hazelcast.internal.adapter.IMapDataStructureAdapter in project hazelcast by hazelcast.

the class ClientMapNearCacheSerializationCountTest method createContext.

@Override
protected <K, V> NearCacheTestContext<K, V, Data, String> createContext() {
    Config config = getConfig().setProperty(MAP_INVALIDATION_MESSAGE_BATCH_SIZE.getName(), String.valueOf(Integer.MAX_VALUE)).setProperty(MAP_INVALIDATION_MESSAGE_BATCH_FREQUENCY_SECONDS.getName(), String.valueOf(Integer.MAX_VALUE)).setProperty(PARTITION_COUNT.getName(), "1").setProperty(PARTITION_OPERATION_THREAD_COUNT.getName(), "1");
    config.getMapConfig(DEFAULT_NEAR_CACHE_NAME).setInMemoryFormat(mapInMemoryFormat).setBackupCount(0).setAsyncBackupCount(0);
    prepareSerializationConfig(config.getSerializationConfig());
    HazelcastInstance member = hazelcastFactory.newHazelcastInstance(config);
    IMap<K, V> memberMap = member.getMap(DEFAULT_NEAR_CACHE_NAME);
    NearCacheTestContextBuilder<K, V, Data, String> contextBuilder = createNearCacheContextBuilder();
    return contextBuilder.setDataInstance(member).setDataAdapter(new IMapDataStructureAdapter<K, V>(memberMap)).build();
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) ClientConfig(com.hazelcast.client.config.ClientConfig) Config(com.hazelcast.config.Config) NearCacheTestUtils.createNearCacheConfig(com.hazelcast.internal.nearcache.impl.NearCacheTestUtils.createNearCacheConfig) NearCacheTestUtils.getBaseConfig(com.hazelcast.internal.nearcache.impl.NearCacheTestUtils.getBaseConfig) IMapDataStructureAdapter(com.hazelcast.internal.adapter.IMapDataStructureAdapter) Data(com.hazelcast.internal.serialization.Data)

Aggregations

IMapDataStructureAdapter (com.hazelcast.internal.adapter.IMapDataStructureAdapter)15 Data (com.hazelcast.internal.serialization.Data)14 Config (com.hazelcast.config.Config)12 HazelcastInstance (com.hazelcast.core.HazelcastInstance)12 NearCacheTestUtils.getBaseConfig (com.hazelcast.internal.nearcache.impl.NearCacheTestUtils.getBaseConfig)12 NearCacheTestUtils.createNearCacheConfig (com.hazelcast.internal.nearcache.impl.NearCacheTestUtils.createNearCacheConfig)11 MapConfig (com.hazelcast.config.MapConfig)8 ClientConfig (com.hazelcast.client.config.ClientConfig)7 NearCacheManager (com.hazelcast.internal.nearcache.NearCacheManager)5 MapNearCacheBasicTest.addMapStoreConfig (com.hazelcast.map.impl.nearcache.MapNearCacheBasicTest.addMapStoreConfig)5 IMapMapStore (com.hazelcast.internal.adapter.IMapMapStore)4 NearCacheTestUtils.getMapNearCacheManager (com.hazelcast.internal.nearcache.impl.NearCacheTestUtils.getMapNearCacheManager)3 HazelcastClientProxy (com.hazelcast.client.impl.clientside.HazelcastClientProxy)2 RepairingTask (com.hazelcast.internal.nearcache.impl.invalidation.RepairingTask)2 ClientContext (com.hazelcast.client.impl.spi.ClientContext)1 ClientProxy (com.hazelcast.client.impl.spi.ClientProxy)1 ClientContext (com.hazelcast.client.spi.ClientContext)1 MapStoreConfig (com.hazelcast.config.MapStoreConfig)1 NearCacheConfig (com.hazelcast.config.NearCacheConfig)1