accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ktur...@apache.org
Subject svn commit: r1478583 [3/3] - in /accumulo/trunk: ./ assemble/ core/ core/src/main/java/org/apache/accumulo/core/client/admin/ core/src/main/java/org/apache/accumulo/core/client/impl/thrift/ core/src/main/java/org/apache/accumulo/core/client/mapreduce/l...
Date Thu, 02 May 2013 21:49:25 GMT
Modified: accumulo/trunk/proxy/src/main/thrift/proxy.thrift
URL: http://svn.apache.org/viewvc/accumulo/trunk/proxy/src/main/thrift/proxy.thrift?rev=1478583&r1=1478582&r2=1478583&view=diff
==============================================================================
--- accumulo/trunk/proxy/src/main/thrift/proxy.thrift (original)
+++ accumulo/trunk/proxy/src/main/thrift/proxy.thrift Thu May  2 21:49:24 2013
@@ -262,6 +262,7 @@ service AccumuloProxy
   void flushTable (1:binary login, 2:string tableName, 3:binary startRow, 4:binary endRow,

                    5:bool wait)
                                                                                         
              throws (1:AccumuloException ouch1, 2:AccumuloSecurityException ouch2, 3:TableNotFoundException
ouch3);
+  list<DiskUsage> getDiskUsage(1:binary login, 2:set<string> tables)        
                          throws (1:AccumuloException ouch1, 2:AccumuloSecurityException ouch2,
3:TableNotFoundException ouch3);
   map<string,set<string>> getLocalityGroups (1:binary login, 2:string tableName)
                      throws (1:AccumuloException ouch1, 2:AccumuloSecurityException ouch2,
3:TableNotFoundException ouch3);
   IteratorSetting getIteratorSetting (1:binary login, 2:string tableName, 
                                       3:string iteratorName, 4:IteratorScope scope) 
@@ -292,7 +293,8 @@ service AccumuloProxy
   set<Range> splitRangeByTablets (1:binary login, 2:string tableName, 3:Range range,
4:i32 maxSplits)  throws (1:AccumuloException ouch1, 2:AccumuloSecurityException ouch2, 3:TableNotFoundException
ouch3);
   bool tableExists (1:binary login, 2:string tableName);
   map<string,string> tableIdMap (1:binary login);
-  list<DiskUsage> getDiskUsage(1:binary login, 2:set<string> tables)        
                            throws (1:AccumuloException ouch1, 2:AccumuloSecurityException
ouch2, 3:TableNotFoundException ouch3);
+  bool testTableClassLoad (1:binary login, 2:string tableName, 3:string className       
             
+                           , 4:string asTypeName)                                       
              throws (1:AccumuloException ouch1, 2:AccumuloSecurityException ouch2, 3:TableNotFoundException
ouch3);
 
   // instance operations
   void pingTabletServer(1:binary login, 2:string tserver)                               
            throws (1:AccumuloException ouch1, 2:AccumuloSecurityException ouch2);

Modified: accumulo/trunk/proxy/src/test/java/org/apache/accumulo/proxy/SimpleTest.java
URL: http://svn.apache.org/viewvc/accumulo/trunk/proxy/src/test/java/org/apache/accumulo/proxy/SimpleTest.java?rev=1478583&r1=1478582&r2=1478583&view=diff
==============================================================================
--- accumulo/trunk/proxy/src/test/java/org/apache/accumulo/proxy/SimpleTest.java (original)
+++ accumulo/trunk/proxy/src/test/java/org/apache/accumulo/proxy/SimpleTest.java Thu May 
2 21:49:24 2013
@@ -50,6 +50,7 @@ import org.apache.accumulo.core.file.Fil
 import org.apache.accumulo.core.iterators.DevNull;
 import org.apache.accumulo.core.iterators.SortedKeyValueIterator;
 import org.apache.accumulo.core.iterators.user.SummingCombiner;
+import org.apache.accumulo.core.iterators.user.VersioningIterator;
 import org.apache.accumulo.core.util.UtilWaitThread;
 import org.apache.accumulo.examples.simple.constraints.NumericValueConstraint;
 import org.apache.accumulo.proxy.thrift.AccumuloProxy.Client;
@@ -312,6 +313,10 @@ public class SimpleTest {
       client.getDiskUsage(creds, Collections.singleton(doesNotExist));
       fail("exception not thrown");
     } catch (TableNotFoundException ex) {}
