}
private void setMode(final ConfigurationBuilder builder, final String clusteringMode, final boolean asynchronous, final boolean synchronous, final XMLExtendedStreamReader reader) {
if (synchronous && asynchronous) {
throw new CacheConfigurationException("Cannot configure <sync> and <async> on the same cluster, " + reader.getLocation());
}
if (clusteringMode != null) {
String mode = clusteringMode.toUpperCase();
if (ParsedCacheMode.REPL.matches(mode)) {
if (!asynchronous) {
builder.clustering().cacheMode(REPL_SYNC);
} else {
builder.clustering().cacheMode(REPL_ASYNC);
}
} else if (ParsedCacheMode.INVALIDATION.matches(mode)) {
if (!asynchronous) {
builder.clustering().cacheMode(INVALIDATION_SYNC);
} else {
builder.clustering().cacheMode(INVALIDATION_ASYNC);
}
} else if (ParsedCacheMode.DIST.matches(mode)) {
if (!asynchronous) {
builder.clustering().cacheMode(DIST_SYNC);
} else {
builder.clustering().cacheMode(DIST_ASYNC);
}
} else if (ParsedCacheMode.LOCAL.matches(mode)) {
builder.clustering().cacheMode(LOCAL);
} else {
throw new CacheConfigurationException("Invalid clustering mode " + clusteringMode + ", " + reader.getLocation());
}
} else {
// If no cache mode is given but sync or async is specified, default to DIST
if (synchronous) {
builder.clustering().cacheMode(DIST_SYNC);