accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ktur...@apache.org
Subject svn commit: r1431474 - in /accumulo/trunk: start/src/main/java/org/apache/accumulo/start/classloader/vfs/AccumuloVFSClassLoader.java test/src/test/java/org/apache/accumulo/test/MiniAccumuloClusterTest.java test/src/test/resources/FooFilter.jar
Date Thu, 10 Jan 2013 16:18:48 GMT
Author: kturner
Date: Thu Jan 10 16:18:48 2013
New Revision: 1431474

URL: http://svn.apache.org/viewvc?rev=1431474&view=rev
Log:
ACCUMULO-708 made per table classpaths work with mini accumulo cluster and added a test

Added:
    accumulo/trunk/test/src/test/resources/FooFilter.jar   (with props)
Modified:
    accumulo/trunk/start/src/main/java/org/apache/accumulo/start/classloader/vfs/AccumuloVFSClassLoader.java
    accumulo/trunk/test/src/test/java/org/apache/accumulo/test/MiniAccumuloClusterTest.java

Modified: accumulo/trunk/start/src/main/java/org/apache/accumulo/start/classloader/vfs/AccumuloVFSClassLoader.java
URL: http://svn.apache.org/viewvc/accumulo/trunk/start/src/main/java/org/apache/accumulo/start/classloader/vfs/AccumuloVFSClassLoader.java?rev=1431474&r1=1431473&r2=1431474&view=diff
==============================================================================
--- accumulo/trunk/start/src/main/java/org/apache/accumulo/start/classloader/vfs/AccumuloVFSClassLoader.java
(original)
+++ accumulo/trunk/start/src/main/java/org/apache/accumulo/start/classloader/vfs/AccumuloVFSClassLoader.java
Thu Jan 10 16:18:48 2013
@@ -297,6 +297,7 @@ public class AccumuloVFSClassLoader {
   
   public static synchronized ContextManager getContextManager() throws IOException {
     if (contextManager == null) {
+      getClassLoader();
       contextManager = new ContextManager(vfs, new ReloadingClassLoader() {
         @Override
         public ClassLoader getClassLoader() {

Modified: accumulo/trunk/test/src/test/java/org/apache/accumulo/test/MiniAccumuloClusterTest.java
URL: http://svn.apache.org/viewvc/accumulo/trunk/test/src/test/java/org/apache/accumulo/test/MiniAccumuloClusterTest.java?rev=1431474&r1=1431473&r2=1431474&view=diff
==============================================================================
--- accumulo/trunk/test/src/test/java/org/apache/accumulo/test/MiniAccumuloClusterTest.java
(original)
+++ accumulo/trunk/test/src/test/java/org/apache/accumulo/test/MiniAccumuloClusterTest.java
Thu Jan 10 16:18:48 2013
@@ -16,6 +16,7 @@
  */
 package org.apache.accumulo.test;
 
+import java.io.File;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.Map.Entry;
@@ -27,6 +28,7 @@ import org.apache.accumulo.core.client.C
 import org.apache.accumulo.core.client.IteratorSetting;
 import org.apache.accumulo.core.client.Scanner;
 import org.apache.accumulo.core.client.ZooKeeperInstance;
+import org.apache.accumulo.core.conf.Property;
 import org.apache.accumulo.core.data.Key;
 import org.apache.accumulo.core.data.Mutation;
 import org.apache.accumulo.core.data.Value;
@@ -35,6 +37,7 @@ import org.apache.accumulo.core.iterator
 import org.apache.accumulo.core.security.Authorizations;
 import org.apache.accumulo.core.security.ColumnVisibility;
 import org.apache.accumulo.core.security.TablePermission;
+import org.apache.commons.io.FileUtils;
 import org.junit.AfterClass;
 import org.junit.Assert;
 import org.junit.BeforeClass;
@@ -129,6 +132,52 @@ public class MiniAccumuloClusterTest {
     conn.tableOperations().delete("table1");
   }
   
+  @Test(timeout = 30000)
+  public void testPerTableClasspath() throws Exception {
+    
+    Connector conn = new ZooKeeperInstance(accumulo.getInstanceName(), accumulo.getZookeepers()).getConnector("root",
"superSecret");
+    
+    conn.tableOperations().create("table2");
+    
+    File jarFile = File.createTempFile("iterator", ".jar");
+    FileUtils.copyURLToFile(this.getClass().getResource("/FooFilter.jar"), jarFile);
+    jarFile.deleteOnExit();
+
+    conn.instanceOperations().setProperty(Property.VFS_CONTEXT_CLASSPATH_PROPERTY.getKey()
+ "cx1", jarFile.toURI().toString());
+    conn.tableOperations().setProperty("table2", Property.TABLE_CLASSPATH.getKey(), "cx1");
+    conn.tableOperations().attachIterator("table2", new IteratorSetting(100, "foocensor",
"org.apache.accumulo.test.FooFilter"));
+
+    BatchWriter bw = conn.createBatchWriter("table2", new BatchWriterConfig());
+    
+    Mutation m1 = new Mutation("foo");
+    m1.put("cf1", "cq1", "v2");
+    m1.put("cf1", "cq2", "v3");
+    
+    bw.addMutation(m1);
+    
+    Mutation m2 = new Mutation("bar");
+    m2.put("cf1", "cq1", "v6");
+    m2.put("cf1", "cq2", "v7");
+    
+    bw.addMutation(m2);
+    
+    bw.close();
+    
+    Scanner scanner = conn.createScanner("table2", new Authorizations());
+    
+    int count = 0;
+    for (Entry<Key,Value> entry : scanner) {
+      Assert.assertFalse(entry.getKey().getRowData().toString().toLowerCase().contains("foo"));
+      count++;
+    }
+    
+    Assert.assertEquals(2, count);
+    
+    conn.instanceOperations().removeProperty(Property.VFS_CONTEXT_CLASSPATH_PROPERTY.getKey()
+ "cx1");
+    conn.tableOperations().delete("table2");
+
+  }
+
   @AfterClass
   public static void tearDownMiniCluster() throws Exception {
     accumulo.stop();

Added: accumulo/trunk/test/src/test/resources/FooFilter.jar
URL: http://svn.apache.org/viewvc/accumulo/trunk/test/src/test/resources/FooFilter.jar?rev=1431474&view=auto
==============================================================================
Binary file - no diff available.

Propchange: accumulo/trunk/test/src/test/resources/FooFilter.jar
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream



Mime
View raw message