Search in sources :

Example 66 with CacheConfig

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();
    }
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) CacheConfig(com.hazelcast.config.CacheConfig)

Example 67 with CacheConfig

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;
}
Also used : CacheConfig(com.hazelcast.config.CacheConfig) SuppressFBWarnings(edu.umd.cs.findbugs.annotations.SuppressFBWarnings)

Example 68 with 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);
}
Also used : StatisticsAwareService(com.hazelcast.spi.StatisticsAwareService) CacheConfig(com.hazelcast.config.CacheConfig) Config(com.hazelcast.config.Config) GroupConfig(com.hazelcast.config.GroupConfig) MultiMapService(com.hazelcast.multimap.impl.MultiMapService) ReplicatedMapService(com.hazelcast.replicatedmap.impl.ReplicatedMapService) QueueService(com.hazelcast.collection.impl.queue.QueueService) WanReplicationService(com.hazelcast.wan.WanReplicationService) CacheStatistics(com.hazelcast.cache.CacheStatistics) TopicService(com.hazelcast.topic.impl.TopicService) ICacheService(com.hazelcast.cache.impl.ICacheService) LocalWanStats(com.hazelcast.monitor.LocalWanStats) DistributedExecutorService(com.hazelcast.executor.impl.DistributedExecutorService) MultiMapService(com.hazelcast.multimap.impl.MultiMapService) ReplicatedMapService(com.hazelcast.replicatedmap.impl.ReplicatedMapService) MapService(com.hazelcast.map.impl.MapService) CacheConfig(com.hazelcast.config.CacheConfig) HashSet(java.util.HashSet)

Example 69 with CacheConfig

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);
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) CacheManager(javax.cache.CacheManager) TestHazelcastInstanceFactory(com.hazelcast.test.TestHazelcastInstanceFactory) HazelcastServerCachingProvider(com.hazelcast.cache.impl.HazelcastServerCachingProvider) CacheConfig(com.hazelcast.config.CacheConfig) Before(org.junit.Before)

Example 70 with CacheConfig

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);
}
Also used : NearCacheManager(com.hazelcast.internal.nearcache.NearCacheManager) ClientConfig(com.hazelcast.client.config.ClientConfig) NearCacheTestUtils.createNearCacheConfig(com.hazelcast.internal.nearcache.NearCacheTestUtils.createNearCacheConfig) Config(com.hazelcast.config.Config) CacheConfig(com.hazelcast.config.CacheConfig) HazelcastServerCacheManager(com.hazelcast.cache.impl.HazelcastServerCacheManager) Data(com.hazelcast.nio.serialization.Data) NearCacheTestContext(com.hazelcast.internal.nearcache.NearCacheTestContext) HazelcastInstance(com.hazelcast.core.HazelcastInstance) ClientConfig(com.hazelcast.client.config.ClientConfig) HazelcastClientProxy(com.hazelcast.client.impl.HazelcastClientProxy) HazelcastServerCachingProvider(com.hazelcast.cache.impl.HazelcastServerCachingProvider) CachingProvider(javax.cache.spi.CachingProvider) HazelcastClientCachingProvider(com.hazelcast.client.cache.impl.HazelcastClientCachingProvider) HazelcastClientCacheManager(com.hazelcast.client.cache.impl.HazelcastClientCacheManager)

Aggregations

CacheConfig (com.hazelcast.config.CacheConfig)77 Test (org.junit.Test)30 CacheManager (javax.cache.CacheManager)28 QuickTest (com.hazelcast.test.annotation.QuickTest)27 ParallelTest (com.hazelcast.test.annotation.ParallelTest)25 CachingProvider (javax.cache.spi.CachingProvider)16 HazelcastServerCachingProvider (com.hazelcast.cache.impl.HazelcastServerCachingProvider)14 HazelcastInstance (com.hazelcast.core.HazelcastInstance)14 AssertTask (com.hazelcast.test.AssertTask)13 NearCacheConfig (com.hazelcast.config.NearCacheConfig)11 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)9 ICacheService (com.hazelcast.cache.impl.ICacheService)8 HazelcastClientCachingProvider (com.hazelcast.client.cache.impl.HazelcastClientCachingProvider)8 ICache (com.hazelcast.cache.ICache)5 ClientConfig (com.hazelcast.client.config.ClientConfig)5 Config (com.hazelcast.config.Config)5 Data (com.hazelcast.nio.serialization.Data)5 CacheService (com.hazelcast.cache.impl.CacheService)4 HazelcastServerCachingProvider.createCachingProvider (com.hazelcast.cache.impl.HazelcastServerCachingProvider.createCachingProvider)4 Map (java.util.Map)4