Skip to content
Closed
Show file tree
Hide file tree
Changes from all 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 @@ -4254,7 +4254,8 @@ public CompletableFuture<ManagedLedgerInternalStats> getManagedLedgerInternalSta
FutureUtil.waitForAll(ledgerMetadataFutures.values()).thenAccept(__ -> {
stats.ledgers = new ArrayList();
ledgersInfos.forEach(li -> {
ManagedLedgerInternalStats.LedgerInfo info = new ManagedLedgerInternalStats.LedgerInfo();
ManagedLedgerInternalStats.InternalLedgerInfo info =
new ManagedLedgerInternalStats.InternalLedgerInfo();
info.ledgerId = li.getLedgerId();
info.entries = li.getEntries();
info.size = li.getSize();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@
import org.apache.pulsar.common.policies.data.ClusterData.ClusterUrl;
import org.apache.pulsar.common.policies.data.InactiveTopicDeleteMode;
import org.apache.pulsar.common.policies.data.ManagedLedgerInternalStats.CursorStats;
import org.apache.pulsar.common.policies.data.ManagedLedgerInternalStats.LedgerInfo;
import org.apache.pulsar.common.policies.data.ManagedLedgerInternalStats.InternalLedgerInfo;
import org.apache.pulsar.common.policies.data.PersistentTopicInternalStats;
import org.apache.pulsar.common.policies.data.Policies;
import org.apache.pulsar.common.policies.data.RetentionPolicies;
Expand Down Expand Up @@ -2204,7 +2204,7 @@ public CompletableFuture<PersistentTopicInternalStats> getInternalStats(boolean
statFuture.completeExceptionally(e);
} else {
ml.getLedgersInfo().forEach((id, li) -> {
LedgerInfo info = new LedgerInfo();
InternalLedgerInfo info = new InternalLedgerInfo();
info.ledgerId = li.getLedgerId();
info.entries = li.getEntries();
info.size = li.getSize();
Expand Down Expand Up @@ -2232,7 +2232,7 @@ public CompletableFuture<PersistentTopicInternalStats> getInternalStats(boolean
);

// Add ledger info for compacted topic ledger if exist.
LedgerInfo info = new LedgerInfo();
InternalLedgerInfo info = new InternalLedgerInfo();
info.ledgerId = -1;
info.entries = -1;
info.size = -1;
Expand Down Expand Up @@ -2316,7 +2316,7 @@ public CompletableFuture<PersistentTopicInternalStats> getInternalStats(boolean
}
if (metadataFuture != null) {
metadataFuture.thenAccept(metadata -> {
LedgerInfo schemaLedgerInfo = new LedgerInfo();
InternalLedgerInfo schemaLedgerInfo = new InternalLedgerInfo();
schemaLedgerInfo.ledgerId = metadata.getLedgerId();
schemaLedgerInfo.entries = metadata.getLastEntryId() + 1;
schemaLedgerInfo.size = metadata.getLength();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
import org.apache.pulsar.client.impl.schema.SchemaInfoImpl;
import org.apache.pulsar.client.impl.schema.StringSchema;
import org.apache.pulsar.common.policies.data.ClusterData;
import org.apache.pulsar.common.policies.data.ManagedLedgerInternalStats;
import org.apache.pulsar.common.policies.data.PersistentTopicInternalStats;
import org.apache.pulsar.common.policies.data.SchemaAutoUpdateCompatibilityStrategy;
import org.apache.pulsar.common.policies.data.SchemaCompatibilityStrategy;
Expand Down Expand Up @@ -384,9 +385,9 @@ public long getCToken() {
}
})).when(mockBookKeeper).getLedgerMetadata(anyLong());
PersistentTopicInternalStats persistentTopicInternalStats = admin.topics().getInternalStats(topicName);
List<PersistentTopicInternalStats.LedgerInfo> list = persistentTopicInternalStats.schemaLedgers;
List<ManagedLedgerInternalStats.InternalLedgerInfo> list = persistentTopicInternalStats.schemaLedgers;
assertEquals(list.size(), 1);
PersistentTopicInternalStats.LedgerInfo ledgerInfo = list.get(0);
ManagedLedgerInternalStats.InternalLedgerInfo ledgerInfo = list.get(0);
assertEquals(ledgerInfo.ledgerId, ledgerId);
assertEquals(ledgerInfo.entries, entryId + 1);
assertEquals(ledgerInfo.size, length);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,15 @@ public class ManagedLedgerInternalStats {
public String state;

/** The ordered list of all ledgers for this topic holding messages. */
public List<LedgerInfo> ledgers;
public List<InternalLedgerInfo> ledgers;

/** The list of all cursors on this topic. Each subscription in the topic stats has a cursor. */
public Map<String, CursorStats> cursors;

/**
* Ledger information.
*/
public static class LedgerInfo {
public static class InternalLedgerInfo {
public long ledgerId;
public long entries;
public long size;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@
/**
* Persistent topic internal statistics.
*/
public class PersistentTopicInternalStats extends ManagedLedgerInternalStats{
public class PersistentTopicInternalStats extends ManagedLedgerInternalStats {

public List<LedgerInfo> schemaLedgers;
public List<InternalLedgerInfo> schemaLedgers;

// LedgerInfo for compacted topic if exist.
public LedgerInfo compactedLedger;
// LedgerInfo for compacted topic if existed.
public InternalLedgerInfo compactedLedger;
}
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
import org.apache.pulsar.common.policies.data.FailureDomain;
import org.apache.pulsar.common.policies.data.InactiveTopicDeleteMode;
import org.apache.pulsar.common.policies.data.InactiveTopicPolicies;
import org.apache.pulsar.common.policies.data.ManagedLedgerInternalStats.LedgerInfo;
import org.apache.pulsar.common.policies.data.ManagedLedgerInternalStats.InternalLedgerInfo;
import org.apache.pulsar.common.policies.data.OffloadPoliciesImpl;
import org.apache.pulsar.common.policies.data.OffloadedReadPriority;
import org.apache.pulsar.common.policies.data.PersistencePolicies;
Expand Down Expand Up @@ -1981,8 +1981,8 @@ public boolean matches(Long timestamp) {

}

private static LedgerInfo newLedger(long id, long entries, long size) {
LedgerInfo l = new LedgerInfo();
private static InternalLedgerInfo newLedger(long id, long entries, long size) {
InternalLedgerInfo l = new InternalLedgerInfo();
l.ledgerId = id;
l.entries = entries;
l.size = size;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
import org.apache.pulsar.common.policies.data.DispatchRate;
import org.apache.pulsar.common.policies.data.InactiveTopicDeleteMode;
import org.apache.pulsar.common.policies.data.InactiveTopicPolicies;
import org.apache.pulsar.common.policies.data.ManagedLedgerInternalStats;
import org.apache.pulsar.common.policies.data.OffloadPoliciesImpl;
import org.apache.pulsar.common.policies.data.OffloadedReadPriority;
import org.apache.pulsar.common.policies.data.PersistencePolicies;
Expand Down Expand Up @@ -1428,13 +1429,13 @@ void run() throws PulsarAdminException {
}
}

static MessageId findFirstLedgerWithinThreshold(List<PersistentTopicInternalStats.LedgerInfo> ledgers,
static MessageId findFirstLedgerWithinThreshold(List<ManagedLedgerInternalStats.InternalLedgerInfo> ledgers,
long sizeThreshold) {
long suffixSize = 0L;

ledgers = Lists.reverse(ledgers);
long previousLedger = ledgers.get(0).ledgerId;
for (PersistentTopicInternalStats.LedgerInfo l : ledgers) {
for (ManagedLedgerInternalStats.InternalLedgerInfo l : ledgers) {
suffixSize += l.size;
if (suffixSize > sizeThreshold) {
return new MessageIdImpl(previousLedger, 0L, -1);
Expand Down Expand Up @@ -1464,7 +1465,7 @@ void run() throws PulsarAdminException {
throw new PulsarAdminException("Topic doesn't have any data");
}

LinkedList<PersistentTopicInternalStats.LedgerInfo> ledgers = new LinkedList(stats.ledgers);
LinkedList<ManagedLedgerInternalStats.InternalLedgerInfo> ledgers = new LinkedList(stats.ledgers);
ledgers.get(ledgers.size() - 1).size = stats.currentLedgerSize; // doesn't get filled in now it seems
MessageId messageId = findFirstLedgerWithinThreshold(ledgers, sizeThreshold);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
import org.apache.pulsar.client.admin.Topics;
import org.apache.pulsar.client.impl.MessageIdImpl;
import org.apache.pulsar.common.naming.TopicDomain;
import org.apache.pulsar.common.policies.data.ManagedLedgerInternalStats.LedgerInfo;
import org.apache.pulsar.common.policies.data.ManagedLedgerInternalStats.InternalLedgerInfo;
import org.mockito.Mockito;
import org.testng.Assert;
import org.testng.annotations.AfterMethod;
Expand Down Expand Up @@ -78,8 +78,8 @@ public void cleanup() throws IOException {
//NOTHING FOR NOW
}

private static LedgerInfo newLedger(long id, long entries, long size) {
LedgerInfo l = new LedgerInfo();
private static InternalLedgerInfo newLedger(long id, long entries, long size) {
InternalLedgerInfo l = new InternalLedgerInfo();
l.ledgerId = id;
l.entries = entries;
l.size = size;
Expand All @@ -88,7 +88,7 @@ private static LedgerInfo newLedger(long id, long entries, long size) {

@Test
public void testFindFirstLedgerWithinThreshold() throws Exception {
List<LedgerInfo> ledgers = new ArrayList<>();
List<InternalLedgerInfo> ledgers = new ArrayList<>();
ledgers.add(newLedger(0, 10, 1000));
ledgers.add(newLedger(1, 10, 2000));
ledgers.add(newLedger(2, 10, 3000));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,11 @@
/**
* Options while updating the sink.
*/
@ApiModel(
value = "UpdateOptions",
description = "Options while updating the sink")
@Data
@NoArgsConstructor
@ApiModel(value = "UpdateOptions", description = "Options while updating the sink")
public class UpdateOptionsImpl implements UpdateOptions {
@ApiModelProperty(
value = "Whether or not to update the auth data",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,12 @@
/**
* Information of admin roles and allowed clusters for tenant.
*/
@ApiModel(
value = "TenantInfo",
description = "Information of adminRoles and allowedClusters for tenant")
@Data
@AllArgsConstructor
@NoArgsConstructor
@ApiModel(value = "TenantInfo", description = "Information of adminRoles and allowedClusters for tenant")
public class TenantInfoImpl implements TenantInfo {
/**
* List of role enabled as admin for this tenant.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
package org.apache.pulsar.tests.integration.admin;

import static org.testng.Assert.assertNotNull;

import java.util.function.Supplier;
import lombok.Cleanup;
import lombok.extern.slf4j.Slf4j;
Expand All @@ -28,6 +27,7 @@
import org.apache.pulsar.client.api.Producer;
import org.apache.pulsar.client.api.PulsarClient;
import org.apache.pulsar.client.api.Schema;
import org.apache.pulsar.common.policies.data.ManagedLedgerInternalStats;
import org.apache.pulsar.common.policies.data.PersistentTopicInternalStats;
import org.apache.pulsar.tests.integration.messaging.MessagingBase;
import org.testng.Assert;
Expand Down Expand Up @@ -68,7 +68,7 @@ public void testUnderReplicatedState(Supplier<String> serviceUrl, Supplier<Strin
log.info("Successfully to publish 10 messages to {}", topicName);
PersistentTopicInternalStats stats = admin.topics().getInternalStats(topicName);
Assert.assertTrue(stats.ledgers.size() > 0);
for (PersistentTopicInternalStats.LedgerInfo ledger : stats.ledgers) {
for (ManagedLedgerInternalStats.InternalLedgerInfo ledger : stats.ledgers) {
Assert.assertFalse(ledger.underReplicated);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import java.util.List;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;

import lombok.extern.slf4j.Slf4j;
import org.apache.bookkeeper.client.BKException;
import org.apache.bookkeeper.client.BookKeeper;
Expand All @@ -32,7 +31,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.PersistentTopicInternalStats;
import org.apache.pulsar.common.policies.data.ManagedLedgerInternalStats;
import org.apache.pulsar.tests.integration.suites.PulsarTieredStorageTestSuite;
import org.awaitility.Awaitility;
import org.testng.Assert;
Expand Down Expand Up @@ -214,7 +213,7 @@ protected void testPublishOffloadAndConsumeViaThreshold(String serviceUrl, Strin
}
}

private boolean ledgerOffloaded(List<PersistentTopicInternalStats.LedgerInfo> ledgers, long ledgerId) {
private boolean ledgerOffloaded(List<ManagedLedgerInternalStats.InternalLedgerInfo> ledgers, long ledgerId) {
return ledgers.stream().filter(l -> l.ledgerId == ledgerId)
.map(l -> l.offloaded).findFirst().get();
}
Expand All @@ -236,7 +235,7 @@ private long writeAndWaitForOffload(String serviceUrl, String adminUrl, String t
? topic + "-partition-" + partitionNum
: topic;

List<PersistentTopicInternalStats.LedgerInfo> ledgers = admin.topics()
List<ManagedLedgerInternalStats.InternalLedgerInfo> ledgers = admin.topics()
.getInternalStats(topicToCheck).ledgers;
long currentLedger = ledgers.get(ledgers.size() - 1).ledgerId;

Expand Down