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 2019/08/18 05:29:26 UTC

[GitHub] [pulsar] sijie commented on a change in pull request #4963: Add more config for auto-topic-creation

sijie commented on a change in pull request #4963: Add more config for auto-topic-creation
URL: https://github.com/apache/pulsar/pull/4963#discussion_r314968631
 
 

 ##########
 File path: pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/AdminResource.java
 ##########
 @@ -535,6 +542,51 @@ public PartitionedTopicMetadata deserialize(String key, byte[] content) throws E
         return metadataFuture;
     }
 
+    protected static PartitionedTopicMetadata fetchPartitionedTopicMetadataCheckAllowAutoCreation(
+            PulsarService pulsar, String path) {
+        try {
+            return fetchPartitionedTopicMetadataCheckAllowAutoCreationAsync(pulsar, path).get();
+        } catch (Exception e) {
+            if (e.getCause() instanceof RestException) {
+                throw (RestException) e;
+            }
+            throw new RestException(e);
+        }
+    }
+
+    protected static CompletableFuture<PartitionedTopicMetadata> fetchPartitionedTopicMetadataCheckAllowAutoCreationAsync(
+            PulsarService pulsar, String path) {
+        CompletableFuture<PartitionedTopicMetadata> metadataFuture = new CompletableFuture<>();
+        try {
+            boolean allowAutoTopicCreation = pulsar.getConfiguration().isAllowAutoTopicCreation();
+            String topicType = pulsar.getConfiguration().getAllowAutoTopicCreationType();
+            fetchPartitionedTopicMetadataAsync(pulsar, path).whenComplete((metadata, ex) -> {
+                if (ex != null) {
+                    metadataFuture.completeExceptionally(ex);
+                } else if (metadata.partitions == 0 && allowAutoTopicCreation &&
 
 Review comment:
   Shall we also check if the non-partitioned topic exist or not? /cc @jiazhai 

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services