/** * Constrcts a server object */ public HadoopThriftServer(String [] args) { if (args.length > 0) { serverPort = new Integer(args[0]); } try { ServerSocket ssock = createServerSocket(serverPort); TServerTransport serverTransport = new TServerSocket(ssock); Iface handler = new HadoopThriftHandler("hdfs-thrift-dhruba"); ThriftHadoopFileSystem.Processor processor = new ThriftHadoopFileSystem.Processor(handler); TThreadPoolServer.Options options = new TThreadPoolServer.Options(); options.minWorkerThreads = 10; server = new TThreadPoolServer(processor, serverTransport, new TTransportFactory(), new TTransportFactory(), new TBinaryProtocol.Factory(), new TBinaryProtocol.Factory(), options); System.out.println("Starting the hadoop thrift server on port [" + serverPort + "]..."); HadoopThriftHandler.LOG.info("Starting the hadoop thrift server on port [" +serverPort + "]..."); System.out.flush(); } catch (Exception x) { x.printStackTrace(); } }
/** @param socketFile to connect to when creating a Thrift client. */ ReconnectingEdenClient(final Path socketFile, Clock clock) { this( () -> { // Creates a new EdenService.Client by creating a new connection via the socketFile. UnixDomainSocket socket = UnixDomainSocket.createSocketWithPath(socketFile); TTransport transport = new TSocket(socket); // No need to invoke transport.open() because the UnixDomainSocket is already connected. TProtocol protocol = new TBinaryProtocol(transport); return new EdenService.Client(protocol); }, clock); }