Configuration configuration = templateCache.getConfiguration().clone();
Integer backups = replConfig.getBackups();
ReplicationMode replMode = replConfig.getReplicationMode();
CacheMode mode = configuration.getCacheMode();
if (backups != null)
{
int value = backups.intValue();
configuration.setNumOwners(value);
if (value == 0)
{
mode = CacheMode.LOCAL;
}
else
{
boolean synchronous = mode.isSynchronous();
if (value > 0)
{
mode = synchronous ? CacheMode.DIST_SYNC : CacheMode.DIST_ASYNC;
}
else // Negative backups means total replication
{
mode = synchronous ? CacheMode.REPL_SYNC : CacheMode.REPL_ASYNC;
}
}
}
if (replMode != null)
{
switch (replMode)
{
case SYNCHRONOUS:
{
mode = mode.toSync();
break;
}
case ASYNCHRONOUS:
{
mode = mode.toAsync();
break;
}
}
}