X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-clustering-commons%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcluster%2Fio%2FFileBackedOutputStream.java;fp=opendaylight%2Fmd-sal%2Fsal-clustering-commons%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcluster%2Fio%2FFileBackedOutputStream.java;h=b00e4bee4e31a9853d574cf6d85fc260bf606922;hp=029464a82b0c83b2a89d93e4bf252a6fd5d3adb0;hb=2209dcefbf9cf3b980ea0c0efab1ca29aed6cccc;hpb=f2230bf53bc46a99b50c8ae1ba0de032d4dcfc19 diff --git a/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/io/FileBackedOutputStream.java b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/io/FileBackedOutputStream.java index 029464a82b..b00e4bee4e 100644 --- a/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/io/FileBackedOutputStream.java +++ b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/io/FileBackedOutputStream.java @@ -91,7 +91,7 @@ public class FileBackedOutputStream extends OutputStream { if (file != null) { return Files.newInputStream(file.toPath()); } else { - return new ByteArrayInputStream(memory.getBuffer(), 0, memory.getCount()); + return new ByteArrayInputStream(memory.buf(), 0, memory.count()); } } } @@ -178,20 +178,20 @@ public class FileBackedOutputStream extends OutputStream { throw new IOException("Stream already closed"); } - if (file == null && memory.getCount() + len > fileThreshold) { + if (file == null && memory.count() + len > fileThreshold) { final File temp = File.createTempFile("FileBackedOutputStream", null, fileDirectory == null ? null : new File(fileDirectory)); temp.deleteOnExit(); final Cleaner.Cleanable cleanup = FILE_CLEANER.register(this, () -> deleteFile(temp)); - LOG.debug("Byte count {} has exceeded threshold {} - switching to file: {}", memory.getCount() + len, + LOG.debug("Byte count {} has exceeded threshold {} - switching to file: {}", memory.count() + len, fileThreshold, temp); final OutputStream transfer; try { transfer = Files.newOutputStream(temp.toPath()); try { - transfer.write(memory.getBuffer(), 0, memory.getCount()); + transfer.write(memory.buf(), 0, memory.count()); transfer.flush(); } catch (IOException e) { try { @@ -224,12 +224,12 @@ public class FileBackedOutputStream extends OutputStream { /** * ByteArrayOutputStream that exposes its internals for efficiency. */ - private static class MemoryOutputStream extends ByteArrayOutputStream { - byte[] getBuffer() { + private static final class MemoryOutputStream extends ByteArrayOutputStream { + byte[] buf() { return buf; } - int getCount() { + int count() { return count; } }