Skip to content
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

Fix: topic with one partition cannot be updated #6560

Merged
merged 2 commits into from
Mar 19, 2020
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 @@ -2162,7 +2162,7 @@ private CompletableFuture<Void> createSubscriptions(TopicName topicName, int num
String path = path(PARTITIONED_TOPIC_PATH_ZNODE, topicName.getPersistenceNamingEncoding());
CompletableFuture<Void> result = new CompletableFuture<>();
pulsar().getBrokerService().fetchPartitionedTopicMetadataAsync(topicName).thenAccept(partitionMetadata -> {
if (partitionMetadata.partitions <= 1) {
merlimat marked this conversation as resolved.
Show resolved Hide resolved
if (partitionMetadata.partitions < 1) {
result.completeExceptionally(new RestException(Status.CONFLICT, "Topic is not partitioned topic"));
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,17 @@ public void testIncrementPartitionsOfTopicOnUnusedTopic() throws Exception {
public void testIncrementPartitionsOfTopic() throws Exception {
final String partitionedTopicName = "persistent://prop-xyz/use/ns1/test-topic-2";

admin.topics().createPartitionedTopic(partitionedTopicName, 10);
assertEquals(admin.topics().getPartitionedTopicMetadata(partitionedTopicName).partitions, 10);
admin.topics().createPartitionedTopic(partitionedTopicName, 1);
assertEquals(admin.topics().getPartitionedTopicMetadata(partitionedTopicName).partitions, 1);

Consumer<byte[]> consumer = pulsarClient.newConsumer().topic(partitionedTopicName).subscriptionName("sub-1")
.subscribe();
.subscribe();

admin.topics().updatePartitionedTopic(partitionedTopicName, 2);
assertEquals(admin.topics().getPartitionedTopicMetadata(partitionedTopicName).partitions, 2);

admin.topics().updatePartitionedTopic(partitionedTopicName, 10);
assertEquals(admin.topics().getPartitionedTopicMetadata(partitionedTopicName).partitions, 10);

admin.topics().updatePartitionedTopic(partitionedTopicName, 20);
assertEquals(admin.topics().getPartitionedTopicMetadata(partitionedTopicName).partitions, 20);
Expand Down