Skip to content
Merged
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 @@ -1063,7 +1063,8 @@ public void loadNamespaceTopics(NamespaceBundle bundle) {
List<CompletableFuture<Topic>> persistentTopics = Lists.newArrayList();
long topicLoadStart = System.nanoTime();

for (String topic : getNamespaceService().getListOfPersistentTopics(nsName).join()) {
for (String topic : getNamespaceService().getListOfPersistentTopics(nsName).
get(config.getZooKeeperOperationTimeoutSeconds(), TimeUnit.SECONDS)) {
try {
TopicName topicName = TopicName.get(topic);
if (bundle.includes(topicName) && !isTransactionSystemTopic(topicName)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,8 @@ protected void internalDeleteNamespaceForcefully(AsyncResponse asyncResponse, bo

List<String> topics;
try {
topics = pulsar().getNamespaceService().getFullListOfTopics(namespaceName).join();
topics = pulsar().getNamespaceService().getFullListOfTopics(namespaceName).
get(config().getZooKeeperOperationTimeoutSeconds(), TimeUnit.SECONDS);
} catch (Exception e) {
asyncResponse.resume(new RestException(e));
return;
Expand Down Expand Up @@ -571,7 +572,8 @@ protected void internalDeleteNamespaceBundle(String bundleRange, boolean authori
try {
NamespaceBundle bundle = validateNamespaceBundleOwnership(namespaceName, policies.bundles, bundleRange,
authoritative, true);
List<String> topics = pulsar().getNamespaceService().getListOfPersistentTopics(namespaceName).join();
List<String> topics = pulsar().getNamespaceService().getListOfPersistentTopics(namespaceName)
.get(config().getZooKeeperOperationTimeoutSeconds(), TimeUnit.SECONDS);
for (String topic : topics) {
NamespaceBundle topicBundle = pulsar().getNamespaceService()
.getBundle(TopicName.get(topic));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import javax.ws.rs.DefaultValue;
import javax.ws.rs.Encoded;
import javax.ws.rs.GET;
Expand Down Expand Up @@ -297,7 +298,14 @@ public List<String> getListFromBundle(@PathParam("property") String property, @P
}

private Topic getTopicReference(TopicName topicName) {
return pulsar().getBrokerService().getTopicIfExists(topicName.toString()).join()
.orElseThrow(() -> new RestException(Status.NOT_FOUND, "Topic not found"));
try {
return pulsar().getBrokerService().getTopicIfExists(topicName.toString())
.get(config().getZooKeeperOperationTimeoutSeconds(), TimeUnit.SECONDS)
.orElseThrow(() -> new RestException(Status.NOT_FOUND, "Topic not found"));
} catch (ExecutionException e) {
throw new RuntimeException(e.getCause());
} catch (InterruptedException | TimeoutException e) {
throw new RestException(e);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
import java.util.List;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.stream.Collectors;
import javax.ws.rs.DELETE;
import javax.ws.rs.DefaultValue;
Expand Down Expand Up @@ -530,7 +532,14 @@ protected void validateAdminOperationOnTopic(TopicName topicName, boolean author
}

private Topic getTopicReference(TopicName topicName) {
return pulsar().getBrokerService().getTopicIfExists(topicName.toString()).join()
.orElseThrow(() -> new RestException(Status.NOT_FOUND, "Topic not found"));
try {
return pulsar().getBrokerService().getTopicIfExists(topicName.toString())
.get(config().getZooKeeperOperationTimeoutSeconds(), TimeUnit.SECONDS)
.orElseThrow(() -> new RestException(Status.NOT_FOUND, "Topic not found"));
} catch (ExecutionException e) {
throw new RestException(e.getCause());
} catch (InterruptedException | TimeoutException e) {
throw new RestException(e);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@
import java.util.Optional;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionException;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Executor;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import org.apache.bookkeeper.util.ZkUtils;
import org.apache.pulsar.broker.PulsarService;
import org.apache.pulsar.common.naming.NamespaceBundle;
Expand Down Expand Up @@ -371,7 +374,13 @@ public boolean isNamespaceBundleOwned(NamespaceBundle bundle) {
public OwnedBundle getOwnedBundle(NamespaceBundle bundle) {
CompletableFuture<OwnedBundle> future = ownedBundlesCache.getIfPresent(ServiceUnitUtils.path(bundle));
if (future != null && future.isDone() && !future.isCompletedExceptionally()) {
return future.join();
try {
return future.get(pulsar.getConfiguration().getZooKeeperOperationTimeoutSeconds(), TimeUnit.SECONDS);
} catch (InterruptedException | TimeoutException e) {
throw new RuntimeException(e);
} catch (ExecutionException e) {
throw new RuntimeException(e.getCause());
}
} else {
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@
import java.util.List;
import java.util.Map;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import lombok.AccessLevel;
Expand Down Expand Up @@ -122,11 +124,19 @@ public CompletableFuture<Consumer<T>> subscribeAsync() {
//Issue 9327: do compatibility check in case of the default retry and dead letter topic name changed
String oldRetryLetterTopic = topicFirst.getNamespace() + "/" + conf.getSubscriptionName() + RetryMessageUtil.RETRY_GROUP_TOPIC_SUFFIX;
String oldDeadLetterTopic = topicFirst.getNamespace() + "/" + conf.getSubscriptionName() + RetryMessageUtil.DLQ_GROUP_TOPIC_SUFFIX;
if (client.getPartitionedTopicMetadata(oldRetryLetterTopic).join().partitions > 0) {
retryLetterTopic = oldRetryLetterTopic;
}
if (client.getPartitionedTopicMetadata(oldDeadLetterTopic).join().partitions > 0) {
deadLetterTopic = oldDeadLetterTopic;
try {
if (client.getPartitionedTopicMetadata(oldRetryLetterTopic)
.get(client.conf.getOperationTimeoutMs(), TimeUnit.MILLISECONDS).partitions > 0) {
retryLetterTopic = oldRetryLetterTopic;
}
if (client.getPartitionedTopicMetadata(oldDeadLetterTopic)
.get(client.conf.getOperationTimeoutMs(), TimeUnit.MILLISECONDS).partitions > 0) {
deadLetterTopic = oldDeadLetterTopic;
}
} catch (InterruptedException | TimeoutException e) {
return FutureUtil.failedFuture(e);
} catch (ExecutionException e) {
return FutureUtil.failedFuture(e.getCause());
}

if(conf.getDeadLetterPolicy() == null) {
Expand Down