use of org.apache.geode.UnmodifiableException in project geode by apache.
the class AbstractDistributionConfig method checkAttribute.
protected Object checkAttribute(String attName, Object value) {
// valid one.
if (!isAttributeModifiable(attName)) {
throw new UnmodifiableException(_getUnmodifiableMsg(attName));
}
ConfigAttribute attribute = attributes.get(attName);
if (attribute == null) {
// checking needed
return value;
}
// for integer attribute, do the range check.
if (attribute.type().equals(Integer.class)) {
Integer intValue = (Integer) value;
minMaxCheck(attName, intValue, attribute.min(), attribute.max());
}
Method checker = checkers.get(attName);
if (checker == null) {
return value;
}
// if specific checker exists for this attribute, call that with the value
try {
return checker.invoke(this, value);
} catch (Exception e) {
if (e instanceof RuntimeException) {
throw (RuntimeException) e;
}
if (e.getCause() instanceof RuntimeException) {
throw (RuntimeException) e.getCause();
} else {
throw new InternalGemFireException("error invoking " + checker.getName() + " with value " + value);
}
}
}
use of org.apache.geode.UnmodifiableException in project geode by apache.
the class ClusterConfigurationLoader method applyClusterPropertiesConfiguration.
/***
* Apply the gemfire properties cluster configuration on this member
*
* @param cache Cache created for this member
* @param response {@link ConfigurationResponse} containing the requested {@link Configuration}
* @param config this member's config
*/
public static void applyClusterPropertiesConfiguration(Cache cache, ConfigurationResponse response, DistributionConfig config) {
if (response == null || response.getRequestedConfiguration().isEmpty()) {
return;
}
List<String> groups = getGroups(config);
Map<String, Configuration> requestedConfiguration = response.getRequestedConfiguration();
final Properties runtimeProps = new Properties();
// apply the cluster config first
Configuration clusterConfiguration = requestedConfiguration.get(ClusterConfigurationService.CLUSTER_CONFIG);
if (clusterConfiguration != null) {
runtimeProps.putAll(clusterConfiguration.getGemfireProperties());
}
// then apply the group config
for (String group : groups) {
Configuration groupConfiguration = requestedConfiguration.get(group);
if (groupConfiguration != null) {
runtimeProps.putAll(groupConfiguration.getGemfireProperties());
}
}
Set<Object> attNames = runtimeProps.keySet();
for (Object attNameObj : attNames) {
String attName = (String) attNameObj;
String attValue = runtimeProps.getProperty(attName);
try {
config.setAttribute(attName, attValue, ConfigSource.runtime());
} catch (IllegalArgumentException e) {
logger.info(e.getMessage());
} catch (UnmodifiableException e) {
logger.info(e.getMessage());
}
}
}
Aggregations