Search in sources :

Example 31 with NearCacheManager

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

the class ClientMapNearCacheBasicTest 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);
    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 32 with NearCacheManager

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

the class ClientMapNearCachePreloaderTest method createNearCacheContextBuilder.

private <K, V> NearCacheTestContextBuilder<K, V, Data, String> createNearCacheContextBuilder() {
    ClientConfig clientConfig = getClientConfig().addNearCacheConfig(nearCacheConfig);
    HazelcastClientProxy client = (HazelcastClientProxy) hazelcastFactory.newHazelcastClient(clientConfig);
    IMap<K, V> clientMap = client.getMap(nearCacheConfig.getName());
    NearCacheManager nearCacheManager = ((ClientMapProxy) clientMap).getContext().getNearCacheManager(clientMap.getServiceName());
    NearCache<Data, String> nearCache = nearCacheManager.getNearCache(nearCacheConfig.getName());
    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 33 with NearCacheManager

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

the class NearCachedClientMapProxy method onInitialize.

@Override
protected void onInitialize() {
    super.onInitialize();
    NearCacheConfig nearCacheConfig = getContext().getClientConfig().getNearCacheConfig(name);
    serializeKeys = nearCacheConfig.isSerializeKeys();
    NearCacheManager nearCacheManager = getContext().getNearCacheManager(getServiceName());
    nearCache = nearCacheManager.getOrCreateNearCache(name, nearCacheConfig);
    if (nearCacheConfig.isInvalidateOnChange()) {
        registerInvalidationListener();
    }
    if (nearCacheConfig.getPreloaderConfig().isEnabled()) {
        nearCacheManager.startPreloading(nearCache, new IMapDataStructureAdapter<>(this));
    }
}
Also used : NearCacheManager(com.hazelcast.internal.nearcache.NearCacheManager) NearCacheConfig(com.hazelcast.config.NearCacheConfig)

Example 34 with NearCacheManager

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

the class ClientReplicatedMapNearCacheLeakTest method createNearCacheContextBuilder.

private <K, V> NearCacheTestContextBuilder<K, V, Data, String> createNearCacheContextBuilder() {
    ClientConfig clientConfig = getClientConfig();
    HazelcastClientProxy client = (HazelcastClientProxy) hazelcastFactory.newHazelcastClient(clientConfig);
    ReplicatedMap<K, V> clientMap = client.getReplicatedMap(DEFAULT_NEAR_CACHE_NAME);
    NearCacheManager nearCacheManager = ((ClientReplicatedMapProxy) 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 ReplicatedMapDataStructureAdapter<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 35 with NearCacheManager

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

the class NearCacheManagerTestSupport method doCreateAndGetNearCache.

void doCreateAndGetNearCache() {
    NearCacheManager nearCacheManager = createNearCacheManager();
    assertNull(nearCacheManager.getNearCache(DEFAULT_NEAR_CACHE_NAME));
    NearCache createdNearCache1 = createNearCache(nearCacheManager, DEFAULT_NEAR_CACHE_NAME);
    assertNotNull(createdNearCache1);
    NearCache createdNearCache2 = createNearCache(nearCacheManager, DEFAULT_NEAR_CACHE_NAME);
    assertNotNull(createdNearCache2);
    assertEquals(createdNearCache1, createdNearCache2);
    Collection<NearCache> nearCaches = nearCacheManager.listAllNearCaches();
    assertEquals(1, nearCaches.size());
    assertEquals(createdNearCache1, nearCaches.iterator().next());
}
Also used : NearCacheManager(com.hazelcast.internal.nearcache.NearCacheManager) NearCache(com.hazelcast.internal.nearcache.NearCache)

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