Example usage for org.apache.thrift.transport TNonblockingSocket setTimeout

List of usage examples for org.apache.thrift.transport TNonblockingSocket setTimeout

Introduction

In this page you can find the example usage for org.apache.thrift.transport TNonblockingSocket setTimeout.

Prototype

public void setTimeout(int timeout) 

Source Link

Document

Sets the socket timeout, although this implementation never uses blocking operations so it is unused.

Usage

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.");
    }/*from w  w w  . j a  v a2s. c  o  m*/
    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  . jav 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.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   www . j a va 2 s  .co  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);
    }
}