+    try {
+      client.testTableClassLoad(creds, doesNotExist, VersioningIterator.class.getName(),
SortedKeyValueIterator.class.getName());
+      fail("exception not thrown");
+    } catch (TableNotFoundException ex) {}
   }
   
   @Test(timeout = 10000)
@@ -819,6 +824,9 @@ public class SimpleTest {
     assertEquals(1, more.results.size());
     ByteBuffer maxRow = client.getMaxRow(creds, "bar", null, null, false, null, false);
     assertEquals(s2bb("a"), maxRow);
+    
+    assertFalse(client.testTableClassLoad(creds, "bar", "abc123", SortedKeyValueIterator.class.getName()));
+    assertTrue(client.testTableClassLoad(creds, "bar", VersioningIterator.class.getName(),
SortedKeyValueIterator.class.getName()));
   }
   
   // scan !METADATA table for file entries for the given table

Propchange: accumulo/trunk/server/
------------------------------------------------------------------------------
  Merged /accumulo/branches/1.5/server:r1478511

Modified: accumulo/trunk/server/src/main/java/org/apache/accumulo/server/client/ClientServiceHandler.java
URL: http://svn.apache.org/viewvc/accumulo/trunk/server/src/main/java/org/apache/accumulo/server/client/ClientServiceHandler.java?rev=1478583&r1=1478582&r2=1478583&view=diff
==============================================================================
--- accumulo/trunk/server/src/main/java/org/apache/accumulo/server/client/ClientServiceHandler.java
(original)
+++ accumulo/trunk/server/src/main/java/org/apache/accumulo/server/client/ClientServiceHandler.java
Thu May  2 21:49:24 2013
@@ -250,6 +250,8 @@ public class ClientServiceHandler implem
   @SuppressWarnings({"rawtypes", "unchecked"})
   @Override
   public boolean checkClass(TInfo tinfo, TCredentials credentials, String className, String
interfaceMatch) throws TException {
+    security.authenticateUser(credentials, credentials);
+    
     ClassLoader loader = getClass().getClassLoader();
     Class shouldMatch;
     try {
@@ -271,4 +273,39 @@ public class ClientServiceHandler implem
       return false;
     }
   }
+  
+  @SuppressWarnings({"rawtypes", "unchecked"})
+  @Override
+  public boolean checkTableClass(TInfo tinfo, TCredentials credentials, String tableName,
String className, String interfaceMatch) throws TException,
+      ThriftTableOperationException, ThriftSecurityException {
+    
+    security.authenticateUser(credentials, credentials);
+    
+    String tableId = checkTableId(tableName, null);
+
+    ClassLoader loader = getClass().getClassLoader();
+    Class shouldMatch;
+    try {
+      shouldMatch = loader.loadClass(interfaceMatch);
+      
+      new ServerConfiguration(instance).getTableConfiguration(tableId);
+      
+      String context = new ServerConfiguration(instance).getTableConfiguration(tableId).get(Property.TABLE_CLASSPATH);
+      
+      ClassLoader currentLoader;
+      
+      if (context != null && !context.equals("")) {
+        currentLoader = AccumuloVFSClassLoader.getContextManager().getClassLoader(context);
+      } else {
+        currentLoader = AccumuloVFSClassLoader.getClassLoader();
+      }
+      
+      Class test = currentLoader.loadClass(className).asSubclass(shouldMatch);
+      test.newInstance();
+      return true;
+    } catch (Exception e) {
+      log.warn("Error checking object types", e);
+      return false;
+    }
+  }
 }

Modified: accumulo/trunk/server/src/main/java/org/apache/accumulo/server/tabletserver/TabletServer.java
URL: http://svn.apache.org/viewvc/accumulo/trunk/server/src/main/java/org/apache/accumulo/server/tabletserver/TabletServer.java?rev=1478583&r1=1478582&r2=1478583&view=diff
==============================================================================
--- accumulo/trunk/server/src/main/java/org/apache/accumulo/server/tabletserver/TabletServer.java
(original)
+++ accumulo/trunk/server/src/main/java/org/apache/accumulo/server/tabletserver/TabletServer.java
Thu May  2 21:49:24 2013
@@ -208,7 +208,6 @@ import org.apache.accumulo.server.zookee
 import org.apache.accumulo.start.Platform;
 import org.apache.accumulo.start.classloader.vfs.AccumuloVFSClassLoader;
 import org.apache.accumulo.start.classloader.vfs.ContextManager;
