Ejemplo n.º 1
0
  /**
   * This method returns all properties in a map of string->string under the given prefix property.
   *
   * @param property the prefix property, and must be of type PropertyType.PREFIX
   * @return a map of strings to strings of the resulting properties
   */
  public Map<String, String> getAllPropertiesWithPrefix(Property property) {
    checkType(property, PropertyType.PREFIX);

    Map<String, String> propMap = new HashMap<String, String>();
    getProperties(propMap, new PrefixFilter(property.getKey()));
    return propMap;
  }
Ejemplo n.º 2
0
  public static boolean isValidTablePropertyKey(String key) {
    if (validTableProperties == null) {
      synchronized (Property.class) {
        if (validTableProperties == null) {
          HashSet<String> tmp = new HashSet<String>();
          for (Property p : Property.values())
            if (!p.getType().equals(PropertyType.PREFIX)
                && p.getKey().startsWith(Property.TABLE_PREFIX.getKey())) tmp.add(p.getKey());
          validTableProperties = tmp;
        }
      }
    }

    return validTableProperties.contains(key)
        || key.startsWith(Property.TABLE_CONSTRAINT_PREFIX.getKey())
        || key.startsWith(Property.TABLE_ITERATOR_PREFIX.getKey())
        || key.startsWith(Property.TABLE_LOCALITY_GROUP_PREFIX.getKey());
  }
Ejemplo n.º 3
0
 private void checkType(Property property, PropertyType type) {
   if (!property.getType().equals(type)) {
     String msg =
         "Configuration method intended for type "
             + type
             + " called with a "
             + property.getType()
             + " argument ("
             + property.getKey()
             + ")";
     IllegalArgumentException err = new IllegalArgumentException(msg);
     log.error(msg, err);
     throw err;
   }
 }
Ejemplo n.º 4
0
  public static void parseIterConf(
      IteratorScope scope,
      List<IterInfo> iters,
      Map<String, Map<String, String>> allOptions,
      AccumuloConfiguration conf) {
    final Property scopeProperty = getProperty(scope);
    final String scopePropertyKey = scopeProperty.getKey();

    for (Entry<String, String> entry : conf.getAllPropertiesWithPrefix(scopeProperty).entrySet()) {
      String suffix = entry.getKey().substring(scopePropertyKey.length());
      String suffixSplit[] = suffix.split("\\.", 3);

      if (suffixSplit.length == 1) {
        String sa[] = entry.getValue().split(",");
        int prio = Integer.parseInt(sa[0]);
        String className = sa[1];
        iters.add(new IterInfo(prio, className, suffixSplit[0]));
      } else if (suffixSplit.length == 3 && suffixSplit[1].equals("opt")) {
        String iterName = suffixSplit[0];
        String optName = suffixSplit[2];

        Map<String, String> options = allOptions.get(iterName);
        if (options == null) {
          options = new HashMap<>();
          allOptions.put(iterName, options);
        }

        options.put(optName, entry.getValue());

      } else {
        log.warn("Unrecognizable option: " + entry.getKey());
      }
    }

    Collections.sort(iters, new IterInfoComparator());
  }
Ejemplo n.º 5
0
 @Override
 public String get(Property property) {
   return map.get(property.getKey());
 }
Ejemplo n.º 6
0
 public static Property getPropertyByKey(String key) {
   for (Property prop : Property.values()) if (prop.getKey().equals(key)) return prop;
   return null;
 }