This is an automated email from the ASF dual-hosted git repository. timoninmaxim pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/ignite.git
The following commit(s) were added to refs/heads/master by this push: new 5481a2d8169 IGNITE-21449 Avoid excessive invocation of channel.position() while dump create (#11234) 5481a2d8169 is described below commit 5481a2d8169dfbb4188efe9b18384f69224c5657 Author: yurinaryshkin <135707807+yurinarysh...@users.noreply.github.com> AuthorDate: Wed Feb 7 14:58:23 2024 +0300 IGNITE-21449 Avoid excessive invocation of channel.position() while dump create (#11234) --- .../cache/persistence/snapshot/dump/BufferedFileIO.java | 9 ++++++++- .../cache/persistence/snapshot/dump/IgniteCacheDumpSelfTest.java | 8 ++++---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/dump/BufferedFileIO.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/dump/BufferedFileIO.java index 40c97df8f3a..84a2d523f29 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/dump/BufferedFileIO.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/dump/BufferedFileIO.java @@ -36,6 +36,9 @@ public class BufferedFileIO extends FileIODecorator { /** */ private ByteBuffer buf; + /** */ + private long position; + /** */ public BufferedFileIO(FileIO fileIO) { super(fileIO); @@ -107,9 +110,13 @@ public class BufferedFileIO extends FileIODecorator { private void flush() throws IOException { buf.flip(); - if (delegate.writeFully(buf) < 0) + int len = delegate.writeFully(buf, position); + + if (len < 0) throw new IOException("Couldn't write data"); + position = position + len; + buf.clear(); } diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/dump/IgniteCacheDumpSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/dump/IgniteCacheDumpSelfTest.java index a5dc92cbb8e..741e797d904 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/dump/IgniteCacheDumpSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/dump/IgniteCacheDumpSelfTest.java @@ -514,14 +514,14 @@ public class IgniteCacheDumpSelfTest extends AbstractCacheDumpTest { if (file.getName().endsWith(DUMP_FILE_EXT)) { return new FileIODecorator(delegate.create(file, modes)) { /** {@inheritDoc} */ - @Override public int writeFully(ByteBuffer srcBuf) throws IOException { + @Override public int writeFully(ByteBuffer srcBuf, long position) throws IOException { if (findValToFail(srcBuf)) { keyToFailFound.set(true); throw new IOException("Val to fail found"); } - return super.writeFully(srcBuf); + return super.writeFully(srcBuf, position); } private boolean findValToFail(ByteBuffer srcBuf) { @@ -671,9 +671,9 @@ public class IgniteCacheDumpSelfTest extends AbstractCacheDumpTest { if (failOnWrite) { return new FileIODecorator(delegate.create(file, modes)) { /** {@inheritDoc} */ - @Override public int writeFully(ByteBuffer srcBuf) throws IOException { + @Override public int writeFully(ByteBuffer srcBuf, long position) throws IOException { if (errorAfter.decrementAndGet() > 0) - return super.writeFully(srcBuf); + return super.writeFully(srcBuf, position); throw new IOException("Test write error"); }