/** * Validate that the provided scope arguments are valid iterator scope settings. Checking for * duplicate entries and invalid scope values. * * Returns an EnumSet of scopes to be set. */ private EnumSet<IteratorScope> validateScopes(final List<String> scopeList) { EnumSet<IteratorScope> scopes = EnumSet.noneOf(IteratorScope.class); for (String scopeStr : scopeList) { try { IteratorScope scope = IteratorScope.valueOf(scopeStr); if (!scopes.add(scope)) throw new IllegalArgumentException("duplicate scope arguments found"); } catch (IllegalArgumentException ex) { throw new IllegalArgumentException("illegal scope arguments: " + ex.getMessage(), ex); } } return scopes; }
@Override public Map<String,EnumSet<IteratorScope>> listIterators(String tableName) throws AccumuloException, TableNotFoundException { Map<String,EnumSet<IteratorScope>> result = new TreeMap<>(); for (Entry<String,String> property : this.getProperties(tableName)) { String name = property.getKey(); String[] parts = name.split("\\."); if (parts.length == 4) { if (parts[0].equals("table") && parts[1].equals("iterator")) { IteratorScope scope = IteratorScope.valueOf(parts[2]); if (!result.containsKey(parts[3])) result.put(parts[3], EnumSet.noneOf(IteratorScope.class)); result.get(parts[3]).add(scope); } } } return result; }
@Override public Map<String,EnumSet<IteratorScope>> listIterators(String namespace) throws AccumuloSecurityException, AccumuloException, NamespaceNotFoundException { if (!exists(namespace)) throw new NamespaceNotFoundException(null, namespace, null); Map<String,EnumSet<IteratorScope>> result = new TreeMap<>(); for (Entry<String,String> property : this.getProperties(namespace)) { String name = property.getKey(); String[] parts = name.split("\\."); if (parts.length == 4) { if (parts[0].equals("table") && parts[1].equals("iterator")) { IteratorScope scope = IteratorScope.valueOf(parts[2]); if (!result.containsKey(parts[3])) result.put(parts[3], EnumSet.noneOf(IteratorScope.class)); result.get(parts[3]).add(scope); } } } return result; }
for (String scope : splitD4mString(scopeStrs)) scopesToConsider.add( IteratorUtil.IteratorScope.valueOf(scope.toLowerCase())); } else scopesToConsider = EnumSet.allOf(IteratorUtil.IteratorScope.class);
@Override public Map<String,EnumSet<IteratorScope>> listIterators(String namespace) throws AccumuloSecurityException, AccumuloException, NamespaceNotFoundException { if (!exists(namespace)) throw new NamespaceNotFoundException(null, namespace, null); Map<String,EnumSet<IteratorScope>> result = new TreeMap<>(); for (Entry<String,String> property : this.getProperties(namespace)) { String name = property.getKey(); String[] parts = name.split("\\."); if (parts.length == 4) { if (parts[0].equals("table") && parts[1].equals("iterator")) { IteratorScope scope = IteratorScope.valueOf(parts[2]); if (!result.containsKey(parts[3])) result.put(parts[3], EnumSet.noneOf(IteratorScope.class)); result.get(parts[3]).add(scope); } } } return result; }
@Override public Map<String,EnumSet<IteratorScope>> listIterators(String tableName) throws AccumuloSecurityException, AccumuloException, TableNotFoundException { Map<String,EnumSet<IteratorScope>> result = new TreeMap<>(); for (Entry<String,String> property : this.getProperties(tableName)) { String name = property.getKey(); String[] parts = name.split("\\."); if (parts.length == 4) { if (parts[0].equals("table") && parts[1].equals("iterator")) { IteratorScope scope = IteratorScope.valueOf(parts[2]); if (!result.containsKey(parts[3])) result.put(parts[3], EnumSet.noneOf(IteratorScope.class)); result.get(parts[3]).add(scope); } } } return result; }
public static IteratorScope fromThrift(org.apache.accumulo.proxy.thrift.IteratorScope tis) { if (tis == null) { return null; } // we can't just use the enum values, since thrift MINC=0 but Apache // minc=1. we can't just use the names, since thrift are in upper case, // and Apache are lower. assuming Thrift will remain uppercase and use // the same characters as Apache try { return IteratorScope.valueOf(tis.name().toLowerCase()); } catch (IllegalArgumentException ex) { throw ExceptionFactory.noEnumMapping(tis, IteratorScope.class); } }
private IteratorScope getIteratorScope(org.apache.accumulo.proxy.thrift.IteratorScope scope) { return IteratorScope.valueOf(scope.toString().toLowerCase()); }