accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ctubb...@apache.org
Subject svn commit: r1491605 - in /accumulo/branches/ACCUMULO-1496: ./ api/ api/src/ api/src/main/ api/src/main/java/ api/src/main/java/org/ api/src/main/java/org/apache/ api/src/main/java/org/apache/accumulo/ api/src/main/java/org/apache/accumulo/api/ api/src...
Date Mon, 10 Jun 2013 21:23:31 GMT
Author: ctubbsii
Date: Mon Jun 10 21:23:30 2013
New Revision: 1491605

URL: http://svn.apache.org/r1491605
Log:
ACCUMULO-1496 Use classloader to locate annotated launchable classes

Added:
    accumulo/branches/ACCUMULO-1496/api/   (with props)
    accumulo/branches/ACCUMULO-1496/api/pom.xml
    accumulo/branches/ACCUMULO-1496/api/src/
    accumulo/branches/ACCUMULO-1496/api/src/main/
    accumulo/branches/ACCUMULO-1496/api/src/main/java/
    accumulo/branches/ACCUMULO-1496/api/src/main/java/org/
    accumulo/branches/ACCUMULO-1496/api/src/main/java/org/apache/
    accumulo/branches/ACCUMULO-1496/api/src/main/java/org/apache/accumulo/
    accumulo/branches/ACCUMULO-1496/api/src/main/java/org/apache/accumulo/api/
    accumulo/branches/ACCUMULO-1496/api/src/main/java/org/apache/accumulo/api/annotations/
    accumulo/branches/ACCUMULO-1496/api/src/main/java/org/apache/accumulo/api/annotations/AccumuloService.java
    accumulo/branches/ACCUMULO-1496/api/src/test/
    accumulo/branches/ACCUMULO-1496/api/src/test/java/
Removed:
    accumulo/branches/ACCUMULO-1496/start/src/test/java/org/apache/commons/
Modified:
    accumulo/branches/ACCUMULO-1496/assemble/pom.xml
    accumulo/branches/ACCUMULO-1496/assemble/src/main/assemblies/component.xml
    accumulo/branches/ACCUMULO-1496/bin/accumulo
    accumulo/branches/ACCUMULO-1496/core/src/main/java/org/apache/accumulo/core/file/rfile/PrintInfo.java
    accumulo/branches/ACCUMULO-1496/core/src/main/java/org/apache/accumulo/core/util/CreateToken.java
    accumulo/branches/ACCUMULO-1496/core/src/main/java/org/apache/accumulo/core/util/shell/Shell.java
    accumulo/branches/ACCUMULO-1496/minicluster/src/main/java/org/apache/accumulo/minicluster/MiniAccumuloRunner.java
    accumulo/branches/ACCUMULO-1496/pom.xml
    accumulo/branches/ACCUMULO-1496/proxy/src/main/java/org/apache/accumulo/proxy/Proxy.java
    accumulo/branches/ACCUMULO-1496/server/src/main/java/org/apache/accumulo/server/gc/SimpleGarbageCollector.java
    accumulo/branches/ACCUMULO-1496/server/src/main/java/org/apache/accumulo/server/master/Master.java
    accumulo/branches/ACCUMULO-1496/server/src/main/java/org/apache/accumulo/server/monitor/Monitor.java
    accumulo/branches/ACCUMULO-1496/server/src/main/java/org/apache/accumulo/server/tabletserver/TabletServer.java
    accumulo/branches/ACCUMULO-1496/server/src/main/java/org/apache/accumulo/server/trace/TraceServer.java
    accumulo/branches/ACCUMULO-1496/server/src/main/java/org/apache/accumulo/server/util/Admin.java
    accumulo/branches/ACCUMULO-1496/server/src/main/java/org/apache/accumulo/server/util/Initialize.java
    accumulo/branches/ACCUMULO-1496/server/src/main/java/org/apache/accumulo/server/util/ZooKeeperMain.java
    accumulo/branches/ACCUMULO-1496/start/pom.xml
    accumulo/branches/ACCUMULO-1496/start/src/main/java/org/apache/accumulo/start/Main.java
    accumulo/branches/ACCUMULO-1496/start/src/main/java/org/apache/accumulo/start/classloader/vfs/AccumuloVFSClassLoader.java

Propchange: accumulo/branches/ACCUMULO-1496/api/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Mon Jun 10 21:23:30 2013
@@ -0,0 +1,3 @@
+.*
+target
+accumulo-api.iml

Added: accumulo/branches/ACCUMULO-1496/api/pom.xml
URL: http://svn.apache.org/viewvc/accumulo/branches/ACCUMULO-1496/api/pom.xml?rev=1491605&view=auto
==============================================================================
--- accumulo/branches/ACCUMULO-1496/api/pom.xml (added)
+++ accumulo/branches/ACCUMULO-1496/api/pom.xml Mon Jun 10 21:23:30 2013
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+  <parent>
+    <groupId>org.apache.accumulo</groupId>
+    <artifactId>accumulo-project</artifactId>
+    <version>1.6.0-SNAPSHOT</version>
+  </parent>
+  <artifactId>accumulo-api</artifactId>
+  <name>API</name>
+</project>

Added: accumulo/branches/ACCUMULO-1496/api/src/main/java/org/apache/accumulo/api/annotations/AccumuloService.java
URL: http://svn.apache.org/viewvc/accumulo/branches/ACCUMULO-1496/api/src/main/java/org/apache/accumulo/api/annotations/AccumuloService.java?rev=1491605&view=auto
==============================================================================
--- accumulo/branches/ACCUMULO-1496/api/src/main/java/org/apache/accumulo/api/annotations/AccumuloService.java
(added)
+++ accumulo/branches/ACCUMULO-1496/api/src/main/java/org/apache/accumulo/api/annotations/AccumuloService.java
Mon Jun 10 21:23:30 2013
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.accumulo.api.annotations;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Annotation to describe a class that can be launched by Accumulo
+ * 
+ * @since 1.6.0
+ */
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.TYPE)
+public @interface AccumuloService {
+  String value();
+}

