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);
}
use of com.hazelcast.config.CacheConfig in project hazelcast by hazelcast.
the class AbstractHazelcastCacheManager method createCacheInternal.
private <K, V, C extends Configuration<K, V>> ICacheInternal<K, V> createCacheInternal(String cacheName, C configuration) throws IllegalArgumentException {
checkIfManagerNotClosed();
checkNotNull(cacheName, "cacheName must not be null");
checkNotNull(configuration, "configuration must not be null");
CacheConfig<K, V> newCacheConfig = createCacheConfig(cacheName, configuration);
if (caches.containsKey(newCacheConfig.getNameWithPrefix())) {
throw new CacheException("A cache named " + cacheName + " already exists.");
}
// Create cache config on all nodes as sync
CacheConfig<K, V> currentCacheConfig = createCacheConfig(cacheName, newCacheConfig, true, true);
// Create cache proxy object with cache config
ICacheInternal<K, V> cacheProxy = createCacheProxy(newCacheConfig);
if (currentCacheConfig == null) {
// Put created cache config.
// Single thread region because "createConfigOnPartition" is single threaded by partition thread
addCacheConfigIfAbsent(newCacheConfig);
// Put created cache. No need to a "putIfAbsent" as this is a single threaded region
caches.put(newCacheConfig.getNameWithPrefix(), cacheProxy);
// Register listeners
registerListeners(newCacheConfig, cacheProxy);
return cacheProxy;
}
ICacheInternal<?, ?> cache = getOrPutIfAbsent(currentCacheConfig.getNameWithPrefix(), cacheProxy);
CacheConfig config = cache.getConfiguration(CacheConfig.class);
if (config.equals(newCacheConfig)) {
return (ICacheInternal<K, V>) cache;
}
throw new CacheException("A cache named " + cacheName + " already exists.");
}
use of com.hazelcast.config.CacheConfig in project hazelcast by hazelcast.
the class CacheReplicationOperation method readInternal.
@Override
protected void readInternal(ObjectDataInput in) throws IOException {
super.readInternal(in);
int confSize = in.readInt();
for (int i = 0; i < confSize; i++) {
final CacheConfig config = in.readObject();
configs.add(config);
}
int count = in.readInt();
for (int i = 0; i < count; i++) {
int subCount = in.readInt();
String name = in.readUTF();
Map<Data, CacheRecord> m = new HashMap<Data, CacheRecord>(subCount);
data.put(name, m);
// which adds another Data entry at the end of the stream!
for (int j = 0; j < subCount + 1; j++) {
Data key = in.readData();
// the number on the stream due to found expired entries
if (key == null || key.dataSize() == 0) {
break;
}
CacheRecord record = in.readObject();
m.put(key, record);
}
}
nearCacheStateHolder.readData(in);
}
use of com.hazelcast.config.CacheConfig in project hazelcast by hazelcast.
the class PostJoinCacheOperation method writeInternal.
@Override
protected void writeInternal(ObjectDataOutput out) throws IOException {
super.writeInternal(out);
out.writeInt(configs.size());
for (CacheConfig config : configs) {
out.writeObject(config);
}
}
Aggregations