cacheMode = Configuration.CacheMode.DIST_SYNC; // the default
Element asyncEl = getSingleElementInCoreNS("async", e);
Element syncEl = getSingleElementInCoreNS("sync", e);
if (syncEl != null && asyncEl != null)
throw new ConfigurationException("Cannot have sync and async elements within the same cluster element!");
boolean sync = asyncEl == null; // even if both are null, we default to sync
if (sync) {
config.setCacheMode(cacheMode);
configureSyncMode(syncEl, config);
} else {
cacheMode = cacheMode.toAsync(); // get the async version of this mode
config.setCacheMode(cacheMode);
configureAsyncMode(asyncEl, config);
}
if (cacheMode.isDistributed()) {
// L1 cache
Element l1 = getSingleElementInCoreNS("l1", e);
String tmp = getAttributeValue(l1, "enabled");
if (existsAttribute(tmp)) config.setL1CacheEnabled(getBoolean(tmp));
tmp = getAttributeValue(l1, "lifespan");
if (existsAttribute(tmp)) config.setL1Lifespan(getLong(tmp));
tmp = getAttributeValue(l1, "onRehash");
if (existsAttribute(tmp)) config.setL1OnRehash(getBoolean(tmp));
// consistent hash algo
Element hash = getSingleElementInCoreNS("hash", e);
tmp = getAttributeValue(hash, "class");
if (existsAttribute(tmp)) config.setConsistentHashClass(tmp);
tmp = getAttributeValue(hash, "numOwners");
if (existsAttribute(tmp)) config.setNumOwners(getInt(tmp));
tmp = getAttributeValue(hash, "rehashWait");
if (existsAttribute(tmp)) config.setRehashWaitTime(getLong(tmp));
} else if (getSingleElementInCoreNS("l1", e) != null || getSingleElementInCoreNS("hash", e) != null) {
throw new ConfigurationException("l1 and hash elements cannot be used with cache modes 'REPLICATION' and 'INVALIDATION'!");
}
configureStateRetrieval(getSingleElementInCoreNS("stateRetrieval", e), config);
}