[TACHYON-152] Client write refactor

Rewriting how client writes out blocks to make it easier to add remote blocks.

The current design is as follows:

Users requests access to a block for writing.

```java
WritableBlockChannel channel = Blocks.createWritableBlock(tachyonFS, blockId, blockCapacityByte);
channel.write(byteBuffer);
channel.close();
```

When the block is full, write returns -1, so you do this in a loop and create new blocks.

```java
while (buffer.remaining() > 0) {
  int n = mCurrentBlockChannel.write(buffer);
  if (n <= 0) {
    // block full, get new block
    getNextBlock();
  }
}
```
Common function to wrap the other numeric types makes sense.  Let's improve
that in another PR.
On Nov 17, 2014 6:54 AM, "Jie Huang" <notifications@github.com> wrote:

> In core/src/main/java/tachyon/client/RemoteBlockInStream.java:
>
> > -      if (mCurrentBuffer != null) {
> > -        int ret = mCurrentBuffer.get() & 0xFF;
> > -        if (mRecache) {
> > -          mBlockOutStream.write(ret);
> > -        }
> > -        return ret;
> > -      }
> > -      setupStreamFromUnderFs(mBlockInfo.offset + mReadByte - 1, mUFSConf);
> > -    }
> > -
> > -    int ret = mCheckpointInputStream.read() & 0xFF;
> > -    if (mRecache) {
> > -      mBlockOutStream.write(ret);
> > -    }
> > -    return ret;
> > +  private ByteBuffer wrap(byte data) {
>
> I wonder if it is possible to have a common util for "ByteBuffer
> wrap(byte)". It seems that write(int b) (see FileOutStream.java 187) has
> similar lines also.
>
> —
> Reply to this email directly or view it on GitHub
> <https://github.com/amplab/tachyon/pull/427/files#r20439273>.
>