Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
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 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.hadoop.hbase.util;
 import java.util.Set;
Base class for command lines that start up various HBase daemons.
 public abstract class ServerCommandLine extends Configured implements Tool {
   private static final Log LOG = LogFactory.getLog(ServerCommandLine.class);
   private static final Set<StringDEFAULT_SKIP_WORDS = new HashSet<String>() {

Implementing subclasses should return a usage string to print out.
   protected abstract String getUsage();

Print usage information for this command line.

message if not null, print this message before the usage info.
   protected void usage(String message) {
     if (message != null) {

Log information about the currently running JVM.
   public static void logJVMInfo() {
     // Print out vm stats before starting up.
     RuntimeMXBean runtime = ManagementFactory.getRuntimeMXBean();
     if (runtime != null) {
       .info("vmName=" + runtime.getVmName() + ", vmVendor=" +
                runtime.getVmVendor() + ", vmVersion=" + runtime.getVmVersion());
       .info("vmInputArguments=" + runtime.getInputArguments());

Logs information about the currently running JVM process including the environment variables. Logging of env vars can be disabled by setting "hbase.envvars.logging.disabled" to "true".

If enabled, you can also exclude environment variables containing certain substrings by setting "hbase.envvars.logging.skipwords" to comma separated list of such substrings.

   public static void logProcessInfo(Configuration conf) {
     // log environment variables unless asked not to
     if (conf == null || !conf.getBoolean("hbase.envvars.logging.disabled"false)) {
       Set<StringskipWords = new HashSet<String>();
       if (conf != null) {
         String[] confSkipWords = conf.getStrings("hbase.envvars.logging.skipwords");
         if (confSkipWords != null) {
      for (Entry<StringStringentry : System.getenv().entrySet()) {
        String key = entry.getKey().toLowerCase();
        String value = entry.getValue().toLowerCase();
        // exclude variables which may contain skip words
        for(String skipWord : skipWords) {
          if (key.contains(skipWord) || value.contains(skipWord))
            continue nextEnv;
    // and JVM info

Parse and run the given command line. This may exit the JVM if a nonzero exit code is returned from run().
  public void doMain(String args[]) {
    try {
      int ret =, thisargs);
      if (ret != 0) {
    } catch (Exception e) {
      .error("Failed to run"e);
New to GrepCode? Check out our FAQ X