Examples of SocketOutputStream


Examples of org.apache.hadoop.net.SocketOutputStream

      }
    }
   
    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

Examples of org.apache.hadoop.net.SocketOutputStream

   
    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

Examples of org.apache.hadoop.net.SocketOutputStream

      }
    }
   
    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

Examples of org.apache.hadoop.net.SocketOutputStream

  private final boolean isLocal;

  NioInetPeer(Socket socket) throws IOException {
    this.socket = socket;
    this.in = new SocketInputStream(socket.getChannel(), 0);
    this.out = new SocketOutputStream(socket.getChannel(), 0);
    this.isLocal = socket.getInetAddress().equals(socket.getLocalAddress());
  }
View Full Code Here

Examples of org.apache.hadoop.net.SocketOutputStream

    long checksumSize = ckHdr.getChecksumSize();
    long startMetaOffset = versionSize + cheaderSize + startChunkNumber * checksumSize;
    long metaLength = numChunks * checksumSize;

    // get a connection back to the client
    SocketOutputStream out = new SocketOutputStream(s, datanode.socketWriteTimeout);

    try {

      // write out the checksum type and bytesperchecksum to client
      // skip the first two bytes that describe the version
View Full Code Here

Examples of org.apache.hadoop.net.SocketOutputStream

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

        if (memoizedBlock.hasBlockChanged(len, offset)) {
          blockDataFileReader.readFully(buf, dataOff, len, offset, true);
          if (dnData != null) {
            dnData.recordReadChunkDataTime();
          }

          ChecksumUtil.updateChunkChecksum(buf, checksumOff, dataOff, len,
              checksum);
          if (dnData != null) {
            dnData.recordUpdateChunkCheckSumTime();
          }
         
          sockOut.write(buf, 0, dataOff + len);
          if (dnData != null) {
            dnData.recordSendChunkToClientTime();
          }
        } else {
          // first write the packet
          sockOut.write(buf, 0, dataOff);
          // no need to flush. since we know out is not a buffered stream.
          blockDataFileReader.transferToSocketFully(sockOut,offset, len);
          if (dnData != null) {
            dnData.recordTransferChunkToClientTime();
          }
View Full Code Here

Examples of org.apache.hadoop.net.SocketOutputStream

    long checksumSize = ckHdr.getChecksumSize();
    long startMetaOffset = versionSize + cheaderSize + startChunkNumber * checksumSize;
    long metaLength = numChunks * checksumSize;

    // get a connection back to the client
    SocketOutputStream out = new SocketOutputStream(s, datanode.socketWriteTimeout);

    try {

      // write out the checksum type and bytesperchecksum to client
      // skip the first two bytes that describe the version
View Full Code Here

Examples of org.apache.hadoop.net.SocketOutputStream

    // find the offset in the metafile
    long startChunkNumber = startOffset / bytesPerChecksum;
    long numChunks = length / bytesPerChecksum;

    // get a connection back to the client
    SocketOutputStream out = new SocketOutputStream(s, datanode.socketWriteTimeout);

    try {
      // Write checksum information
      checksum.writeHeader(new DataOutputStream(out));
     
View Full Code Here

Examples of org.jmxtrans.embedded.util.net.SocketOutputStream

    public SocketOutputStream makeObject(HostAndPort HostAndPort) throws Exception {
        Socket socket = new Socket();
        socket.setKeepAlive(true);
        socket.connect(new InetSocketAddress(HostAndPort.getHost(), HostAndPort.getPort()), socketConnectTimeoutInMillis);

        return new SocketOutputStream(socket);
    }
View Full Code Here

Examples of org.jmxtrans.embedded.util.net.SocketOutputStream

                "org.jmxtrans.embedded:Type=SocketPool,Host=" + host + ",Port=" + port + ",Name=GraphiteSocketPool@" + System.identityHashCode(this),
                ManagementFactory.getPlatformMBeanServer());

        if (isEnabled()) {
            try {
                SocketOutputStream socketOutputStream = socketOutputStreamPool.borrowObject(graphiteServerHostAndPort);
                socketOutputStreamPool.returnObject(graphiteServerHostAndPort, socketOutputStream);
            } catch (Exception e) {
                logger.warn("Test Connection: FAILURE to connect to Graphite server '{}'", graphiteServerHostAndPort, e);
            }
        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.