Search in sources :

Example 1 with MAX_FRAME_SIZE_CONF_DEFAULT

use of org.apache.hadoop.hbase.thrift.Constants.MAX_FRAME_SIZE_CONF_DEFAULT in project hbase by apache.

the class ThriftServer method setupServer.

/**
 * Setting up the thrift TServer
 */
protected void setupServer() throws Exception {
    // Construct correct ProtocolFactory
    TProtocolFactory protocolFactory = getProtocolFactory();
    ImplType implType = ImplType.getServerImpl(conf);
    TProcessor processorToUse = processor;
    // Construct correct TransportFactory
    TTransportFactory transportFactory;
    if (conf.getBoolean(FRAMED_CONF_KEY, FRAMED_CONF_DEFAULT) || implType.isAlwaysFramed) {
        if (qop != null) {
            throw new RuntimeException("Thrift server authentication" + " doesn't work with framed transport yet");
        }
        transportFactory = new TFramedTransport.Factory(conf.getInt(MAX_FRAME_SIZE_CONF_KEY, MAX_FRAME_SIZE_CONF_DEFAULT) * 1024 * 1024);
        LOG.debug("Using framed transport");
    } else if (qop == null) {
        transportFactory = new TTransportFactory();
    } else {
        // Extract the name from the principal
        String thriftKerberosPrincipal = conf.get(THRIFT_KERBEROS_PRINCIPAL_KEY);
        if (thriftKerberosPrincipal == null) {
            throw new IllegalArgumentException(THRIFT_KERBEROS_PRINCIPAL_KEY + " cannot be null");
        }
        String name = SecurityUtil.getUserFromPrincipal(thriftKerberosPrincipal);
        Map<String, String> saslProperties = SaslUtil.initSaslProperties(qop.name());
        TSaslServerTransport.Factory saslFactory = new TSaslServerTransport.Factory();
        saslFactory.addServerDefinition("GSSAPI", name, host, saslProperties, new SaslRpcServer.SaslGssCallbackHandler() {

            @Override
            public void handle(Callback[] callbacks) throws UnsupportedCallbackException {
                AuthorizeCallback ac = null;
                for (Callback callback : callbacks) {
                    if (callback instanceof AuthorizeCallback) {
                        ac = (AuthorizeCallback) callback;
                    } else {
                        throw new UnsupportedCallbackException(callback, "Unrecognized SASL GSSAPI Callback");
                    }
                }
                if (ac != null) {
                    String authid = ac.getAuthenticationID();
                    String authzid = ac.getAuthorizationID();
                    if (!authid.equals(authzid)) {
                        ac.setAuthorized(false);
                    } else {
                        ac.setAuthorized(true);
                        String userName = SecurityUtil.getUserFromPrincipal(authzid);
                        LOG.info("Effective user: {}", userName);
                        ac.setAuthorizedID(userName);
                    }
                }
            }
        });
        transportFactory = saslFactory;
        // Create a processor wrapper, to get the caller
        processorToUse = (inProt, outProt) -> {
            TSaslServerTransport saslServerTransport = (TSaslServerTransport) inProt.getTransport();
            SaslServer saslServer = saslServerTransport.getSaslServer();
            String principal = saslServer.getAuthorizationID();
            hbaseServiceHandler.setEffectiveUser(principal);
            processor.process(inProt, outProt);
        };
    }
    if (conf.get(BIND_CONF_KEY) != null && !implType.canSpecifyBindIP) {
        LOG.error("Server types {} don't support IP address binding at the moment. See " + "https://issues.apache.org/jira/browse/HBASE-2155 for details.", Joiner.on(", ").join(ImplType.serversThatCannotSpecifyBindIP()));
        throw new RuntimeException("-" + BIND_CONF_KEY + " not supported with " + implType);
    }
    InetSocketAddress inetSocketAddress = new InetSocketAddress(getBindAddress(conf), listenPort);
    if (implType == ImplType.HS_HA || implType == ImplType.NONBLOCKING || implType == ImplType.THREADED_SELECTOR) {
        TNonblockingServerTransport serverTransport = new TNonblockingServerSocket(inetSocketAddress);
        if (implType == ImplType.NONBLOCKING) {
            tserver = getTNonBlockingServer(serverTransport, protocolFactory, processorToUse, transportFactory, inetSocketAddress);
        } else if (implType == ImplType.HS_HA) {
            tserver = getTHsHaServer(serverTransport, protocolFactory, processorToUse, transportFactory, inetSocketAddress);
        } else {
            // THREADED_SELECTOR
            tserver = getTThreadedSelectorServer(serverTransport, protocolFactory, processorToUse, transportFactory, inetSocketAddress);
        }
        LOG.info("starting HBase {} server on {}", implType.simpleClassName(), Integer.toString(listenPort));
    } else if (implType == ImplType.THREAD_POOL) {
        this.tserver = getTThreadPoolServer(protocolFactory, processorToUse, transportFactory, inetSocketAddress);
    } else {
        throw new AssertionError("Unsupported Thrift server implementation: " + implType.simpleClassName());
    }
    // A sanity check that we instantiated the right type of server.
    if (tserver.getClass() != implType.serverClass) {
        throw new AssertionError("Expected to create Thrift server class " + implType.serverClass.getName() + " but got " + tserver.getClass().getName());
    }
}
Also used : THRIFT_SERVER_SOCKET_READ_TIMEOUT_KEY(org.apache.hadoop.hbase.thrift.Constants.THRIFT_SERVER_SOCKET_READ_TIMEOUT_KEY) UserProvider(org.apache.hadoop.hbase.security.UserProvider) Server(org.apache.hbase.thirdparty.org.eclipse.jetty.server.Server) TThreadedSelectorServer(org.apache.thrift.server.TThreadedSelectorServer) ThreadFactoryBuilder(org.apache.hbase.thirdparty.com.google.common.util.concurrent.ThreadFactoryBuilder) UnsupportedCallbackException(javax.security.auth.callback.UnsupportedCallbackException) SslConnectionFactory(org.apache.hbase.thirdparty.org.eclipse.jetty.server.SslConnectionFactory) TServer(org.apache.thrift.server.TServer) TBinaryProtocol(org.apache.thrift.protocol.TBinaryProtocol) THRIFT_SUPPORT_PROXYUSER_KEY(org.apache.hadoop.hbase.thrift.Constants.THRIFT_SUPPORT_PROXYUSER_KEY) InetAddress(java.net.InetAddress) THRIFT_INFO_SERVER_BINDING_ADDRESS(org.apache.hadoop.hbase.thrift.Constants.THRIFT_INFO_SERVER_BINDING_ADDRESS) HttpConfiguration(org.apache.hbase.thirdparty.org.eclipse.jetty.server.HttpConfiguration) THRIFT_KEYTAB_FILE_KEY(org.apache.hadoop.hbase.thrift.Constants.THRIFT_KEYTAB_FILE_KEY) ProxyUsers(org.apache.hadoop.security.authorize.ProxyUsers) DefaultParser(org.apache.hbase.thirdparty.org.apache.commons.cli.DefaultParser) MIN_WORKERS_OPTION(org.apache.hadoop.hbase.thrift.Constants.MIN_WORKERS_OPTION) Map(java.util.Map) Configuration(org.apache.hadoop.conf.Configuration) ParseFilter(org.apache.hadoop.hbase.filter.ParseFilter) BACKLOG_CONF_DEAFULT(org.apache.hadoop.hbase.thrift.Constants.BACKLOG_CONF_DEAFULT) THRIFT_SERVER_SOCKET_READ_TIMEOUT_DEFAULT(org.apache.hadoop.hbase.thrift.Constants.THRIFT_SERVER_SOCKET_READ_TIMEOUT_DEFAULT) TCompactProtocol(org.apache.thrift.protocol.TCompactProtocol) Joiner(org.apache.hbase.thirdparty.com.google.common.base.Joiner) HTTP_MAX_THREADS_KEY(org.apache.hadoop.hbase.thrift.Constants.HTTP_MAX_THREADS_KEY) HTTP_MIN_THREADS_KEY(org.apache.hadoop.hbase.thrift.Constants.HTTP_MIN_THREADS_KEY) HttpServerUtil(org.apache.hadoop.hbase.http.HttpServerUtil) ExitCodeException(org.apache.hadoop.util.Shell.ExitCodeException) HttpConnectionFactory(org.apache.hbase.thirdparty.org.eclipse.jetty.server.HttpConnectionFactory) TNonblockingServerTransport(org.apache.thrift.transport.TNonblockingServerTransport) THRIFT_INFO_SERVER_BINDING_ADDRESS_DEFAULT(org.apache.hadoop.hbase.thrift.Constants.THRIFT_INFO_SERVER_BINDING_ADDRESS_DEFAULT) BlockingQueue(java.util.concurrent.BlockingQueue) READ_TIMEOUT_OPTION(org.apache.hadoop.hbase.thrift.Constants.READ_TIMEOUT_OPTION) Strings(org.apache.hadoop.hbase.util.Strings) MAX_FRAME_SIZE_CONF_DEFAULT(org.apache.hadoop.hbase.thrift.Constants.MAX_FRAME_SIZE_CONF_DEFAULT) JvmPauseMonitor(org.apache.hadoop.hbase.util.JvmPauseMonitor) QueuedThreadPool(org.apache.hbase.thirdparty.org.eclipse.jetty.util.thread.QueuedThreadPool) COMPACT_CONF_KEY(org.apache.hadoop.hbase.thrift.Constants.COMPACT_CONF_KEY) Callback(javax.security.auth.callback.Callback) TProcessor(org.apache.thrift.TProcessor) MAX_FRAME_SIZE_CONF_KEY(org.apache.hadoop.hbase.thrift.Constants.MAX_FRAME_SIZE_CONF_KEY) TServlet(org.apache.thrift.server.TServlet) Options(org.apache.hbase.thirdparty.org.apache.commons.cli.Options) DEFAULT_HTTP_MAX_HEADER_SIZE(org.apache.hadoop.hbase.thrift.Constants.DEFAULT_HTTP_MAX_HEADER_SIZE) ServletContextHandler(org.apache.hbase.thirdparty.org.eclipse.jetty.servlet.ServletContextHandler) COMPACT_CONF_DEFAULT(org.apache.hadoop.hbase.thrift.Constants.COMPACT_CONF_DEFAULT) USE_HTTP_CONF_KEY(org.apache.hadoop.hbase.thrift.Constants.USE_HTTP_CONF_KEY) HTTP_MAX_THREADS_KEY_DEFAULT(org.apache.hadoop.hbase.thrift.Constants.HTTP_MAX_THREADS_KEY_DEFAULT) FRAMED_CONF_DEFAULT(org.apache.hadoop.hbase.thrift.Constants.FRAMED_CONF_DEFAULT) SaslUtil(org.apache.hadoop.hbase.security.SaslUtil) TSaslServerTransport(org.apache.thrift.transport.TSaslServerTransport) UserGroupInformation(org.apache.hadoop.security.UserGroupInformation) THRIFT_SSL_KEYSTORE_PASSWORD_KEY(org.apache.hadoop.hbase.thrift.Constants.THRIFT_SSL_KEYSTORE_PASSWORD_KEY) InfoServer(org.apache.hadoop.hbase.http.InfoServer) PORT_OPTION(org.apache.hadoop.hbase.thrift.Constants.PORT_OPTION) FRAMED_OPTION(org.apache.hadoop.hbase.thrift.Constants.FRAMED_OPTION) ServletHolder(org.apache.hbase.thirdparty.org.eclipse.jetty.servlet.ServletHolder) KEEP_ALIVE_SEC_OPTION(org.apache.hadoop.hbase.thrift.Constants.KEEP_ALIVE_SEC_OPTION) IOException(java.io.IOException) HelpFormatter(org.apache.hbase.thirdparty.org.apache.commons.cli.HelpFormatter) HttpVersion(org.apache.hbase.thirdparty.org.eclipse.jetty.http.HttpVersion) THRIFT_SPNEGO_KEYTAB_FILE_KEY(org.apache.hadoop.hbase.thrift.Constants.THRIFT_SPNEGO_KEYTAB_FILE_KEY) ServerConnector(org.apache.hbase.thirdparty.org.eclipse.jetty.server.ServerConnector) TProtocolFactory(org.apache.thrift.protocol.TProtocolFactory) UnknownHostException(java.net.UnknownHostException) SELECTOR_NUM_OPTION(org.apache.hadoop.hbase.thrift.Constants.SELECTOR_NUM_OPTION) CommandLineParser(org.apache.hbase.thirdparty.org.apache.commons.cli.CommandLineParser) HTTP_MIN_THREADS_KEY_DEFAULT(org.apache.hadoop.hbase.thrift.Constants.HTTP_MIN_THREADS_KEY_DEFAULT) THRIFT_SSL_KEYSTORE_TYPE_DEFAULT(org.apache.hadoop.hbase.thrift.Constants.THRIFT_SSL_KEYSTORE_TYPE_DEFAULT) CommandLine(org.apache.hbase.thirdparty.org.apache.commons.cli.CommandLine) THRIFT_SSL_EXCLUDE_PROTOCOLS_KEY(org.apache.hadoop.hbase.thrift.Constants.THRIFT_SSL_EXCLUDE_PROTOCOLS_KEY) INFOPORT_OPTION(org.apache.hadoop.hbase.thrift.Constants.INFOPORT_OPTION) THsHaServer(org.apache.thrift.server.THsHaServer) THRIFT_INFO_SERVER_PORT(org.apache.hadoop.hbase.thrift.Constants.THRIFT_INFO_SERVER_PORT) LoggerFactory(org.slf4j.LoggerFactory) PORT_CONF_KEY(org.apache.hadoop.hbase.thrift.Constants.PORT_CONF_KEY) Splitter(org.apache.hbase.thirdparty.com.google.common.base.Splitter) COMPACT_OPTION(org.apache.hadoop.hbase.thrift.Constants.COMPACT_OPTION) THRIFT_HTTP_ALLOW_OPTIONS_METHOD_DEFAULT(org.apache.hadoop.hbase.thrift.Constants.THRIFT_HTTP_ALLOW_OPTIONS_METHOD_DEFAULT) THRIFT_SSL_INCLUDE_PROTOCOLS_KEY(org.apache.hadoop.hbase.thrift.Constants.THRIFT_SSL_INCLUDE_PROTOCOLS_KEY) SslContextFactory(org.apache.hbase.thirdparty.org.eclipse.jetty.util.ssl.SslContextFactory) FRAMED_CONF_KEY(org.apache.hadoop.hbase.thrift.Constants.FRAMED_CONF_KEY) Configured(org.apache.hadoop.conf.Configured) Hbase(org.apache.hadoop.hbase.thrift.generated.Hbase) TFramedTransport(org.apache.thrift.transport.layered.TFramedTransport) THRIFT_SSL_KEYSTORE_KEYPASSWORD_KEY(org.apache.hadoop.hbase.thrift.Constants.THRIFT_SSL_KEYSTORE_KEYPASSWORD_KEY) THRIFT_FILTERS(org.apache.hadoop.hbase.thrift.Constants.THRIFT_FILTERS) TNonblockingServer(org.apache.thrift.server.TNonblockingServer) DEFAULT_BIND_ADDR(org.apache.hadoop.hbase.thrift.Constants.DEFAULT_BIND_ADDR) HBaseInterfaceAudience(org.apache.hadoop.hbase.HBaseInterfaceAudience) PrivilegedAction(java.security.PrivilegedAction) InetSocketAddress(java.net.InetSocketAddress) LinkedBlockingQueue(java.util.concurrent.LinkedBlockingQueue) Tool(org.apache.hadoop.util.Tool) THRIFT_SSL_KEYSTORE_STORE_KEY(org.apache.hadoop.hbase.thrift.Constants.THRIFT_SSL_KEYSTORE_STORE_KEY) TServerTransport(org.apache.thrift.transport.TServerTransport) DEFAULT_LISTEN_PORT(org.apache.hadoop.hbase.thrift.Constants.DEFAULT_LISTEN_PORT) List(java.util.List) MAX_WORKERS_OPTION(org.apache.hadoop.hbase.thrift.Constants.MAX_WORKERS_OPTION) AuthorizeCallback(javax.security.sasl.AuthorizeCallback) HBaseConfiguration(org.apache.hadoop.hbase.HBaseConfiguration) EnvironmentEdgeManager(org.apache.hadoop.hbase.util.EnvironmentEdgeManager) MAX_QUEUE_SIZE_OPTION(org.apache.hadoop.hbase.thrift.Constants.MAX_QUEUE_SIZE_OPTION) THRIFT_SSL_KEYSTORE_TYPE_KEY(org.apache.hadoop.hbase.thrift.Constants.THRIFT_SSL_KEYSTORE_TYPE_KEY) TTransportFactory(org.apache.thrift.transport.TTransportFactory) DNS(org.apache.hadoop.hbase.util.DNS) THRIFT_KERBEROS_PRINCIPAL_KEY(org.apache.hadoop.hbase.thrift.Constants.THRIFT_KERBEROS_PRINCIPAL_KEY) THRIFT_DNS_NAMESERVER_KEY(org.apache.hadoop.hbase.thrift.Constants.THRIFT_DNS_NAMESERVER_KEY) THRIFT_SPNEGO_PRINCIPAL_KEY(org.apache.hadoop.hbase.thrift.Constants.THRIFT_SPNEGO_PRINCIPAL_KEY) THRIFT_SSL_INCLUDE_CIPHER_SUITES_KEY(org.apache.hadoop.hbase.thrift.Constants.THRIFT_SSL_INCLUDE_CIPHER_SUITES_KEY) ThreadPoolExecutor(java.util.concurrent.ThreadPoolExecutor) THRIFT_INFO_SERVER_PORT_DEFAULT(org.apache.hadoop.hbase.thrift.Constants.THRIFT_INFO_SERVER_PORT_DEFAULT) ArrayUtils(org.apache.commons.lang3.ArrayUtils) SaslRpcServer(org.apache.hadoop.security.SaslRpcServer) TNonblockingServerSocket(org.apache.thrift.transport.TNonblockingServerSocket) THRIFT_SSL_ENABLED_KEY(org.apache.hadoop.hbase.thrift.Constants.THRIFT_SSL_ENABLED_KEY) SecurityUtil(org.apache.hadoop.hbase.security.SecurityUtil) THRIFT_QOP_KEY(org.apache.hadoop.hbase.thrift.Constants.THRIFT_QOP_KEY) THRIFT_HTTP_ALLOW_OPTIONS_METHOD(org.apache.hadoop.hbase.thrift.Constants.THRIFT_HTTP_ALLOW_OPTIONS_METHOD) ExecutorService(java.util.concurrent.ExecutorService) THRIFT_SSL_EXCLUDE_CIPHER_SUITES_KEY(org.apache.hadoop.hbase.thrift.Constants.THRIFT_SSL_EXCLUDE_CIPHER_SUITES_KEY) Logger(org.slf4j.Logger) HBaseMarkers(org.apache.hadoop.hbase.log.HBaseMarkers) VersionInfo(org.apache.hadoop.hbase.util.VersionInfo) THRIFT_DNS_INTERFACE_KEY(org.apache.hadoop.hbase.thrift.Constants.THRIFT_DNS_INTERFACE_KEY) ToolRunner(org.apache.hadoop.util.ToolRunner) THRIFT_SELECTOR_NUM(org.apache.hadoop.hbase.thrift.Constants.THRIFT_SELECTOR_NUM) TimeUnit(java.util.concurrent.TimeUnit) TServerSocket(org.apache.thrift.transport.TServerSocket) SecureRequestCustomizer(org.apache.hbase.thirdparty.org.eclipse.jetty.server.SecureRequestCustomizer) InterfaceAudience(org.apache.yetus.audience.InterfaceAudience) BIND_OPTION(org.apache.hadoop.hbase.thrift.Constants.BIND_OPTION) BACKLOG_CONF_KEY(org.apache.hadoop.hbase.thrift.Constants.BACKLOG_CONF_KEY) BIND_CONF_KEY(org.apache.hadoop.hbase.thrift.Constants.BIND_CONF_KEY) SaslServer(javax.security.sasl.SaslServer) TProtocolFactory(org.apache.thrift.protocol.TProtocolFactory) TNonblockingServerTransport(org.apache.thrift.transport.TNonblockingServerTransport) SaslServer(javax.security.sasl.SaslServer) InetSocketAddress(java.net.InetSocketAddress) SslConnectionFactory(org.apache.hbase.thirdparty.org.eclipse.jetty.server.SslConnectionFactory) HttpConnectionFactory(org.apache.hbase.thirdparty.org.eclipse.jetty.server.HttpConnectionFactory) TProtocolFactory(org.apache.thrift.protocol.TProtocolFactory) LoggerFactory(org.slf4j.LoggerFactory) SslContextFactory(org.apache.hbase.thirdparty.org.eclipse.jetty.util.ssl.SslContextFactory) TTransportFactory(org.apache.thrift.transport.TTransportFactory) TTransportFactory(org.apache.thrift.transport.TTransportFactory) AuthorizeCallback(javax.security.sasl.AuthorizeCallback) TSaslServerTransport(org.apache.thrift.transport.TSaslServerTransport) Callback(javax.security.auth.callback.Callback) AuthorizeCallback(javax.security.sasl.AuthorizeCallback) TProcessor(org.apache.thrift.TProcessor) TFramedTransport(org.apache.thrift.transport.layered.TFramedTransport) TNonblockingServerSocket(org.apache.thrift.transport.TNonblockingServerSocket) UnsupportedCallbackException(javax.security.auth.callback.UnsupportedCallbackException) Map(java.util.Map)

Aggregations

IOException (java.io.IOException)1 InetAddress (java.net.InetAddress)1 InetSocketAddress (java.net.InetSocketAddress)1 UnknownHostException (java.net.UnknownHostException)1 PrivilegedAction (java.security.PrivilegedAction)1 List (java.util.List)1 Map (java.util.Map)1 BlockingQueue (java.util.concurrent.BlockingQueue)1 ExecutorService (java.util.concurrent.ExecutorService)1 LinkedBlockingQueue (java.util.concurrent.LinkedBlockingQueue)1 ThreadPoolExecutor (java.util.concurrent.ThreadPoolExecutor)1 TimeUnit (java.util.concurrent.TimeUnit)1 Callback (javax.security.auth.callback.Callback)1 UnsupportedCallbackException (javax.security.auth.callback.UnsupportedCallbackException)1 AuthorizeCallback (javax.security.sasl.AuthorizeCallback)1 SaslServer (javax.security.sasl.SaslServer)1 ArrayUtils (org.apache.commons.lang3.ArrayUtils)1 Configuration (org.apache.hadoop.conf.Configuration)1 Configured (org.apache.hadoop.conf.Configured)1 HBaseConfiguration (org.apache.hadoop.hbase.HBaseConfiguration)1