eolivelli commented on a change in pull request #12590:
URL: https://github.com/apache/pulsar/pull/12590#discussion_r743561080
##########
File path:
pulsar-broker-common/src/main/java/org/apache/pulsar/broker/resources/NamespaceResources.java
##########
@@ -122,7 +118,7 @@ public void setPolicies(NamespaceName ns,
Function<Policies, Policies> function)
}
public static boolean pathIsFromNamespace(String path) {
- return path.startsWith(BASE_POLICIES_PATH);
+ return path.startsWith(BASE_POLICIES_PATH) &&
path.substring(BASE_POLICIES_PATH.length() + 1).contains("/");
Review comment:
can you explain better this line ?
##########
File path:
pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/AdminResource.java
##########
@@ -669,14 +672,20 @@ protected void
internalCreatePartitionedTopic(AsyncResponse asyncResponse, int n
return;
}
- if (!createLocalTopicOnly && topicName.isGlobal() &&
isNamespaceReplicated(namespaceName)) {
- getNamespaceReplicatedClusters(namespaceName)
- .stream()
- .filter(cluster ->
!cluster.equals(pulsar().getConfiguration().getClusterName()))
- .forEach(cluster -> createFutureList.add(
- ((TopicsImpl)
pulsar().getBrokerService().getClusterPulsarAdmin(cluster).topics())
+ if (!replicatedClusters.isEmpty()) {
+ replicatedClusters.forEach(cluster -> {
+
pulsar().getPulsarResources().getClusterResources().getClusterAsync(cluster)
+ .thenAccept(clusterDataOp -> {
+ ((TopicsImpl) pulsar().getBrokerService()
+ .getClusterPulsarAdmin(cluster,
clusterDataOp).topics())
.createPartitionedTopicAsync(
-
topicName.getPartitionedTopicName(), numPartitions, true)));
+
topicName.getPartitionedTopicName(), numPartitions, true);
+ })
+ .exceptionally(throwable -> {
+ log.error("Failed to create partition topic in
cluster {}.", cluster, throwable);
Review comment:
should we fail the operation ?
##########
File path:
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/BrokerService.java
##########
@@ -1061,43 +1062,53 @@ public void deleteTopicAuthenticationWithRetry(String
topic, CompletableFuture<V
}
final long topicCreateTimeMs =
TimeUnit.NANOSECONDS.toMillis(System.nanoTime());
NonPersistentTopic nonPersistentTopic = new NonPersistentTopic(topic,
this);
-
- CompletableFuture<Optional<Topic>> future =
nonPersistentTopic.initialize()
- .thenCompose(__ -> nonPersistentTopic.checkReplication())
- .thenApply(__ -> {
- log.info("Created topic {}", nonPersistentTopic);
- long topicLoadLatencyMs =
TimeUnit.NANOSECONDS.toMillis(System.nanoTime()) - topicCreateTimeMs;
- pulsarStats.recordTopicLoadTimeValue(topic, topicLoadLatencyMs);
- addTopicToStatsMaps(TopicName.get(topic), nonPersistentTopic);
- return Optional.of(nonPersistentTopic);
- });
-
- future.exceptionally((ex) -> {
- log.warn("Replication check failed. Removing topic from topics
list {}, {}", topic, ex);
- nonPersistentTopic.stopReplProducers().whenComplete((v, exception)
-> {
- pulsar.getExecutor().execute(() -> topics.remove(topic,
future));
+ CompletableFuture<Void> isOwner = checkTopicNsOwnership(topic);
+ isOwner.thenRun(() -> {
+ nonPersistentTopic.initialize()
+ .thenCompose(__ -> nonPersistentTopic.checkReplication())
+ .thenRun(() -> {
+ log.info("Created topic {}", nonPersistentTopic);
+ long topicLoadLatencyMs =
TimeUnit.NANOSECONDS.toMillis(System.nanoTime()) - topicCreateTimeMs;
+ pulsarStats.recordTopicLoadTimeValue(topic,
topicLoadLatencyMs);
+ addTopicToStatsMaps(TopicName.get(topic),
nonPersistentTopic);
+ topicFuture.complete(Optional.of(nonPersistentTopic));
+ }).exceptionally(ex -> {
+ log.warn("Replication check failed. Removing topic from topics
list {}, {}", topic, ex.getCause());
+ nonPersistentTopic.stopReplProducers().whenComplete((v,
exception) -> {
+ pulsar.getExecutor().execute(() -> topics.remove(topic,
topicFuture));
+ topicFuture.completeExceptionally(ex);
Review comment:
should we run this after the execution of "topics.remove" ?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]