use of com.hazelcast.config.CacheConfig in project hazelcast by hazelcast.
the class PostJoinCacheOperationTest method test_cachePostJoinOperationFails_whenJCacheNotAvailable_withCacheConfigs.
@Test
public void test_cachePostJoinOperationFails_whenJCacheNotAvailable_withCacheConfigs() throws Exception {
// JCache is not available in classpath
when(JCacheDetector.isJCacheAvailable(classLoader)).thenReturn(false);
// node engine throws HazelcastException due to missing CacheService
when(nodeEngine.getService(CacheService.SERVICE_NAME)).thenThrow(new HazelcastException("CacheService not found"));
// some CacheConfigs are added in the PostJoinCacheOperation (so JCache is actually in use in the rest of the cluster)
PostJoinCacheOperation postJoinCacheOperation = new PostJoinCacheOperation();
postJoinCacheOperation.addCacheConfig(new CacheConfig("test"));
postJoinCacheOperation.setNodeEngine(nodeEngine);
expectedException.expect(HazelcastException.class);
postJoinCacheOperation.run();
verify(nodeEngine).getConfigClassLoader();
verify(nodeEngine).getService(CacheService.SERVICE_NAME);
verify(logger, never()).warning(anyString());
}
use of com.hazelcast.config.CacheConfig in project hazelcast by hazelcast.
the class TimedMemberStateFactory method createMemState.
private void createMemState(TimedMemberState timedMemberState, MemberStateImpl memberState, Collection<StatisticsAwareService> services) {
int count = 0;
Config config = instance.getConfig();
Set<String> longInstanceNames = new HashSet<String>(maxVisibleInstanceCount);
for (StatisticsAwareService service : services) {
if (count < maxVisibleInstanceCount) {
if (service instanceof MapService) {
count = handleMap(memberState, count, config, ((MapService) service).getStats(), longInstanceNames);
} else if (service instanceof MultiMapService) {
count = handleMultimap(memberState, count, config, ((MultiMapService) service).getStats(), longInstanceNames);
} else if (service instanceof QueueService) {
count = handleQueue(memberState, count, config, ((QueueService) service).getStats(), longInstanceNames);
} else if (service instanceof TopicService) {
count = handleTopic(memberState, count, config, ((TopicService) service).getStats(), longInstanceNames);
} else if (service instanceof DistributedExecutorService) {
count = handleExecutorService(memberState, count, config, ((DistributedExecutorService) service).getStats(), longInstanceNames);
} else if (service instanceof ReplicatedMapService) {
count = handleReplicatedMap(memberState, count, config, ((ReplicatedMapService) service).getStats(), longInstanceNames);
}
}
}
WanReplicationService wanReplicationService = instance.node.nodeEngine.getWanReplicationService();
Map<String, LocalWanStats> wanStats = wanReplicationService.getStats();
if (wanStats != null) {
count = handleWan(memberState, count, wanStats, longInstanceNames);
}
if (cacheServiceEnabled) {
ICacheService cacheService = getCacheService();
for (CacheConfig cacheConfig : cacheService.getCacheConfigs()) {
if (cacheConfig.isStatisticsEnabled() && count < maxVisibleInstanceCount) {
CacheStatistics statistics = cacheService.getStatistics(cacheConfig.getNameWithPrefix());
//is filled.git
if (statistics != null) {
count = handleCache(memberState, count, cacheConfig, statistics, longInstanceNames);
}
}
}
}
timedMemberState.setInstanceNames(longInstanceNames);
}
use of com.hazelcast.config.CacheConfig in project hazelcast by hazelcast.
the class ClientCacheNearCacheSerializationCountTest method createContext.
@Override
protected <K, V> NearCacheTestContext<K, V, Data, String> createContext() {
Config config = getConfig();
prepareSerializationConfig(config.getSerializationConfig());
ClientConfig clientConfig = getClientConfig();
if (nearCacheConfig != null) {
clientConfig.addNearCacheConfig(nearCacheConfig);
}
prepareSerializationConfig(clientConfig.getSerializationConfig());
CacheConfig<K, V> cacheConfig = createCacheConfig(cacheInMemoryFormat);
HazelcastInstance member = hazelcastFactory.newHazelcastInstance(config);
HazelcastClientProxy client = (HazelcastClientProxy) hazelcastFactory.newHazelcastClient(clientConfig);
CachingProvider memberProvider = HazelcastServerCachingProvider.createCachingProvider(member);
HazelcastServerCacheManager memberCacheManager = (HazelcastServerCacheManager) memberProvider.getCacheManager();
NearCacheManager nearCacheManager = client.client.getNearCacheManager();
CachingProvider provider = HazelcastClientCachingProvider.createCachingProvider(client);
HazelcastClientCacheManager cacheManager = (HazelcastClientCacheManager) provider.getCacheManager();
String cacheNameWithPrefix = cacheManager.getCacheNameWithPrefix(DEFAULT_NEAR_CACHE_NAME);
ICache<K, V> clientCache = cacheManager.createCache(DEFAULT_NEAR_CACHE_NAME, cacheConfig);
ICache<K, V> memberCache = memberCacheManager.createCache(DEFAULT_NEAR_CACHE_NAME, cacheConfig);
NearCache<Data, String> nearCache = nearCacheManager.getNearCache(cacheNameWithPrefix);
return new NearCacheTestContext<K, V, Data, String>(client.getSerializationService(), client, member, new ICacheDataStructureAdapter<K, V>(clientCache), new ICacheDataStructureAdapter<K, V>(memberCache), false, nearCache, nearCacheManager, cacheManager, memberCacheManager);
}
use of com.hazelcast.config.CacheConfig in project hazelcast by hazelcast.
the class ClientCacheStatsTest method testNearCacheStatsWhenNearCacheEnabled.
@Test
public void testNearCacheStatsWhenNearCacheEnabled() {
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 AbstractCacheService method deleteCache.
@Override
public void deleteCache(String name, String callerUuid, boolean destroy) {
CacheConfig config = deleteCacheConfig(name);
if (destroy) {
destroySegments(name);
sendInvalidationEvent(name, null, SOURCE_NOT_AVAILABLE);
} else {
closeSegments(name);
}
cacheContexts.remove(name);
operationProviderCache.remove(name);
deregisterAllListener(name);
setStatisticsEnabled(config, name, false);
setManagementEnabled(config, name, false);
deleteCacheStat(name);
deleteCacheResources(name);
}
Aggregations