1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.apache.hadoop.hbase.util;
21
22 import java.lang.management.RuntimeMXBean;
23 import java.lang.management.ManagementFactory;
24
25 import org.apache.commons.logging.Log;
26 import org.apache.commons.logging.LogFactory;
27 import org.apache.hadoop.conf.Configuration;
28 import org.apache.hadoop.conf.Configured;
29 import org.apache.hadoop.hbase.HBaseConfiguration;
30 import org.apache.hadoop.util.Tool;
31 import org.apache.hadoop.util.ToolRunner;
32
33
34
35
36 public abstract class ServerCommandLine extends Configured implements Tool {
37 private static final Log LOG = LogFactory.getLog(ServerCommandLine.class);
38
39
40
41
42 protected abstract String getUsage();
43
44
45
46
47
48
49 protected void usage(String message) {
50 if (message != null) {
51 System.err.println(message);
52 System.err.println("");
53 }
54
55 System.err.println(getUsage());
56 }
57
58
59
60
61 public static void logJVMInfo() {
62
63 RuntimeMXBean runtime = ManagementFactory.getRuntimeMXBean();
64 if (runtime != null) {
65 LOG.info("vmName=" + runtime.getVmName() + ", vmVendor=" +
66 runtime.getVmVendor() + ", vmVersion=" + runtime.getVmVersion());
67 LOG.info("vmInputArguments=" + runtime.getInputArguments());
68 }
69 }
70
71
72
73
74
75 public void doMain(String args[]) throws Exception {
76 int ret = ToolRunner.run(
77 HBaseConfiguration.create(), this, args);
78 if (ret != 0) {
79 System.exit(ret);
80 }
81 }
82 }