accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ktur...@apache.org
Subject svn commit: r1448692 - in /accumulo/branches/1.5/core/src: main/java/org/apache/accumulo/core/iterators/user/TransformingIterator.java test/java/org/apache/accumulo/core/iterators/user/TransformingIteratorTest.java
Date Thu, 21 Feb 2013 15:55:22 GMT
Author: kturner
Date: Thu Feb 21 15:55:22 2013
New Revision: 1448692

URL: http://svn.apache.org/r1448692
Log:
ACCUMULO-1001 implemented verifyopts for TransformingIterator

Modified:
    accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/iterators/user/TransformingIterator.java
    accumulo/branches/1.5/core/src/test/java/org/apache/accumulo/core/iterators/user/TransformingIteratorTest.java

Modified: accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/iterators/user/TransformingIterator.java
URL: http://svn.apache.org/viewvc/accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/iterators/user/TransformingIterator.java?rev=1448692&r1=1448691&r2=1448692&view=diff
==============================================================================
--- accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/iterators/user/TransformingIterator.java
(original)
+++ accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/iterators/user/TransformingIterator.java
Thu Feb 21 15:55:22 2013
@@ -140,9 +140,22 @@ abstract public class TransformingIterat
   
   @Override
   public boolean validateOptions(Map<String,String> options) {
+    
+    for (String opt : options.keySet()) {
+      try {
+        if (options.equals(AUTH_OPT)) {
+          new Authorizations(options.get(opt).getBytes());
+        } else if (opt.equals(MAX_BUFFER_SIZE_OPT)) {
+          AccumuloConfiguration.getMemoryInBytes(options.get(opt));
+        }
+      } catch (Exception e) {
+        throw new IllegalArgumentException("Failed to parse opt " + opt + " " + options.get(opt),
e);
+      }
+    }
+    
     return true;
   }
-  
+
   @Override
   public SortedKeyValueIterator<Key,Value> deepCopy(IteratorEnvironment env) {
     TransformingIterator copy;

Modified: accumulo/branches/1.5/core/src/test/java/org/apache/accumulo/core/iterators/user/TransformingIteratorTest.java
URL: http://svn.apache.org/viewvc/accumulo/branches/1.5/core/src/test/java/org/apache/accumulo/core/iterators/user/TransformingIteratorTest.java?rev=1448692&r1=1448691&r2=1448692&view=diff
==============================================================================
--- accumulo/branches/1.5/core/src/test/java/org/apache/accumulo/core/iterators/user/TransformingIteratorTest.java
(original)
+++ accumulo/branches/1.5/core/src/test/java/org/apache/accumulo/core/iterators/user/TransformingIteratorTest.java
Thu Feb 21 15:55:22 2013
@@ -25,6 +25,7 @@ import java.io.IOException;
 import java.util.Arrays;
 import java.util.Collection;
 import java.util.Collections;
+import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Iterator;
 import java.util.List;
@@ -55,6 +56,7 @@ import org.apache.accumulo.core.iterator
 import org.apache.accumulo.core.security.Authorizations;
 import org.apache.accumulo.core.security.ColumnVisibility;
 import org.apache.hadoop.io.Text;
+import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
 
@@ -388,6 +390,28 @@ public class TransformingIteratorTest {
     assertEquals(81, count);
   }
   
+  @Test
+  public void testValidateOptions() {
+    TransformingIterator ti = new ColFamReversingKeyTransformingIterator();
+    IteratorSetting is = new IteratorSetting(100, "cfrkt", ColFamReversingKeyTransformingIterator.class);
+    TransformingIterator.setAuthorizations(is, new Authorizations("A", "B"));
+    TransformingIterator.setMaxBufferSize(is, 10000000);
+    Assert.assertTrue(ti.validateOptions(is.getOptions()));
+    
+    Map<String,String> opts = new HashMap<String,String>();
+    
+    opts.put(TransformingIterator.MAX_BUFFER_SIZE_OPT, "10M");
+    Assert.assertTrue(ti.validateOptions(is.getOptions()));
+    
+    opts.clear();
+    opts.put(TransformingIterator.MAX_BUFFER_SIZE_OPT, "A,B");
+    try {
+      ti.validateOptions(opts);
+      Assert.assertFalse(true);
+    } catch (IllegalArgumentException e) {}
+
+  }
+  
   private Key createDeleteKey(String row, String colFam, String colQual, String colVis, long
timestamp) {
     Key key = new Key(row, colFam, colQual, colVis, timestamp);
     key.setDeleted(true);



Mime
View raw message