Modified: accumulo/branches/ACCUMULO-1496/assemble/pom.xml
URL: http://svn.apache.org/viewvc/accumulo/branches/ACCUMULO-1496/assemble/pom.xml?rev=1491605&r1=1491604&r2=1491605&view=diff
==============================================================================
--- accumulo/branches/ACCUMULO-1496/assemble/pom.xml (original)
+++ accumulo/branches/ACCUMULO-1496/assemble/pom.xml Mon Jun 10 21:23:30 2013
@@ -47,6 +47,14 @@
       <artifactId>jline</artifactId>
     </dependency>
     <dependency>
+      <groupId>net.sf.scannotation</groupId>
+      <artifactId>scannotation</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.accumulo</groupId>
+      <artifactId>accumulo-api</artifactId>
+    </dependency>
+    <dependency>
       <groupId>org.apache.accumulo</groupId>
       <artifactId>accumulo-core</artifactId>
     </dependency>
@@ -90,6 +98,10 @@
       <groupId>org.apache.thrift</groupId>
       <artifactId>libthrift</artifactId>
     </dependency>
+    <dependency>
+      <groupId>org.javassist</groupId>
+      <artifactId>javassist</artifactId>
+    </dependency>
   </dependencies>
   <profiles>
     <profile>

Modified: accumulo/branches/ACCUMULO-1496/assemble/src/main/assemblies/component.xml
URL: http://svn.apache.org/viewvc/accumulo/branches/ACCUMULO-1496/assemble/src/main/assemblies/component.xml?rev=1491605&r1=1491604&r2=1491605&view=diff
==============================================================================
--- accumulo/branches/ACCUMULO-1496/assemble/src/main/assemblies/component.xml (original)
+++ accumulo/branches/ACCUMULO-1496/assemble/src/main/assemblies/component.xml Mon Jun 10
21:23:30 2013
@@ -32,7 +32,9 @@
         <include>com.google.code.gson:gson</include>
         <include>com.google.guava:guava</include>
         <include>jline:jline</include>
+        <include>net.sf.scannotation:scannotation</include>
         <include>org.apache.thrift:libthrift</include>
+        <include>org.javassist:javassist</include>
       </includes>
       <excludes>
         <exclude>${groupId}:${artifactId}-docs</exclude>

Modified: accumulo/branches/ACCUMULO-1496/bin/accumulo
URL: http://svn.apache.org/viewvc/accumulo/branches/ACCUMULO-1496/bin/accumulo?rev=1491605&r1=1491604&r2=1491605&view=diff
==============================================================================
--- accumulo/branches/ACCUMULO-1496/bin/accumulo (original)
+++ accumulo/branches/ACCUMULO-1496/bin/accumulo Mon Jun 10 21:23:30 2013
@@ -29,6 +29,9 @@ script=$( basename "$SOURCE" )
 . "$bin"/config.sh
 
 START_JAR=$ACCUMULO_HOME/lib/accumulo-start.jar
+API_JAR=$ACCUMULO_HOME/lib/accumulo-api.jar
+SCANNOTATION_JAR=$ACCUMULO_HOME/lib/scannotation.jar
+JAVASSIST_JAR=$ACCUMULO_HOME/lib/javassist.jar
 
 #
 # Resolve a program to its installation directory
@@ -81,7 +84,7 @@ esac
 
 XML_FILES=${ACCUMULO_HOME}/conf
 LOG4J_JAR=$(find $HADOOP_PREFIX/lib $HADOOP_PREFIX/share/hadoop/common/lib -name 'log4j*.jar'
-print 2>/dev/null | head -1)
-CLASSPATH=${XML_FILES}:${START_JAR}:${LOG4J_JAR}
+CLASSPATH=${XML_FILES}:${API_JAR}:${JAVASSIST_JAR}:${SCANNOTATION_JAR}:${START_JAR}:${LOG4J_JAR}
 
 if [ -z "$JAVA_HOME" -o ! -d "$JAVA_HOME" ]; then
    echo "JAVA_HOME is not set or is not a directory.  Please make sure it's set globally
or in conf/accumulo-env.sh"

Modified: accumulo/branches/ACCUMULO-1496/core/src/main/java/org/apache/accumulo/core/file/rfile/PrintInfo.java
URL: http://svn.apache.org/viewvc/accumulo/branches/ACCUMULO-1496/core/src/main/java/org/apache/accumulo/core/file/rfile/PrintInfo.java?rev=1491605&r1=1491604&r2=1491605&view=diff
==============================================================================
--- accumulo/branches/ACCUMULO-1496/core/src/main/java/org/apache/accumulo/core/file/rfile/PrintInfo.java
(original)
+++ accumulo/branches/ACCUMULO-1496/core/src/main/java/org/apache/accumulo/core/file/rfile/PrintInfo.java
Mon Jun 10 21:23:30 2013
@@ -19,6 +19,7 @@ package org.apache.accumulo.core.file.rf
 import java.util.ArrayList;
 import java.util.List;
 
+import org.apache.accumulo.api.annotations.AccumuloService;
 import org.apache.accumulo.core.cli.Help;
 import org.apache.accumulo.core.conf.AccumuloConfiguration;
 import org.apache.accumulo.core.data.ByteSequence;
@@ -34,6 +35,7 @@ import org.apache.hadoop.fs.Path;
 
 import com.beust.jcommander.Parameter;
 
