use of com.hazelcast.config.CacheConfig in project hazelcast by hazelcast.
the class CacheExpirationPromotionTest method getCacheConfig.
protected CacheConfig getCacheConfig() {
CacheConfig cacheConfig = new CacheConfig();
cacheConfig.setName(cacheName);
cacheConfig.setBackupCount(1);
return cacheConfig;
}
use of com.hazelcast.config.CacheConfig in project hazelcast by hazelcast.
the class ClientCacheStatsTest method testNearCacheStats_whenNearCacheEnabled.
private void testNearCacheStats_whenNearCacheEnabled() {
String cacheName = randomName();
CacheConfig cacheConfig = createCacheConfig();
cacheConfig.setName(cacheName);
ClientConfig clientConfig = ((HazelcastClientProxy) client).getClientConfig();
clientConfig.addNearCacheConfig(new NearCacheConfig().setName(cacheName));
ICache<Integer, String> cache = createCache(cacheName, cacheConfig);
CacheStatistics stats = cache.getLocalCacheStatistics();
assertNotNull(stats.getNearCacheStatistics());
}
use of com.hazelcast.config.CacheConfig in project hazelcast by hazelcast.
the class ClientCacheNearCacheRecordStateStressTest method setUp.
@Before
public void setUp() {
String cacheName = randomMapName();
Config config = getBaseConfig();
ClientConfig clientConfig = new ClientConfig().addNearCacheConfig(newNearCacheConfig(cacheName));
EvictionConfig evictionConfig = new EvictionConfig().setMaxSizePolicy(ENTRY_COUNT).setSize(MAX_VALUE);
CacheConfig<Integer, Integer> cacheConfig = new CacheConfig<Integer, Integer>().setEvictionConfig(evictionConfig);
HazelcastInstance member = factory.newHazelcastInstance(config);
factory.newHazelcastInstance(config);
factory.newHazelcastInstance(config);
HazelcastInstance client = factory.newHazelcastClient(clientConfig);
CachingProvider provider = createServerCachingProvider(member);
CacheManager serverCacheManager = provider.getCacheManager();
memberCache = serverCacheManager.createCache(cacheName, cacheConfig);
CachingProvider clientCachingProvider = createClientCachingProvider(client);
CacheManager cacheManager = clientCachingProvider.getCacheManager();
clientCache = cacheManager.createCache(cacheName, cacheConfig);
}
use of com.hazelcast.config.CacheConfig in project hazelcast by hazelcast.
the class ClientNearCacheTestSupport method putToCacheAndDontInvalidateFromClientNearCacheWhenPerEntryInvalidationIsDisabled.
protected void putToCacheAndDontInvalidateFromClientNearCacheWhenPerEntryInvalidationIsDisabled(InMemoryFormat inMemoryFormat) {
CacheConfig cacheConfig = createCacheConfig(inMemoryFormat);
cacheConfig.setDisablePerEntryInvalidationEvents(true);
NearCacheConfig nearCacheConfig = createNearCacheConfig(inMemoryFormat);
nearCacheConfig.setInvalidateOnChange(true);
NearCacheTestContext nearCacheTestContext1 = createNearCacheTest(DEFAULT_CACHE_NAME, nearCacheConfig, cacheConfig);
final NearCacheTestContext nearCacheTestContext2 = createNearCacheTest(DEFAULT_CACHE_NAME, nearCacheConfig, cacheConfig);
// put cache record from client-1
for (int i = 0; i < DEFAULT_RECORD_COUNT; i++) {
nearCacheTestContext1.cache.put(i, generateValueFromKey(i));
}
// get records from client-2
for (int i = 0; i < DEFAULT_RECORD_COUNT; i++) {
final Integer key = i;
final String value = nearCacheTestContext2.cache.get(key);
// records are stored in the cache as async not sync, so these records will be there in cache eventually
assertTrueEventually(new AssertTask() {
@Override
public void run() throws Exception {
Data keyData = nearCacheTestContext2.serializationService.toData(key);
assertEquals(value, nearCacheTestContext2.nearCache.get(keyData));
}
});
}
// update cache record from client-1
for (int i = 0; i < DEFAULT_RECORD_COUNT; i++) {
// update the cache records with new values
nearCacheTestContext1.cache.put(i, generateValueFromKey(i + DEFAULT_RECORD_COUNT));
}
int invalidationEventFlushFreq = Integer.parseInt(CACHE_INVALIDATION_MESSAGE_BATCH_FREQUENCY_SECONDS.getDefaultValue());
// wait some time and if there are invalidation events to be sent in batch
// (we assume that they should be flushed, received and processed in this time window already)
sleepSeconds(2 * invalidationEventFlushFreq);
// get records from client-2
for (int i = 0; i < DEFAULT_RECORD_COUNT; i++) {
String actualValue = nearCacheTestContext2.cache.get(i);
String expectedValue = generateValueFromKey(i);
// verify that still we have old records in the Near Cache, because, per entry invalidation events are disabled
assertEquals(expectedValue, actualValue);
}
nearCacheTestContext1.cache.clear();
// can't get expired records from client-2
for (int i = 0; i < DEFAULT_RECORD_COUNT; i++) {
final int key = i;
// records are stored in the Near Cache will be invalidated eventually, since cache records are cleared
// because we just disable per entry invalidation events, not full-flush events
assertTrueEventually(new AssertTask() {
@Override
public void run() throws Exception {
Data keyData = nearCacheTestContext2.serializationService.toData(key);
assertNull(nearCacheTestContext2.nearCache.get(keyData));
}
});
}
}
use of com.hazelcast.config.CacheConfig in project hazelcast by hazelcast.
the class ClientCacheProxyTest method isCacheOnUpdate_prints_warning_message_for_deprecated_policy_CACHE.
@Test
public void isCacheOnUpdate_prints_warning_message_for_deprecated_policy_CACHE() throws Exception {
NearCacheConfig nearCacheConfig = new NearCacheConfig().setLocalUpdatePolicy(CACHE);
TestLogger logger = new TestLogger();
new ClientCacheProxy(new CacheConfig()).isCacheOnUpdate(nearCacheConfig, "cacheName", logger);
assertNotNull(logger.message);
}
Aggregations