use of com.hazelcast.config.CacheConfig in project hazelcast by hazelcast.
the class CacheSplitBrainTest method onAfterSplitBrainCreated.
@Override
protected void onAfterSplitBrainCreated(HazelcastInstance[] firstBrain, HazelcastInstance[] secondBrain) throws Exception {
mergeLifecycleListener = new MergeLifecycleListener(secondBrain.length);
for (HazelcastInstance instance : secondBrain) {
instance.getLifecycleService().addLifecycleListener(mergeLifecycleListener);
}
CacheConfig cacheConfig = newCacheConfig(cacheName, mergePolicyClass);
cache1 = createCache(firstBrain[0], cacheConfig);
cache2 = createCache(secondBrain[0], cacheConfig);
if (mergePolicyClass == LatestAccessCacheMergePolicy.class) {
afterSplitLatestAccessCacheMergePolicy();
}
if (mergePolicyClass == HigherHitsCacheMergePolicy.class) {
afterSplitHigherHitsCacheMergePolicy();
}
if (mergePolicyClass == PutIfAbsentCacheMergePolicy.class) {
afterSplitPutIfAbsentCacheMergePolicy();
}
if (mergePolicyClass == PassThroughCacheMergePolicy.class) {
afterSplitPassThroughCacheMergePolicy();
}
if (mergePolicyClass == CustomCacheMergePolicy.class) {
afterSplitCustomCacheMergePolicy();
}
}
use of com.hazelcast.config.CacheConfig in project hazelcast by hazelcast.
the class ClientCacheProxyFactory method findCacheConfig.
@SuppressFBWarnings("RV_RETURN_VALUE_OF_PUTIFABSENT_IGNORED")
private CacheConfig findCacheConfig(String cacheName) {
CacheConfig cacheConfig = configs.get(cacheName);
if (cacheConfig != null) {
return cacheConfig;
}
// otherwise, request it from server
String simpleCacheName = cacheName.substring(HazelcastCacheManager.CACHE_MANAGER_PREFIX.length());
cacheConfig = ClientCacheHelper.getCacheConfig(client, cacheName, simpleCacheName);
if (cacheConfig != null) {
configs.putIfAbsent(cacheName, cacheConfig);
}
return cacheConfig;
}
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 ICacheDataStructureAdapterTest method setUp.
@Before
public void setUp() {
TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory();
HazelcastInstance hazelcastInstance = factory.newHazelcastInstance();
HazelcastServerCachingProvider cachingProvider = createCachingProvider(hazelcastInstance);
CacheManager cacheManager = cachingProvider.getCacheManager();
CacheConfig<Integer, String> cacheConfig = new CacheConfig<Integer, String>();
cache = (ICache<Integer, String>) cacheManager.createCache("CacheDataStructureAdapterTest", cacheConfig);
adapter = new ICacheDataStructureAdapter<Integer, String>(cache);
}
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);
}
Aggregations