HDFS-10351. Ozone: Optimize key writes to chunks by providing a bulk write implementation in ChunkOutputStream. Contributed by Chris Nauroth.

This commit is contained in:
Anu Engineer 2016-05-02 14:50:40 -07:00 committed by Owen O'Malley
parent acf0b220ce
commit aa3ca951f9
2 changed files with 26 additions and 2 deletions

View File

@ -380,8 +380,6 @@ public VolumeInfo getVolumeInfo(VolumeArgs args) throws OzoneException {
public ListVolumes listVolumes(ListArgs args) throws OzoneException {
lock.readLock().lock();
try {
Preconditions.checkState(args.getArgs() instanceof UserArgs);
if (args.isRootScan()) {
return listAllVolumes(args);
}

View File

@ -100,6 +100,32 @@ public synchronized void write(int b) throws IOException {
}
}
@Override
public void write(byte[] b, int off, int len) throws IOException {
if (b == null) {
throw new NullPointerException();
}
if ((off < 0) || (off > b.length) || (len < 0) ||
((off + len) > b.length) || ((off + len) < 0)) {
throw new IndexOutOfBoundsException();
}
if (len == 0) {
return;
}
checkOpen();
while (len > 0) {
int writeLen = Math.min(CHUNK_SIZE - buffer.position(), len);
int rollbackPosition = buffer.position();
int rollbackLimit = buffer.limit();
buffer.put(b, off, writeLen);
if (buffer.position() == CHUNK_SIZE) {
flushBufferToChunk(rollbackPosition, rollbackLimit);
}
off += writeLen;
len -= writeLen;
}
}
@Override
public synchronized void flush() throws IOException {
checkOpen();