accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ktur...@apache.org
Subject svn commit: r1426328 - in /accumulo/trunk/core/src: main/java/org/apache/accumulo/core/client/mapreduce/AccumuloFileOutputFormat.java test/java/org/apache/accumulo/core/client/mapreduce/AccumuloFileOutputFormatTest.java
Date Thu, 27 Dec 2012 21:06:06 GMT
Author: kturner
Date: Thu Dec 27 21:06:06 2012
New Revision: 1426328

URL: http://svn.apache.org/viewvc?rev=1426328&view=rev
Log:
ACCUMULO-360 made AccumuloFileOutputFormat reject bad visibilities 

Modified:
    accumulo/trunk/core/src/main/java/org/apache/accumulo/core/client/mapreduce/AccumuloFileOutputFormat.java
    accumulo/trunk/core/src/test/java/org/apache/accumulo/core/client/mapreduce/AccumuloFileOutputFormatTest.java

Modified: accumulo/trunk/core/src/main/java/org/apache/accumulo/core/client/mapreduce/AccumuloFileOutputFormat.java
URL: http://svn.apache.org/viewvc/accumulo/trunk/core/src/main/java/org/apache/accumulo/core/client/mapreduce/AccumuloFileOutputFormat.java?rev=1426328&r1=1426327&r2=1426328&view=diff
==============================================================================
--- accumulo/trunk/core/src/main/java/org/apache/accumulo/core/client/mapreduce/AccumuloFileOutputFormat.java
(original)
+++ accumulo/trunk/core/src/main/java/org/apache/accumulo/core/client/mapreduce/AccumuloFileOutputFormat.java
Thu Dec 27 21:06:06 2012
@@ -17,6 +17,7 @@
 package org.apache.accumulo.core.client.mapreduce;
 
 import java.io.IOException;
+import java.util.Arrays;
 import java.util.Map.Entry;
 
 import org.apache.accumulo.core.client.Instance;
@@ -24,11 +25,14 @@ import org.apache.accumulo.core.client.Z
 import org.apache.accumulo.core.conf.AccumuloConfiguration;
 import org.apache.accumulo.core.conf.ConfigurationCopy;
 import org.apache.accumulo.core.conf.Property;
+import org.apache.accumulo.core.data.ArrayByteSequence;
 import org.apache.accumulo.core.data.Key;
 import org.apache.accumulo.core.data.Value;
 import org.apache.accumulo.core.file.FileOperations;
 import org.apache.accumulo.core.file.FileSKVWriter;
+import org.apache.accumulo.core.security.ColumnVisibility;
 import org.apache.accumulo.core.util.ArgumentChecker;
+import org.apache.commons.collections.map.LRUMap;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.mapreduce.Job;
@@ -160,6 +164,8 @@ public class AccumuloFileOutputFormat ex
     final String extension = acuConf.get(Property.TABLE_FILE_TYPE);
     final Path file = this.getDefaultWorkFile(context, "." + extension);
     
+    final LRUMap validVisibilities = new LRUMap(1000);
+
     return new RecordWriter<Key,Value>() {
       FileSKVWriter out = null;
       
@@ -171,6 +177,14 @@ public class AccumuloFileOutputFormat ex
       
       @Override
       public void write(Key key, Value value) throws IOException {
+        
+        Boolean wasChecked = (Boolean) validVisibilities.get(key.getColumnVisibilityData());
+        if (wasChecked == null) {
+          byte[] cv = key.getColumnVisibilityData().toArray();
+          new ColumnVisibility(cv);
+          validVisibilities.put(new ArrayByteSequence(Arrays.copyOf(cv, cv.length)), Boolean.TRUE);
+        }
+
         if (out == null) {
           out = FileOperations.getInstance().openWriter(file.toString(), file.getFileSystem(conf),
conf, acuConf);
           out.startDefaultLocalityGroup();

Modified: accumulo/trunk/core/src/test/java/org/apache/accumulo/core/client/mapreduce/AccumuloFileOutputFormatTest.java
URL: http://svn.apache.org/viewvc/accumulo/trunk/core/src/test/java/org/apache/accumulo/core/client/mapreduce/AccumuloFileOutputFormatTest.java?rev=1426328&r1=1426327&r2=1426328&view=diff
==============================================================================
--- accumulo/trunk/core/src/test/java/org/apache/accumulo/core/client/mapreduce/AccumuloFileOutputFormatTest.java
(original)
+++ accumulo/trunk/core/src/test/java/org/apache/accumulo/core/client/mapreduce/AccumuloFileOutputFormatTest.java
Thu Dec 27 21:06:06 2012
@@ -87,6 +87,23 @@ public class AccumuloFileOutputFormatTes
   }
   
   @Test
+  public void writeBadVisibility() throws IOException, InterruptedException {
+    AccumuloFileOutputFormat afof = new AccumuloFileOutputFormat();
+    RecordWriter<Key,Value> rw = afof.getRecordWriter(tac);
+    
+    Path file = afof.getDefaultWorkFile(tac, ".rf");
+
+    rw.write(new Key("r1", "cf1", "cq1", "A&B"), new Value("".getBytes()));
+    rw.write(new Key("r1", "cf1", "cq2", "A&B"), new Value("".getBytes()));
+    try {
+      rw.write(new Key("r1", "cf1", "cq2", "A&"), new Value("".getBytes()));
+      assertFalse(true);
+    } catch (Exception e) {}
+    
+    file.getFileSystem(tac.getConfiguration()).delete(file.getParent(), true);
+  }
+
+  @Test
   public void validateConfiguration() throws IOException, InterruptedException {
     
     int a = 7;



Mime
View raw message