Examples of BlockSender


Examples of org.apache.hadoop.dfs.DataNode.BlockSender

    throttler.setBandwidth(Math.min(bw, MAX_SCAN_RATE));
  }
 
  private void verifyBlock(Block block) {
   
    BlockSender blockSender = null;

    /* In case of failure, attempt to read second time to reduce
     * transient errors. How do we flush block data from kernel
     * buffers before the second read?
     */
    for (int i=0; i<2; i++) {
      boolean second = (i > 0);
     
      try {
        adjustThrottler();
       
        blockSender = datanode.new BlockSender(block, 0, -1, false,
                                               false, true);

        DataOutputStream out =
                new DataOutputStream(new IOUtils.NullOutputStream());
       
        blockSender.sendBlock(out, throttler);

        LOG.info((second ? "Second " : "") +
                 "Verification succeeded for " + block);
       
        if ( second ) {
View Full Code Here

Examples of org.apache.hadoop.dfs.DataNode.BlockSender

    throttler.setBandwidth(Math.min(bw, MAX_SCAN_RATE));
  }
 
  private void verifyBlock(Block block) {
   
    BlockSender blockSender = null;

    /* In case of failure, attempt to read second time to reduce
     * transient errors. How do we flush block data from kernel
     * buffers before the second read?
     */
    for (int i=0; i<2; i++) {
      boolean second = (i > 0);
     
      try {
        adjustThrottler();
       
        blockSender = datanode.new BlockSender(block, 0, -1, false,
                                               false, true);

        DataOutputStream out =
                new DataOutputStream(new IOUtils.NullOutputStream());
       
        blockSender.sendBlock(out, null, throttler);

        LOG.info((second ? "Second " : "") +
                 "Verification succeeded for " + block);
       
        if ( second ) {
View Full Code Here

Examples of org.apache.hadoop.dfs.DataNode.BlockSender

    throttler.setBandwidth(Math.min(bw, MAX_SCAN_RATE));
  }
 
  private void verifyBlock(Block block) {
   
    BlockSender blockSender = null;

    /* In case of failure, attempt to read second time to reduce
     * transient errors. How do we flush block data from kernel
     * buffers before the second read?
     */
    for (int i=0; i<2; i++) {
      boolean second = (i > 0);
     
      try {
        adjustThrottler();
       
        blockSender = datanode.new BlockSender(block, 0, -1, false,
                                               false, true);

        DataOutputStream out =
                new DataOutputStream(new IOUtils.NullOutputStream());
       
        blockSender.sendBlock(out, throttler);

        LOG.info((second ? "Second " : "") +
                 "Verification succeeded for " + block);
       
        if ( second ) {
View Full Code Here

Examples of org.apache.hadoop.hdfs.server.datanode.BlockSender

    try {
      LOG.info("Sending block " + block +
          " from " + sock.getLocalSocketAddress().toString() +
          " to " + sock.getRemoteSocketAddress().toString());
      BlockSender blockSender =
        new BlockSender(namespaceId, block, blockSize, 0, blockSize,
            corruptChecksumOk, chunkOffsetOK, verifyChecksum,
            transferToAllowed,
            metadataIn, new BlockSender.InputStreamFactory() {
          @Override
          public InputStream createStream(long offset)
          throws IOException {
            // we are passing 0 as the offset above,
            // so we can safely ignore
            // the offset passed
            return blockContents;
          }
        });

      // Header info
      out.writeShort(dataTransferVersion);
      out.writeByte(DataTransferProtocol.OP_WRITE_BLOCK);
      if (dataTransferVersion >= DataTransferProtocol.FEDERATION_VERSION) {
        out.writeInt(namespaceId);
      }
      out.writeLong(block.getBlockId());
      out.writeLong(block.getGenerationStamp());
      out.writeInt(0);           // no pipelining
      out.writeBoolean(false);   // not part of recovery
      Text.writeString(out, ""); // client
      out.writeBoolean(true); // sending src node information
      DatanodeInfo srcNode = new DatanodeInfo();
      srcNode.write(out); // Write src node DatanodeInfo
      // write targets
      out.writeInt(0); // num targets
      // send data & checksum
      blockSender.sendBlock(out, baseStream, null, progress);

      LOG.info("Sent block " + block + " to " + datanode);
    } finally {
      sock.close();
      out.close();
View Full Code Here

Examples of org.apache.hadoop.hdfs.server.datanode.BlockSender

    try {
      LOG.info("Sending block " + block +
          " from " + sock.getLocalSocketAddress().toString() +
          " to " + sock.getRemoteSocketAddress().toString());
      BlockSender blockSender =
        new BlockSender(namespaceId, block, blockSize, 0, blockSize,
            corruptChecksumOk, chunkOffsetOK, verifyChecksum,
            transferToAllowed, dataTransferVersion >= DataTransferProtocol.PACKET_INCLUDE_VERSION_VERSION,
            new BlockWithChecksumFileReader.InputStreamWithChecksumFactory() {
              @Override
              public InputStream createStream(long offset) throws IOException {
                // we are passing 0 as the offset above,
                // so we can safely ignore
                // the offset passed
                return blockContents;
              }

              @Override
              public DataInputStream getChecksumStream() throws IOException {
                return metadataIn;
              }

            @Override
            public BlockDataFile.Reader getBlockDataFileReader()
                throws IOException {
              return BlockDataFile.getDummyDataFileFromFileChannel(
                  blockContents.getChannel()).getReader(null);
            }
          });

      WriteBlockHeader header = new WriteBlockHeader(new VersionAndOpcode(
          dataTransferVersion, DataTransferProtocol.OP_WRITE_BLOCK));
      header.set(namespaceId, block.getBlockId(), block.getGenerationStamp(),
          0, false, true, new DatanodeInfo(), 0, null, "");
      header.writeVersionAndOpCode(out);
      header.write(out);
      blockSender.sendBlock(out, baseStream, null, progress);

      LOG.info("Sent block " + block + " to " + datanode);
    } finally {
      sock.close();
      out.close();
View Full Code Here

Examples of rabbit.proxy.BlockSender

  public void write (byte[] b, int off, int len) throws IOException {
      ByteBuffer buf = ByteBuffer.wrap (b, off, len);
      if (cacheChannel != null)
    writeCache (buf);
      new BlockSender (con.getChannel (), con.getSelector (),
           getLogger (), tlh.getClient (), buf,
           con.getChunking (), GZipHandler.this);     
  }
View Full Code Here

Examples of rabbit.proxy.BlockSender

     * This is not a fully correct handling, but it seems to work well enough.
     */   
    public void bufferRead (ByteBuffer buf) {
  try {
      mpp.parseBuffer (buf);
      new BlockSender (con.getChannel (), con.getSelector (),
           getLogger (), tlh.getClient (),
           buf, con.getChunking (), this)
  } catch (IOException e) {
      failed (e);     
  }
View Full Code Here

Examples of rabbit.proxy.BlockSender

  try {
      // TODO: do this in another thread?
      if (cacheChannel != null)
    writeCache (buf);
      totalRead += buf.remaining ();
      new BlockSender (con.getChannel (), con.getSelector (),
           getLogger (), tlh.getClient (),
           buf, con.getChunking (), this);
  } catch (IOException e) {
      failed (e);
  }
View Full Code Here

Examples of rabbit.proxy.BlockSender

  this.tlClient = tlClient;
  HttpHeader response = con.getHttpGenerator ().getHeader ();
  response.setHeader ("Transfer-Encoding", "Chunked");
  byte[] b2 = response.toString ().getBytes ("ASCII");
  ByteBuffer buffer = ByteBuffer.wrap (b2);
  BlockSender bs =
    new BlockSender (con.getChannel (), con.getSelector (),
         con.getLogger (), tlClient, buffer,
         false, this);
    }
View Full Code Here

Examples of rabbit.proxy.BlockSender

      sb.append ("\n</body></html>");
      mode = Mode.SEND_DATA;
  }
  byte[] b1 = sb.toString ().getBytes ("ASCII");
  ByteBuffer data = ByteBuffer.wrap (b1);
  BlockSender bs =
      new BlockSender (con.getChannel (), con.getSelector (),
           con.getLogger (), tlClient, data, true, this);
    }
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.