Package org.apache.hadoop.net

Examples of org.apache.hadoop.net.SocketOutputStream


      }
    }
   
    try {
      if (transferTo) {
        SocketOutputStream sockOut = (SocketOutputStream)out;
        sockOut.write(buf, 0, dataOff); // First write checksum
       
        // no need to flush. since we know out is not a buffered stream.
        sockOut.transferToFully(((FileInputStream)blockIn).getChannel(),
                                blockInPosition, dataLen);
        blockInPosition += dataLen;
      } else {
        // normal transfer
        out.write(buf, 0, dataOff + dataLen);
View Full Code Here


        throw ioeToSocketException(e);
      }
    } else {
      try {
        //use transferTo(). Checks on out and blockIn are already done.
        SocketOutputStream sockOut = (SocketOutputStream) out;
        FileChannel fileChannel = ((FileInputStream) blockIn).getChannel();

        if (memoizedBlock.hasBlockChanged(len)) {
          fileChannel.position(blockInPosition);
          IOUtils.readFileChannelFully(
            fileChannel,
            buf,
            dataOff,
            len
          );
         
          ChecksumUtil.updateChunkChecksum(
            buf, checksumOff, dataOff, len, checksum
          );         
          sockOut.write(buf, 0, dataOff + len);
        } else {
          //first write the packet
          sockOut.write(buf, 0, dataOff);
          // no need to flush. since we know out is not a buffered stream.
          sockOut.transferToFully(fileChannel, blockInPosition, len);
        }

        blockInPosition += len;

      } catch (IOException e) {
View Full Code Here

      }
    }
   
    try {
      if (transferTo) {
        SocketOutputStream sockOut = (SocketOutputStream)out;
        sockOut.write(buf, 0, dataOff); // First write checksum
       
        // no need to flush. since we know out is not a buffered stream.
        sockOut.transferToFully(((FileInputStream)blockIn).getChannel(),
                                blockInPosition, dataLen);
        blockInPosition += dataLen;
      } else {
        // normal transfer
        out.write(buf, 0, dataOff + dataLen);
View Full Code Here

      }
    }
   
    try {
      if (transferTo) {
        SocketOutputStream sockOut = (SocketOutputStream)out;
        // First write header and checksums
        sockOut.write(buf, headerOff, dataOff - headerOff);
       
        // no need to flush since we know out is not a buffered stream
        FileChannel fileCh = ((FileInputStream)blockIn).getChannel();
        LongWritable waitTime = new LongWritable();
        LongWritable transferTime = new LongWritable();
        sockOut.transferToFully(fileCh, blockInPosition, dataLen,
            waitTime, transferTime);
        datanode.metrics.addSendDataPacketBlockedOnNetworkNanos(waitTime.get());
        datanode.metrics.addSendDataPacketTransferNanos(transferTime.get());
        blockInPosition += dataLen;
      } else {
View Full Code Here

        throw ioeToSocketException(e);
      }
    } else {
      try {
        //use transferTo(). Checks on out and blockIn are already done.
        SocketOutputStream sockOut = (SocketOutputStream) out;
        FileChannel fileChannel = ((FileInputStream) blockIn).getChannel();

        if (memoizedBlock.hasBlockChanged(len)) {
          fileChannel.position(blockInPosition);
          IOUtils.readFileChannelFully(
            fileChannel,
            buf,
            dataOff,
            len
          );
         
          ChecksumUtil.updateChunkChecksum(
            buf, checksumOff, dataOff, len, checksum
          );         
          sockOut.write(buf, 0, dataOff + len);
        } else {
          //first write the packet
          sockOut.write(buf, 0, dataOff);
          // no need to flush. since we know out is not a buffered stream.
          sockOut.transferToFully(fileChannel, blockInPosition, len);
        }

        blockInPosition += len;

      } catch (IOException e) {
View Full Code Here

   
    try {
      if (blockInPosition >= 0) {
        //use transferTo(). Checks on out and blockIn are already done.

        SocketOutputStream sockOut = (SocketOutputStream)out;
        //first write the packet
        sockOut.write(buf, 0, dataOff);
        // no need to flush. since we know out is not a buffered stream.

        sockOut.transferToFully(((FileInputStream)blockIn).getChannel(),
                                blockInPosition, len);

        blockInPosition += len;
      } else {
        // normal transfer
View Full Code Here

      }
    }
   
    try {
      if (transferTo) {
        SocketOutputStream sockOut = (SocketOutputStream)out;
        sockOut.write(buf, 0, dataOff); // First write checksum
       
        // no need to flush. since we know out is not a buffered stream.
        sockOut.transferToFully(((FileInputStream)blockIn).getChannel(),
                                blockInPosition, dataLen);
        blockInPosition += dataLen;
      } else {
        // normal transfer
        out.write(buf, 0, dataOff + dataLen);
View Full Code Here

     
      try {
        if (blockInPosition >= 0) {
          //use transferTo(). Checks on out and blockIn are already done.

          SocketOutputStream sockOut = (SocketOutputStream)out;
          //first write the packet
          sockOut.write(buf, 0, dataOff);
          // no need to flush. since we know out is not a buffered stream.

          sockOut.transferToFully(((FileInputStream)blockIn).getChannel(),
                                  blockInPosition, len);

          blockInPosition += len;
        } else {
          // normal transfer
View Full Code Here

      }
    }
   
    try {
      if (transferTo) {
        SocketOutputStream sockOut = (SocketOutputStream)out;
        // First write header and checksums
        sockOut.write(buf, headerOff, dataOff - headerOff);
       
        // no need to flush since we know out is not a buffered stream
        FileChannel fileCh = ((FileInputStream)blockIn).getChannel();
        LongWritable waitTime = new LongWritable();
        LongWritable transferTime = new LongWritable();
        sockOut.transferToFully(fileCh, blockInPosition, dataLen,
            waitTime, transferTime);
        datanode.metrics.addSendDataPacketBlockedOnNetworkNanos(waitTime.get());
        datanode.metrics.addSendDataPacketTransferNanos(transferTime.get());
        blockInPosition += dataLen;
      } else {
View Full Code Here

   
    try {
      if (blockInPosition >= 0) {
        //use transferTo(). Checks on out and blockIn are already done.

        SocketOutputStream sockOut = (SocketOutputStream)out;
        //first write the packet
        sockOut.write(buf, 0, dataOff);
        // no need to flush. since we know out is not a buffered stream.

        sockOut.transferToFully(((FileInputStream)blockIn).getChannel(),
                                blockInPosition, len);

        blockInPosition += len;
      } else {
        // normal transfer
View Full Code Here

TOP

Related Classes of org.apache.hadoop.net.SocketOutputStream

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.