Example usage for org.apache.hadoop.hdfs DFSClient getDatanodeReadTimeout

List of usage examples for org.apache.hadoop.hdfs DFSClient getDatanodeReadTimeout

Introduction

In this page you can find the example usage for org.apache.hadoop.hdfs DFSClient getDatanodeReadTimeout.

Prototype

int getDatanodeReadTimeout(int numNodes) 

Source Link

Usage

From source file:com.mellanox.r4h.DFSOutputStream.java

License:Apache License

/**
 * Create a socket for a write pipeline//from  w w  w  .  j a  v a 2s. c om
 * 
 * @param first
 *            the first datanode
 * @param length
 *            the pipeline length
 * @param client
 *            client
 * @return the socket connected to the first datanode
 */
static Socket createSocketForPipeline(final DatanodeInfo first, final int length, final DFSClient client)
        throws IOException {
    final String dnAddr = first.getXferAddr(client.getConf().getConnectToDnViaHostname());
    if (DFSClient.LOG.isDebugEnabled()) {
        DFSClient.LOG.debug("Connecting to datanode " + dnAddr);
    }
    final InetSocketAddress isa = NetUtils.createSocketAddr(dnAddr);
    final Socket sock = client.socketFactory.createSocket();
    final int timeout = client.getDatanodeReadTimeout(length);
    NetUtils.connect(sock, isa, client.getRandomLocalInterfaceAddr(), client.getConf().getSocketTimeout());
    sock.setSoTimeout(timeout);
    sock.setSendBufferSize(HdfsConstants.DEFAULT_DATA_SOCKET_SIZE);
    if (DFSClient.LOG.isDebugEnabled()) {
        DFSClient.LOG.debug("Send buf size " + sock.getSendBufferSize());
    }
    return sock;
}