accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From md...@apache.org
Subject [07/10] git commit: Merge branch '1.4.5-SNAPSHOT' into 1.5.1-SNAPSHOT
Date Tue, 25 Feb 2014 19:53:13 GMT
Merge branch '1.4.5-SNAPSHOT' into 1.5.1-SNAPSHOT

Conflicts:
	src/start/src/main/java/org/apache/accumulo/start/Main.java


Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo
Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/62580184
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/62580184
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/62580184

Branch: refs/heads/master
Commit: 625801848cbb93ac0240eecf09ce62f225ee0960
Parents: 7e106a2 1543d65
Author: Mike Drob <mdrob@cloudera.com>
Authored: Tue Feb 25 14:38:25 2014 -0500
Committer: Mike Drob <mdrob@cloudera.com>
Committed: Tue Feb 25 14:38:25 2014 -0500

----------------------------------------------------------------------
 .../java/org/apache/accumulo/start/Main.java    | 30 ++++++++++++++++----
 1 file changed, 24 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/62580184/start/src/main/java/org/apache/accumulo/start/Main.java
----------------------------------------------------------------------
diff --cc start/src/main/java/org/apache/accumulo/start/Main.java
index cbc90c6,0000000..29c47a7
mode 100644,000000..100644
--- a/start/src/main/java/org/apache/accumulo/start/Main.java
+++ b/start/src/main/java/org/apache/accumulo/start/Main.java
@@@ -1,125 -1,0 +1,143 @@@
 +/*
 + * 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.start;
 +
++import java.lang.reflect.InvocationTargetException;
 +import java.lang.reflect.Method;
 +import java.lang.reflect.Modifier;
- 
++ 
 +import org.apache.accumulo.start.classloader.AccumuloClassLoader;
 +
 +public class Main {
 +  
-   public static void main(String[] args) throws Exception {
++  public static void main(String[] args) {
 +    Runnable r = null;
 +    
 +    try {
 +      if (args.length == 0) {
 +        printUsage();
 +        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("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.server.util.LoginProperties");
 +      } else if (args[0].equals("zookeeper")) {
 +        runTMP = cl.loadClass("org.apache.accumulo.server.util.ZooKeeperMain");
 +      } else if (args[0].equals("info")) {
 +        runTMP = cl.loadClass("org.apache.accumulo.server.util.Info");
 +      } 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);
 +        }
 +      }
 +      Method main = null;
 +      try {
 +        main = runTMP.getMethod("main", args.getClass());
 +      } catch (Throwable t) {
 +        t.printStackTrace();
 +      }
 +      if (main == null || !Modifier.isPublic(main.getModifiers()) || !Modifier.isStatic(main.getModifiers()))
{
 +        System.out.println(args[0] + " must implement a public static void main(String args[])
method");
 +        System.exit(1);
 +      }
 +      final Object thisIsJustOneArgument = argsToPass;
 +      final Method finalMain = main;
 +      r = new Runnable() {
 +        public void run() {
 +          try {
 +            finalMain.invoke(null, thisIsJustOneArgument);
++          } catch (InvocationTargetException e) {
++            if (e.getCause() != null) {
++              die(e.getCause());
++            } else {
++              // Should never happen, but check anyway.
++              die(e);
++            }
 +          } catch (Exception e) {
-             System.err.println("Thread \"" + Thread.currentThread().getName() + "\" died
" + e);
-             e.printStackTrace(System.err);
-             System.exit(1);
++            die(e);
 +          }
 +        }
 +      };
 +      
 +      Thread t = new Thread(r, args[0]);
 +      t.setContextClassLoader(cl);
 +      t.start();
 +    } catch (Throwable t) {
 +      System.err.println("Uncaught exception: " + t);
 +      t.printStackTrace(System.err);
 +      System.exit(1);
 +    }
 +  }
-   
++
++  /**
++   * Print a stack trace to stderr and exit with a non-zero status.
++   *
++   * @param t
++   *          The {@link Throwable} containing a stack trace to print.
++   */
++  private static void die(Throwable t) {
++    System.err.println("Thread \"" + Thread.currentThread().getName() + "\" died " + t.getMessage());
++    t.printStackTrace(System.err);
++    System.exit(1);
++  }
++
 +  private static void printUsage() {
 +    System.out.println("accumulo init | master | tserver | monitor | shell | admin | gc
| classpath | rfile-info | login-info | tracer | proxy | zookeeper | info | version | <accumulo
class> args");
 +  }
 +}


Mime
View raw message