}
HBaseHandler handler = new HBaseHandler();
Hbase.Processor processor = new Hbase.Processor(handler);
TServer server;
if (cmd.hasOption("nonblocking") || cmd.hasOption("hsha")) {
if (cmd.hasOption("bind")) {
LOG.error("The Nonblocking and HsHa servers don't support IP address binding at the moment." +
" See https://issues.apache.org/jira/browse/HBASE-2155 for details.");
printUsageAndExit(options, -1);
}
TNonblockingServerTransport serverTransport = new TNonblockingServerSocket(listenPort);
TFramedTransport.Factory transportFactory = new TFramedTransport.Factory();
if (cmd.hasOption("nonblocking")) {
LOG.info("starting HBase Nonblocking Thrift server on " + Integer.toString(listenPort));
server = new TNonblockingServer(processor, serverTransport, transportFactory, protocolFactory);
} else {
LOG.info("starting HBase HsHA Thrift server on " + Integer.toString(listenPort));
server = new THsHaServer(processor, serverTransport, transportFactory, protocolFactory);
}
} else {
// Get IP address to bind to
InetAddress listenAddress = null;
if (cmd.hasOption("bind")) {
try {
listenAddress = InetAddress.getByName(cmd.getOptionValue("bind"));
} catch (UnknownHostException e) {
LOG.error("Could not bind to provided ip address", e);
printUsageAndExit(options, -1);
}
} else {
listenAddress = InetAddress.getByName("0.0.0.0");
}
TServerTransport serverTransport = new TServerSocket(new InetSocketAddress(listenAddress, listenPort));
// Construct correct TransportFactory
TTransportFactory transportFactory;
if (cmd.hasOption("framed")) {
transportFactory = new TFramedTransport.Factory();
LOG.debug("Using framed transport");
} else {
transportFactory = new TTransportFactory();
}
LOG.info("starting HBase ThreadPool Thrift server on " + listenAddress + ":" + Integer.toString(listenPort));
server = new TThreadPoolServer(processor, serverTransport, transportFactory, protocolFactory);
}
server.serve();
}