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/04/27 09:43:48 UTC
[GitHub] [pulsar] nodece opened a new pull request, #15347: [cleanup][broker] Remove duplicate code to improve delete subscription
nodece opened a new pull request, #15347:
URL: https://github.com/apache/pulsar/pull/15347
Fixes #15324
### Motivation
`internalDeleteSubscriptionForcefully ` and `internalDeleteSubscription` have duplicate code.
### Modifications
- Merge the duplicate code into `internalDeleteSubscription()`
### Documentation
- [x] `no-need-doc`
Just cleanup
--
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
[GitHub] [pulsar] tisonkun commented on pull request #15347: [cleanup][broker] Remove duplicate code to improve delete subscription
Posted by GitBox <gi...@apache.org>.
tisonkun commented on PR #15347:
URL: https://github.com/apache/pulsar/pull/15347#issuecomment-1353889682
@nodece we can proceed this patch if you can rebase and resolve the conflict. What do you think?
--
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
[GitHub] [pulsar] nodece commented on a diff in pull request #15347: [cleanup][broker] Remove duplicate code to improve delete subscription
Posted by GitBox <gi...@apache.org>.
nodece commented on code in PR #15347:
URL: https://github.com/apache/pulsar/pull/15347#discussion_r860635176
##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/PersistentTopicsBase.java:
##########
@@ -1452,216 +1452,74 @@ protected void internalGetPartitionedStatsInternal(AsyncResponse asyncResponse,
});
}
- protected void internalDeleteSubscription(AsyncResponse asyncResponse,
- String subName, boolean authoritative, boolean force) {
- if (force) {
- internalDeleteSubscriptionForcefully(asyncResponse, subName, authoritative);
- } else {
- internalDeleteSubscription(asyncResponse, subName, authoritative);
- }
- }
-
- protected void internalDeleteSubscription(AsyncResponse asyncResponse, String subName, boolean authoritative) {
+ protected CompletableFuture<Void> internalDeleteSubscriptionAsync(String subName,
+ boolean authoritative,
+ boolean force) {
CompletableFuture<Void> future;
if (topicName.isGlobal()) {
future = validateGlobalNamespaceOwnershipAsync(namespaceName);
} else {
future = CompletableFuture.completedFuture(null);
}
- future.thenCompose(__ -> validateTopicOwnershipAsync(topicName, authoritative)).thenAccept(__ -> {
+ return future.thenCompose(__ -> {
if (topicName.isPartitioned()) {
- internalDeleteSubscriptionForNonPartitionedTopic(asyncResponse, subName, authoritative);
+ return internalDeleteSubscriptionForNonPartitionedTopicAsync(subName, authoritative, force);
} else {
- getPartitionedTopicMetadataAsync(topicName,
- authoritative, false).thenAcceptAsync(partitionMetadata -> {
- if (partitionMetadata.partitions > 0) {
- final List<CompletableFuture<Void>> futures = Lists.newArrayList();
-
- for (int i = 0; i < partitionMetadata.partitions; i++) {
- TopicName topicNamePartition = topicName.getPartition(i);
- try {
- futures.add(pulsar().getAdminClient().topics()
- .deleteSubscriptionAsync(topicNamePartition.toString(), subName, false));
- } catch (Exception e) {
- log.error("[{}] Failed to delete subscription {} {}",
- clientAppId(), topicNamePartition, subName,
- e);
- asyncResponse.resume(new RestException(e));
- return;
- }
- }
+ return getPartitionedTopicMetadataAsync(topicName, authoritative, false)
+ .thenCompose(partitionMetadata -> {
Review Comment:
Should return a CompletableFuture, so use the `thenCompose` without `Executor`.
--
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
[GitHub] [pulsar] github-actions[bot] commented on pull request #15347: [cleanup][broker] Remove duplicate code to improve delete subscription
Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on PR #15347:
URL: https://github.com/apache/pulsar/pull/15347#issuecomment-1150594292
The pr had no activity for 30 days, mark with Stale label.
--
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
[GitHub] [pulsar] nodece commented on a diff in pull request #15347: [cleanup][broker] Remove duplicate code to improve delete subscription
Posted by GitBox <gi...@apache.org>.
nodece commented on code in PR #15347:
URL: https://github.com/apache/pulsar/pull/15347#discussion_r860550508
##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/PersistentTopicsBase.java:
##########
@@ -1452,216 +1452,93 @@ protected void internalGetPartitionedStatsInternal(AsyncResponse asyncResponse,
});
}
- protected void internalDeleteSubscription(AsyncResponse asyncResponse,
- String subName, boolean authoritative, boolean force) {
- if (force) {
- internalDeleteSubscriptionForcefully(asyncResponse, subName, authoritative);
- } else {
- internalDeleteSubscription(asyncResponse, subName, authoritative);
- }
- }
-
- protected void internalDeleteSubscription(AsyncResponse asyncResponse, String subName, boolean authoritative) {
+ protected void internalDeleteSubscriptionAsync(AsyncResponse asyncResponse, String subName, boolean authoritative,
Review Comment:
@codelipenghui Fixed.
--
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
[GitHub] [pulsar] nodece commented on pull request #15347: [cleanup][broker] Remove duplicate code to improve delete subscription
Posted by GitBox <gi...@apache.org>.
nodece commented on PR #15347:
URL: https://github.com/apache/pulsar/pull/15347#issuecomment-1354436447
> @nodece we can proceed this patch if you can rebase and resolve the conflict. What do you think?
Done.
--
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
[GitHub] [pulsar] tisonkun merged pull request #15347: [cleanup][broker] Remove duplicate code to improve delete subscription
Posted by GitBox <gi...@apache.org>.
tisonkun merged PR #15347:
URL: https://github.com/apache/pulsar/pull/15347
--
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
[GitHub] [pulsar] codelipenghui commented on a diff in pull request #15347: [cleanup][broker] Remove duplicate code to improve delete subscription
Posted by GitBox <gi...@apache.org>.
codelipenghui commented on code in PR #15347:
URL: https://github.com/apache/pulsar/pull/15347#discussion_r860391215
##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/PersistentTopicsBase.java:
##########
@@ -1452,216 +1452,93 @@ protected void internalGetPartitionedStatsInternal(AsyncResponse asyncResponse,
});
}
- protected void internalDeleteSubscription(AsyncResponse asyncResponse,
- String subName, boolean authoritative, boolean force) {
- if (force) {
- internalDeleteSubscriptionForcefully(asyncResponse, subName, authoritative);
- } else {
- internalDeleteSubscription(asyncResponse, subName, authoritative);
- }
- }
-
- protected void internalDeleteSubscription(AsyncResponse asyncResponse, String subName, boolean authoritative) {
+ protected void internalDeleteSubscriptionAsync(AsyncResponse asyncResponse, String subName, boolean authoritative,
Review Comment:
It's better to avoid passing the AsyncResponse into the implementation method because it's hard to know the return type from the API.
Instead, return CompletableFuture for this method.
--
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
[GitHub] [pulsar] nodece commented on pull request #15347: [cleanup][broker] Remove duplicate code to improve delete subscription
Posted by GitBox <gi...@apache.org>.
nodece commented on PR #15347:
URL: https://github.com/apache/pulsar/pull/15347#issuecomment-1111821446
/pulsarbot rerun-failure-checks
--
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
[GitHub] [pulsar] leizhiyuan commented on a diff in pull request #15347: [cleanup][broker] Remove duplicate code to improve delete subscription
Posted by GitBox <gi...@apache.org>.
leizhiyuan commented on code in PR #15347:
URL: https://github.com/apache/pulsar/pull/15347#discussion_r860599142
##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/PersistentTopicsBase.java:
##########
@@ -1452,216 +1452,74 @@ protected void internalGetPartitionedStatsInternal(AsyncResponse asyncResponse,
});
}
- protected void internalDeleteSubscription(AsyncResponse asyncResponse,
- String subName, boolean authoritative, boolean force) {
- if (force) {
- internalDeleteSubscriptionForcefully(asyncResponse, subName, authoritative);
- } else {
- internalDeleteSubscription(asyncResponse, subName, authoritative);
- }
- }
-
- protected void internalDeleteSubscription(AsyncResponse asyncResponse, String subName, boolean authoritative) {
+ protected CompletableFuture<Void> internalDeleteSubscriptionAsync(String subName,
+ boolean authoritative,
+ boolean force) {
CompletableFuture<Void> future;
if (topicName.isGlobal()) {
future = validateGlobalNamespaceOwnershipAsync(namespaceName);
} else {
future = CompletableFuture.completedFuture(null);
}
- future.thenCompose(__ -> validateTopicOwnershipAsync(topicName, authoritative)).thenAccept(__ -> {
+ return future.thenCompose(__ -> {
if (topicName.isPartitioned()) {
- internalDeleteSubscriptionForNonPartitionedTopic(asyncResponse, subName, authoritative);
+ return internalDeleteSubscriptionForNonPartitionedTopicAsync(subName, authoritative, force);
} else {
- getPartitionedTopicMetadataAsync(topicName,
- authoritative, false).thenAcceptAsync(partitionMetadata -> {
- if (partitionMetadata.partitions > 0) {
- final List<CompletableFuture<Void>> futures = Lists.newArrayList();
-
- for (int i = 0; i < partitionMetadata.partitions; i++) {
- TopicName topicNamePartition = topicName.getPartition(i);
- try {
- futures.add(pulsar().getAdminClient().topics()
- .deleteSubscriptionAsync(topicNamePartition.toString(), subName, false));
- } catch (Exception e) {
- log.error("[{}] Failed to delete subscription {} {}",
- clientAppId(), topicNamePartition, subName,
- e);
- asyncResponse.resume(new RestException(e));
- return;
- }
- }
+ return getPartitionedTopicMetadataAsync(topicName, authoritative, false)
+ .thenCompose(partitionMetadata -> {
Review Comment:
I used thenAcceptAsync, it should be the same.
--
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