+@AccumuloService("rfile-info")
 public class PrintInfo {
   
   static class Opts extends Help {
@@ -49,7 +51,7 @@ public class PrintInfo {
     Configuration conf = new Configuration();
     @SuppressWarnings("deprecation")
     FileSystem hadoopFs = FileUtil.getFileSystem(conf, AccumuloConfiguration.getSiteConfiguration());
-    FileSystem localFs  = FileSystem.getLocal(conf);
+    FileSystem localFs = FileSystem.getLocal(conf);
     Opts opts = new Opts();
     opts.parseArgs(PrintInfo.class.getName(), args);
     if (opts.files.isEmpty()) {

Modified: accumulo/branches/ACCUMULO-1496/core/src/main/java/org/apache/accumulo/core/util/CreateToken.java
URL: http://svn.apache.org/viewvc/accumulo/branches/ACCUMULO-1496/core/src/main/java/org/apache/accumulo/core/util/CreateToken.java?rev=1491605&r1=1491604&r2=1491605&view=diff
==============================================================================
--- accumulo/branches/ACCUMULO-1496/core/src/main/java/org/apache/accumulo/core/util/CreateToken.java
(original)
+++ accumulo/branches/ACCUMULO-1496/core/src/main/java/org/apache/accumulo/core/util/CreateToken.java
Mon Jun 10 21:23:30 2013
@@ -23,6 +23,7 @@ import java.io.PrintStream;
 
 import jline.console.ConsoleReader;
 
+import org.apache.accumulo.api.annotations.AccumuloService;
 import org.apache.accumulo.core.Constants;
 import org.apache.accumulo.core.cli.ClientOpts.Password;
 import org.apache.accumulo.core.cli.ClientOpts.PasswordConverter;
@@ -35,6 +36,7 @@ import org.apache.accumulo.core.security
 
 import com.beust.jcommander.Parameter;
 
+@AccumuloService("create-token")
 public class CreateToken {
   
   private static ConsoleReader reader = null;

Modified: accumulo/branches/ACCUMULO-1496/core/src/main/java/org/apache/accumulo/core/util/shell/Shell.java
URL: http://svn.apache.org/viewvc/accumulo/branches/ACCUMULO-1496/core/src/main/java/org/apache/accumulo/core/util/shell/Shell.java?rev=1491605&r1=1491604&r2=1491605&view=diff
==============================================================================
--- accumulo/branches/ACCUMULO-1496/core/src/main/java/org/apache/accumulo/core/util/shell/Shell.java
(original)
+++ accumulo/branches/ACCUMULO-1496/core/src/main/java/org/apache/accumulo/core/util/shell/Shell.java
Mon Jun 10 21:23:30 2013
@@ -37,6 +37,7 @@ import java.util.UUID;
 import jline.console.ConsoleReader;
 import jline.console.history.FileHistory;
 
+import org.apache.accumulo.api.annotations.AccumuloService;
 import org.apache.accumulo.core.Constants;
 import org.apache.accumulo.core.client.AccumuloException;
 import org.apache.accumulo.core.client.AccumuloSecurityException;
@@ -158,6 +159,7 @@ import com.beust.jcommander.ParameterExc
 /**
  * A convenient console interface to perform basic accumulo functions Includes auto-complete,
help, and quoted strings with escape sequences
  */
+@AccumuloService("shell")
 public class Shell extends ShellOptions {
   public static final Logger log = Logger.getLogger(Shell.class);
   private static final Logger audit = Logger.getLogger(Shell.class.getName() + ".audit");

Modified: accumulo/branches/ACCUMULO-1496/minicluster/src/main/java/org/apache/accumulo/minicluster/MiniAccumuloRunner.java
URL: http://svn.apache.org/viewvc/accumulo/branches/ACCUMULO-1496/minicluster/src/main/java/org/apache/accumulo/minicluster/MiniAccumuloRunner.java?rev=1491605&r1=1491604&r2=1491605&view=diff
==============================================================================
--- accumulo/branches/ACCUMULO-1496/minicluster/src/main/java/org/apache/accumulo/minicluster/MiniAccumuloRunner.java
(original)
+++ accumulo/branches/ACCUMULO-1496/minicluster/src/main/java/org/apache/accumulo/minicluster/MiniAccumuloRunner.java
Mon Jun 10 21:23:30 2013
@@ -27,6 +27,7 @@ import java.util.Map;
 import java.util.Properties;
 import java.util.regex.Pattern;
 
+import org.apache.accumulo.api.annotations.AccumuloService;
 import org.apache.accumulo.core.cli.Help;
 import org.apache.accumulo.core.util.Pair;
 import org.apache.commons.io.FileUtils;
@@ -58,6 +59,7 @@ import com.google.common.io.Files;
  * 
  * @since 1.6.0
  */
+@AccumuloService("minicluster")
 public class MiniAccumuloRunner {
   public static class PropertiesConverter implements IStringConverter<Properties> {
     @Override

Modified: accumulo/branches/ACCUMULO-1496/pom.xml
URL: http://svn.apache.org/viewvc/accumulo/branches/ACCUMULO-1496/pom.xml?rev=1491605&r1=1491604&r2=1491605&view=diff
==============================================================================
--- accumulo/branches/ACCUMULO-1496/pom.xml (original)
+++ accumulo/branches/ACCUMULO-1496/pom.xml Mon Jun 10 21:23:30 2013
@@ -72,6 +72,7 @@
     <maven>${maven.min-version}</maven>
   </prerequisites>
   <modules>
+    <module>api</module>
     <module>trace</module>
     <module>core</module>
     <module>fate</module>
@@ -205,6 +206,16 @@
         <version>1.2.16</version>
       </dependency>
       <dependency>
+        <groupId>net.sf.scannotation</groupId>
+        <artifactId>scannotation</artifactId>
+        <version>1.0.2</version>
+      </dependency>
+      <dependency>
+        <groupId>org.apache.accumulo</groupId>
+        <artifactId>accumulo-api</artifactId>
+        <version>${project.version}</version>
+      </dependency>
+      <dependency>
         <groupId>org.apache.accumulo</groupId>
         <artifactId>accumulo-core</artifactId>
         <version>${project.version}</version>
@@ -312,6 +323,11 @@
         <version>3.1</version>
       </dependency>
       <dependency>
+        <groupId>org.javassist</groupId>
+        <artifactId>javassist</artifactId>
+        <version>3.17.1-GA</version>
+      </dependency>
+      <dependency>
         <groupId>org.mortbay.jetty</groupId>
         <artifactId>jetty</artifactId>
         <version>6.1.26</version>

Modified: accumulo/branches/ACCUMULO-1496/proxy/src/main/java/org/apache/accumulo/proxy/Proxy.java
URL: http://svn.apache.org/viewvc/accumulo/branches/ACCUMULO-1496/proxy/src/main/java/org/apache/accumulo/proxy/Proxy.java?rev=1491605&r1=1491604&r2=1491605&view=diff
==============================================================================
--- accumulo/branches/ACCUMULO-1496/proxy/src/main/java/org/apache/accumulo/proxy/Proxy.java
(original)
+++ accumulo/branches/ACCUMULO-1496/proxy/src/main/java/org/apache/accumulo/proxy/Proxy.java
Mon Jun 10 21:23:30 2013
@@ -23,6 +23,7 @@ import java.io.InputStream;
 import java.lang.reflect.Constructor;
 import java.util.Properties;
 
+import org.apache.accumulo.api.annotations.AccumuloService;
 import org.apache.accumulo.core.cli.Help;
 import org.apache.accumulo.core.conf.AccumuloConfiguration;
 import org.apache.accumulo.minicluster.MiniAccumuloCluster;
@@ -40,6 +41,7 @@ import com.beust.jcommander.IStringConve
 import com.beust.jcommander.Parameter;
 import com.google.common.io.Files;
 
+@AccumuloService("proxy")
 public class Proxy {
   
   private static final Logger log = Logger.getLogger(Proxy.class);
@@ -100,6 +102,7 @@ public class Proxy {
       opts.prop.setProperty("instance", accumulo.getConfig().getInstanceName());
       opts.prop.setProperty("zookeepers", accumulo.getConfig().getZooKeepers());
       Runtime.getRuntime().addShutdownHook(new Thread() {
+        @Override
         public void start() {
           try {
             accumulo.stop();
@@ -128,7 +131,7 @@ public class Proxy {
     
     Class<?> proxyProcClass = Class.forName(api.getName() + "$Processor");
     Class<?> proxyIfaceClass = Class.forName(api.getName() + "$Iface");
-
+    
     @SuppressWarnings("unchecked")
     Constructor<? extends TProcessor> proxyProcConstructor = (Constructor<? extends
TProcessor>) proxyProcClass.getConstructor(proxyIfaceClass);
     
@@ -139,7 +142,7 @@ public class Proxy {
     final long maxFrameSize = AccumuloConfiguration.getMemoryInBytes(properties.getProperty("maxFrameSize",
"16M"));
     if (maxFrameSize > Integer.MAX_VALUE)
       throw new RuntimeException(maxFrameSize + " is larger than MAX_INT");
-    args.transportFactory(new TFramedTransport.Factory((int)maxFrameSize));
+    args.transportFactory(new TFramedTransport.Factory((int) maxFrameSize));
     args.protocolFactory(protoClass.newInstance());
     return new THsHaServer(args);
   }

Modified: accumulo/branches/ACCUMULO-1496/server/src/main/java/org/apache/accumulo/server/gc/SimpleGarbageCollector.java
URL: http://svn.apache.org/viewvc/accumulo/branches/ACCUMULO-1496/server/src/main/java/org/apache/accumulo/server/gc/SimpleGarbageCollector.java?rev=1491605&r1=1491604&r2=1491605&view=diff
==============================================================================
--- accumulo/branches/ACCUMULO-1496/server/src/main/java/org/apache/accumulo/server/gc/SimpleGarbageCollector.java
(original)
+++ accumulo/branches/ACCUMULO-1496/server/src/main/java/org/apache/accumulo/server/gc/SimpleGarbageCollector.java
Mon Jun 10 21:23:30 2013
@@ -36,6 +36,7 @@ import java.util.concurrent.ExecutorServ
 import java.util.concurrent.Executors;
 import java.util.concurrent.TimeUnit;
 
+import org.apache.accumulo.api.annotations.AccumuloService;
 import org.apache.accumulo.core.Constants;
 import org.apache.accumulo.core.cli.Help;
 import org.apache.accumulo.core.client.AccumuloException;
@@ -101,6 +102,7 @@ import org.apache.zookeeper.KeeperExcept
 
 import com.beust.jcommander.Parameter;
 
+@AccumuloService("gc")
 public class SimpleGarbageCollector implements Iface {
   private static final Text EMPTY_TEXT = new Text();
   

Modified: accumulo/branches/ACCUMULO-1496/server/src/main/java/org/apache/accumulo/server/master/Master.java
URL: http://svn.apache.org/viewvc/accumulo/branches/ACCUMULO-1496/server/src/main/java/org/apache/accumulo/server/master/Master.java?rev=1491605&r1=1491604&r2=1491605&view=diff
==============================================================================
--- accumulo/branches/ACCUMULO-1496/server/src/main/java/org/apache/accumulo/server/master/Master.java
(original)
+++ accumulo/branches/ACCUMULO-1496/server/src/main/java/org/apache/accumulo/server/master/Master.java
Mon Jun 10 21:23:30 2013
@@ -37,6 +37,7 @@ import java.util.TreeSet;
 import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.concurrent.atomic.AtomicInteger;
 
+import org.apache.accumulo.api.annotations.AccumuloService;
 import org.apache.accumulo.core.Constants;
 import org.apache.accumulo.core.client.AccumuloException;
 import org.apache.accumulo.core.client.AccumuloSecurityException;
@@ -175,6 +176,7 @@ import org.apache.zookeeper.data.Stat;
  * 
  * The master will also coordinate log recoveries and reports general status.
  */
+@AccumuloService("master")
 public class Master implements LiveTServerSet.Listener, TableObserver, CurrentState {
   
   final private static Logger log = Logger.getLogger(Master.class);

Modified: accumulo/branches/ACCUMULO-1496/server/src/main/java/org/apache/accumulo/server/monitor/Monitor.java
URL: http://svn.apache.org/viewvc/accumulo/branches/ACCUMULO-1496/server/src/main/java/org/apache/accumulo/server/monitor/Monitor.java?rev=1491605&r1=1491604&r2=1491605&view=diff
==============================================================================
--- accumulo/branches/ACCUMULO-1496/server/src/main/java/org/apache/accumulo/server/monitor/Monitor.java
(original)
+++ accumulo/branches/ACCUMULO-1496/server/src/main/java/org/apache/accumulo/server/monitor/Monitor.java
Mon Jun 10 21:23:30 2013
@@ -27,7 +27,7 @@ import java.util.Map;
 import java.util.Map.Entry;
 import java.util.Set;
 
-import org.apache.accumulo.trace.instrument.Tracer;
+import org.apache.accumulo.api.annotations.AccumuloService;
 import org.apache.accumulo.core.Constants;
 import org.apache.accumulo.core.client.Instance;
 import org.apache.accumulo.core.client.impl.MasterClient;
@@ -73,6 +73,7 @@ import org.apache.accumulo.server.proble
 import org.apache.accumulo.server.problems.ProblemType;
 import org.apache.accumulo.server.security.SecurityConstants;
 import org.apache.accumulo.server.util.EmbeddedWebServer;
+import org.apache.accumulo.trace.instrument.Tracer;
 import org.apache.hadoop.fs.FileSystem;
 import org.apache.log4j.Logger;
 import org.apache.zookeeper.WatchedEvent;
@@ -82,6 +83,7 @@ import org.apache.zookeeper.ZooKeeper;
 /**
  * Serve master statistics with an embedded web server.
  */
+@AccumuloService("monitor")
 public class Monitor {
   private static final Logger log = Logger.getLogger(Monitor.class);
   

Modified: accumulo/branches/ACCUMULO-1496/server/src/main/java/org/apache/accumulo/server/tabletserver/TabletServer.java
URL: http://svn.apache.org/viewvc/accumulo/branches/ACCUMULO-1496/server/src/main/java/org/apache/accumulo/server/tabletserver/TabletServer.java?rev=1491605&r1=1491604&r2=1491605&view=diff
==============================================================================
--- accumulo/branches/ACCUMULO-1496/server/src/main/java/org/apache/accumulo/server/tabletserver/TabletServer.java
(original)
+++ accumulo/branches/ACCUMULO-1496/server/src/main/java/org/apache/accumulo/server/tabletserver/TabletServer.java
Mon Jun 10 21:23:30 2013
@@ -64,6 +64,7 @@ import java.util.concurrent.atomic.Atomi
 import javax.management.ObjectName;
 import javax.management.StandardMBean;
 
+import org.apache.accumulo.api.annotations.AccumuloService;
 import org.apache.accumulo.core.Constants;
 import org.apache.accumulo.core.client.AccumuloException;
 import org.apache.accumulo.core.client.AccumuloSecurityException;
@@ -226,6 +227,7 @@ enum ScanRunState {
   QUEUED, RUNNING, FINISHED
 }
 
+@AccumuloService("tserver")
 public class TabletServer extends AbstractMetricsImpl implements org.apache.accumulo.server.tabletserver.metrics.TabletServerMBean
{
   private static final Logger log = Logger.getLogger(TabletServer.class);
   

Modified: accumulo/branches/ACCUMULO-1496/server/src/main/java/org/apache/accumulo/server/trace/TraceServer.java
URL: http://svn.apache.org/viewvc/accumulo/branches/ACCUMULO-1496/server/src/main/java/org/apache/accumulo/server/trace/TraceServer.java?rev=1491605&r1=1491604&r2=1491605&view=diff
==============================================================================
--- accumulo/branches/ACCUMULO-1496/server/src/main/java/org/apache/accumulo/server/trace/TraceServer.java
(original)
+++ accumulo/branches/ACCUMULO-1496/server/src/main/java/org/apache/accumulo/server/trace/TraceServer.java
Mon Jun 10 21:23:30 2013
@@ -23,6 +23,7 @@ import java.util.Map;
 import java.util.Map.Entry;
 import java.util.concurrent.TimeUnit;
 
+import org.apache.accumulo.api.annotations.AccumuloService;
 import org.apache.accumulo.core.Constants;
 import org.apache.accumulo.core.client.BatchWriter;
 import org.apache.accumulo.core.client.BatchWriterConfig;
@@ -71,6 +72,7 @@ import org.apache.zookeeper.Watcher;
 import org.apache.zookeeper.Watcher.Event.EventType;
 import org.apache.zookeeper.Watcher.Event.KeeperState;
 
+@AccumuloService("tracer")
 public class TraceServer implements Watcher {
   
   final private static Logger log = Logger.getLogger(TraceServer.class);
@@ -171,12 +173,12 @@ public class TraceServer implements Watc
           Properties props = new Properties();
           AuthenticationToken token = AccumuloClassLoader.getClassLoader().loadClass(conf.get(Property.TRACE_TOKEN_TYPE)).asSubclass(AuthenticationToken.class)
               .newInstance();
-
+          
           int prefixLength = Property.TRACE_TOKEN_PROPERTY_PREFIX.getKey().length() + 1;
           for (Entry<String,String> entry : loginMap.entrySet()) {
             props.put(entry.getKey().substring(prefixLength), entry.getValue());
           }
-
+          
           token.init(props);
           
           at = token;

Modified: accumulo/branches/ACCUMULO-1496/server/src/main/java/org/apache/accumulo/server/util/Admin.java
URL: http://svn.apache.org/viewvc/accumulo/branches/ACCUMULO-1496/server/src/main/java/org/apache/accumulo/server/util/Admin.java?rev=1491605&r1=1491604&r2=1491605&view=diff
==============================================================================
--- accumulo/branches/ACCUMULO-1496/server/src/main/java/org/apache/accumulo/server/util/Admin.java
(original)
+++ accumulo/branches/ACCUMULO-1496/server/src/main/java/org/apache/accumulo/server/util/Admin.java
Mon Jun 10 21:23:30 2013
@@ -22,6 +22,7 @@ import java.util.List;
 import java.util.Set;
 import java.util.concurrent.atomic.AtomicInteger;
 
+import org.apache.accumulo.api.annotations.AccumuloService;
 import org.apache.accumulo.core.Constants;
 import org.apache.accumulo.core.client.AccumuloException;
 import org.apache.accumulo.core.client.AccumuloSecurityException;
@@ -44,6 +45,7 @@ import com.beust.jcommander.JCommander;
 import com.beust.jcommander.Parameter;
 import com.beust.jcommander.Parameters;
 
+@AccumuloService("admin")
 public class Admin {
   private static final Logger log = Logger.getLogger(Admin.class);
   

Modified: accumulo/branches/ACCUMULO-1496/server/src/main/java/org/apache/accumulo/server/util/Initialize.java
URL: http://svn.apache.org/viewvc/accumulo/branches/ACCUMULO-1496/server/src/main/java/org/apache/accumulo/server/util/Initialize.java?rev=1491605&r1=1491604&r2=1491605&view=diff
==============================================================================
--- accumulo/branches/ACCUMULO-1496/server/src/main/java/org/apache/accumulo/server/util/Initialize.java
(original)
+++ accumulo/branches/ACCUMULO-1496/server/src/main/java/org/apache/accumulo/server/util/Initialize.java
Mon Jun 10 21:23:30 2013
@@ -25,6 +25,7 @@ import java.util.UUID;
 
 import jline.console.ConsoleReader;
 
+import org.apache.accumulo.api.annotations.AccumuloService;
 import org.apache.accumulo.core.Constants;
 import org.apache.accumulo.core.cli.Help;
 import org.apache.accumulo.core.client.AccumuloSecurityException;
@@ -71,6 +72,7 @@ import com.beust.jcommander.Parameter;
  * This class is used to setup the directory structure and the root tablet to get an instance
started
  * 
  */
+@AccumuloService("init")
 public class Initialize {
   private static final Logger log = Logger.getLogger(Initialize.class);
   private static final String DEFAULT_ROOT_USER = "root";

Modified: accumulo/branches/ACCUMULO-1496/server/src/main/java/org/apache/accumulo/server/util/ZooKeeperMain.java
URL: http://svn.apache.org/viewvc/accumulo/branches/ACCUMULO-1496/server/src/main/java/org/apache/accumulo/server/util/ZooKeeperMain.java?rev=1491605&r1=1491604&r2=1491605&view=diff
==============================================================================
--- accumulo/branches/ACCUMULO-1496/server/src/main/java/org/apache/accumulo/server/util/ZooKeeperMain.java
(original)
+++ accumulo/branches/ACCUMULO-1496/server/src/main/java/org/apache/accumulo/server/util/ZooKeeperMain.java
Mon Jun 10 21:23:30 2013
@@ -16,6 +16,7 @@
  */
 package org.apache.accumulo.server.util;
 
+import org.apache.accumulo.api.annotations.AccumuloService;
 import org.apache.accumulo.core.Constants;
 import org.apache.accumulo.core.cli.Help;
 import org.apache.accumulo.core.client.Instance;
@@ -27,6 +28,7 @@ import org.apache.hadoop.fs.Path;
 
 import com.beust.jcommander.Parameter;
 
+@AccumuloService("zookeeper")
 public class ZooKeeperMain {
   
   static class Opts extends Help {
@@ -50,7 +52,7 @@ public class ZooKeeperMain {
     }
     System.out.println("The accumulo instance id is " + instance.getInstanceID());
     if (!opts.servers.contains("/"))
-      opts.servers += "/accumulo/"+instance.getInstanceID(); 
-    org.apache.zookeeper.ZooKeeperMain.main(new String[]{"-server", opts.servers, "-timeout",
"" + (opts.timeout * 1000)});
+      opts.servers += "/accumulo/" + instance.getInstanceID();
+    org.apache.zookeeper.ZooKeeperMain.main(new String[] {"-server", opts.servers, "-timeout",
"" + (opts.timeout * 1000)});
   }
 }

Modified: accumulo/branches/ACCUMULO-1496/start/pom.xml
URL: http://svn.apache.org/viewvc/accumulo/branches/ACCUMULO-1496/start/pom.xml?rev=1491605&r1=1491604&r2=1491605&view=diff
==============================================================================
--- accumulo/branches/ACCUMULO-1496/start/pom.xml (original)
+++ accumulo/branches/ACCUMULO-1496/start/pom.xml Mon Jun 10 21:23:30 2013
@@ -26,10 +26,22 @@
   <name>Start</name>
   <dependencies>
     <dependency>
+      <groupId>net.sf.scannotation</groupId>
+      <artifactId>scannotation</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.accumulo</groupId>
+      <artifactId>accumulo-api</artifactId>
+    </dependency>
+    <dependency>
       <groupId>org.apache.commons</groupId>
       <artifactId>commons-vfs2</artifactId>
     </dependency>
     <dependency>
+      <groupId>org.javassist</groupId>
+      <artifactId>javassist</artifactId>
+    </dependency>
+    <dependency>
       <groupId>commons-io</groupId>
       <artifactId>commons-io</artifactId>
       <scope>provided</scope>

Modified: accumulo/branches/ACCUMULO-1496/start/src/main/java/org/apache/accumulo/start/Main.java
URL: http://svn.apache.org/viewvc/accumulo/branches/ACCUMULO-1496/start/src/main/java/org/apache/accumulo/start/Main.java?rev=1491605&r1=1491604&r2=1491605&view=diff
==============================================================================
--- accumulo/branches/ACCUMULO-1496/start/src/main/java/org/apache/accumulo/start/Main.java
(original)
+++ accumulo/branches/ACCUMULO-1496/start/src/main/java/org/apache/accumulo/start/Main.java
Mon Jun 10 21:23:30 2013
@@ -16,75 +16,65 @@
  */
 package org.apache.accumulo.start;
 
+import java.io.IOException;
 import java.lang.reflect.Method;
 import java.lang.reflect.Modifier;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Set;
 
+import org.apache.accumulo.api.annotations.AccumuloService;
 import org.apache.accumulo.start.classloader.AccumuloClassLoader;
+import org.scannotation.AnnotationDB;
 
 public class Main {
   
+  private static AnnotationDB annotationDatabase;
+  
   public static void main(String[] args) throws Exception {
     Runnable r = null;
     
     try {
+      Thread.currentThread().setContextClassLoader(AccumuloClassLoader.getClassLoader());
+      Class<?> vfsClassLoader = AccumuloClassLoader.getClassLoader().loadClass("org.apache.accumulo.start.classloader.vfs.AccumuloVFSClassLoader");
+      ClassLoader cl = (ClassLoader) vfsClassLoader.getMethod("getClassLoader", new Class[]
{}).invoke(null, new Object[] {});
+      Thread.currentThread().setContextClassLoader(cl);
+      
+      URL[] urls = (URL[]) vfsClassLoader.getMethod("getURLs", new Class[] {}).invoke(null,
new Object[] {});
+      
       if (args.length == 0) {
-        printUsage();
+        printUsage(cl, urls);
         System.exit(1);
       }
       final String argsToPass[] = new String[args.length - 1];
       System.arraycopy(args, 1, argsToPass, 0, args.length - 1);
       
-      Thread.currentThread().setContextClassLoader(AccumuloClassLoader.getClassLoader());
-      
-      Class<?> vfsClassLoader = AccumuloClassLoader.getClassLoader().loadClass("org.apache.accumulo.start.classloader.vfs.AccumuloVFSClassLoader");
-      
-      ClassLoader cl = (ClassLoader) vfsClassLoader.getMethod("getClassLoader", new Class[]
{}).invoke(null, new Object[] {});
-      
       Class<?> runTMP = null;
       
-      Thread.currentThread().setContextClassLoader(cl);
-      
-      if (args[0].equals("master")) {
-        runTMP = cl.loadClass("org.apache.accumulo.server.master.Master");
-      } else if (args[0].equals("tserver")) {
-        runTMP = cl.loadClass("org.apache.accumulo.server.tabletserver.TabletServer");
-      } else if (args[0].equals("shell")) {
-        runTMP = cl.loadClass("org.apache.accumulo.core.util.shell.Shell");
-      } else if (args[0].equals("init")) {
-        runTMP = cl.loadClass("org.apache.accumulo.server.util.Initialize");
-      } else if (args[0].equals("admin")) {
-        runTMP = cl.loadClass("org.apache.accumulo.server.util.Admin");
-      } else if (args[0].equals("gc")) {
-        runTMP = cl.loadClass("org.apache.accumulo.server.gc.SimpleGarbageCollector");
-      } else if (args[0].equals("monitor")) {
-        runTMP = cl.loadClass("org.apache.accumulo.server.monitor.Monitor");
-      } else if (args[0].equals("tracer")) {
-        runTMP = cl.loadClass("org.apache.accumulo.server.trace.TraceServer");
-      } else if (args[0].equals("proxy")) {
-        runTMP = cl.loadClass("org.apache.accumulo.proxy.Proxy");
-      } else if (args[0].equals("minicluster")) {
-        runTMP = cl.loadClass("org.apache.accumulo.minicluster.MiniAccumuloRunner");
-      } else if (args[0].equals("classpath")) {
+      if (args[0].equals("classpath")) {
         vfsClassLoader.getMethod("printClassPath", new Class[] {}).invoke(vfsClassLoader,
new Object[] {});
         return;
       } else if (args[0].equals("version")) {
         runTMP = cl.loadClass("org.apache.accumulo.core.Constants");
         System.out.println(runTMP.getField("VERSION").get(null));
         return;
-      } else if (args[0].equals("rfile-info")) {
-        runTMP = cl.loadClass("org.apache.accumulo.core.file.rfile.PrintInfo");
-      } else if (args[0].equals("login-info")) {
-        runTMP = cl.loadClass("org.apache.accumulo.core.util.LoginProperties");
-      } else if (args[0].equals("zookeeper")) {
-        runTMP = cl.loadClass("org.apache.accumulo.server.util.ZooKeeperMain");
-      } else if (args[0].equals("create-token")) {
-        runTMP = cl.loadClass("org.apache.accumulo.core.util.CreateToken");
       } else {
-        try {
-          runTMP = cl.loadClass(args[0]);
-        } catch (ClassNotFoundException cnfe) {
-          System.out.println("Classname " + args[0] + " not found.  Please make sure you
use the wholly qualified package name.");
-          System.exit(1);
+        for (String className : loadAnnotationDB(urls, AccumuloService.class)) {
+          Class<?> runTMPCandidate = cl.loadClass(className);
+          if (args[0].equals(runTMPCandidate.getAnnotation(AccumuloService.class).value()))
{
+            runTMP = runTMPCandidate;
+            break;
+          }
+        }
+        
+        if (runTMP == null) {
+          try {
+            runTMP = cl.loadClass(args[0]);
+          } catch (ClassNotFoundException cnfe) {
+            System.out.println("Classname " + args[0] + " not found.  Please make sure you
use the wholly qualified package name.");
+            System.exit(1);
+          }
         }
       }
       Method main = null;
@@ -100,6 +90,7 @@ public class Main {
       final Object thisIsJustOneArgument = argsToPass;
       final Method finalMain = main;
       r = new Runnable() {
+        @Override
         public void run() {
           try {
             finalMain.invoke(null, thisIsJustOneArgument);
@@ -120,7 +111,32 @@ public class Main {
     }
   }
   
-  private static void printUsage() {
-    System.out.println("accumulo init | master | tserver | monitor | shell | admin | gc |
classpath | rfile-info | login-info | tracer | minicluster | proxy | zookeeper | create-token
| <accumulo class> args");
+  private static void printUsage(ClassLoader cl, URL[] urls) throws IOException, ClassNotFoundException
{
+    ArrayList<String> keywords = new ArrayList<String>(20);
+    for (String className : loadAnnotationDB(urls, AccumuloService.class)) {
+      Class<?> runTMPCandidate = cl.loadClass(className);
+      keywords.add(runTMPCandidate.getAnnotation(AccumuloService.class).value());
+    }
+    keywords.add("classpath");
+    keywords.add("version");
+    
+    String prefix = "";
+    String kwString = "";
+    for (String kw : keywords) {
+      kwString += prefix + kw;
+      prefix = " | ";
+    }
+    System.out.println("accumulo " + kwString + " | <accumulo class> args");
+  }
+  
+  protected synchronized static Set<String> loadAnnotationDB(URL[] urls, Class<?>
annotationClass) throws IOException {
+    if (annotationDatabase == null) {
+      AnnotationDB database = new AnnotationDB();
+      database.setScanClassAnnotations(true);
+      database.scanArchives(urls);
+      annotationDatabase = database;
+    }
+    Set<String> retVal = annotationDatabase.getAnnotationIndex().get(annotationClass.getName());
+    return retVal == null ? (retVal = Collections.emptySet()) : retVal;
   }
 }

Modified: accumulo/branches/ACCUMULO-1496/start/src/main/java/org/apache/accumulo/start/classloader/vfs/AccumuloVFSClassLoader.java
URL: http://svn.apache.org/viewvc/accumulo/branches/ACCUMULO-1496/start/src/main/java/org/apache/accumulo/start/classloader/vfs/AccumuloVFSClassLoader.java?rev=1491605&r1=1491604&r2=1491605&view=diff
==============================================================================
--- accumulo/branches/ACCUMULO-1496/start/src/main/java/org/apache/accumulo/start/classloader/vfs/AccumuloVFSClassLoader.java
(original)
+++ accumulo/branches/ACCUMULO-1496/start/src/main/java/org/apache/accumulo/start/classloader/vfs/AccumuloVFSClassLoader.java
Mon Jun 10 21:23:30 2013
@@ -61,6 +61,7 @@ public class AccumuloVFSClassLoader {
   
   public static class AccumuloVFSClassLoaderShutdownThread implements Runnable {
     
+    @Override
     public void run() {
       try {
         AccumuloVFSClassLoader.close();
@@ -99,7 +100,7 @@ public class AccumuloVFSClassLoader {
   
   public synchronized static <U> Class<? extends U> loadClass(String classname,
Class<U> extension) throws ClassNotFoundException {
     try {
-      return (Class<? extends U>) getClassLoader().loadClass(classname).asSubclass(extension);
+      return getClassLoader().loadClass(classname).asSubclass(extension);
     } catch (IOException e) {
       throw new ClassNotFoundException("IO Error loading class " + classname, e);
     }
@@ -282,6 +283,28 @@ public class AccumuloVFSClassLoader {
     });
   }
   
+  public static URL[] getURLs() {
+    ArrayList<URL> urls = new ArrayList<URL>(20);
+    try {
+      ClassLoader cl = getClassLoader();
+      while (cl != null && cl != ClassLoader.getSystemClassLoader()) {
+        if (cl instanceof URLClassLoader) {
+          URLClassLoader ucl = (URLClassLoader) cl;
+          for (URL u : ucl.getURLs())
+            urls.add(u);
+        } else if (cl instanceof VFSClassLoader) {
+          VFSClassLoader vcl = (VFSClassLoader) cl;
+          for (FileObject f : vcl.getFileObjects())
+            urls.add(f.getURL());
+        }
+        cl = cl.getParent();
+      }
+    } catch (Exception t) {
+      throw new RuntimeException(t);
+    }
+    return urls.toArray(new URL[urls.size()]);
+  }
+  
   public static void printClassPath(Printer out) {
     try {
       ClassLoader cl = getClassLoader();



Mime
View raw message