final Servers servers = server.getParent(Servers.class);
final Domain domain = servers.getParent(Domain.class);
final Configs configs = domain.getConfigs();
if (servers.getServer(serverName) != null) { // validate for set, not _register-instance
// cannot change config ref of a clustered instance
Cluster cluster = domain.getClusterForInstance(serverName);
if (cluster != null) { // cluster is not null during create-local-instance --cluster c1 i1
if (!cluster.getConfigRef().equals(configRef)) {
// During set when trying to change config-ref of a clustered instance,
// the value of desired config-ref will be different than the current config-ref.
// During _register-instance, (create-local-instance --cluster c1 i1)
// cluster.getConfigRef().equals(configRef) will be true and not come here.
logger.warning(ConfigApiLoggerInfo.configRefClusteredInstance);
return false;
}
}
// cannot use a non-existent config (Only used by set. _register-instance will fail earlier)
if (configs == null || configs.getConfigByName(configRef) == null) {
logger.warning(ConfigApiLoggerInfo.configRefNonexistent);
return false;
}
}
}