-import org.apache.accumulo.start.classloader.vfs.ContextManager.ContextConfig;
 import org.apache.accumulo.trace.instrument.Span;
 import org.apache.accumulo.trace.instrument.Trace;
 import org.apache.accumulo.trace.instrument.thrift.TraceWrap;
@@ -3079,32 +3078,12 @@ public class TabletServer extends Abstra
     }
     
     try {
-      AccumuloVFSClassLoader.getContextManager().setContextConfig(new ContextManager.ContextsConfig()
{
+      AccumuloVFSClassLoader.getContextManager().setContextConfig(new ContextManager.DefaultContextsConfig(new
Iterable<Entry<String,String>>() {
         @Override
-        public ContextConfig getContextConfig(String context) {
-          String key = Property.VFS_CONTEXT_CLASSPATH_PROPERTY.getKey() + context;
-          
-          String uris = null;
-          boolean preDelegate = true;
-          
-          Iterator<Entry<String,String>> iter = getSystemConfiguration().iterator();
-          while (iter.hasNext()) {
-            Entry<String,String> entry = iter.next();
-            if (entry.getKey().equals(key)) {
-              uris = entry.getValue();
-            }
-            
-            if (entry.getKey().equals(key + ".delegation") && entry.getValue().trim().equalsIgnoreCase("post"))
{
-              preDelegate = false;
-            }
-          }
-          
-          if (uris != null)
-            return new ContextConfig(uris, preDelegate);
-          
-          return null;
+        public Iterator<Entry<String,String>> iterator() {
+          return getSystemConfiguration().iterator();
         }
-      });
+      }));
     } catch (IOException e) {
       throw new RuntimeException(e);
     }

Propchange: accumulo/trunk/src/
------------------------------------------------------------------------------
  Merged /accumulo/branches/1.5/src:r1478511

Modified: accumulo/trunk/start/src/main/java/org/apache/accumulo/start/classloader/vfs/ContextManager.java
URL: http://svn.apache.org/viewvc/accumulo/trunk/start/src/main/java/org/apache/accumulo/start/classloader/vfs/ContextManager.java?rev=1478583&r1=1478582&r2=1478583&view=diff
==============================================================================
--- accumulo/trunk/start/src/main/java/org/apache/accumulo/start/classloader/vfs/ContextManager.java
(original)
+++ accumulo/trunk/start/src/main/java/org/apache/accumulo/start/classloader/vfs/ContextManager.java
Thu May  2 21:49:24 2013
@@ -18,7 +18,9 @@ package org.apache.accumulo.start.classl
 
 import java.io.IOException;
 import java.util.HashMap;
+import java.util.Iterator;
 import java.util.Map;
+import java.util.Map.Entry;
 import java.util.Set;
 
 import org.apache.commons.vfs2.FileSystemException;
@@ -95,6 +97,41 @@ public class ContextManager {
     ContextConfig getContextConfig(String context);
   }
   
+  public static class DefaultContextsConfig implements ContextsConfig {
+    
+    private Iterable<Entry<String,String>> config;
+    
+    public DefaultContextsConfig(Iterable<Entry<String,String>> config) {
+      this.config = config;
+    }
+    
+    @Override
+    public ContextConfig getContextConfig(String context) {
+      
+      String key = AccumuloVFSClassLoader.VFS_CONTEXT_CLASSPATH_PROPERTY + context;
+      
+      String uris = null;
+      boolean preDelegate = true;
+      
+      Iterator<Entry<String,String>> iter = config.iterator();
+      while (iter.hasNext()) {
+        Entry<String,String> entry = iter.next();
+        if (entry.getKey().equals(key)) {
+          uris = entry.getValue();
+        }
+        
+        if (entry.getKey().equals(key + ".delegation") && entry.getValue().trim().equalsIgnoreCase("post"))
{
+          preDelegate = false;
+        }
+      }
+      
+      if (uris != null)
+        return new ContextConfig(uris, preDelegate);
+      
+      return null;
+    }
+  }
+
   /**
    * configuration must be injected for ContextManager to work
    * 

Modified: accumulo/trunk/test/src/test/java/org/apache/accumulo/test/ShellServerTest.java
URL: http://svn.apache.org/viewvc/accumulo/trunk/test/src/test/java/org/apache/accumulo/test/ShellServerTest.java?rev=1478583&r1=1478582&r2=1478583&view=diff
==============================================================================
--- accumulo/trunk/test/src/test/java/org/apache/accumulo/test/ShellServerTest.java (original)
+++ accumulo/trunk/test/src/test/java/org/apache/accumulo/test/ShellServerTest.java Thu May
 2 21:49:24 2013
@@ -39,6 +39,7 @@ import org.apache.accumulo.core.client.S
 import org.apache.accumulo.core.client.ZooKeeperInstance;
 import org.apache.accumulo.core.client.security.tokens.PasswordToken;
 import org.apache.accumulo.core.conf.AccumuloConfiguration;
+import org.apache.accumulo.core.conf.Property;
 import org.apache.accumulo.core.data.Key;
 import org.apache.accumulo.core.data.Value;
 import org.apache.accumulo.core.file.FileOperations;
@@ -46,6 +47,7 @@ import org.apache.accumulo.core.file.Fil
 import org.apache.accumulo.core.util.UtilWaitThread;
 import org.apache.accumulo.core.util.shell.Shell;
 import org.apache.accumulo.server.trace.TraceServer;
+import org.apache.commons.io.FileUtils;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.fs.Path;
@@ -242,7 +244,7 @@ public class ShellServerTest {
     output.clear();
     shell.execCommand("du -h", false, false);
     String o = output.get();
-    assertTrue(o.matches(".*26[0-9]\\s\\[t\\]\\n"));  // for some reason, there's 1-2 bytes
of fluctuation
+    assertTrue(o.matches(".*26[0-9]\\s\\[t\\]\\n")); // for some reason, there's 1-2 bytes
of fluctuation
     exec("deletetable -f t");
   }
   
@@ -360,7 +362,7 @@ public class ShellServerTest {
   public void addauths() throws Exception {
     // addauths
     exec("createtable xyzzy -evc");
-    exec("insert a b c d -l foo", true, "does not have authorization", true);
+    exec("insert a b c d -l foo", false, "does not have authorization", true);
     exec("addauths -s foo,bar", true);
     exec("getauths", true, "foo", true);
     exec("getauths", true, "bar", true);
@@ -703,6 +705,48 @@ public class ShellServerTest {
   }
   
   @Test(timeout = 30000)
+  public void testPertableClasspath() throws Exception {
+    File fooFilterJar = File.createTempFile("FooFilter", ".jar");
+    FileUtils.copyURLToFile(this.getClass().getResource("/FooFilter.jar"), fooFilterJar);
+    fooFilterJar.deleteOnExit();
+    
+    File fooConstraintJar = File.createTempFile("FooConstraint", ".jar");
+    FileUtils.copyURLToFile(this.getClass().getResource("/FooConstraint.jar"), fooConstraintJar);
+    fooConstraintJar.deleteOnExit();
+    
+    exec(
+        "config -s " + Property.VFS_CONTEXT_CLASSPATH_PROPERTY.getKey() + "cx1=" + fooFilterJar.toURI().toString()
+ "," + fooConstraintJar.toURI().toString(),
+        true);
+    
+    exec("createtable ptc", true);
+    exec("config -t ptc -s " + Property.TABLE_CLASSPATH.getKey() + "=cx1", true);
+    
+    UtilWaitThread.sleep(200);
+    
+    exec("setiter -scan -class org.apache.accumulo.test.FooFilter -p 10 -n foo", true);
+    
+    exec("insert foo f q v", true);
+    
+    UtilWaitThread.sleep(100);
+
+    exec("scan -np", true, "foo", false);
+
+    exec("constraint -a FooConstraint", true);
+    
+    exec("offline ptc");
+    UtilWaitThread.sleep(500);
+    exec("online ptc");
+
+    exec("table ptc", true);
+    exec("insert foo f q v", false);
+    exec("insert ok foo q v", true);
+    
+    exec("deletetable ptc", true);
+    exec("config -d " + Property.VFS_CONTEXT_CLASSPATH_PROPERTY.getKey() + "cx1");
+
+  }
+  
+  @Test(timeout = 30000)
   public void trace() throws Exception {
     exec("trace on", true);
     exec("createtable t", true);



Mime
View raw message