Search in sources :

Example 6 with IMapDataStructureAdapter

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

the class ClientMapNearCachePreloaderTest method createContext.

@Override
protected <K, V> NearCacheTestContext<K, V, Data, String> createContext(boolean createNearCacheInstance) {
    Config config = getConfig();
    HazelcastInstance member = hazelcastFactory.newHazelcastInstance(config);
    IMap<K, V> memberMap = member.getMap(nearCacheConfig.getName());
    IMapDataStructureAdapter<K, V> dataAdapter = new IMapDataStructureAdapter<K, V>(memberMap);
    if (createNearCacheInstance) {
        NearCacheTestContextBuilder<K, V, Data, String> contextBuilder = createNearCacheContextBuilder();
        return contextBuilder.setDataInstance(member).setDataAdapter(dataAdapter).build();
    }
    return new NearCacheTestContextBuilder<K, V, Data, String>(nearCacheConfig, getSerializationService(member)).setDataInstance(member).setDataAdapter(dataAdapter).build();
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) ClientConfig(com.hazelcast.client.config.ClientConfig) Config(com.hazelcast.config.Config) NearCacheTestUtils.getBaseConfig(com.hazelcast.internal.nearcache.impl.NearCacheTestUtils.getBaseConfig) IMapDataStructureAdapter(com.hazelcast.internal.adapter.IMapDataStructureAdapter) Data(com.hazelcast.internal.serialization.Data)

Example 7 with IMapDataStructureAdapter

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

the class ClientMapNearCacheLeakTest method createContext.

@Override
protected <K, V> NearCacheTestContext<K, V, Data, String> createContext() {
    Config config = getConfig();
    HazelcastInstance member = hazelcastFactory.newHazelcastInstance(config);
    IMap<K, V> memberMap = member.getMap(DEFAULT_NEAR_CACHE_NAME);
    IMapDataStructureAdapter<K, V> dataAdapter = new IMapDataStructureAdapter<K, V>(memberMap);
    // wait until the initial load is done
    dataAdapter.waitUntilLoaded();
    NearCacheTestContextBuilder<K, V, Data, String> builder = createNearCacheContextBuilder();
    return builder.setDataInstance(member).setDataAdapter(dataAdapter).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)

Example 8 with IMapDataStructureAdapter

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

the class ClientMapNearCacheLeakTest method createNearCacheContextBuilder.

private <K, V> NearCacheTestContextBuilder<K, V, Data, String> createNearCacheContextBuilder() {
    ClientConfig clientConfig = getClientConfig();
    HazelcastClientProxy client = (HazelcastClientProxy) hazelcastFactory.newHazelcastClient(clientConfig);
    IMap<K, V> clientMap = client.getMap(DEFAULT_NEAR_CACHE_NAME);
    NearCacheManager nearCacheManager = ((ClientMapProxy) clientMap).getContext().getNearCacheManager(clientMap.getServiceName());
    NearCache<Data, String> nearCache = nearCacheManager.getNearCache(DEFAULT_NEAR_CACHE_NAME);
    ClientContext clientContext = ((ClientProxy) clientMap).getContext();
    RepairingTask repairingTask = clientContext.getRepairingTask(MapService.SERVICE_NAME);
    return new NearCacheTestContextBuilder<K, V, Data, String>(nearCacheConfig, client.getSerializationService()).setNearCacheInstance(client).setNearCacheAdapter(new IMapDataStructureAdapter<K, V>(clientMap)).setNearCache(nearCache).setNearCacheManager(nearCacheManager).setRepairingTask(repairingTask);
}
Also used : NearCacheManager(com.hazelcast.internal.nearcache.NearCacheManager) RepairingTask(com.hazelcast.internal.nearcache.impl.invalidation.RepairingTask) ClientContext(com.hazelcast.client.impl.spi.ClientContext) Data(com.hazelcast.internal.serialization.Data) IMapDataStructureAdapter(com.hazelcast.internal.adapter.IMapDataStructureAdapter) ClientProxy(com.hazelcast.client.impl.spi.ClientProxy) HazelcastClientProxy(com.hazelcast.client.impl.clientside.HazelcastClientProxy) ClientConfig(com.hazelcast.client.config.ClientConfig) HazelcastClientProxy(com.hazelcast.client.impl.clientside.HazelcastClientProxy)

Example 9 with IMapDataStructureAdapter

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

the class LiteMemberClientMapNearCacheBasicTest 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) 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)

Example 10 with IMapDataStructureAdapter

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

the class LiteMemberClientMapNearCacheBasicTest method createContext.

@Override
protected <K, V> NearCacheTestContext<K, V, Data, String> createContext(boolean loaderEnabled) {
    IMapMapStore mapStore = loaderEnabled ? new IMapMapStore() : null;
    Config config = getConfig(mapStore, false);
    ClientConfig clientConfig = getClientConfig();
    // create a Hazelcast member to hold the data
    hazelcastFactory.newHazelcastInstance(config);
    // create a Hazelcast client to be used in the tests
    HazelcastClientProxy client = (HazelcastClientProxy) hazelcastFactory.newHazelcastClient(clientConfig);
    IMap<K, V> clientMap = client.getMap(DEFAULT_NEAR_CACHE_NAME);
    IMapDataStructureAdapter<K, V> dataAdapter = new IMapDataStructureAdapter<K, V>(clientMap);
    // wait until the initial load is done
    dataAdapter.waitUntilLoaded();
    NearCacheTestContextBuilder<K, V, Data, String> builder = createNearCacheContextBuilder(mapStore);
    return builder.setDataInstance(client).setDataAdapter(dataAdapter).setLoader(mapStore).build();
}
Also used : MapNearCacheBasicTest.addMapStoreConfig(com.hazelcast.map.impl.nearcache.MapNearCacheBasicTest.addMapStoreConfig) MapConfig(com.hazelcast.config.MapConfig) 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) IMapMapStore(com.hazelcast.internal.adapter.IMapMapStore) ClientConfig(com.hazelcast.client.config.ClientConfig) HazelcastClientProxy(com.hazelcast.client.impl.clientside.HazelcastClientProxy)

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