You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2022/06/28 08:43:23 UTC

[GitHub] [pulsar] nodece commented on a diff in pull request #16264: [improve][functions] Check whether the resource exists and create it

nodece commented on code in PR #16264:
URL: https://github.com/apache/pulsar/pull/16264#discussion_r908207591


##########
pulsar-functions/worker/src/main/java/org/apache/pulsar/functions/worker/PulsarWorkerService.java:
##########
@@ -389,7 +397,11 @@ private static Policies createFunctionsNamespacePolicies(String pulsarFunctionsC
 
     private void tryCreateNonPartitionedTopic(final String topic) throws PulsarAdminException {
         try {
-            getBrokerAdmin().topics().createNonPartitionedTopic(topic);
+            TopicName topicName = TopicName.get(topic);
+            List<String> topics = getBrokerAdmin().topics().getList(topicName.getNamespace());
+            if (topics.stream().noneMatch(n -> TopicName.get(n).equals(topicName))) {
+                getBrokerAdmin().topics().createNonPartitionedTopic(topic);
+            }
         } catch (PulsarAdminException e) {
             if (e instanceof PulsarAdminException.ConflictException) {
                 log.warn("Failed to create topic '{}': {}", topic, e.getMessage());

Review Comment:
   Switch to the "debug" level is easier, but you can still see some logs in the broker.



-- 
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: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org