List of usage examples for org.apache.thrift.transport TNonblockingTransport registerSelector
public abstract SelectionKey registerSelector(Selector selector, int interests) throws IOException;
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 w w .j a v a 2 s .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(); } }