public String getValue(Properties properties) { Objects.requireNonNull(properties); String value = properties.getProperty(getKey()); if (value == null || value.isEmpty()) { value = getDefaultValue(); } Objects.requireNonNull(value); if (isRequired() && value.isEmpty()) { throw new IllegalArgumentException(getKey() + " must be set!"); } if (!type.isValidFormat(value)) { throw new IllegalArgumentException( "Invalid format for type \"" + type + "\" for provided value: " + value); } return value; }
public static boolean isPropertyValid(String property, String value) { Property p = Property.getPropertyByKey(property); return (p == null || p.getType().isValidFormat(value)) && Property.isValidTablePropertyKey(property); }
@Override public String get(Property property) { String value = config.get(property.getKey()); if (value == null || !property.getType().isValidFormat(value)) { if (value != null) { log.error("Using default value for {} due to improperly formatted {}: {}", property.getKey(), property.getType(), value); } value = parent.get(property); } return value; }
public static boolean isPropertyValid(String property, String value) { Property p = Property.getPropertyByKey(property); return (p == null || p.getType().isValidFormat(value)) && Property.isValidTablePropertyKey(property); }
/** * Helper for transforming Accumulo configuration properties into something that can be stored * safely inside the Hadoop Job configuration. * * @param implementingClass * the class whose name will be used as a prefix for the property configuration key * @param conf * the Hadoop configuration object to configure * @param property * the supported Accumulo property * @param value * the value of the property to set * @since 1.6.0 */ private static <T> void setAccumuloProperty(Class<?> implementingClass, Configuration conf, Property property, T value) { if (isSupportedAccumuloProperty(property)) { String val = String.valueOf(value); if (property.getType().isValidFormat(val)) conf.set( enumToConfKey(implementingClass, Opts.ACCUMULO_PROPERTIES) + "." + property.getKey(), val); else throw new IllegalArgumentException( "Value is not appropriate for property type '" + property.getType() + "'"); } else throw new IllegalArgumentException("Unsupported configuration property " + property.getKey()); }
public static boolean setSystemProperty(ServerContext context, String property, String value) throws KeeperException, InterruptedException { if (!Property.isValidZooPropertyKey(property)) { IllegalArgumentException iae = new IllegalArgumentException( "Zookeeper property is not mutable: " + property); log.debug("Attempted to set zookeeper property. It is not mutable", iae); throw iae; } // Find the property taking prefix into account Property foundProp = null; for (Property prop : Property.values()) { if (prop.getType() == PropertyType.PREFIX && property.startsWith(prop.getKey()) || prop.getKey().equals(property)) { foundProp = prop; break; } } if ((foundProp == null || (foundProp.getType() != PropertyType.PREFIX && !foundProp.getType().isValidFormat(value)))) { IllegalArgumentException iae = new IllegalArgumentException( "Ignoring property " + property + " it is either null or in an invalid format"); log.debug("Attempted to set zookeeper property. Value is either null or invalid", iae); throw iae; } // create the zk node for this property and set it's data to the specified value String zPath = context.getZooKeeperRoot() + Constants.ZCONFIG + "/" + property; return context.getZooReaderWriter().putPersistentData(zPath, value.getBytes(UTF_8), NodeExistsPolicy.OVERWRITE); }
private String _get(Property property) { String key = property.getKey(); String value = null; if (Property.isValidZooPropertyKey(key)) { value = getRaw(key); } if (value == null || !property.getType().isValidFormat(value)) { if (value != null) log.error("Using parent value for {} due to improperly formatted {}: {}", key, property.getType(), value); value = parent.get(property); } return value; }
/** * Gets a property. If the property is not in ZooKeeper or is present but an invalid format for * the property type, the parent configuration is consulted (if provided). * * @param property * property to get * @param path * ZooKeeper path where properties lie * @param parent * parent configuration (optional) * @return property value, or null if not found */ String get(Property property, String path, AccumuloConfiguration parent) { String key = property.getKey(); String value = get(path + "/" + key); if (value == null || !property.getType().isValidFormat(value)) { if (value != null) { log.error("Using default value for {} due to improperly formatted {}: {}", key, property.getType(), value); } if (parent != null) { value = parent.get(property); } } return value; }
else if (prop.getType() == PropertyType.PREFIX) fatal(PREFIX + "incomplete property key (" + key + ")"); else if (!prop.getType().isValidFormat(value)) fatal(PREFIX + "improperly formatted value for key (" + key + ", type=" + prop.getType() + ") : " + value);
public static boolean isPropertyValid(String property, String value) { Property p = Property.getPropertyByKey(property); if ((p != null && !p.getType().isValidFormat(value)) || !Property.isValidTablePropertyKey(property)) return false; return true; }
public static boolean isPropertyValid(String property, String value) { Property p = Property.getPropertyByKey(property); if ((p != null && !p.getType().isValidFormat(value)) || !Property.isValidTablePropertyKey(property)) return false; return true; }
public static boolean isPropertyValid(String property, String value) { Property p = Property.getPropertyByKey(property); if ((p != null && !p.getType().isValidFormat(value)) || !Property.isValidTablePropertyKey(property)) return false; return true; }
public String get(Property property) { String key = property.getKey(); String value = get(key); if (value == null || !property.getType().isValidFormat(value)) { if (value != null) log.error("Using default value for " + key + " due to improperly formatted " + property.getType() + ": " + value); value = parent.get(property); } return value; }
/** * Helper for transforming Accumulo configuration properties into something that can be stored * safely inside the Hadoop Job configuration. * * @param implementingClass * the class whose name will be used as a prefix for the property configuration key * @param conf * the Hadoop configuration object to configure * @param property * the supported Accumulo property * @param value * the value of the property to set * @since 1.6.0 */ private static <T> void setAccumuloProperty(Class<?> implementingClass, Configuration conf, Property property, T value) { if (isSupportedAccumuloProperty(property)) { String val = String.valueOf(value); if (property.getType().isValidFormat(val)) conf.set( enumToConfKey(implementingClass, Opts.ACCUMULO_PROPERTIES) + "." + property.getKey(), val); else throw new IllegalArgumentException( "Value is not appropriate for property type '" + property.getType() + "'"); } else throw new IllegalArgumentException("Unsupported configuration property " + property.getKey()); }
/** * Helper for transforming Accumulo configuration properties into something that can be stored * safely inside the Hadoop Job configuration. * * @param implementingClass * the class whose name will be used as a prefix for the property configuration key * @param conf * the Hadoop configuration object to configure * @param property * the supported Accumulo property * @param value * the value of the property to set * @since 1.6.0 */ private static <T> void setAccumuloProperty(Class<?> implementingClass, Configuration conf, Property property, T value) { if (isSupportedAccumuloProperty(property)) { String val = String.valueOf(value); if (property.getType().isValidFormat(val)) { String key = enumToConfKey(implementingClass, Opts.ACCUMULO_PROPERTIES) + "." + property.getKey(); log.debug("Setting accumulo property {} = {} ", key, val); conf.set(key, val); } else throw new IllegalArgumentException( "Value is not appropriate for property type '" + property.getType() + "'"); } else throw new IllegalArgumentException("Unsupported configuration property " + property.getKey()); }
/** * Helper for transforming Accumulo configuration properties into something that can be stored * safely inside the Hadoop Job configuration. * * @param implementingClass * the class whose name will be used as a prefix for the property configuration key * @param conf * the Hadoop configuration object to configure * @param property * the supported Accumulo property * @param value * the value of the property to set * @since 1.6.0 */ private static <T> void setAccumuloProperty(Class<?> implementingClass, Configuration conf, Property property, T value) { if (isSupportedAccumuloProperty(property)) { String val = String.valueOf(value); if (property.getType().isValidFormat(val)) conf.set( enumToConfKey(implementingClass, Opts.ACCUMULO_PROPERTIES) + "." + property.getKey(), val); else throw new IllegalArgumentException( "Value is not appropriate for property type '" + property.getType() + "'"); } else throw new IllegalArgumentException("Unsupported configuration property " + property.getKey()); }
private String _get(Property property) { String key = property.getKey(); String value = null; if (Property.isValidZooPropertyKey(key)) { value = getRaw(key); } if (value == null || !property.getType().isValidFormat(value)) { if (value != null) log.error("Using parent value for " + key + " due to improperly formatted " + property.getType() + ": " + value); value = parent.get(property); } return value; }
private String _get(Property property) { String key = property.getKey(); String value = null; if (Property.isValidZooPropertyKey(key)) { value = get(key); } if (value == null || !property.getType().isValidFormat(value)) { if (value != null) log.error("Using parent value for " + key + " due to improperly formatted " + property.getType() + ": " + value); value = parent.get(property); } return value; }
public static boolean setSystemProperty(String property, String value) throws KeeperException, InterruptedException { Property p = Property.getPropertyByKey(property); if ((p != null && !p.getType().isValidFormat(value)) || !Property.isValidZooPropertyKey(property)) return false; // create the zk node for this property and set it's data to the specified value String zPath = ZooUtil.getRoot(HdfsZooInstance.getInstance()) + Constants.ZCONFIG + "/" + property; ZooReaderWriter.getInstance().putPersistentData(zPath, value.getBytes(UTF_8), NodeExistsPolicy.OVERWRITE); return true; }
/** * Gets a property. If the property is not in ZooKeeper or is present but an invalid format for * the property type, the parent configuration is consulted (if provided). * * @param property * property to get * @param path * ZooKeeper path where properties lie * @param parent * parent configuration (optional) * @return property value, or null if not found */ String get(Property property, String path, AccumuloConfiguration parent) { String key = property.getKey(); String value = get(path + "/" + key); if (value == null || !property.getType().isValidFormat(value)) { if (value != null) { log.error("Using default value for " + key + " due to improperly formatted " + property.getType() + ": " + value); } if (parent != null) { value = parent.get(property); } } return value; }