Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4398,6 +4398,7 @@ public CompletableFuture<ManagedLedgerInternalStats> getManagedLedgerInternalSta
info.entries = li.getEntries();
info.size = li.getSize();
info.offloaded = li.hasOffloadContext() && li.getOffloadContext().getComplete();
info.bookkeeperDeleted = li.hasOffloadContext() && li.getOffloadContext().getBookkeeperDeleted();
if (includeLedgerMetadata) {
// lookup metadata from the hashmap which contains completed async operations
info.metadata = ledgerMetadataFutures.get(li.getLedgerId()).getNow(null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2420,6 +2420,8 @@ public CompletableFuture<PersistentTopicInternalStats> getInternalStats(boolean
info.entries = li.getEntries();
info.size = li.getSize();
info.offloaded = li.hasOffloadContext() && li.getOffloadContext().getComplete();
info.bookkeeperDeleted =
li.hasOffloadContext() && li.getOffloadContext().getBookkeeperDeleted();
stats.ledgers.add(info);
if (includeLedgerMetadata) {
futures.add(ml.getLedgerMetadata(li.getLedgerId()).handle((lMetadata, ex) -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ public static class LedgerInfo {
public boolean offloaded;
public String metadata;
public boolean underReplicated;
public boolean bookkeeperDeleted;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'd better add a compatibility test to cover the newly added field. Refer to: #21521 (comment)

}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import org.apache.pulsar.client.api.Message;
import org.apache.pulsar.client.api.Producer;
import org.apache.pulsar.client.api.PulsarClient;
import org.apache.pulsar.common.policies.data.ManagedLedgerInternalStats;
import org.apache.pulsar.common.policies.data.PersistentTopicInternalStats;
import org.apache.pulsar.tests.integration.suites.PulsarTieredStorageTestSuite;
import org.awaitility.Awaitility;
Expand Down Expand Up @@ -304,12 +305,21 @@ protected void testPublishOffloadAndConsumeDeletionLag(String serviceUrl, String
"namespaces", "get-offload-deletion-lag", namespace).getStdout();
Assert.assertTrue(output.contains("Unset for namespace"));

PulsarAdmin admin = PulsarAdmin.builder().serviceHttpUrl(adminUrl).build();

long offloadedLedger = writeAndWaitForOffload(serviceUrl, adminUrl, topic);
// give it up to 5 seconds to delete, it shouldn't
// so we wait this every time
Thread.sleep(5000);
Assert.assertTrue(ledgerExistsInBookKeeper(offloadedLedger));

long finalOffloadedLedger1 = offloadedLedger;
ManagedLedgerInternalStats.LedgerInfo offloadedLedgerInfo =
admin.topics().getInternalStats(topic).ledgers.stream()
.filter((x) -> x.ledgerId == finalOffloadedLedger1).findFirst().get();
Assert.assertTrue(offloadedLedgerInfo.offloaded);
Assert.assertFalse(offloadedLedgerInfo.bookkeeperDeleted);

pulsarCluster.runAdminCommandOnAnyBroker("namespaces", "set-offload-deletion-lag", namespace,
"--lag", "0m");
output = pulsarCluster.runAdminCommandOnAnyBroker(
Expand All @@ -324,6 +334,12 @@ protected void testPublishOffloadAndConsumeDeletionLag(String serviceUrl, String
}
Assert.assertFalse(ledgerExistsInBookKeeper(offloadedLedger));

long finalOffloadedLedger2 = offloadedLedger;
offloadedLedgerInfo = admin.topics().getInternalStats(topic).ledgers.stream()
.filter((x) -> x.ledgerId == finalOffloadedLedger2).findFirst().get();
Assert.assertTrue(offloadedLedgerInfo.offloaded);
Assert.assertTrue(offloadedLedgerInfo.bookkeeperDeleted);

pulsarCluster.runAdminCommandOnAnyBroker("namespaces", "clear-offload-deletion-lag", namespace);

Thread.sleep(5); // wait 5 seconds to allow broker to see update
Expand All @@ -338,6 +354,14 @@ protected void testPublishOffloadAndConsumeDeletionLag(String serviceUrl, String
// so we wait this every time
Thread.sleep(5000);
Assert.assertTrue(ledgerExistsInBookKeeper(offloadedLedger));

long finalOffloadedLedger3 = offloadedLedger;
offloadedLedgerInfo = admin.topics().getInternalStats(topic).ledgers.stream()
.filter((x) -> x.ledgerId == finalOffloadedLedger3).findFirst().get();
Assert.assertTrue(offloadedLedgerInfo.offloaded);
Assert.assertFalse(offloadedLedgerInfo.bookkeeperDeleted);

admin.close();
}

protected void testDeleteOffloadedTopic(String serviceUrl, String adminUrl,
Expand Down