void serverThread(int port, boost::shared_ptr<TProcessor> &processor) { boost::shared_ptr<TProtocolFactory> protocolFactory(new TBinaryProtocolFactory()); boost::shared_ptr<TServerTransport> serverTransport(new TServerSocket(port)); boost::shared_ptr<TTransportFactory> transportFactory(new TBufferedTransportFactory()); boost::shared_ptr<ThreadManager> threadManager = ThreadManager::newSimpleThreadManager(THREADS); boost::shared_ptr<PosixThreadFactory> threadFactory = boost::shared_ptr<PosixThreadFactory>(new PosixThreadFactory()); threadManager->threadFactory(threadFactory); threadManager->start(); TThreadPoolServer server(processor, serverTransport, transportFactory, protocolFactory, threadManager); server.serve(); cout << "should never reach this part" << endl; }
void* WatDHTServer::start_rpc_server(void* param) { WatDHTServer* dht = static_cast<WatDHTServer*>(param); shared_ptr<WatDHTHandler> handler(new WatDHTHandler(dht)); shared_ptr<TProcessor> processor(new WatDHTProcessor(handler)); shared_ptr<TServerTransport> serverTransport( new TServerSocket(dht->get_port())); shared_ptr<TTransportFactory> transportFactory( new TBufferedTransportFactory()); shared_ptr<TProtocolFactory> protocolFactory(new TBinaryProtocolFactory()); shared_ptr<ThreadManager> threadManager = ThreadManager::newSimpleThreadManager(num_rpc_threads, 0); shared_ptr<PosixThreadFactory> threadFactory = shared_ptr<PosixThreadFactory>(new PosixThreadFactory()); threadManager->threadFactory(threadFactory); threadManager->start(); TThreadedServer* server = new TThreadedServer( processor, serverTransport, transportFactory, protocolFactory); dht->set_rpc_server(server); server->serve(); return NULL; }
void ExtensionRunner::enter() { // Set the socket information for the extension manager. auto socket_path = path_; // Create the thrift instances. OSQUERY_THRIFT_POINTER::shared_ptr<ExtensionHandler> handler( new ExtensionHandler(uuid_)); OSQUERY_THRIFT_POINTER::shared_ptr<TProcessor> processor( new ExtensionProcessor(handler)); OSQUERY_THRIFT_POINTER::shared_ptr<TServerTransport> serverTransport( new TServerSocket(socket_path)); OSQUERY_THRIFT_POINTER::shared_ptr<TTransportFactory> transportFactory( new TBufferedTransportFactory()); OSQUERY_THRIFT_POINTER::shared_ptr<TProtocolFactory> protocolFactory( new TBinaryProtocolFactory()); OSQUERY_THRIFT_POINTER::shared_ptr<ThreadManager> threadManager = ThreadManager::newSimpleThreadManager(FLAGS_worker_threads); OSQUERY_THRIFT_POINTER::shared_ptr<PosixThreadFactory> threadFactory = OSQUERY_THRIFT_POINTER::shared_ptr<PosixThreadFactory>( new PosixThreadFactory()); threadManager->threadFactory(threadFactory); threadManager->start(); // Start the Thrift server's run loop. try { VLOG(1) << "Extension service starting: " << socket_path; TThreadPoolServer server(processor, serverTransport, transportFactory, protocolFactory, threadManager); server.serve(); } catch (const std::exception& e) { LOG(ERROR) << "Cannot start extension handler: " << socket_path << " (" << e.what() << ")"; return; } }
void buildNonBlockingServer(int port, boost::shared_ptr<TProcessor> &processor) { boost::shared_ptr<TProtocolFactory> protocolFactory(new TBinaryProtocolFactory()); TNonblockingServer server(processor, protocolFactory, port); server.serve(); cout << "should never reach this part" << endl; }