Search in sources :

Example 11 with HazelcastServerCacheManager

use of com.hazelcast.cache.impl.HazelcastServerCacheManager in project hazelcast by hazelcast.

the class ClientCacheNearCacheSerializationCountTest method createContext.

@Override
protected <K, V> NearCacheTestContext<K, V, Data, String> createContext() {
    Config config = getConfig().setProperty(CACHE_INVALIDATION_MESSAGE_BATCH_SIZE.getName(), String.valueOf(Integer.MAX_VALUE)).setProperty(CACHE_INVALIDATION_MESSAGE_BATCH_FREQUENCY_SECONDS.getName(), String.valueOf(Integer.MAX_VALUE)).setProperty(PARTITION_COUNT.getName(), "1").setProperty(PARTITION_OPERATION_THREAD_COUNT.getName(), "1");
    prepareSerializationConfig(config.getSerializationConfig());
    HazelcastInstance member = hazelcastFactory.newHazelcastInstance(config);
    CachingProvider memberProvider = createServerCachingProvider(member);
    HazelcastServerCacheManager memberCacheManager = (HazelcastServerCacheManager) memberProvider.getCacheManager();
    CacheConfig<K, V> cacheConfig = createCacheConfig(cacheInMemoryFormat);
    ICache<K, V> memberCache = memberCacheManager.createCache(DEFAULT_NEAR_CACHE_NAME, cacheConfig);
    return createNearCacheContextBuilder(cacheConfig).setDataInstance(member).setDataAdapter(new ICacheDataStructureAdapter<>(memberCache)).setMemberCacheManager(memberCacheManager).build();
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) CacheConfig(com.hazelcast.config.CacheConfig) ClientConfig(com.hazelcast.client.config.ClientConfig) Config(com.hazelcast.config.Config) NearCacheTestUtils.createNearCacheConfig(com.hazelcast.internal.nearcache.impl.NearCacheTestUtils.createNearCacheConfig) HazelcastServerCacheManager(com.hazelcast.cache.impl.HazelcastServerCacheManager) CacheTestSupport.createServerCachingProvider(com.hazelcast.cache.CacheTestSupport.createServerCachingProvider) CachingProvider(javax.cache.spi.CachingProvider) CacheTestSupport.createClientCachingProvider(com.hazelcast.cache.CacheTestSupport.createClientCachingProvider)

Example 12 with HazelcastServerCacheManager

use of com.hazelcast.cache.impl.HazelcastServerCacheManager in project hazelcast by hazelcast.

the class CacheExpirationPromotionTest method promoted_replica_should_send_eviction_to_other_backup.

@Test
public void promoted_replica_should_send_eviction_to_other_backup() {
    final CachingProvider provider = createServerCachingProvider(instances[0]);
    provider.getCacheManager().createCache(cacheName, getCacheConfig());
    HazelcastCacheManager cacheManager = (HazelcastServerCacheManager) provider.getCacheManager();
    final String keyOwnedByLastInstance = generateKeyOwnedBy(instances[nodeCount - 1]);
    ICache<String, String> cache = cacheManager.getCache(cacheName).unwrap(ICache.class);
    cache.put(keyOwnedByLastInstance, "dummyVal", new CreatedExpiryPolicy(new Duration(TimeUnit.SECONDS, 5)));
    final BackupAccessor<String, String> backupAccessor = TestBackupUtils.newCacheAccessor(instances, cacheName, 1);
    assertTrueEventually(new AssertTask() {

        @Override
        public void run() {
            assertNotNull(backupAccessor.get(keyOwnedByLastInstance));
        }
    });
    instances[nodeCount - 1].shutdown();
    // the backup replica became the primary, now the backup is the other node.
    // we check if the newly appointed replica sent expiration to backups
    assertTrueEventually(new AssertTask() {

        @Override
        public void run() {
            assertEquals(0, backupAccessor.size());
        }
    });
}
Also used : HazelcastCacheManager(com.hazelcast.cache.HazelcastCacheManager) HazelcastServerCacheManager(com.hazelcast.cache.impl.HazelcastServerCacheManager) AssertTask(com.hazelcast.test.AssertTask) Duration(javax.cache.expiry.Duration) CreatedExpiryPolicy(javax.cache.expiry.CreatedExpiryPolicy) CacheTestSupport.createServerCachingProvider(com.hazelcast.cache.CacheTestSupport.createServerCachingProvider) CachingProvider(javax.cache.spi.CachingProvider) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 13 with HazelcastServerCacheManager

use of com.hazelcast.cache.impl.HazelcastServerCacheManager in project hazelcast by hazelcast.

the class ClientCacheNearCacheLeakTest method createContext.

