List of usage examples for org.apache.thrift.transport TNonblockingSocket TNonblockingSocket
public TNonblockingSocket(SocketChannel socketChannel) throws IOException
From source file:com.netflix.suro.input.thrift.CustomServerSocket.java
License:Apache License
protected TNonblockingSocket acceptImpl() throws TTransportException { if (serverSocket_ == null) { throw new TTransportException(TTransportException.NOT_OPEN, "No underlying server socket."); }/* w w w . j a va2 s.c om*/ try { SocketChannel socketChannel = serverSocketChannel.accept(); if (socketChannel == null) { return null; } TNonblockingSocket tsocket = new TNonblockingSocket(socketChannel); tsocket.setTimeout(0); // disabling client timeout tsocket.getSocketChannel().socket().setKeepAlive(true); tsocket.getSocketChannel().socket().setSendBufferSize(config.getSocketSendBufferBytes()); tsocket.getSocketChannel().socket().setReceiveBufferSize(config.getSocketRecvBufferBytes()); return tsocket; } catch (IOException iox) { throw new TTransportException(iox); } }
From source file:org.apache.accumulo.server.rpc.TNonblockingServerSocket.java
License:Apache License
@Override protected TNonblockingSocket acceptImpl() throws TTransportException { if (serverSocket_ == null) { throw new TTransportException(TTransportException.NOT_OPEN, "No underlying server socket."); }/* w w w.j a va2s . c om*/ try { SocketChannel socketChannel = serverSocketChannel.accept(); if (socketChannel == null) { return null; } TNonblockingSocket tsocket = new TNonblockingSocket(socketChannel); tsocket.setTimeout(clientTimeout_); return tsocket; } catch (IOException iox) { throw new TTransportException(iox); } }
From source file:org.apache.accumulo.server.util.TNonblockingServerSocket.java
License:Apache License
protected TNonblockingSocket acceptImpl() throws TTransportException { if (serverSocket_ == null) { throw new TTransportException(TTransportException.NOT_OPEN, "No underlying server socket."); }/*from w w w . ja v a2 s .c o m*/ try { SocketChannel socketChannel = serverSocketChannel.accept(); if (socketChannel == null) { return null; } TNonblockingSocket tsocket = new TNonblockingSocket(socketChannel); tsocket.setTimeout(clientTimeout_); return tsocket; } catch (IOException iox) { throw new TTransportException(iox); } }
From source file:org.commoncrawl.rpc.thriftrpc.ThriftRPCServerChannel.java
License:Apache License
@Override public void Accepted(NIOClientSocket theSocket) throws IOException { SelectionKey clientKey = null; TNonblockingTransport client = null; try {/*from w ww.j av a 2s .c o m*/ // accept the connection client = new TNonblockingSocket((SocketChannel) theSocket.getChannel()); try { clientKey = client.registerSelector(eventLoop.getSelector().getSelector(), SelectionKey.OP_READ); } catch (IOException e) { LOG.error(CCStringUtils.stringifyException(e)); throw new TTransportException(e); } // add this key to the map ThriftRPCClientChannel frameBuffer = new ThriftRPCClientChannel(this, this, client, clientKey); clientKey.attach(frameBuffer); } catch (TTransportException tte) { // something went wrong accepting. LOG.warn("Exception trying to accept!", tte); tte.printStackTrace(); if (clientKey != null) cleanupSelectionkey(clientKey); if (client != null) client.close(); } }