Example #1
0
 public void addContent(BytesReference content, boolean last) {
   try {
     addContent(content.toChannelBuffer(), last);
   } catch (IOException e) {
     throw new BlobWriteException(digest, size, e);
   }
 }
Example #2
0
  public void addToHead(BytesReference content) throws IOException {
    if (content == null) {
      return;
    }

    int written = 0;
    ChannelBuffer channelBuffer = content.toChannelBuffer();
    int readableBytes = channelBuffer.readableBytes();
    assert readableBytes + headSize.get() <= headLength : "Got too many bytes in addToHead()";

    ByteBuffer byteBuffer = channelBuffer.toByteBuffer();
    while (written < readableBytes) {
      updateDigest(byteBuffer);
      written += headFileChannel.write(byteBuffer);
    }
    headSize.addAndGet(written);
    if (headSize.get() == headLength) {
      headCatchedUpLatch.countDown();
    }
  }