// Write file data one block at a time
boolean done = false;
while (!done && exception.get() == null) {
// This throttles us so we don't get too far ahead of
// ourselves if one of the threads is stuck
final int chunkNumber = chunkCounter.incrementAndGet();
// Get a block or allocate a new one
final ByteBuffer bb = blocks.poll(new Supplier<ByteBuffer>() {
@Override
public ByteBuffer get() {