@Override
protected <K, V> NearCacheTestContext<K, V, Data, String> createContext() {
    Config config = getConfig();
    CacheConfig<K, V> cacheConfig = getCacheConfig(nearCacheConfig);
    HazelcastInstance member = hazelcastFactory.newHazelcastInstance(config);
    CachingProvider memberProvider = createServerCachingProvider(member);
    HazelcastServerCacheManager memberCacheManager = (HazelcastServerCacheManager) memberProvider.getCacheManager();
    ICache<K, V> memberCache = memberCacheManager.createCache(DEFAULT_NEAR_CACHE_NAME, cacheConfig);
    ICacheDataStructureAdapter<K, V> dataAdapter = new ICacheDataStructureAdapter<K, V>(memberCache);
    NearCacheTestContextBuilder<K, V, Data, String> builder = createNearCacheContextBuilder(cacheConfig);
    return builder.setDataInstance(member).setDataAdapter(dataAdapter).setMemberCacheManager(memberCacheManager).build();
}
Also used : ClientConfig(com.hazelcast.client.config.ClientConfig) Config(com.hazelcast.config.Config) CacheConfig(com.hazelcast.config.CacheConfig) NearCacheTestUtils.createNearCacheConfig(com.hazelcast.internal.nearcache.impl.NearCacheTestUtils.createNearCacheConfig) NearCacheConfig(com.hazelcast.config.NearCacheConfig) NearCacheTestUtils.getBaseConfig(com.hazelcast.internal.nearcache.impl.NearCacheTestUtils.getBaseConfig) HazelcastServerCacheManager(com.hazelcast.cache.impl.HazelcastServerCacheManager) Data(com.hazelcast.internal.serialization.Data) HazelcastInstance(com.hazelcast.core.HazelcastInstance) ICacheDataStructureAdapter(com.hazelcast.internal.adapter.ICacheDataStructureAdapter) CacheTestSupport.createClientCachingProvider(com.hazelcast.cache.CacheTestSupport.createClientCachingProvider) CacheTestSupport.createServerCachingProvider(com.hazelcast.cache.CacheTestSupport.createServerCachingProvider) CachingProvider(javax.cache.spi.CachingProvider)

Example 14 with HazelcastServerCacheManager

use of com.hazelcast.cache.impl.HazelcastServerCacheManager in project hazelcast by hazelcast.

the class CacheBackupAccessor method getCacheNameWithPrefix.

private static String getCacheNameWithPrefix(HazelcastInstance hz, String cacheName) {
    HazelcastInstanceImpl hazelcastInstanceImpl = getHazelcastInstanceImpl(hz);
    CachingProvider provider = createServerCachingProvider(hazelcastInstanceImpl);
    HazelcastCacheManager cacheManager = (HazelcastServerCacheManager) provider.getCacheManager();
    return cacheManager.getCacheNameWithPrefix(cacheName);
}
Also used : HazelcastInstanceImpl(com.hazelcast.instance.impl.HazelcastInstanceImpl) Accessors.getHazelcastInstanceImpl(com.hazelcast.test.Accessors.getHazelcastInstanceImpl) HazelcastCacheManager(com.hazelcast.cache.HazelcastCacheManager) HazelcastServerCacheManager(com.hazelcast.cache.impl.HazelcastServerCacheManager) CachingProvider(javax.cache.spi.CachingProvider) CacheTestSupport.createServerCachingProvider(com.hazelcast.cache.CacheTestSupport.createServerCachingProvider)

Aggregations

HazelcastServerCacheManager (com.hazelcast.cache.impl.HazelcastServerCacheManager)14 CachingProvider (javax.cache.spi.CachingProvider)13 HazelcastInstance (com.hazelcast.core.HazelcastInstance)10 CacheTestSupport.createServerCachingProvider (com.hazelcast.cache.CacheTestSupport.createServerCachingProvider)9 ClientConfig (com.hazelcast.client.config.ClientConfig)8 CacheConfig (com.hazelcast.config.CacheConfig)6 Config (com.hazelcast.config.Config)6 CacheTestSupport.createClientCachingProvider (com.hazelcast.cache.CacheTestSupport.createClientCachingProvider)5 HazelcastServerCachingProvider (com.hazelcast.cache.impl.HazelcastServerCachingProvider)5 HazelcastCacheManager (com.hazelcast.cache.HazelcastCacheManager)4 HazelcastClientCacheManager (com.hazelcast.client.cache.impl.HazelcastClientCacheManager)4 HazelcastClientCachingProvider (com.hazelcast.client.cache.impl.HazelcastClientCachingProvider)4 NearCacheConfig (com.hazelcast.config.NearCacheConfig)4 ICacheDataStructureAdapter (com.hazelcast.internal.adapter.ICacheDataStructureAdapter)4 NearCacheManager (com.hazelcast.internal.nearcache.NearCacheManager)4 NearCacheTestUtils.getBaseConfig (com.hazelcast.internal.nearcache.impl.NearCacheTestUtils.getBaseConfig)4 Data (com.hazelcast.nio.serialization.Data)4 HazelcastClientProxy (com.hazelcast.client.impl.HazelcastClientProxy)3 NearCacheTestContext (com.hazelcast.internal.nearcache.NearCacheTestContext)3 NearCacheTestUtils.createNearCacheConfig (com.hazelcast.internal.nearcache.impl.NearCacheTestUtils.createNearCacheConfig)3