accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bil...@apache.org
Subject svn commit: r1209274 - in /incubator/accumulo/trunk: ./ src/core/src/main/java/org/apache/accumulo/core/client/ src/core/src/main/java/org/apache/accumulo/core/client/admin/ src/core/src/main/java/org/apache/accumulo/core/client/impl/ src/core/src/main...
Date Thu, 01 Dec 2011 22:16:36 GMT
Author: billie
Date: Thu Dec  1 22:16:35 2011
New Revision: 1209274

URL: http://svn.apache.org/viewvc?rev=1209274&view=rev
Log:
ACCUMULO-200 merged to trunk

Modified:
    incubator/accumulo/trunk/   (props changed)
    incubator/accumulo/trunk/src/core/src/main/java/org/apache/accumulo/core/client/ScannerBase.java
    incubator/accumulo/trunk/src/core/src/main/java/org/apache/accumulo/core/client/admin/TableOperations.java
    incubator/accumulo/trunk/src/core/src/main/java/org/apache/accumulo/core/client/admin/TableOperationsHelper.java
    incubator/accumulo/trunk/src/core/src/main/java/org/apache/accumulo/core/client/impl/ScannerOptions.java
    incubator/accumulo/trunk/src/core/src/main/java/org/apache/accumulo/core/util/shell/commands/DeleteIterCommand.java
    incubator/accumulo/trunk/src/core/src/test/java/org/apache/accumulo/core/client/admin/TableOperationsHelperTest.java

Propchange: incubator/accumulo/trunk/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Dec  1 22:16:35 2011
@@ -1,2 +1,2 @@
 /incubator/accumulo/branches/1.3:1190280,1190413,1190420,1190427,1190500,1195622,1195625,1195629,1195635,1196044,1196054,1196057,1196071-1196072,1196106,1197066,1198935,1199383,1203683,1204625,1205547,1205880,1206169,1208031,1209124
-/incubator/accumulo/branches/1.4:1201902-1209269
+/incubator/accumulo/branches/1.4:1201902-1209272

Modified: incubator/accumulo/trunk/src/core/src/main/java/org/apache/accumulo/core/client/ScannerBase.java
URL: http://svn.apache.org/viewvc/incubator/accumulo/trunk/src/core/src/main/java/org/apache/accumulo/core/client/ScannerBase.java?rev=1209274&r1=1209273&r2=1209274&view=diff
==============================================================================
--- incubator/accumulo/trunk/src/core/src/main/java/org/apache/accumulo/core/client/ScannerBase.java
(original)
+++ incubator/accumulo/trunk/src/core/src/main/java/org/apache/accumulo/core/client/ScannerBase.java
Thu Dec  1 22:16:35 2011
@@ -35,7 +35,8 @@ public interface ScannerBase extends Ite
    * @param cfg
    *          fully specified scan-time iterator, including all options for the iterator.
Any changes to the iterator setting after this call are not propagated
    *          to the stored iterator.
-   * 
+   * @throws IllegalArgumentException
+   *           if the setting conflicts with existing iterators
    */
   public void addScanIterator(IteratorSetting cfg);
   

