accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From e..@apache.org
Subject svn commit: r1464194 - in /accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/util/shell/commands: SetIterCommand.java SetScanIterCommand.java SetShellIterCommand.java
Date Wed, 03 Apr 2013 20:31:52 GMT
Author: ecn
Date: Wed Apr  3 20:31:52 2013
New Revision: 1464194

URL: http://svn.apache.org/r1464194
Log:
ACCUMULO-1234 do a local check for classes that are only used locally

Modified:
    accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/util/shell/commands/SetIterCommand.java
    accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/util/shell/commands/SetScanIterCommand.java
    accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/util/shell/commands/SetShellIterCommand.java

Modified: accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/util/shell/commands/SetIterCommand.java
URL: http://svn.apache.org/viewvc/accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/util/shell/commands/SetIterCommand.java?rev=1464194&r1=1464193&r2=1464194&view=diff
==============================================================================
--- accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/util/shell/commands/SetIterCommand.java
(original)
+++ accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/util/shell/commands/SetIterCommand.java
Wed Apr  3 20:31:52 2013
@@ -75,11 +75,22 @@ public class SetIterCommand extends Comm
       classname = ReqVisFilter.class.getName();
     }
     
+    final String name = cl.getOptionValue(nameOpt.getOpt(), setUpOptions(shellState.getReader(),
classname, options));
+    
+    setTableProperties(cl, shellState, priority, options, classname, name);
+    return 0;
+  }
+  
+  protected void setTableProperties(final CommandLine cl, final Shell shellState, final int
priority, final Map<String,String> options, final String classname,
+      final String name) throws AccumuloException, AccumuloSecurityException, ShellCommandException,
TableNotFoundException {
+    // remove empty values
+    
+    final String tableName = OptUtil.getTableOpt(cl, shellState);
+
     if (!shellState.getConnector().instanceOperations().testClassLoad(classname, SortedKeyValueIterator.class.getName()))
{
       throw new ShellCommandException(ErrorCode.INITIALIZATION_FAILURE, "Servers are unable
to load " + classname + " as type "
           + SortedKeyValueIterator.class.getName());
     }
-    final String name = cl.getOptionValue(nameOpt.getOpt(), setUpOptions(shellState.getReader(),
classname, options));
     
     final String aggregatorClass = options.get("aggregatorClass");
     @SuppressWarnings("deprecation")
@@ -88,16 +99,6 @@ public class SetIterCommand extends Comm
       throw new ShellCommandException(ErrorCode.INITIALIZATION_FAILURE, "Servers are unable
to load " + aggregatorClass + " as type "
           + deprecatedAggregatorClassName);
     }
-    setTableProperties(cl, shellState, priority, options, classname, name);
-    
-    return 0;
-  }
-  
-  protected void setTableProperties(final CommandLine cl, final Shell shellState, final int
priority, final Map<String,String> options, final String classname,
-      final String name) throws AccumuloException, AccumuloSecurityException, ShellCommandException,
TableNotFoundException {
-    // remove empty values
-    
-    final String tableName = OptUtil.getTableOpt(cl, shellState);
     
     for (Iterator<Entry<String,String>> i = options.entrySet().iterator(); i.hasNext();)
{
       final Entry<String,String> entry = i.next();

Modified: accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/util/shell/commands/SetScanIterCommand.java
URL: http://svn.apache.org/viewvc/accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/util/shell/commands/SetScanIterCommand.java?rev=1464194&r1=1464193&r2=1464194&view=diff
==============================================================================
--- accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/util/shell/commands/SetScanIterCommand.java
(original)
+++ accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/util/shell/commands/SetScanIterCommand.java
Wed Apr  3 20:31:52 2013
@@ -55,8 +55,16 @@ public class SetScanIterCommand extends 
     final String tableName = OptUtil.getTableOpt(cl, shellState);
 
     // instead of setting table properties, just put the options in a list to use at scan
time
-    if (!shellState.getConnector().instanceOperations().testClassLoad(classname, SortedKeyValueIterator.class.getName()))
{
-      throw new ShellCommandException(ErrorCode.INITIALIZATION_FAILURE, "Servers are unable
to load " + classname + " as type "
+    Class<?> loadClass;
+    try {
+      loadClass = getClass().getClassLoader().loadClass(classname);
+    } catch (ClassNotFoundException e) {
+      throw new ShellCommandException(ErrorCode.INITIALIZATION_FAILURE, "Unable to load "
+ classname);
+    }
+    try {
+      loadClass.asSubclass(SortedKeyValueIterator.class);
+    } catch (ClassCastException ex) {
+      throw new ShellCommandException(ErrorCode.INITIALIZATION_FAILURE, "Unable to load "
+ classname  + " as type "
           + SortedKeyValueIterator.class.getName());
     }
     

Modified: accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/util/shell/commands/SetShellIterCommand.java
URL: http://svn.apache.org/viewvc/accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/util/shell/commands/SetShellIterCommand.java?rev=1464194&r1=1464193&r2=1464194&view=diff
==============================================================================
--- accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/util/shell/commands/SetShellIterCommand.java
(original)
+++ accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/util/shell/commands/SetShellIterCommand.java
Wed Apr  3 20:31:52 2013
@@ -54,8 +54,17 @@ public class SetShellIterCommand extends
     
     String profile = cl.getOptionValue(profileOpt.getOpt());
 
-    if (!shellState.getConnector().instanceOperations().testClassLoad(classname, SortedKeyValueIterator.class.getName()))
{
-      throw new ShellCommandException(ErrorCode.INITIALIZATION_FAILURE, "Servers are unable
to load " + classname + " as type "
+    // instead of setting table properties, just put the options in a list to use at scan
time
+    Class<?> loadClass;
+    try {
+      loadClass = getClass().getClassLoader().loadClass(classname);
+    } catch (ClassNotFoundException e) {
+      throw new ShellCommandException(ErrorCode.INITIALIZATION_FAILURE, "Unable to load "
+ classname);
+    }
+    try {
+      loadClass.asSubclass(SortedKeyValueIterator.class);
+    } catch (ClassCastException ex) {
+      throw new ShellCommandException(ErrorCode.INITIALIZATION_FAILURE, "xUnable to load
" + classname  + " as type "
           + SortedKeyValueIterator.class.getName());
     }
     



Mime
View raw message