Search in sources :

Example 1 with UnmodifiableException

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);
        }
    }
}
Also used : UnmodifiableException(org.apache.geode.UnmodifiableException) InternalGemFireException(org.apache.geode.InternalGemFireException) Method(java.lang.reflect.Method) InvalidValueException(org.apache.geode.InvalidValueException) UnmodifiableException(org.apache.geode.UnmodifiableException) InternalGemFireException(org.apache.geode.InternalGemFireException) UnknownHostException(java.net.UnknownHostException)

Example 2 with UnmodifiableException

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());
        }
    }
}
Also used : UnmodifiableException(org.apache.geode.UnmodifiableException) Configuration(org.apache.geode.management.internal.configuration.domain.Configuration) Properties(java.util.Properties)

Aggregations

UnmodifiableException (org.apache.geode.UnmodifiableException)2 Method (java.lang.reflect.Method)1 UnknownHostException (java.net.UnknownHostException)1 Properties (java.util.Properties)1 InternalGemFireException (org.apache.geode.InternalGemFireException)1 InvalidValueException (org.apache.geode.InvalidValueException)1 Configuration (org.apache.geode.management.internal.configuration.domain.Configuration)1