Modified: jackrabbit/oak/trunk/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/file/tar/index/IndexLoaderV2Test.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/file/tar/index/IndexLoaderV2Test.java?rev=1848226&r1=1848225&r2=1848226&view=diff ============================================================================== --- jackrabbit/oak/trunk/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/file/tar/index/IndexLoaderV2Test.java (original) +++ jackrabbit/oak/trunk/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/file/tar/index/IndexLoaderV2Test.java Wed Dec 5 17:00:25 2018 @@ -20,27 +20,27 @@ package org.apache.jackrabbit.oak.segmen import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; -import java.nio.ByteBuffer; import java.util.zip.CRC32; +import org.apache.jackrabbit.oak.segment.spi.persistence.Buffer; import org.junit.Test; public class IndexLoaderV2Test { - private static IndexV2 loadIndex(ByteBuffer buffer) throws Exception { + private static IndexV2 loadIndex(Buffer buffer) throws Exception { return loadIndex(1, buffer); } - private static IndexV2 loadIndex(int blockSize, ByteBuffer buffer) throws Exception { + private static IndexV2 loadIndex(int blockSize, Buffer buffer) throws Exception { return new IndexLoaderV2(blockSize).loadIndex((whence, length) -> { - ByteBuffer slice = buffer.duplicate(); + Buffer slice = buffer.duplicate(); slice.position(slice.limit() - whence); slice.limit(slice.position() + length); return slice.slice(); }); } - private static void assertInvalidIndexException(ByteBuffer buffer, String message) throws Exception { + private static void assertInvalidIndexException(Buffer buffer, String message) throws Exception { try { loadIndex(buffer); } catch (InvalidIndexException e) { @@ -49,7 +49,7 @@ public class IndexLoaderV2Test { } } - private static void assertInvalidIndexException(int blockSize, ByteBuffer buffer, String message) throws Exception { + private static void assertInvalidIndexException(int blockSize, Buffer buffer, String message) throws Exception { try { loadIndex(blockSize, buffer); } catch (InvalidIndexException e) { @@ -58,23 +58,23 @@ public class IndexLoaderV2Test { } } - private static int checksum(ByteBuffer buffer) { + private static int checksum(Buffer buffer) { CRC32 checksum = new CRC32(); int position = buffer.position(); - checksum.update(buffer); + buffer.update(checksum); buffer.position(position); return (int) checksum.getValue(); } @Test(expected = InvalidIndexException.class) public void testInvalidMagic() throws Exception { - ByteBuffer buffer = ByteBuffer.allocate(IndexV2.FOOTER_SIZE); + Buffer buffer = Buffer.allocate(IndexV2.FOOTER_SIZE); assertInvalidIndexException(buffer, "Magic number mismatch"); } @Test(expected = InvalidIndexException.class) public void testInvalidCount() throws Exception { - ByteBuffer buffer = ByteBuffer.allocate(IndexV2.FOOTER_SIZE); + Buffer buffer = Buffer.allocate(IndexV2.FOOTER_SIZE); buffer.duplicate() .putInt(0) .putInt(0) @@ -85,7 +85,7 @@ public class IndexLoaderV2Test { @Test(expected = InvalidIndexException.class) public void testInvalidSize() throws Exception { - ByteBuffer buffer = ByteBuffer.allocate(IndexV2.FOOTER_SIZE); + Buffer buffer = Buffer.allocate(IndexV2.FOOTER_SIZE); buffer.duplicate() .putInt(0) .putInt(1) @@ -96,7 +96,7 @@ public class IndexLoaderV2Test { @Test(expected = InvalidIndexException.class) public void testInvalidSizeAlignment() throws Exception { - ByteBuffer buffer = ByteBuffer.allocate(IndexV2.FOOTER_SIZE); + Buffer buffer = Buffer.allocate(IndexV2.FOOTER_SIZE); buffer.duplicate() .putInt(0) .putInt(1) @@ -107,7 +107,7 @@ public class IndexLoaderV2Test { @Test(expected = InvalidIndexException.class) public void testInvalidChecksum() throws Exception { - ByteBuffer buffer = ByteBuffer.allocate(IndexEntryV2.SIZE + IndexV2.FOOTER_SIZE); + Buffer buffer = Buffer.allocate(IndexEntryV2.SIZE + IndexV2.FOOTER_SIZE); buffer.duplicate() .putLong(1).putLong(2).putInt(3).putInt(4).putInt(5).putInt(6).put((byte) 0) .putInt(0) @@ -119,12 +119,12 @@ public class IndexLoaderV2Test { @Test(expected = InvalidIndexException.class) public void testIncorrectEntryOrderingByMsb() throws Exception { - ByteBuffer entries = ByteBuffer.allocate(2 * IndexEntryV2.SIZE); + Buffer entries = Buffer.allocate(2 * IndexEntryV2.SIZE); entries.duplicate() .putLong(1).putLong(0).putInt(0).putInt(1).putInt(0).putInt(0).put((byte) 0) .putLong(0).putLong(0).putInt(1).putInt(1).putInt(0).putInt(0).put((byte) 0); - ByteBuffer buffer = ByteBuffer.allocate(2 * IndexEntryV2.SIZE + IndexV2.FOOTER_SIZE); + Buffer buffer = Buffer.allocate(2 * IndexEntryV2.SIZE + IndexV2.FOOTER_SIZE); buffer.duplicate() .put(entries.duplicate()) .putInt(checksum(entries)) @@ -137,12 +137,12 @@ public class IndexLoaderV2Test { @Test(expected = InvalidIndexException.class) public void testIncorrectEntryOrderingByLsb() throws Exception { - ByteBuffer entries = ByteBuffer.allocate(2 * IndexEntryV2.SIZE); + Buffer entries = Buffer.allocate(2 * IndexEntryV2.SIZE); entries.duplicate() .putLong(0).putLong(1).putInt(0).putInt(1).putInt(0).putInt(0).put((byte) 0) .putLong(0).putLong(0).putInt(1).putInt(1).putInt(0).putInt(0).put((byte) 0); - ByteBuffer buffer = ByteBuffer.allocate(2 * IndexEntryV2.SIZE + IndexV2.FOOTER_SIZE); + Buffer buffer = Buffer.allocate(2 * IndexEntryV2.SIZE + IndexV2.FOOTER_SIZE); buffer.duplicate() .put(entries.duplicate()) .putInt(checksum(entries)) @@ -155,12 +155,12 @@ public class IndexLoaderV2Test { @Test(expected = InvalidIndexException.class) public void testDuplicateEntry() throws Exception { - ByteBuffer entries = ByteBuffer.allocate(2 * IndexEntryV2.SIZE); + Buffer entries = Buffer.allocate(2 * IndexEntryV2.SIZE); entries.duplicate() .putLong(0).putLong(0).putInt(0).putInt(1).putInt(0).putInt(0).put((byte) 0) .putLong(0).putLong(0).putInt(1).putInt(1).putInt(0).putInt(0).put((byte) 0); - ByteBuffer buffer = ByteBuffer.allocate(2 * IndexEntryV2.SIZE + IndexV2.FOOTER_SIZE); + Buffer buffer = Buffer.allocate(2 * IndexEntryV2.SIZE + IndexV2.FOOTER_SIZE); buffer.duplicate() .put(entries.duplicate()) .putInt(checksum(entries)) @@ -173,11 +173,11 @@ public class IndexLoaderV2Test { @Test(expected = InvalidIndexException.class) public void testInvalidEntryOffset() throws Exception { - ByteBuffer entries = ByteBuffer.allocate(IndexEntryV2.SIZE); + Buffer entries = Buffer.allocate(IndexEntryV2.SIZE); entries.duplicate() .putLong(0).putLong(0).putInt(-1).putInt(1).putInt(0).putInt(0).put((byte) 0); - ByteBuffer buffer = ByteBuffer.allocate(IndexEntryV2.SIZE + IndexV2.FOOTER_SIZE); + Buffer buffer = Buffer.allocate(IndexEntryV2.SIZE + IndexV2.FOOTER_SIZE); buffer.duplicate() .put(entries.duplicate()) .putInt(checksum(entries)) @@ -190,11 +190,11 @@ public class IndexLoaderV2Test { @Test(expected = InvalidIndexException.class) public void testInvalidEntryOffsetAlignment() throws Exception { - ByteBuffer entries = ByteBuffer.allocate(IndexEntryV2.SIZE); + Buffer entries = Buffer.allocate(IndexEntryV2.SIZE); entries.duplicate() .putLong(0).putLong(0).putInt(1).putInt(1).putInt(0).putInt(0).put((byte) 0); - ByteBuffer index = ByteBuffer.allocate(IndexEntryV2.SIZE + IndexV2.FOOTER_SIZE); + Buffer index = Buffer.allocate(IndexEntryV2.SIZE + IndexV2.FOOTER_SIZE); index.duplicate() .put(entries.duplicate()) .putInt(checksum(entries)) @@ -202,7 +202,7 @@ public class IndexLoaderV2Test { .putInt(2 * (IndexEntryV2.SIZE + IndexV2.FOOTER_SIZE)) .putInt(IndexLoaderV2.MAGIC); - ByteBuffer buffer = ByteBuffer.allocate(2 * (IndexEntryV2.SIZE + IndexV2.FOOTER_SIZE)); + Buffer buffer = Buffer.allocate(2 * (IndexEntryV2.SIZE + IndexV2.FOOTER_SIZE)); buffer.mark(); buffer.position(buffer.limit() - IndexEntryV2.SIZE - IndexV2.FOOTER_SIZE); buffer.put(index); @@ -213,11 +213,11 @@ public class IndexLoaderV2Test { @Test(expected = InvalidIndexException.class) public void testInvalidEntrySize() throws Exception { - ByteBuffer entries = ByteBuffer.allocate(IndexEntryV2.SIZE); + Buffer entries = Buffer.allocate(IndexEntryV2.SIZE); entries.duplicate() .putLong(0).putLong(0).putInt(0).putInt(0).putInt(0).putInt(0).put((byte) 0); - ByteBuffer buffer = ByteBuffer.allocate(IndexEntryV2.SIZE + IndexV2.FOOTER_SIZE); + Buffer buffer = Buffer.allocate(IndexEntryV2.SIZE + IndexV2.FOOTER_SIZE); buffer.duplicate() .put(entries.duplicate()) .putInt(checksum(entries)) @@ -230,12 +230,12 @@ public class IndexLoaderV2Test { @Test public void testLoadIndex() throws Exception { - ByteBuffer entries = ByteBuffer.allocate(2 * IndexEntryV2.SIZE); + Buffer entries = Buffer.allocate(2 * IndexEntryV2.SIZE); entries.duplicate() .putLong(0).putLong(0).putInt(0).putInt(1).putInt(0).putInt(0).put((byte) 0) .putLong(0).putLong(1).putInt(1).putInt(1).putInt(0).putInt(0).put((byte) 0); - ByteBuffer buffer = ByteBuffer.allocate(2 * IndexEntryV2.SIZE + IndexV2.FOOTER_SIZE); + Buffer buffer = Buffer.allocate(2 * IndexEntryV2.SIZE + IndexV2.FOOTER_SIZE); buffer.duplicate() .put(entries.duplicate()) .putInt(checksum(entries))
Modified: jackrabbit/oak/trunk/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/file/tar/index/IndexV1Test.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/file/tar/index/IndexV1Test.java?rev=1848226&r1=1848225&r2=1848226&view=diff ============================================================================== --- jackrabbit/oak/trunk/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/file/tar/index/IndexV1Test.java (original) +++ jackrabbit/oak/trunk/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/file/tar/index/IndexV1Test.java Wed Dec 5 17:00:25 2018 @@ -19,18 +19,18 @@ package org.apache.jackrabbit.oak.segmen import static org.junit.Assert.assertEquals; -import java.nio.ByteBuffer; import java.util.HashSet; import java.util.Set; import java.util.UUID; +import org.apache.jackrabbit.oak.segment.spi.persistence.Buffer; import org.junit.Test; public class IndexV1Test { @Test public void testGetUUIDs() throws Exception { - ByteBuffer buffer = ByteBuffer.allocate(2 * IndexEntryV1.SIZE); + Buffer buffer = Buffer.allocate(2 * IndexEntryV1.SIZE); buffer.duplicate() .putLong(1).putLong(2).putInt(3).putInt(4).putInt(5) .putLong(6).putLong(7).putInt(8).putInt(9).putInt(10); @@ -42,7 +42,7 @@ public class IndexV1Test { @Test public void testFindEntry() throws Exception { - ByteBuffer buffer = ByteBuffer.allocate(4 * IndexEntryV1.SIZE); + Buffer buffer = Buffer.allocate(4 * IndexEntryV1.SIZE); buffer.duplicate() .putLong(1).putLong(1).putInt(0).putInt(0).putInt(0) .putLong(1).putLong(3).putInt(0).putInt(0).putInt(0) @@ -61,7 +61,7 @@ public class IndexV1Test { @Test public void testSize() throws Exception { - ByteBuffer buffer = ByteBuffer.allocate(IndexEntryV1.SIZE); + Buffer buffer = Buffer.allocate(IndexEntryV1.SIZE); buffer.duplicate() .putLong(1).putLong(2).putInt(3).putInt(4).putInt(5); assertEquals(IndexEntryV1.SIZE + IndexV1.FOOTER_SIZE, new IndexV1(buffer).size()); @@ -69,7 +69,7 @@ public class IndexV1Test { @Test public void testCount() throws Exception { - ByteBuffer buffer = ByteBuffer.allocate(2 * IndexEntryV1.SIZE); + Buffer buffer = Buffer.allocate(2 * IndexEntryV1.SIZE); buffer.duplicate() .putLong(1).putLong(2).putInt(3).putInt(4).putInt(5) .putLong(6).putLong(7).putInt(8).putInt(9).putInt(10); @@ -78,7 +78,7 @@ public class IndexV1Test { @Test public void testEntry() throws Exception { - ByteBuffer buffer = ByteBuffer.allocate(IndexEntryV1.SIZE); + Buffer buffer = Buffer.allocate(IndexEntryV1.SIZE); buffer.duplicate() .putLong(1).putLong(2).putInt(3).putInt(4).putInt(5); IndexEntryV1 entry = new IndexV1(buffer).entry(0); Modified: jackrabbit/oak/trunk/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/file/tar/index/IndexV2Test.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/file/tar/index/IndexV2Test.java?rev=1848226&r1=1848225&r2=1848226&view=diff ============================================================================== --- jackrabbit/oak/trunk/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/file/tar/index/IndexV2Test.java (original) +++ jackrabbit/oak/trunk/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/file/tar/index/IndexV2Test.java Wed Dec 5 17:00:25 2018 @@ -19,18 +19,18 @@ package org.apache.jackrabbit.oak.segmen import static org.junit.Assert.assertEquals; -import java.nio.ByteBuffer; import java.util.HashSet; import java.util.Set; import java.util.UUID; +import org.apache.jackrabbit.oak.segment.spi.persistence.Buffer; import org.junit.Test; public class IndexV2Test { @Test public void testGetUUIDs() throws Exception { - ByteBuffer buffer = ByteBuffer.allocate(2 * IndexEntryV2.SIZE); + Buffer buffer = Buffer.allocate(2 * IndexEntryV2.SIZE); buffer.duplicate() .putLong(1).putLong(2).putInt(3).putInt(4).putInt(5).putInt(6).put((byte) 0) .putLong(7).putLong(8).putInt(9).putInt(10).putInt(11).putInt(12).put((byte) 1); @@ -42,7 +42,7 @@ public class IndexV2Test { @Test public void testFindEntry() throws Exception { - ByteBuffer buffer = ByteBuffer.allocate(4 * IndexEntryV2.SIZE); + Buffer buffer = Buffer.allocate(4 * IndexEntryV2.SIZE); buffer.duplicate() .putLong(1).putLong(1).putInt(0).putInt(0).putInt(0).putInt(0).put((byte) 0) .putLong(1).putLong(3).putInt(0).putInt(0).putInt(0).putInt(0).put((byte) 0) @@ -61,7 +61,7 @@ public class IndexV2Test { @Test public void testSize() throws Exception { - ByteBuffer buffer = ByteBuffer.allocate(IndexEntryV2.SIZE); + Buffer buffer = Buffer.allocate(IndexEntryV2.SIZE); buffer.duplicate() .putLong(1).putLong(2).putInt(3).putInt(4).putInt(5).putInt(6).put((byte) 0); assertEquals(IndexEntryV2.SIZE + IndexV2.FOOTER_SIZE, new IndexV2(buffer).size()); @@ -69,7 +69,7 @@ public class IndexV2Test { @Test public void testCount() throws Exception { - ByteBuffer buffer = ByteBuffer.allocate(2 * IndexEntryV2.SIZE); + Buffer buffer = Buffer.allocate(2 * IndexEntryV2.SIZE); buffer.duplicate() .putLong(1).putLong(2).putInt(3).putInt(4).putInt(5).putInt(6).put((byte) 0) .putLong(7).putLong(8).putInt(9).putInt(10).putInt(11).putInt(12).put((byte) 1); @@ -78,7 +78,7 @@ public class IndexV2Test { @Test public void testEntry() throws Exception { - ByteBuffer buffer = ByteBuffer.allocate(IndexEntryV2.SIZE); + Buffer buffer = Buffer.allocate(IndexEntryV2.SIZE); buffer.duplicate() .putLong(1).putLong(2).putInt(3).putInt(4).putInt(5).putInt(6).put((byte) 1); IndexEntryV2 entry = new IndexV2(buffer).entry(0); Modified: jackrabbit/oak/trunk/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/standby/StandbyTestUtils.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/standby/StandbyTestUtils.java?rev=1848226&r1=1848225&r2=1848226&view=diff ============================================================================== --- jackrabbit/oak/trunk/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/standby/StandbyTestUtils.java (original) +++ jackrabbit/oak/trunk/oak-segment-tar/src/test/java/org/apache/jackrabbit/oak/segment/standby/StandbyTestUtils.java Wed Dec 5 17:00:25 2018 @@ -19,7 +19,6 @@ package org.apache.jackrabbit.oak.segmen import static org.mockito.Mockito.mock; -import java.nio.ByteBuffer; import java.util.UUID; import com.google.common.base.Charsets; @@ -32,6 +31,7 @@ import org.apache.jackrabbit.oak.segment import org.apache.jackrabbit.oak.segment.SegmentIdProvider; import org.apache.jackrabbit.oak.segment.SegmentReader; import org.apache.jackrabbit.oak.segment.SegmentStore; +import org.apache.jackrabbit.oak.segment.spi.persistence.Buffer; public class StandbyTestUtils { @@ -50,7 +50,7 @@ public class StandbyTestUtils { long msb = uuid.getMostSignificantBits(); long lsb = uuid.getLeastSignificantBits(); SegmentId id = new SegmentId(store, msb, lsb); - ByteBuffer data = ByteBuffer.wrap(buffer); + Buffer data = Buffer.wrap(buffer); return new Segment(idProvider, reader, id, data); } Modified: jackrabbit/oak/trunk/oak-upgrade/src/main/java/org/apache/jackrabbit/oak/upgrade/PersistingDiff.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-upgrade/src/main/java/org/apache/jackrabbit/oak/upgrade/PersistingDiff.java?rev=1848226&r1=1848225&r2=1848226&view=diff ============================================================================== --- jackrabbit/oak/trunk/oak-upgrade/src/main/java/org/apache/jackrabbit/oak/upgrade/PersistingDiff.java (original) +++ jackrabbit/oak/trunk/oak-upgrade/src/main/java/org/apache/jackrabbit/oak/upgrade/PersistingDiff.java Wed Dec 5 17:00:25 2018 @@ -16,6 +16,15 @@ */ package org.apache.jackrabbit.oak.upgrade; +import static com.google.common.base.Preconditions.checkNotNull; +import static com.google.common.base.Preconditions.checkState; +import static org.apache.jackrabbit.oak.plugins.memory.EmptyNodeState.EMPTY_NODE; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import java.util.function.Supplier; + import com.google.common.collect.Lists; import org.apache.jackrabbit.oak.api.PropertyState; import org.apache.jackrabbit.oak.plugins.memory.MemoryNodeBuilder; @@ -24,6 +33,7 @@ import org.apache.jackrabbit.oak.segment import org.apache.jackrabbit.oak.segment.SegmentReader; import org.apache.jackrabbit.oak.segment.SegmentWriter; import org.apache.jackrabbit.oak.segment.file.FileStore; +import org.apache.jackrabbit.oak.segment.spi.persistence.Buffer; import org.apache.jackrabbit.oak.spi.blob.BlobStore; import org.apache.jackrabbit.oak.spi.state.NodeState; import org.apache.jackrabbit.oak.spi.state.NodeStateDiff; @@ -32,15 +42,6 @@ import org.jetbrains.annotations.Nullabl import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.io.IOException; -import java.nio.ByteBuffer; -import java.util.ArrayList; -import java.util.List; -import java.util.function.Supplier; -import static com.google.common.base.Preconditions.checkNotNull; -import static com.google.common.base.Preconditions.checkState; -import static org.apache.jackrabbit.oak.plugins.memory.EmptyNodeState.EMPTY_NODE; - public class PersistingDiff implements NodeStateDiff { private static final Logger LOG = LoggerFactory.getLogger(PersistingDiff.class); @@ -214,7 +215,7 @@ public class PersistingDiff implements N } @Nullable - private static ByteBuffer getStableIdBytes(NodeState state) { + private static Buffer getStableIdBytes(NodeState state) { if (state instanceof SegmentNodeState) { return ((SegmentNodeState) state).getStableIdBytes(); } else {