Search in sources :

Example 21 with NearCacheManager

use of com.hazelcast.internal.nearcache.NearCacheManager in project hazelcast by hazelcast.

the class NearCacheManagerTestSupport method doDestroyNearCacheAndDestroyAllNearCaches.

void doDestroyNearCacheAndDestroyAllNearCaches() {
    NearCacheManager nearCacheManager = createNearCacheManager();
    for (int i = 0; i < DEFAULT_NEAR_CACHE_COUNT; i++) {
        createNearCache(nearCacheManager, DEFAULT_NEAR_CACHE_NAME + "-" + i);
    }
    Collection<NearCache> nearCaches1 = nearCacheManager.listAllNearCaches();
    assertEquals(DEFAULT_NEAR_CACHE_COUNT, nearCaches1.size());
    for (int i = 0; i < DEFAULT_NEAR_CACHE_COUNT; i++) {
        assertTrue(nearCacheManager.destroyNearCache(DEFAULT_NEAR_CACHE_NAME + "-" + i));
    }
    Collection<NearCache> nearCaches2 = nearCacheManager.listAllNearCaches();
    // destroy also removes Near Cache
    assertEquals(0, nearCaches2.size());
    assertFalse(nearCacheManager.clearNearCache(DEFAULT_NEAR_CACHE_NAME + "-" + DEFAULT_NEAR_CACHE_COUNT));
    for (int i = 0; i < DEFAULT_NEAR_CACHE_COUNT; i++) {
        createNearCache(nearCacheManager, DEFAULT_NEAR_CACHE_NAME + "-" + i);
    }
    Collection<NearCache> nearCaches3 = nearCacheManager.listAllNearCaches();
    assertEquals(DEFAULT_NEAR_CACHE_COUNT, nearCaches3.size());
    nearCacheManager.destroyAllNearCaches();
    Collection<NearCache> nearCaches4 = nearCacheManager.listAllNearCaches();
    // destroy all also removes Near Caches
    assertEquals(0, nearCaches4.size());
}
Also used : NearCacheManager(com.hazelcast.internal.nearcache.NearCacheManager) NearCache(com.hazelcast.internal.nearcache.NearCache)

Example 22 with NearCacheManager

use of com.hazelcast.internal.nearcache.NearCacheManager in project hazelcast by hazelcast.

the class ClientMapNearCacheSerializationCountTest method createNearCacheContextBuilder.

private <K, V> NearCacheTestContextBuilder<K, V, Data, String> createNearCacheContextBuilder() {
    ClientConfig clientConfig = getClientConfig();
    if (nearCacheConfig != null) {
        clientConfig.addNearCacheConfig(nearCacheConfig);
    }
    prepareSerializationConfig(clientConfig.getSerializationConfig());
    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);
    return new NearCacheTestContextBuilder<K, V, Data, String>(nearCacheConfig, client.getSerializationService()).setNearCacheInstance(client).setNearCacheAdapter(new IMapDataStructureAdapter<K, V>(clientMap)).setNearCache(nearCache).setNearCacheManager(nearCacheManager);
}
Also used : NearCacheManager(com.hazelcast.internal.nearcache.NearCacheManager) NearCacheTestContextBuilder(com.hazelcast.internal.nearcache.impl.NearCacheTestContextBuilder) Data(com.hazelcast.internal.serialization.Data) ClientConfig(com.hazelcast.client.config.ClientConfig) HazelcastClientProxy(com.hazelcast.client.impl.clientside.HazelcastClientProxy)

Example 23 with NearCacheManager

use of com.hazelcast.internal.nearcache.NearCacheManager 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 24 with NearCacheManager

use of com.hazelcast.internal.nearcache.NearCacheManager 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 25 with NearCacheManager

use of com.hazelcast.internal.nearcache.NearCacheManager in project hazelcast by hazelcast.

the class ClientMapNearCachePreloaderTest method createClientContext.

@Override
protected <K, V> NearCacheTestContext<K, V, Data, String> createClientContext() {
    ClientConfig clientConfig = getClientConfig().addNearCacheConfig(nearCacheConfig);
    HazelcastClientProxy client = (HazelcastClientProxy) hazelcastFactory.newHazelcastClient(clientConfig);
    IMap<K, V> clientMap = client.getMap(nearCacheConfig.getName());
    NearCacheManager nearCacheManager = client.client.getNearCacheManager();
    NearCache<Data, String> nearCache = nearCacheManager.getNearCache(nearCacheConfig.getName());
    return new NearCacheTestContext<K, V, Data, String>(client.getSerializationService(), client, null, new IMapDataStructureAdapter<K, V>(clientMap), null, false, nearCache, nearCacheManager);
}
Also used : NearCacheTestContext(com.hazelcast.internal.nearcache.NearCacheTestContext) NearCacheManager(com.hazelcast.internal.nearcache.NearCacheManager) Data(com.hazelcast.nio.serialization.Data) ClientConfig(com.hazelcast.client.config.ClientConfig) HazelcastClientProxy(com.hazelcast.client.impl.HazelcastClientProxy)

Aggregations

NearCacheManager (com.hazelcast.internal.nearcache.NearCacheManager)40 ClientConfig (com.hazelcast.client.config.ClientConfig)22 Data (com.hazelcast.internal.serialization.Data)21 HazelcastInstance (com.hazelcast.core.HazelcastInstance)19 NearCacheTestContextBuilder (com.hazelcast.internal.nearcache.impl.NearCacheTestContextBuilder)15 HazelcastClientProxy (com.hazelcast.client.impl.clientside.HazelcastClientProxy)13 Config (com.hazelcast.config.Config)12 HazelcastClientCacheManager (com.hazelcast.client.cache.impl.HazelcastClientCacheManager)11 Data (com.hazelcast.nio.serialization.Data)11 CachingProvider (javax.cache.spi.CachingProvider)11 NearCacheTestUtils.getMapNearCacheManager (com.hazelcast.internal.nearcache.impl.NearCacheTestUtils.getMapNearCacheManager)10 NearCacheTestContext (com.hazelcast.internal.nearcache.NearCacheTestContext)9 HazelcastClientProxy (com.hazelcast.client.impl.HazelcastClientProxy)8 NearCacheTestUtils.getBaseConfig (com.hazelcast.internal.nearcache.impl.NearCacheTestUtils.getBaseConfig)8 NearCacheTestUtils.createNearCacheConfig (com.hazelcast.internal.nearcache.impl.NearCacheTestUtils.createNearCacheConfig)7 CacheTestSupport.createClientCachingProvider (com.hazelcast.cache.CacheTestSupport.createClientCachingProvider)6 CacheTestSupport.createServerCachingProvider (com.hazelcast.cache.CacheTestSupport.createServerCachingProvider)6 HazelcastServerCachingProvider (com.hazelcast.cache.impl.HazelcastServerCachingProvider)6 HazelcastClientCachingProvider (com.hazelcast.client.cache.impl.HazelcastClientCachingProvider)5 MapConfig (com.hazelcast.config.MapConfig)5