[ 
https://issues.apache.org/jira/browse/HDFS-8287?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14734591#comment-14734591
 ] 

Tsz Wo Nicholas Sze commented on HDFS-8287:
-------------------------------------------

> ... we needed to copy current cell buffer for ParityGenerateTask. If there 
> are any better way to avoid double using of cell buffer rather than copying, 
> please let me know that. ...

(I somehow overlooked your comment earlier.)  We could avoid copying buffers 
using wait-nodify; see below

{code}
    synchronized CellBuffers flip() throws InterruptedIOException { //renamed 
from setReadyToCurrent
      if (bufReady == null) {
        try {
          wait();
        } catch(InterruptedException ie) {
          throw DFSUtil.toInterruptedIOException("flip interrupted.", ie);
        }
      }
      CellBuffers tmp = bufCurrent;
      bufCurrent = bufReady;
      bufCurrent.clear();
      bufReady = null;
      return tmp;
    }

    synchronized void releaseBuf(CellBuffers buf) {
      bufReady = buf;
      notifyAll();
    }

  //we also need to synchronized, check null and wait-nodify in other methods
{code}

{code}
  void writeParityCells() throws IOException {
    final CellBuffers cb = doubleCellBuffer.flip();
    //encode the data cells
    final ByteBuffer[] buffers = cb.getBuffers();
    final byte[][] checkSumArrays = 
doubleCellBuffer.getCheckSumArrays().clone();
    // Create parity packets asynchronously.
    completionService.submit(new Callable<Void>() {
      @Override
      public Void call() throws Exception {
        encode(encoder, numDataBlocks, buffers);
        for (int i = numDataBlocks; i < numAllBlocks; i++) {
          try {
            writeParity(i, buffers[i], checkSumArrays[i]);
          } catch (IOException e) {
            LOG.warn("Caught exception ", e);
          }
        }
        return null;
      }
    });
    doubleCellBuffer.releaseBuf(cb);
  }
{code}


> DFSStripedOutputStream.writeChunk should not wait for writing parity 
> ---------------------------------------------------------------------
>
>                 Key: HDFS-8287
>                 URL: https://issues.apache.org/jira/browse/HDFS-8287
>             Project: Hadoop HDFS
>          Issue Type: Sub-task
>          Components: hdfs-client
>            Reporter: Tsz Wo Nicholas Sze
>            Assignee: Kai Sasaki
>         Attachments: HDFS-8287-HDFS-7285.00.patch, 
> HDFS-8287-HDFS-7285.01.patch, HDFS-8287-HDFS-7285.02.patch, 
> HDFS-8287-HDFS-7285.03.patch, HDFS-8287-HDFS-7285.04.patch, 
> HDFS-8287-HDFS-7285.05.patch, HDFS-8287-HDFS-7285.06.patch, 
> HDFS-8287-HDFS-7285.07.patch
>
>
> When a stripping cell is full, writeChunk computes and generates parity 
> packets.  It sequentially calls waitAndQueuePacket so that user client cannot 
> continue to write data until it finishes.
> We should allow user client to continue writing instead but not blocking it 
> when writing parity.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to