HBASE-26412 Handle sink failure in RegionReplicationSink (#3815)
[hbase.git] / hbase-server / src / main / java / org / apache / hadoop / hbase / regionserver / HRegionServerCommandLine.java
blob5fd12333ad9165c3e113de3f5bcbf013b853a4ac
1 /**
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
19 package org.apache.hadoop.hbase.regionserver;
21 import org.apache.hadoop.conf.Configuration;
22 import org.apache.hadoop.hbase.HConstants;
23 import org.apache.hadoop.hbase.LocalHBaseCluster;
24 import org.apache.hadoop.hbase.util.ServerCommandLine;
25 import org.apache.yetus.audience.InterfaceAudience;
26 import org.slf4j.Logger;
27 import org.slf4j.LoggerFactory;
29 /**
30 * Class responsible for parsing the command line and starting the
31 * RegionServer.
33 @InterfaceAudience.Private
34 public class HRegionServerCommandLine extends ServerCommandLine {
35 private static final Logger LOG = LoggerFactory.getLogger(HRegionServerCommandLine.class);
37 private final Class<? extends HRegionServer> regionServerClass;
39 private static final String USAGE =
40 "Usage: HRegionServer [-D conf.param=value] start";
42 public HRegionServerCommandLine(Class<? extends HRegionServer> clazz) {
43 this.regionServerClass = clazz;
46 @Override
47 protected String getUsage() {
48 return USAGE;
51 private int start() throws Exception {
52 Configuration conf = getConf();
53 try {
54 // If 'local', don't start a region server here. Defer to
55 // LocalHBaseCluster. It manages 'local' clusters.
56 if (LocalHBaseCluster.isLocal(conf)) {
57 LOG.warn("Not starting a distinct region server because "
58 + HConstants.CLUSTER_DISTRIBUTED + " is false");
59 } else {
60 logProcessInfo(getConf());
61 HRegionServer hrs = HRegionServer.constructRegionServer(regionServerClass, conf);
62 hrs.start();
63 hrs.join();
64 if (hrs.isAborted()) {
65 throw new RuntimeException("HRegionServer Aborted");
68 } catch (Throwable t) {
69 LOG.error("Region server exiting", t);
70 return 1;
72 return 0;
75 @Override
76 public int run(String args[]) throws Exception {
77 if (args.length != 1) {
78 usage(null);
79 return 1;
82 String cmd = args[0];
84 if ("start".equals(cmd)) {
85 return start();
86 } else if ("stop".equals(cmd)) {
87 System.err.println(
88 "To shutdown the regionserver run " +
89 "hbase-daemon.sh stop regionserver or send a kill signal to " +
90 "the regionserver pid");
91 return 1;
92 } else {
93 usage("Unknown command: " + args[0]);
94 return 1;