use of com.hazelcast.config.CacheConfig in project hazelcast by hazelcast.
the class AbstractCacheRecordStore method canPersistWanReplicatedData.
private boolean canPersistWanReplicatedData(CacheConfig cacheConfig, NodeEngine nodeEngine) {
boolean persistWanReplicatedData = false;
WanReplicationRef wanReplicationRef = cacheConfig.getWanReplicationRef();
if (wanReplicationRef != null) {
String wanReplicationRefName = wanReplicationRef.getName();
Config config = nodeEngine.getConfig();
WanReplicationConfig wanReplicationConfig = config.getWanReplicationConfig(wanReplicationRefName);
if (wanReplicationConfig != null) {
WanConsumerConfig wanConsumerConfig = wanReplicationConfig.getConsumerConfig();
if (wanConsumerConfig != null) {
persistWanReplicatedData = wanConsumerConfig.isPersistWanReplicatedData();
}
}
}
return persistWanReplicatedData;
}
use of com.hazelcast.config.CacheConfig in project hazelcast by hazelcast.
the class AbstractCacheService method putCacheConfigIfAbsent.
@Override
public CacheConfig putCacheConfigIfAbsent(CacheConfig config) {
// ensure all configs registered in CacheService are not PreJoinCacheConfig's
CacheConfig cacheConfig = asCacheConfig(config);
CompletableFuture<CacheConfig> future = new CompletableFuture<>();
CompletableFuture<CacheConfig> localConfigFuture = configs.putIfAbsent(cacheConfig.getNameWithPrefix(), future);
// if the existing cache config future is not yet fully configured, we block here
CacheConfig localConfig = localConfigFuture == null ? null : localConfigFuture.join();
if (localConfigFuture == null) {
try {
if (cacheConfig.isStatisticsEnabled()) {
setStatisticsEnabled(cacheConfig, cacheConfig.getNameWithPrefix(), true);
}
if (cacheConfig.isManagementEnabled()) {
setManagementEnabled(cacheConfig, cacheConfig.getNameWithPrefix(), true);
}
logger.info("Added cache config: " + cacheConfig);
additionalCacheConfigSetup(config, false);
// now it is safe for others to obtain the new cache config
future.complete(cacheConfig);
} catch (Throwable e) {
configs.remove(cacheConfig.getNameWithPrefix(), future);
future.completeExceptionally(e);
throw rethrow(e);
}
} else {
additionalCacheConfigSetup(localConfig, true);
}
return localConfig;
}
use of com.hazelcast.config.CacheConfig in project hazelcast by hazelcast.
the class AbstractCacheService method getMergePolicy.
public SplitBrainMergePolicy getMergePolicy(String dataStructureName) {
CacheConfig cacheConfig = getCacheConfig(dataStructureName);
String mergePolicyName = cacheConfig.getMergePolicyConfig().getPolicy();
return mergePolicyProvider.getMergePolicy(mergePolicyName);
}
use of com.hazelcast.config.CacheConfig in project hazelcast by hazelcast.
the class AbstractCacheService method createDistributedObject.
@Override
public DistributedObject createDistributedObject(String cacheNameWithPrefix, UUID source, boolean local) {
try {
/*
* In here, cacheNameWithPrefix is the full cache name.
* Full cache name contains, Hazelcast prefix, cache name prefix and pure cache name.
*/
// At first, lookup cache name in the created cache configs.
CacheConfig cacheConfig = getCacheConfig(cacheNameWithPrefix);
if (cacheConfig == null) {
/*
* Prefixed cache name contains cache name prefix and pure cache name, but not Hazelcast prefix (`/hz/`).
* Cache name prefix is generated by using specified URI and classloader scopes.
* This means, if there is no specified URI and classloader, prefixed cache name is pure cache name.
* This means, if there is no specified URI and classloader, prefixed cache name is pure cache name.
*/
// If cache config is not created yet, remove Hazelcast prefix and get prefixed cache name.
String cacheName = cacheNameWithPrefix.substring(HazelcastCacheManager.CACHE_MANAGER_PREFIX.length());
// Lookup prefixed cache name in the config.
cacheConfig = findCacheConfig(cacheName);
if (cacheConfig == null) {
throw new CacheNotExistsException("Couldn't find cache config with name " + cacheNameWithPrefix);
}
cacheConfig.setManagerPrefix(HazelcastCacheManager.CACHE_MANAGER_PREFIX);
}
checkCacheConfig(cacheConfig, mergePolicyProvider);
if (putCacheConfigIfAbsent(cacheConfig) == null && !local) {
// if the cache config was not previously known, ensure the new cache config
// becomes available on all members before the proxy is returned to the caller
createCacheConfigOnAllMembers(PreJoinCacheConfig.of(cacheConfig));
}
return new CacheProxy(cacheConfig, nodeEngine, this);
} catch (Throwable t) {
throw rethrow(t);
}
}
use of com.hazelcast.config.CacheConfig in project hazelcast by hazelcast.
the class RingbufferCacheEventJournalImpl method getEventJournalConfig.
/**
* {@inheritDoc}
*
* @throws CacheNotExistsException if the cache configuration was not found
*/
@Override
public EventJournalConfig getEventJournalConfig(ObjectNamespace namespace) {
String name = namespace.getObjectName();
CacheConfig cacheConfig = getCacheService().getCacheConfig(name);
if (cacheConfig == null) {
throw new CacheNotExistsException("Cache " + name + " is already destroyed or not created yet, on " + nodeEngine.getLocalMember());
}
EventJournalConfig config = cacheConfig.getEventJournalConfig();
if (config == null || !config.isEnabled()) {
return null;
}
return config;
}
Aggregations