16 #ifndef IMPALA_RPC_THRIFT_SERVER_H
17 #define IMPALA_RPC_THRIFT_SERVER_H
19 #include <boost/thread/mutex.hpp>
20 #include <boost/scoped_ptr.hpp>
21 #include <boost/shared_ptr.hpp>
22 #include <boost/unordered_map.hpp>
23 #include <boost/uuid/uuid_generators.hpp>
24 #include <thrift/server/TServer.h>
25 #include <thrift/TProcessor.h>
83 const boost::shared_ptr<apache::thrift::TProcessor>& processor,
int port,
90 Status EnableSsl(
const std::string& certificate,
const std::string& private_key);
137 boost::shared_ptr<apache::thrift::transport::TServerTransport>* socket);
168 boost::scoped_ptr<apache::thrift::server::TServer>
server_;
179 typedef boost::unordered_map<ConnectionContext*, boost::shared_ptr<ConnectionContext> >
bool ssl_enabled_
True if the server socket only accepts SSL connections.
boost::scoped_ptr< apache::thrift::server::TServer > server_
Thrift housekeeping.
static const TUniqueId & GetThreadConnectionId()
virtual void ConnectionStart(const ConnectionContext &connection_context)=0
Called when a connection is established (when a client connects).
class SimpleMetric< int64_t, TMetricKind::COUNTER > IntCounter
boost::scoped_ptr< Thread > server_thread_
Thread that runs ThriftServerEventProcessor::Supervise() in a separate loop.
static const int DEFAULT_WORKER_THREADS
std::string Username
Username.
MetricGroups may be organised hierarchically as a tree.
Status EnableSsl(const std::string &certificate, const std::string &private_key)
void Join()
Blocks until the server stops and exits its main thread.
TNetworkAddress network_address
int port_
The port on which the server interface is exposed.
bool started_
True if the server has been successfully started, for internal use only.
Interface class for receiving connection creation / termination events.
std::string private_key_path_
Path to private key file in .PEM format.
ThriftServer(const std::string &name, const boost::shared_ptr< apache::thrift::TProcessor > &processor, int port, AuthProvider *auth_provider=NULL, MetricGroup *metrics=NULL, int num_worker_threads=DEFAULT_WORKER_THREADS, ServerType server_type=Threaded)
AuthProvider * auth_provider_
Not owned by us, owned by the AuthManager.
ConnectionContextSet connection_contexts_
IntGauge * num_current_connections_metric_
Number of currently active connections.
Per-connection information.
boost::mutex connection_contexts_lock_
Protects connection_contexts_.
ConnectionHandlerIf * connection_handler_
If not NULL, called when connection events happen. Not owned by us.
Status CreateSocket(boost::shared_ptr< apache::thrift::transport::TServerTransport > *socket)
bool metrics_enabled_
True if metrics are enabled.
void SetConnectionHandler(ConnectionHandlerIf *connection)
ServerType server_type_
ThreadPool or Threaded server.
static const ConnectionContext * GetThreadConnectionContext()
virtual void ConnectionEnd(const ConnectionContext &connection_context)=0
boost::uuids::random_generator uuid_generator_
Used to generate a unique connection id for every connection.
IntCounter * total_connections_metric_
Total connections made over the lifetime of this server.
std::string certificate_path_
Path to certificate file in .PEM format.
boost::unordered_map< ConnectionContext *, boost::shared_ptr< ConnectionContext > > ConnectionContextSet
const std::string name_
User-specified identifier that shows up in logs.
boost::shared_ptr< apache::thrift::TProcessor > processor_