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.regionserver;
21
22 import org.apache.commons.logging.Log;
23 import org.apache.commons.logging.LogFactory;
24
25 import org.apache.hadoop.conf.Configuration;
26 import org.apache.hadoop.hbase.HConstants;
27 import org.apache.hadoop.hbase.LocalHBaseCluster;
28 import org.apache.hadoop.hbase.util.ServerCommandLine;
29
30
31
32
33
34 public class HRegionServerCommandLine extends ServerCommandLine {
35 private static final Log LOG = LogFactory.getLog(HRegionServerCommandLine.class);
36
37 private final Class<? extends HRegionServer> regionServerClass;
38
39 private static final String USAGE =
40 "Usage: HRegionServer [-D conf.param=value] start";
41
42 public HRegionServerCommandLine(Class<? extends HRegionServer> clazz) {
43 this.regionServerClass = clazz;
44 }
45
46 protected String getUsage() {
47 return USAGE;
48 }
49
50 private int start() throws Exception {
51 Configuration conf = getConf();
52
53
54
55 if (LocalHBaseCluster.isLocal(conf)) {
56 LOG.warn("Not starting a distinct region server because "
57 + HConstants.CLUSTER_DISTRIBUTED + " is false");
58 } else {
59 logJVMInfo();
60 HRegionServer hrs = HRegionServer.constructRegionServer(regionServerClass, conf);
61 HRegionServer.startRegionServer(hrs);
62 }
63 return 0;
64 }
65
66 public int run(String args[]) throws Exception {
67 if (args.length != 1) {
68 usage(null);
69 return -1;
70 }
71
72 String cmd = args[0];
73
74 if ("start".equals(cmd)) {
75 return start();
76 } else if ("stop".equals(cmd)) {
77 System.err.println(
78 "To shutdown the regionserver run " +
79 "bin/hbase-daemon.sh stop regionserver or send a kill signal to" +
80 "the regionserver pid");
81 return -1;
82 } else {
83 usage("Unknown command: " + args[0]);
84 return -1;
85 }
86 }
87 }