@Test public void testInvalidIteratorFormats() { Map<String,String> data = new HashMap<>(); Map<String,Map<String,String>> options = new HashMap<>(); AccumuloConfiguration conf; List<IterInfo> iterators = new ArrayList<>(); try { data.put(Property.TABLE_ITERATOR_SCAN_PREFIX + "foo.bar", "50," + SummingCombiner.class.getName()); conf = new ConfigurationCopy(data); iterators = IterConfigUtil.parseIterConf(IteratorScope.scan, iterators, options, conf); } catch (IllegalArgumentException ex) { log.debug("caught expected exception: " + ex.getMessage()); } data.clear(); iterators.clear(); options.clear(); try { data.put(Property.TABLE_ITERATOR_SCAN_PREFIX + "foo.bar.baz", "49," + SummingCombiner.class.getName()); conf = new ConfigurationCopy(data); iterators = IterConfigUtil.parseIterConf(IteratorScope.scan, iterators, options, conf); } catch (IllegalArgumentException ex) { log.debug("caught expected exception: " + ex.getMessage()); } data.clear(); iterators.clear(); options.clear(); try { data.put(Property.TABLE_ITERATOR_SCAN_PREFIX + "foobar", "48," + SummingCombiner.class.getName()); data.put(Property.TABLE_ITERATOR_SCAN_PREFIX + "foobar.opt", "fakevalue"); conf = new ConfigurationCopy(data); iterators = IterConfigUtil.parseIterConf(IteratorScope.scan, iterators, options, conf); assertEquals(1, iterators.size()); IterInfo ii = iterators.get(0); assertEquals(new IterInfo(48, SummingCombiner.class.getName(), "foobar"), ii); } catch (IllegalArgumentException ex) { log.debug("caught expected exception: " + ex.getMessage()); } data.clear(); iterators.clear(); options.clear(); try { data.put(Property.TABLE_ITERATOR_SCAN_PREFIX + "foobaz", "47," + SummingCombiner.class.getName()); data.put(Property.TABLE_ITERATOR_SCAN_PREFIX + "foobaz.fake.opt", "fakevalue"); conf = new ConfigurationCopy(data); iterators = IterConfigUtil.parseIterConf(IteratorScope.scan, iterators, options, conf); assertEquals(1, iterators.size()); IterInfo ii = iterators.get(0); assertEquals(new IterInfo(47, SummingCombiner.class.getName(), "foobaz"), ii); } catch (IllegalArgumentException ex) { log.debug("caught expected exception: " + ex.getMessage()); } }
public static List<IterInfo> parseIterConf(IteratorScope scope, List<IterInfo> iters, Map<String,Map<String,String>> allOptions, AccumuloConfiguration conf) { Map<String,String> properties = conf.getAllPropertiesWithPrefix(getProperty(scope)); ArrayList<IterInfo> iterators = new ArrayList<>(iters); final Property scopeProperty = getProperty(scope); final String scopePropertyKey = scopeProperty.getKey(); for (Entry<String,String> entry : properties.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]; iterators.add(new IterInfo(prio, className, suffixSplit[0])); } else if (suffixSplit.length == 3 && suffixSplit[1].equals("opt")) { String iterName = suffixSplit[0]; String optName = suffixSplit[2]; allOptions.computeIfAbsent(iterName, k -> new HashMap<>()).put(optName, entry.getValue()); } else { throw new IllegalArgumentException("Invalid iterator format: " + entry.getKey()); } } iterators.sort(ITER_INFO_COMPARATOR); return iterators; }
IterConfigUtil { public static List<IterInfo> parseIterConf(IteratorScope scope, List<IterInfo> iters, Map<String,Map<String,String>> allOptions, AccumuloConfiguration conf) { Map<String,String> properties = conf.getAllPropertiesWithPrefix(getProperty(scope)); ArrayList<IterInfo> iterators = new ArrayList<>(iters); final Property scopeProperty = getProperty(scope); final String scopePropertyKey = scopeProperty.getKey(); for (Entry<String,String> entry : properties.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]; iterators.add(new IterInfo(prio, className, suffixSplit[0])); } else if (suffixSplit.length == 3 && suffixSplit[1].equals("opt")) { String iterName = suffixSplit[0]; String optName = suffixSplit[2]; allOptions.computeIfAbsent(iterName, k -> new HashMap<>()).put(optName, entry.getValue()); } else { throw new IllegalArgumentException("Invalid iterator format: " + entry.getKey()); } } iterators.sort(ITER_INFO_COMPARATOR); return iterators; } }
IterConfigUtil { public static List<IterInfo> parseIterConf(IteratorScope scope, List<IterInfo> iters, Map<String,Map<String,String>> allOptions, AccumuloConfiguration conf) { Map<String,String> properties = conf.getAllPropertiesWithPrefix(getProperty(scope)); ArrayList<IterInfo> iterators = new ArrayList<>(iters); final Property scopeProperty = getProperty(scope); final String scopePropertyKey = scopeProperty.getKey(); for (Entry<String,String> entry : properties.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]; iterators.add(new IterInfo(prio, className, suffixSplit[0])); } else if (suffixSplit.length == 3 && suffixSplit[1].equals("opt")) { String iterName = suffixSplit[0]; String optName = suffixSplit[2]; allOptions.computeIfAbsent(iterName, k -> new HashMap<>()).put(optName, entry.getValue()); } else { throw new IllegalArgumentException("Invalid iterator format: " + entry.getKey()); } } iterators.sort(ITER_INFO_COMPARATOR); return iterators; }  }
IterConfigUtil { public static List<IterInfo> parseIterConf(IteratorScope scope, List<IterInfo> iters, Map<String,Map<String,String>> allOptions, AccumuloConfiguration conf) { Map<String,String> properties = conf.getAllPropertiesWithPrefix(getProperty(scope)); ArrayList<IterInfo> iterators = new ArrayList<>(iters); final Property scopeProperty = getProperty(scope); final String scopePropertyKey = scopeProperty.getKey(); for (Entry<String,String> entry : properties.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]; iterators.add(new IterInfo(prio, className, suffixSplit[0])); } else if (suffixSplit.length == 3 && suffixSplit[1].equals("opt")) { String iterName = suffixSplit[0]; String optName = suffixSplit[2]; allOptions.computeIfAbsent(iterName, k -> new HashMap<>()).put(optName, entry.getValue()); } else { throw new IllegalArgumentException("Invalid iterator format: " + entry.getKey()); } } iterators.sort(ITER_INFO_COMPARATOR); return iterators; }  static Property getProperty(IteratorScope scope); static Map<String,String> generateInitialTableProperties(boolean limitVersion); static List<IterInfo> parseIterConf(IteratorScope scope, List<IterInfo> iters,
      Map<String,Map<String,String>> allOptions, AccumuloConfiguration conf); static void mergeIteratorConfig(List<IterInfo> destList,
      Map<String,Map<String,String>> destOpts, List<IterInfo> tableIters,
      Map<String,Map<String,String>> tableOpts, List<IterInfo> ssi,
      Map<String,Map<String,String>> ssio); static IterLoad loadIterConf(IteratorScope scope, List<IterInfo> iters,
      Map<String,Map<String,String>> iterOpts, AccumuloConfiguration conf); static SortedKeyValueIterator<Key,Value> convertItersAndLoad(IteratorScope scope,
      SortedKeyValueIterator<Key,Value> source, AccumuloConfiguration conf,
      List<IteratorSetting> iterators, IteratorEnvironment env); static SortedKeyValueIterator<Key,Value> loadIterators(
      SortedKeyValueIterator<Key,Value> source, IterLoad iterLoad); }