Modified: incubator/accumulo/trunk/src/core/src/main/java/org/apache/accumulo/core/client/admin/TableOperations.java
URL: http://svn.apache.org/viewvc/incubator/accumulo/trunk/src/core/src/main/java/org/apache/accumulo/core/client/admin/TableOperations.java?rev=1209274&r1=1209273&r2=1209274&view=diff
==============================================================================
--- incubator/accumulo/trunk/src/core/src/main/java/org/apache/accumulo/core/client/admin/TableOperations.java
(original)
+++ incubator/accumulo/trunk/src/core/src/main/java/org/apache/accumulo/core/client/admin/TableOperations.java
Thu Dec  1 22:16:35 2011
@@ -470,6 +470,8 @@ public interface TableOperations {
    * @throws AccumuloException
    * @throws TableNotFoundException
    *           throw if the table no longer exists
+   * @throws IllegalArgumentException
+   *           if the setting conflicts with any existing iterators
    */
   public void attachIterator(String tableName, IteratorSetting setting) throws AccumuloSecurityException,
AccumuloException, TableNotFoundException;
   
@@ -521,4 +523,19 @@ public interface TableOperations {
    * @throws TableNotFoundException
    */
   public Set<String> listIterators(String tableName) throws AccumuloSecurityException,
AccumuloException, TableNotFoundException;
+  
+  /**
+   * Check whether a given iterator configuration conflicts with existing configuration;
in particular, determine if the name or priority are already in use for
+   * the specified scopes.
+   * 
+   * @param tableName
+   *          the name of the table
+   * @param setting
+   *          object specifying the properties of the iterator
+   * @throws AccumuloException
+   * @throws TableNotFoundException
+   * @throws IllegalStateException
+   *           if the setting conflicts with any existing iterators
+   */
+  public void checkIteratorConflicts(String tableName, IteratorSetting setting) throws AccumuloException,
TableNotFoundException;
 }

Modified: incubator/accumulo/trunk/src/core/src/main/java/org/apache/accumulo/core/client/admin/TableOperationsHelper.java
URL: http://svn.apache.org/viewvc/incubator/accumulo/trunk/src/core/src/main/java/org/apache/accumulo/core/client/admin/TableOperationsHelper.java?rev=1209274&r1=1209273&r2=1209274&view=diff
==============================================================================
--- incubator/accumulo/trunk/src/core/src/main/java/org/apache/accumulo/core/client/admin/TableOperationsHelper.java
(original)
+++ incubator/accumulo/trunk/src/core/src/main/java/org/apache/accumulo/core/client/admin/TableOperationsHelper.java
Thu Dec  1 22:16:35 2011
@@ -22,6 +22,7 @@ import java.util.HashSet;
 import java.util.Map;
 import java.util.Map.Entry;
 import java.util.Set;
+import java.util.TreeMap;
 
 import org.apache.accumulo.core.client.AccumuloException;
 import org.apache.accumulo.core.client.AccumuloSecurityException;
@@ -34,7 +35,7 @@ public abstract class TableOperationsHel
   
   @Override
   public void attachIterator(String tableName, IteratorSetting setting) throws AccumuloSecurityException,
AccumuloException, TableNotFoundException {
-    removeIterator(tableName, setting.getName(), setting.getScopes());
+    checkIteratorConflicts(tableName, setting);
     for (IteratorScope scope : setting.getScopes()) {
       String root = String.format("%s%s.%s", Property.TABLE_ITERATOR_PREFIX, scope.name().toLowerCase(),
setting.getName());
       this.setProperty(tableName, root, setting.getPriority() + "," + setting.getIteratorClass());
@@ -103,4 +104,35 @@ public abstract class TableOperationsHel
     }
     return result;
   }
+  
+  @Override
+  public void checkIteratorConflicts(String tableName, IteratorSetting setting) throws AccumuloException,
TableNotFoundException {
+    for (IteratorScope scope : setting.getScopes()) {
+      String scopeStr = String.format("%s%s", Property.TABLE_ITERATOR_PREFIX, scope.name().toLowerCase());
+      String nameStr = String.format("%s.%s", scopeStr, setting.getName());
+      String optStr = String.format("%s.opt.", nameStr);
+      Map<String,String> optionConflicts = new TreeMap<String,String>();
+      for (Entry<String,String> property : this.getProperties(tableName)) {
+        if (property.getKey().startsWith(scopeStr)) {
+          if (property.getKey().equals(nameStr))
+            throw new IllegalArgumentException("iterator name conflict for " + setting.getName()
+ ": " + property.getKey() + "=" + property.getValue());
+          if (property.getKey().startsWith(optStr))
+            optionConflicts.put(property.getKey(), property.getValue());
+          if (property.getKey().contains(".opt."))
+            continue;
+          String parts[] = property.getValue().split(",");
+          if (parts.length != 2)
+            throw new AccumuloException("Bad value for existing iterator setting: " + property.getKey()
+ "=" + property.getValue());
+          try {
+            if (Integer.parseInt(parts[0]) == setting.getPriority())
+              throw new IllegalArgumentException("iterator priority conflict: " + property.getKey()
+ "=" + property.getValue());
+          } catch (NumberFormatException e) {
+            throw new AccumuloException("Bad value for existing iterator setting: " + property.getKey()
+ "=" + property.getValue());
+          }
+        }
+      }
+      if (optionConflicts.size() > 0)
+        throw new IllegalArgumentException("iterator options conflict for " + setting.getName()
+ ": " + optionConflicts);
+    }
+  }
 }

Modified: incubator/accumulo/trunk/src/core/src/main/java/org/apache/accumulo/core/client/impl/ScannerOptions.java
URL: http://svn.apache.org/viewvc/incubator/accumulo/trunk/src/core/src/main/java/org/apache/accumulo/core/client/impl/ScannerOptions.java?rev=1209274&r1=1209273&r2=1209274&view=diff
==============================================================================
--- incubator/accumulo/trunk/src/core/src/main/java/org/apache/accumulo/core/client/impl/ScannerOptions.java
(original)
+++ incubator/accumulo/trunk/src/core/src/main/java/org/apache/accumulo/core/client/impl/ScannerOptions.java
Thu Dec  1 22:16:35 2011
@@ -62,9 +62,12 @@ public class ScannerOptions implements S
     if (serverSideIteratorList.size() == 0)
       serverSideIteratorList = new ArrayList<IterInfo>();
     
