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();
}
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());
}
});
}
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();
}
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);
}
Aggregations