IterConfigUtil { public static List<IterInfo> parseIterConf(IteratorScope scope, List<IterInfo> iters, Map<String,Map<String,String>> allOptions, AccumuloConfiguration conf) { Map<String,String> properties = conf.getAllPropertiesWithPrefix(getProperty(scope)); ArrayList<IterInfo> iterators = new ArrayList<>(iters); final Property scopeProperty = getProperty(scope); final String scopePropertyKey = scopeProperty.getKey(); for (Entry<String,String> entry : properties.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]; iterators.add(new IterInfo(prio, className, suffixSplit[0])); } else if (suffixSplit.length == 3 && suffixSplit[1].equals("opt")) { String iterName = suffixSplit[0]; String optName = suffixSplit[2]; allOptions.computeIfAbsent(iterName, k -> new HashMap<>()).put(optName, entry.getValue()); } else { throw new IllegalArgumentException("Invalid iterator format: " + entry.getKey()); } } iterators.sort(ITER_INFO_COMPARATOR); return iterators; }  static Property getProperty(IteratorScope scope); static Map<String,String> generateInitialTableProperties(boolean limitVersion); static List<IterInfo> parseIterConf(IteratorScope scope, List<IterInfo> iters,
      Map<String,Map<String,String>> allOptions, AccumuloConfiguration conf); static void mergeIteratorConfig(List<IterInfo> destList,
      Map<String,Map<String,String>> destOpts, List<IterInfo> tableIters,
      Map<String,Map<String,String>> tableOpts, List<IterInfo> ssi,
      Map<String,Map<String,String>> ssio); static IterLoad loadIterConf(IteratorScope scope, List<IterInfo> iters,
      Map<String,Map<String,String>> iterOpts, AccumuloConfiguration conf); static SortedKeyValueIterator<Key,Value> convertItersAndLoad(IteratorScope scope,
      SortedKeyValueIterator<Key,Value> source, AccumuloConfiguration conf,
      List<IteratorSetting> iterators, IteratorEnvironment env); static SortedKeyValueIterator<Key,Value> loadIterators(
      SortedKeyValueIterator<Key,Value> source, IterLoad iterLoad); static final Comparator<IterInfo> ITER_INFO_COMPARATOR; }