[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();
  }
}
```
All this did was make buffer larger than the users expected. So it is a bug
that we didn't respect user given configs but should not impact the system
now than just increasing the buffer.

To unit test it... Not sure how myself since it's just a larger buffer size
and buffers are fully encapsulated by the objects that user then
On Nov 17, 2014 10:35 PM, "Haoyuan Li" <notifications@github.com> wrote:

> In core/src/main/java/tachyon/client/Blocks.java:
>
> > +      int bufferSize = (int) Math.min(maxBlockSize, DEFAULT_BUFFER_SIZE);
> > +      LocalWritableBlockChannel local = new LocalWritableBlockChannel(tachyonFS, blockId);
> > +      BufferedWritableBlockChannel buffered = new BufferedWritableBlockChannel(bufferSize, local);
> > +      BoundedWritableBlockChannel bounded = new BoundedWritableBlockChannel(maxBlockSize, buffered);
> > +      return bounded;
> > +    }
> > +    throw new IOException("The machine does not have any local worker.");
> > +  }
> > +
> > +  /**
> > +   * Attempts to copy the {@link java.io.InputStream} into the channel. If the channel becomes full,
> > +   * this method will return a {@link java.io.IOException}.
> > +   */
> > +  public static void copy(InputStream inputStream, WritableBlockChannel channel, long length)
> > +      throws IOException {
> > +    final byte[] buffer = new byte[UserConf.get().FILE_BUFFER_BYTES * 4];
>
> was that a bug? is this unit tested?
>
> —
> Reply to this email directly or view it on GitHub
> <https://github.com/amplab/tachyon/pull/427/files#r20487817>.
>