From 1c405fe51f77c69539f149e72ba6320adb0fca38 Mon Sep 17 00:00:00 2001 From: Andrey Yegorov Date: Mon, 9 Sep 2024 14:18:28 -0700 Subject: [PATCH] post-rebase fixes --- .../apache/bookkeeper/mledger/impl/ManagedCursorImpl.java | 8 ++++---- .../apache/bookkeeper/mledger/impl/PositionInfoUtils.java | 4 +++- .../apache/bookkeeper/mledger/impl/ManagedCursorTest.java | 4 ++-- .../bookkeeper/mledger/impl/PositionInfoUtilsTest.java | 8 +++++--- 4 files changed, 14 insertions(+), 10 deletions(-) diff --git a/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedCursorImpl.java b/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedCursorImpl.java index aa97ed38e001b4..8e25a2a0ee41ff 100644 --- a/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedCursorImpl.java +++ b/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedCursorImpl.java @@ -747,7 +747,7 @@ private Throwable tryCompleteCursorRecovery(LedgerHandle lh, byte[] data) { } } - PositionImpl position = new PositionImpl(positionInfo); + Position position = PositionFactory.create(positionInfo.getLedgerId(), positionInfo.getEntryId()); if (positionInfo.getIndividualDeletedMessagesCount() > 0) { recoverIndividualDeletedMessages(positionInfo.getIndividualDeletedMessagesList()); } @@ -3333,9 +3333,9 @@ private void buildBatchEntryDeletionIndexInfoList( return; } int count = 0; - Iterator> iterator = batchDeletedIndexes.entrySet().iterator(); + Iterator> iterator = batchDeletedIndexes.entrySet().iterator(); while (iterator.hasNext() && count < maxBatchDeletedIndexToPersist) { - Map.Entry entry = iterator.next(); + Map.Entry entry = iterator.next(); long[] array = entry.getValue().toLongArray(); consumer.acceptRange(entry.getKey().getLedgerId(), entry.getKey().getEntryId(), array); count++; @@ -3436,7 +3436,7 @@ private void writeToBookKeeperLastChunk(LedgerHandle lh, VoidCallback callback, ByteBuf data, int totalLength, - PositionImpl position, + Position position, Runnable onFinished) { lh.asyncAddEntry(data, (rc, lh1, entryId, ctx) -> { try { diff --git a/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/PositionInfoUtils.java b/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/PositionInfoUtils.java index 2cf68ac92b57de..96c363cb28990f 100644 --- a/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/PositionInfoUtils.java +++ b/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/PositionInfoUtils.java @@ -23,6 +23,8 @@ import java.nio.charset.StandardCharsets; import java.util.Map; import java.util.function.Consumer; + +import org.apache.bookkeeper.mledger.Position; import org.apache.pulsar.common.allocator.PulsarByteBufAllocator; final class PositionInfoUtils { @@ -35,7 +37,7 @@ interface BatchedEntryDeletionIndexInfoConsumer { void acceptRange(long ledgerId, long entryId, long[] array); } - static ByteBuf serializePositionInfo(ManagedCursorImpl.MarkDeleteEntry mdEntry, PositionImpl position, + static ByteBuf serializePositionInfo(ManagedCursorImpl.MarkDeleteEntry mdEntry, Position position, Consumer rangeScanner, Consumer batchDeletedIndexesScanner, int lastSerializedSize) { diff --git a/managed-ledger/src/test/java/org/apache/bookkeeper/mledger/impl/ManagedCursorTest.java b/managed-ledger/src/test/java/org/apache/bookkeeper/mledger/impl/ManagedCursorTest.java index ccb7ddb20f9b52..a46193e93292c5 100644 --- a/managed-ledger/src/test/java/org/apache/bookkeeper/mledger/impl/ManagedCursorTest.java +++ b/managed-ledger/src/test/java/org/apache/bookkeeper/mledger/impl/ManagedCursorTest.java @@ -3634,7 +3634,7 @@ public void testRecoverCursorCorruptLastEntry() throws Exception { assertEquals(c.getReadPosition().getEntryId(), 0); assertEquals(ml.getLastConfirmedEntry().getEntryId(), -1); - c.resetCursor(PositionImpl.LATEST); + c.resetCursor(PositionFactory.LATEST); // A reset cursor starts out with these values. The rest of the test assumes this, so we assert it here. assertEquals(c.getMarkDeletedPosition().getEntryId(), -1); @@ -3647,7 +3647,7 @@ public void testRecoverCursorCorruptLastEntry() throws Exception { ml.addEntry(new byte[1]); ml.addEntry(new byte[1]); - c.resetCursor(PositionImpl.LATEST); + c.resetCursor(PositionFactory.LATEST); //corrupt last entry LedgerHandle cursorLedger = (LedgerHandle)FieldUtils.readDeclaredField(c, "cursorLedger", true); // can't parse json diff --git a/managed-ledger/src/test/java/org/apache/bookkeeper/mledger/impl/PositionInfoUtilsTest.java b/managed-ledger/src/test/java/org/apache/bookkeeper/mledger/impl/PositionInfoUtilsTest.java index dc953676ca9474..6332092d61a57b 100644 --- a/managed-ledger/src/test/java/org/apache/bookkeeper/mledger/impl/PositionInfoUtilsTest.java +++ b/managed-ledger/src/test/java/org/apache/bookkeeper/mledger/impl/PositionInfoUtilsTest.java @@ -26,6 +26,8 @@ import java.util.Map; import java.util.List; +import org.apache.bookkeeper.mledger.Position; +import org.apache.bookkeeper.mledger.PositionFactory; import org.apache.bookkeeper.mledger.proto.LightMLDataFormats; import org.apache.bookkeeper.mledger.proto.MLDataFormats; import org.apache.pulsar.common.allocator.PulsarByteBufAllocator; @@ -38,7 +40,7 @@ public class PositionInfoUtilsTest { @Test public void testSerializeDeserialize() throws Exception { - PositionImpl position = new PositionImpl(1, 2); + Position position = PositionFactory.create(1, 2); ManagedCursorImpl.MarkDeleteEntry entry = new ManagedCursorImpl.MarkDeleteEntry(position, Map.of("foo", 1L), null, null); @@ -79,7 +81,7 @@ public void testSerializeDeserialize() throws Exception { @Test public void testSerializeDeserializeEmpty() throws Exception { - PositionImpl position = new PositionImpl(1, 2); + Position position = PositionFactory.create(1, 2); ManagedCursorImpl.MarkDeleteEntry entry = new ManagedCursorImpl.MarkDeleteEntry(position, null, null, null); @@ -100,7 +102,7 @@ public void testSerializeDeserializeEmpty() throws Exception { @Test public void testSerializeDeserialize2() throws Exception { - PositionImpl position = new PositionImpl(1, 2); + Position position = PositionFactory.create(1, 2); ManagedCursorImpl.MarkDeleteEntry entry = new ManagedCursorImpl.MarkDeleteEntry(position, Map.of("foo", 1L), null, null);