-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PIP 110: Support Topic metadata - PART-1 create topic with properties #12818
Merged
Merged
Changes from all commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
304d15a
PIP 110: Support Topic metadata (#12629).
Technoboy- d2234c4
fix checkstyle
Technoboy- 58eecf1
fix path
Technoboy- 18efd4d
remove required=true
Technoboy- 978f04f
change the field name from topicMetadata to properties
Technoboy- c62643f
change the field name from topicMetadata to properties
Technoboy- 42b2f42
fix test.
Technoboy- fa420e5
fix test.
Technoboy- 96fc5dc
fix test.
Technoboy- 3972fb5
fix test.
Technoboy- 8bbc2a0
Merge branch 'master' into topic-metadata-1
Technoboy- 524911d
fix compile failure
Technoboy- 13e5a28
fix checkstyle
Technoboy- 5cdef7f
fix test.
Technoboy- 8f4b015
fix test.
Technoboy- d435669
fix checkstyle.
Technoboy- ff8347f
Merge branch 'master' into topic-metadata-1
Technoboy- b17c7de
fix checkstyle
Technoboy- b3373bf
Merge branch 'master' into topic-metadata-1
Technoboy- ab8adba
Remove createPartitionedTopic from v1.
Technoboy- 2131936
remove createNonPartitionedTopic in v1
Technoboy- 629517c
updates
Technoboy- a4121fe
updates
Technoboy- 244e71e
updates
Technoboy- ed7f06e
updates
Technoboy- 8a009e1
fix checkstyle
Technoboy- 20ff27f
updates
Technoboy- b22e555
add comment for `topicPath`
Technoboy- File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
93 changes: 93 additions & 0 deletions
93
pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v3/PersistentTopics.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
/** | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
package org.apache.pulsar.broker.admin.v3; | ||
|
||
import io.swagger.annotations.Api; | ||
import io.swagger.annotations.ApiOperation; | ||
import io.swagger.annotations.ApiParam; | ||
import io.swagger.annotations.ApiResponse; | ||
import io.swagger.annotations.ApiResponses; | ||
import javax.ws.rs.DefaultValue; | ||
import javax.ws.rs.Encoded; | ||
import javax.ws.rs.PUT; | ||
import javax.ws.rs.Path; | ||
import javax.ws.rs.PathParam; | ||
import javax.ws.rs.Produces; | ||
import javax.ws.rs.QueryParam; | ||
import javax.ws.rs.container.AsyncResponse; | ||
import javax.ws.rs.container.Suspended; | ||
import javax.ws.rs.core.MediaType; | ||
import org.apache.pulsar.broker.admin.impl.PersistentTopicsBase; | ||
import org.apache.pulsar.common.partition.PartitionedTopicMetadata; | ||
import org.apache.pulsar.common.policies.data.PolicyName; | ||
import org.apache.pulsar.common.policies.data.PolicyOperation; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
/** | ||
*/ | ||
@Path("/persistent") | ||
@Produces(MediaType.APPLICATION_JSON) | ||
@Api(value = "/persistent", description = "Persistent topic admin apis", tags = "persistent topic") | ||
public class PersistentTopics extends PersistentTopicsBase { | ||
|
||
@PUT | ||
@Path("/{tenant}/{namespace}/{topic}/partitions") | ||
@ApiOperation(value = "Create a partitioned topic.", | ||
notes = "It needs to be called before creating a producer on a partitioned topic.") | ||
@ApiResponses(value = { | ||
@ApiResponse(code = 307, message = "Current broker doesn't serve the namespace of this topic"), | ||
@ApiResponse(code = 401, message = "Don't have permission to administrate resources on this tenant"), | ||
@ApiResponse(code = 403, message = "Don't have admin permission"), | ||
@ApiResponse(code = 404, message = "Tenant does not exist"), | ||
@ApiResponse(code = 406, message = "The number of partitions should be more than 0 and" | ||
+ " less than or equal to maxNumPartitionsPerPartitionedTopic"), | ||
@ApiResponse(code = 409, message = "Partitioned topic already exist"), | ||
@ApiResponse(code = 412, | ||
message = "Failed Reason : Name is invalid or Namespace does not have any clusters configured"), | ||
@ApiResponse(code = 500, message = "Internal server error"), | ||
@ApiResponse(code = 503, message = "Failed to validate global cluster configuration") | ||
}) | ||
public void createPartitionedTopic( | ||
@Suspended final AsyncResponse asyncResponse, | ||
@ApiParam(value = "Specify the tenant", required = true) | ||
@PathParam("tenant") String tenant, | ||
@ApiParam(value = "Specify the namespace", required = true) | ||
@PathParam("namespace") String namespace, | ||
@ApiParam(value = "Specify topic name", required = true) | ||
@PathParam("topic") @Encoded String encodedTopic, | ||
@ApiParam(value = "The metadata for the topic", | ||
required = true, type = "PartitionedTopicMetadata") PartitionedTopicMetadata metadata, | ||
@QueryParam("createLocalTopicOnly") @DefaultValue("false") boolean createLocalTopicOnly) { | ||
try { | ||
validateNamespaceName(tenant, namespace); | ||
validateGlobalNamespaceOwnership(); | ||
validatePartitionedTopicName(tenant, namespace, encodedTopic); | ||
validateTopicPolicyOperation(topicName, PolicyName.PARTITION, PolicyOperation.WRITE); | ||
validateCreateTopic(topicName); | ||
internalCreatePartitionedTopic(asyncResponse, metadata.partitions, createLocalTopicOnly, | ||
metadata.properties); | ||
} catch (Exception e) { | ||
log.error("[{}] Failed to create partitioned topic {}", clientAppId(), topicName, e); | ||
resumeAsyncResponseExceptionally(asyncResponse, e); | ||
} | ||
} | ||
|
||
private static final Logger log = LoggerFactory.getLogger(PersistentTopics.class); | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need this new package?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can see the discussion in #12818 (comment).
Because when new PulsarAdmin sends the request to old broker, the old broker cannot recognize the JSON body like
{"partitions":3}
. /cc @codelipenghuiThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because we have changed the method from
createPartitionedTopic(partitions)
tocreatePartitionedTopic(partitionedTopicMetadata)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
makes sense to me.
so when you use the "new" pulsar-admin (2.10) with an old broker
how can we deal with compatibility ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should be possible to handle that in a backwards compatible way without breaking the API. It's better to revert the addition of a new API version and instead revisit the solution in a proper way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
my understanding in this patch was that we are using the v3 endpoint only in case of passing the "properties" and to use v2 in the other cases
it looks like it is kind of a simple but in the logic to choose the endpoint