-    for (IterInfo ii : serverSideIteratorList)
+    for (IterInfo ii : serverSideIteratorList) {
       if (ii.iterName.equals(si.getName()))
         throw new IllegalArgumentException("Iterator name is already in use " + si.getName());
+      if (ii.getPriority() == si.getPriority())
+        throw new IllegalArgumentException("Iterator priority is already in use " + si.getPriority());
+    }
     
     serverSideIteratorList.add(new IterInfo(si.getPriority(), si.getIteratorClass(), si.getName()));
     

Modified: incubator/accumulo/trunk/src/core/src/main/java/org/apache/accumulo/core/util/shell/commands/DeleteIterCommand.java
URL: http://svn.apache.org/viewvc/incubator/accumulo/trunk/src/core/src/main/java/org/apache/accumulo/core/util/shell/commands/DeleteIterCommand.java?rev=1209274&r1=1209273&r2=1209274&view=diff
==============================================================================
--- incubator/accumulo/trunk/src/core/src/main/java/org/apache/accumulo/core/util/shell/commands/DeleteIterCommand.java
(original)
+++ incubator/accumulo/trunk/src/core/src/main/java/org/apache/accumulo/core/util/shell/commands/DeleteIterCommand.java
Thu Dec  1 22:16:35 2011
@@ -58,6 +58,8 @@ public class DeleteIterCommand extends C
       scopes.add(IteratorScope.majc);
     if (cl.hasOption(scanScopeOpt.getOpt()))
       scopes.add(IteratorScope.scan);
+    if (scopes.isEmpty())
+      throw new IllegalArgumentException("You must select at least one scope to configure");
     shellState.getConnector().tableOperations().removeIterator(tableName, name, scopes);
     return 0;
   }

Modified: incubator/accumulo/trunk/src/core/src/test/java/org/apache/accumulo/core/client/admin/TableOperationsHelperTest.java
URL: http://svn.apache.org/viewvc/incubator/accumulo/trunk/src/core/src/test/java/org/apache/accumulo/core/client/admin/TableOperationsHelperTest.java?rev=1209274&r1=1209273&r2=1209274&view=diff
==============================================================================
--- incubator/accumulo/trunk/src/core/src/test/java/org/apache/accumulo/core/client/admin/TableOperationsHelperTest.java
(original)
+++ incubator/accumulo/trunk/src/core/src/test/java/org/apache/accumulo/core/client/admin/TableOperationsHelperTest.java
Thu Dec  1 22:16:35 2011
@@ -203,7 +203,7 @@ public class TableOperationsHelperTest {
     t.check("table", new String[] {"table.iterator.scan.someName=10,foo.bar",});
     t.removeIterator("table", "someName", EnumSet.of(IteratorScope.scan));
     t.check("table", new String[] {});
-
+    
     IteratorSetting setting = new IteratorSetting(10, "someName", "foo.bar");
     setting.setScopes(EnumSet.of(IteratorScope.majc));
     setting.addOptions(Collections.singletonMap("key", "value"));
@@ -212,7 +212,7 @@ public class TableOperationsHelperTest {
     t.attachIterator("table", setting);
     t.check("table", new String[] {"table.iterator.majc.someName=10,foo.bar", "table.iterator.majc.someName.opt.key=value",
         "table.iterator.scan.someName=10,foo.bar",});
-
+    
     setting = new IteratorSetting(20, "otherName", "some.classname");
     setting.setScopes(EnumSet.of(IteratorScope.majc));
     setting.addOptions(Collections.singletonMap("key", "value"));
@@ -226,7 +226,7 @@ public class TableOperationsHelperTest {
     t.removeIterator("table", "someName", EnumSet.allOf(IteratorScope.class));
     t.check("table", new String[] {"table.iterator.majc.otherName=20,some.classname", "table.iterator.majc.otherName.opt.key=value",
         "table.iterator.scan.otherName=20,some.classname",});
-
+    
     setting = t.getIteratorSetting("table", "otherName", IteratorScope.scan);
     Assert.assertEquals(20, setting.getPriority());
     Assert.assertEquals("some.classname", setting.getIteratorClass());
@@ -240,6 +240,18 @@ public class TableOperationsHelperTest {
     t.attachIterator("table", setting);
     t.check("table", new String[] {"table.iterator.majc.otherName=20,some.classname", "table.iterator.majc.otherName.opt.key=value",
         "table.iterator.minc.otherName=20,some.classname", "table.iterator.minc.otherName.opt.key=value",
"table.iterator.scan.otherName=20,some.classname",});
+    
+    try {
+      t.attachIterator("table", setting);
+      Assert.fail();
+    } catch (IllegalArgumentException e) {}
+    setting.setName("thirdName");
+    try {
+      t.attachIterator("table", setting);
+      Assert.fail();
+    } catch (IllegalArgumentException e) {}
+    setting.setPriority(10);
+    t.attachIterator("table", setting);
   }
   
 }



Mime
View raw message