use of com.hazelcast.config.CacheSimpleConfig in project hazelcast by hazelcast.
the class CacheQuorumConfigTest method cacheConfigXmlTest.
@Test
public void cacheConfigXmlTest() throws IOException {
final String cacheName = "configtestCache" + randomString();
Config config = new XmlConfigBuilder(configUrl).build();
CacheSimpleConfig cacheConfig1 = config.getCacheConfig(cacheName);
final String quorumName = cacheConfig1.getQuorumName();
assertEquals("cache-quorum", quorumName);
QuorumConfig quorumConfig = config.getQuorumConfig(quorumName);
assertEquals(3, quorumConfig.getSize());
assertEquals(QuorumType.READ_WRITE, quorumConfig.getType());
}
use of com.hazelcast.config.CacheSimpleConfig in project hazelcast by hazelcast.
the class TestJCache method cacheConfigXmlTest_ClusterQuorum.
@Test
public void cacheConfigXmlTest_ClusterQuorum() {
assertNotNull(instance1);
CacheSimpleConfig simpleConfig = instance1.getConfig().getCacheConfig("cacheWithQuorumRef");
assertNotNull(simpleConfig);
assertEquals("cacheQuorumRefString", simpleConfig.getQuorumName());
}
use of com.hazelcast.config.CacheSimpleConfig in project hazelcast by hazelcast.
the class ClientCacheWriteQuorumTest method initialize.
@BeforeClass
public static void initialize() throws Exception {
QuorumConfig quorumConfig = new QuorumConfig();
quorumConfig.setName(QUORUM_ID);
quorumConfig.setType(QuorumType.WRITE);
quorumConfig.setEnabled(true);
quorumConfig.setSize(3);
CacheSimpleConfig cacheConfig = new CacheSimpleConfig();
cacheConfig.setName(CACHE_NAME_PREFIX + "*");
cacheConfig.setQuorumName(QUORUM_ID);
factory = new TestHazelcastFactory();
cluster = new PartitionedCluster(factory).createFiveMemberCluster(cacheConfig, quorumConfig);
initializeClients();
initializeCaches();
cluster.splitFiveMembersThreeAndTwo();
verifyClients();
}
use of com.hazelcast.config.CacheSimpleConfig in project hazelcast by hazelcast.
the class AbstractCacheService method createDistributedObject.
@Override
public DistributedObject createDistributedObject(String fullCacheName) {
try {
/*
* In here, `fullCacheName` is the full cache name.
* Full cache name contains, Hazelcast prefix, cache name prefix and pure cache name.
*/
if (fullCacheName.equals(SETUP_REF)) {
// workaround to make clients older than 3.7 to work with 3.7+ servers due to changes in the cache init!
CacheSimpleConfig cacheSimpleConfig = new CacheSimpleConfig();
cacheSimpleConfig.setName("setupRef");
CacheConfig cacheConfig = new CacheConfig(cacheSimpleConfig);
cacheConfig.setManagerPrefix(HazelcastCacheManager.CACHE_MANAGER_PREFIX);
return new CacheProxy(cacheConfig, nodeEngine, this);
} else {
// At first, lookup cache name in the created cache configs.
CacheConfig cacheConfig = getCacheConfig(fullCacheName);
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 = fullCacheName.substring(HazelcastCacheManager.CACHE_MANAGER_PREFIX.length());
// Lookup prefixed cache name in the config.
cacheConfig = findCacheConfig(cacheName);
checkCacheSimpleConfig(cacheName, cacheConfig);
cacheConfig.setManagerPrefix(HazelcastCacheManager.CACHE_MANAGER_PREFIX);
}
checkCacheConfig(fullCacheName, cacheConfig);
putCacheConfigIfAbsent(cacheConfig);
return new CacheProxy(cacheConfig, nodeEngine, this);
}
} catch (Throwable t) {
throw ExceptionUtil.rethrow(t);
}
}
use of com.hazelcast.config.CacheSimpleConfig in project hazelcast by hazelcast.
the class PartitionedCluster method createFiveMemberCluster.
public PartitionedCluster createFiveMemberCluster(CacheSimpleConfig cacheSimpleConfig, QuorumConfig quorumConfig) {
Config config = createClusterConfig().addCacheConfig(cacheSimpleConfig).addQuorumConfig(quorumConfig);
createInstances(config);
return this;
}
Aggregations