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/05/24 08:56:46 UTC
[GitHub] [pulsar] eolivelli opened a new pull request, #15751: PIP-105 add support for updating the Subscription properties (DRAFT)
eolivelli opened a new pull request, #15751:
URL: https://github.com/apache/pulsar/pull/15751
This is only a draft.
We have to fix this https://github.com/apache/pulsar/issues/15750 before reviewing this patch
--
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] lhotari commented on a diff in pull request #15751: PIP-105 add support for updating the Subscription properties
Posted by GitBox <gi...@apache.org>.
lhotari commented on code in PR #15751:
URL: https://github.com/apache/pulsar/pull/15751#discussion_r888682978
##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v2/PersistentTopics.java:
##########
@@ -1527,6 +1527,43 @@ public void resetCursor(
}
}
+ @POST
+ @Path("/{tenant}/{namespace}/{topic}/subscription/{subName}/updateProperties")
Review Comment:
```suggestion
@PUT
@Path("/{tenant}/{namespace}/{topic}/subscription/{subName}/properties")
```
It would be more RESTful to model the properties as a resource that can be updated with `PUT`.
It would also be RESTful to make a GET return the existing properties.
--
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 #15751: PIP-105 add support for updating the Subscription properties
Posted by GitBox <gi...@apache.org>.
codelipenghui commented on code in PR #15751:
URL: https://github.com/apache/pulsar/pull/15751#discussion_r888831150
##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/PersistentTopicsBase.java:
##########
@@ -2289,6 +2316,85 @@ private void internalCreateSubscriptionForNonPartitionedTopic(
});
}
+ protected void internalUpdateSubscriptionProperties(AsyncResponse asyncResponse, String subName,
+ Map<String, String> subscriptionProperties,
+ boolean authoritative) {
+ CompletableFuture<Void> future;
+ if (topicName.isGlobal()) {
+ future = validateGlobalNamespaceOwnershipAsync(namespaceName);
+ } else {
+ future = CompletableFuture.completedFuture(null);
+ }
+
+ future.thenCompose(__ -> validateTopicOwnershipAsync(topicName, authoritative)).thenAccept(__ -> {
+ if (topicName.isPartitioned()) {
+ internalUpdateSubscriptionPropertiesForNonPartitionedTopic(asyncResponse, subName,
+ subscriptionProperties, authoritative);
+ } 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()
+ .updateSubscriptionPropertiesAsync(topicNamePartition.toString(),
+ subName, subscriptionProperties));
+ } catch (Exception e) {
+ log.error("[{}] Failed to update properties for subscription {} {}",
+ clientAppId(), topicNamePartition, subName,
+ e);
+ asyncResponse.resume(new RestException(e));
+ return;
+ }
+ }
+
+ FutureUtil.waitForAll(futures).handle((result, exception) -> {
+ if (exception != null) {
+ Throwable t = exception.getCause();
+ if (t instanceof NotFoundException) {
+ asyncResponse.resume(new RestException(Status.NOT_FOUND,
+ getSubNotFoundErrorMessage(topicName.toString(), subName)));
+ return null;
+ } else if (t instanceof PreconditionFailedException) {
+ asyncResponse.resume(new RestException(Status.PRECONDITION_FAILED,
+ "Subscription has active connected consumers"));
+ return null;
+ } else {
+ log.error("[{}] Failed to update properties for subscription {} {}",
+ clientAppId(), topicName, subName, t);
+ asyncResponse.resume(new RestException(t));
+ return null;
+ }
+ }
+
+ asyncResponse.resume(Response.noContent().build());
+ return null;
+ });
+ } else {
+ internalUpdateSubscriptionPropertiesForNonPartitionedTopic(asyncResponse, subName,
+ subscriptionProperties, authoritative);
+ }
+ }, pulsar().getExecutor()).exceptionally(ex -> {
+ log.error("[{}] Failed to update properties for subscription {} from topic {}",
+ clientAppId(), subName, topicName, ex);
+ resumeAsyncResponseExceptionally(asyncResponse, ex);
+ return null;
+ });
+ }
+ }).exceptionally(ex -> {
+ // If the exception is not redirect exception we need to log it.
+ if (!isRedirectException(ex)) {
+ log.error("[{}] Failed to update subscription {} from topic {}",
+ clientAppId(), subName, topicName, ex);
+ }
Review Comment:
We will not get a RedirectException here?
--
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] eolivelli commented on a diff in pull request #15751: PIP-105 add support for updating the Subscription properties
Posted by GitBox <gi...@apache.org>.
eolivelli commented on code in PR #15751:
URL: https://github.com/apache/pulsar/pull/15751#discussion_r888688990
##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v2/PersistentTopics.java:
##########
@@ -1527,6 +1527,43 @@ public void resetCursor(
}
}
+ @POST
+ @Path("/{tenant}/{namespace}/{topic}/subscription/{subName}/updateProperties")
Review Comment:
I have switched to PUT, thanks
for GET I would prefer to do a follow up PR, as the information is already available in stats and I would prefer to keep the patch as small as possible
--
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] eolivelli commented on a diff in pull request #15751: PIP-105 add support for updating the Subscription properties
Posted by GitBox <gi...@apache.org>.
eolivelli commented on code in PR #15751:
URL: https://github.com/apache/pulsar/pull/15751#discussion_r888863411
##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/PersistentTopicsBase.java:
##########
@@ -2289,6 +2316,85 @@ private void internalCreateSubscriptionForNonPartitionedTopic(
});
}
+ protected void internalUpdateSubscriptionProperties(AsyncResponse asyncResponse, String subName,
+ Map<String, String> subscriptionProperties,
+ boolean authoritative) {
+ CompletableFuture<Void> future;
+ if (topicName.isGlobal()) {
+ future = validateGlobalNamespaceOwnershipAsync(namespaceName);
+ } else {
+ future = CompletableFuture.completedFuture(null);
+ }
+
+ future.thenCompose(__ -> validateTopicOwnershipAsync(topicName, authoritative)).thenAccept(__ -> {
+ if (topicName.isPartitioned()) {
+ internalUpdateSubscriptionPropertiesForNonPartitionedTopic(asyncResponse, subName,
+ subscriptionProperties, authoritative);
+ } 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()
+ .updateSubscriptionPropertiesAsync(topicNamePartition.toString(),
+ subName, subscriptionProperties));
+ } catch (Exception e) {
+ log.error("[{}] Failed to update properties for subscription {} {}",
+ clientAppId(), topicNamePartition, subName,
+ e);
+ asyncResponse.resume(new RestException(e));
+ return;
+ }
+ }
+
+ FutureUtil.waitForAll(futures).handle((result, exception) -> {
+ if (exception != null) {
+ Throwable t = exception.getCause();
+ if (t instanceof NotFoundException) {
+ asyncResponse.resume(new RestException(Status.NOT_FOUND,
+ getSubNotFoundErrorMessage(topicName.toString(), subName)));
+ return null;
+ } else if (t instanceof PreconditionFailedException) {
+ asyncResponse.resume(new RestException(Status.PRECONDITION_FAILED,
+ "Subscription has active connected consumers"));
+ return null;
+ } else {
+ log.error("[{}] Failed to update properties for subscription {} {}",
+ clientAppId(), topicName, subName, t);
+ asyncResponse.resume(new RestException(t));
+ return null;
+ }
+ }
+
+ asyncResponse.resume(Response.noContent().build());
+ return null;
+ });
+ } else {
+ internalUpdateSubscriptionPropertiesForNonPartitionedTopic(asyncResponse, subName,
+ subscriptionProperties, authoritative);
+ }
+ }, pulsar().getExecutor()).exceptionally(ex -> {
+ log.error("[{}] Failed to update properties for subscription {} from topic {}",
+ clientAppId(), subName, topicName, ex);
+ resumeAsyncResponseExceptionally(asyncResponse, ex);
+ return null;
+ });
+ }
+ }).exceptionally(ex -> {
+ // If the exception is not redirect exception we need to log it.
+ if (!isRedirectException(ex)) {
+ log.error("[{}] Failed to update subscription {} from topic {}",
+ clientAppId(), subName, topicName, ex);
+ }
Review Comment:
it should come from here
https://github.com/apache/pulsar/blob/eb1daaeb05a351c5b832a3f49e1f96e8ba4df3f1/pulsar-broker/src/main/java/org/apache/pulsar/broker/web/PulsarWebResource.java#L732
in `validateTopicOwnershipAsync`
--
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] eolivelli commented on pull request #15751: PIP-105 add support for updating the Subscription properties (DRAFT)
Posted by GitBox <gi...@apache.org>.
eolivelli commented on PR #15751:
URL: https://github.com/apache/pulsar/pull/15751#issuecomment-1141947665
/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] lhotari commented on a diff in pull request #15751: PIP-105 add support for updating the Subscription properties
Posted by GitBox <gi...@apache.org>.
lhotari commented on code in PR #15751:
URL: https://github.com/apache/pulsar/pull/15751#discussion_r888700712
##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/PersistentTopicsBase.java:
##########
@@ -2289,6 +2316,85 @@ private void internalCreateSubscriptionForNonPartitionedTopic(
});
}
+ protected void internalUpdateSubscriptionProperties(AsyncResponse asyncResponse, String subName,
+ Map<String, String> subscriptionProperties,
+ boolean authoritative) {
+ CompletableFuture<Void> future;
+ if (topicName.isGlobal()) {
+ future = validateGlobalNamespaceOwnershipAsync(namespaceName);
+ } else {
+ future = CompletableFuture.completedFuture(null);
+ }
+
+ future.thenCompose(__ -> validateTopicOwnershipAsync(topicName, authoritative)).thenAccept(__ -> {
+ if (topicName.isPartitioned()) {
+ internalUpdateSubscriptionPropertiesForNonPartitionedTopic(asyncResponse, subName,
+ subscriptionProperties, authoritative);
+ } 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()
+ .updateSubscriptionPropertiesAsync(topicNamePartition.toString(),
+ subName, subscriptionProperties));
+ } catch (Exception e) {
+ log.error("[{}] Failed to update subscription {} {}",
Review Comment:
```suggestion
log.error("[{}] Failed to update properties for subscription {} {}",
```
##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/PersistentTopicsBase.java:
##########
@@ -2289,6 +2316,85 @@ private void internalCreateSubscriptionForNonPartitionedTopic(
});
}
+ protected void internalUpdateSubscriptionProperties(AsyncResponse asyncResponse, String subName,
+ Map<String, String> subscriptionProperties,
+ boolean authoritative) {
+ CompletableFuture<Void> future;
+ if (topicName.isGlobal()) {
+ future = validateGlobalNamespaceOwnershipAsync(namespaceName);
+ } else {
+ future = CompletableFuture.completedFuture(null);
+ }
+
+ future.thenCompose(__ -> validateTopicOwnershipAsync(topicName, authoritative)).thenAccept(__ -> {
+ if (topicName.isPartitioned()) {
+ internalUpdateSubscriptionPropertiesForNonPartitionedTopic(asyncResponse, subName,
+ subscriptionProperties, authoritative);
+ } 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()
+ .updateSubscriptionPropertiesAsync(topicNamePartition.toString(),
+ subName, subscriptionProperties));
+ } catch (Exception e) {
+ log.error("[{}] Failed to update subscription {} {}",
+ clientAppId(), topicNamePartition, subName,
+ e);
+ asyncResponse.resume(new RestException(e));
+ return;
+ }
+ }
+
+ FutureUtil.waitForAll(futures).handle((result, exception) -> {
+ if (exception != null) {
+ Throwable t = exception.getCause();
+ if (t instanceof NotFoundException) {
+ asyncResponse.resume(new RestException(Status.NOT_FOUND,
+ getSubNotFoundErrorMessage(topicName.toString(), subName)));
+ return null;
+ } else if (t instanceof PreconditionFailedException) {
+ asyncResponse.resume(new RestException(Status.PRECONDITION_FAILED,
+ "Subscription has active connected consumers"));
+ return null;
+ } else {
+ log.error("[{}] Failed to delete subscription {} {}",
+ clientAppId(), topicName, subName, t);
+ asyncResponse.resume(new RestException(t));
+ return null;
+ }
+ }
+
+ asyncResponse.resume(Response.noContent().build());
+ return null;
+ });
+ } else {
+ internalUpdateSubscriptionPropertiesForNonPartitionedTopic(asyncResponse, subName,
+ subscriptionProperties, authoritative);
+ }
+ }, pulsar().getExecutor()).exceptionally(ex -> {
+ log.error("[{}] Failed to update subscription {} from topic {}",
Review Comment:
```suggestion
log.error("[{}] Failed to update properties for subscription {} from topic {}",
```
##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/PersistentTopicsBase.java:
##########
@@ -2289,6 +2316,85 @@ private void internalCreateSubscriptionForNonPartitionedTopic(
});
}
+ protected void internalUpdateSubscriptionProperties(AsyncResponse asyncResponse, String subName,
+ Map<String, String> subscriptionProperties,
+ boolean authoritative) {
+ CompletableFuture<Void> future;
+ if (topicName.isGlobal()) {
+ future = validateGlobalNamespaceOwnershipAsync(namespaceName);
+ } else {
+ future = CompletableFuture.completedFuture(null);
+ }
+
+ future.thenCompose(__ -> validateTopicOwnershipAsync(topicName, authoritative)).thenAccept(__ -> {
+ if (topicName.isPartitioned()) {
+ internalUpdateSubscriptionPropertiesForNonPartitionedTopic(asyncResponse, subName,
+ subscriptionProperties, authoritative);
+ } 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()
+ .updateSubscriptionPropertiesAsync(topicNamePartition.toString(),
+ subName, subscriptionProperties));
+ } catch (Exception e) {
+ log.error("[{}] Failed to update subscription {} {}",
+ clientAppId(), topicNamePartition, subName,
+ e);
+ asyncResponse.resume(new RestException(e));
+ return;
+ }
+ }
+
+ FutureUtil.waitForAll(futures).handle((result, exception) -> {
+ if (exception != null) {
+ Throwable t = exception.getCause();
+ if (t instanceof NotFoundException) {
+ asyncResponse.resume(new RestException(Status.NOT_FOUND,
+ getSubNotFoundErrorMessage(topicName.toString(), subName)));
+ return null;
+ } else if (t instanceof PreconditionFailedException) {
+ asyncResponse.resume(new RestException(Status.PRECONDITION_FAILED,
+ "Subscription has active connected consumers"));
+ return null;
+ } else {
+ log.error("[{}] Failed to delete subscription {} {}",
Review Comment:
```suggestion
log.error("[{}] Failed to update properties for subscription {} {}",
```
--
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] eolivelli commented on pull request #15751: PIP-105 add support for updating the Subscription properties (DRAFT)
Posted by GitBox <gi...@apache.org>.
eolivelli commented on PR #15751:
URL: https://github.com/apache/pulsar/pull/15751#issuecomment-1145634487
/pulsar-bot 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] lhotari merged pull request #15751: PIP-105 add support for updating the Subscription properties
Posted by GitBox <gi...@apache.org>.
lhotari merged PR #15751:
URL: https://github.com/apache/pulsar/pull/15751
--
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] eolivelli commented on a diff in pull request #15751: PIP-105 add support for updating the Subscription properties
Posted by GitBox <gi...@apache.org>.
eolivelli commented on code in PR #15751:
URL: https://github.com/apache/pulsar/pull/15751#discussion_r888836544
##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/PersistentTopicsBase.java:
##########
@@ -2289,6 +2316,85 @@ private void internalCreateSubscriptionForNonPartitionedTopic(
});
}
+ protected void internalUpdateSubscriptionProperties(AsyncResponse asyncResponse, String subName,
+ Map<String, String> subscriptionProperties,
+ boolean authoritative) {
+ CompletableFuture<Void> future;
+ if (topicName.isGlobal()) {
+ future = validateGlobalNamespaceOwnershipAsync(namespaceName);
+ } else {
+ future = CompletableFuture.completedFuture(null);
+ }
+
+ future.thenCompose(__ -> validateTopicOwnershipAsync(topicName, authoritative)).thenAccept(__ -> {
+ if (topicName.isPartitioned()) {
+ internalUpdateSubscriptionPropertiesForNonPartitionedTopic(asyncResponse, subName,
+ subscriptionProperties, authoritative);
+ } 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()
+ .updateSubscriptionPropertiesAsync(topicNamePartition.toString(),
+ subName, subscriptionProperties));
+ } catch (Exception e) {
+ log.error("[{}] Failed to update properties for subscription {} {}",
+ clientAppId(), topicNamePartition, subName,
+ e);
+ asyncResponse.resume(new RestException(e));
+ return;
+ }
+ }
+
+ FutureUtil.waitForAll(futures).handle((result, exception) -> {
+ if (exception != null) {
+ Throwable t = exception.getCause();
+ if (t instanceof NotFoundException) {
+ asyncResponse.resume(new RestException(Status.NOT_FOUND,
+ getSubNotFoundErrorMessage(topicName.toString(), subName)));
+ return null;
+ } else if (t instanceof PreconditionFailedException) {
+ asyncResponse.resume(new RestException(Status.PRECONDITION_FAILED,
+ "Subscription has active connected consumers"));
+ return null;
+ } else {
+ log.error("[{}] Failed to update properties for subscription {} {}",
+ clientAppId(), topicName, subName, t);
+ asyncResponse.resume(new RestException(t));
+ return null;
+ }
+ }
+
+ asyncResponse.resume(Response.noContent().build());
+ return null;
+ });
+ } else {
+ internalUpdateSubscriptionPropertiesForNonPartitionedTopic(asyncResponse, subName,
+ subscriptionProperties, authoritative);
+ }
+ }, pulsar().getExecutor()).exceptionally(ex -> {
+ log.error("[{}] Failed to update properties for subscription {} from topic {}",
+ clientAppId(), subName, topicName, ex);
+ resumeAsyncResponseExceptionally(asyncResponse, ex);
+ return null;
+ });
+ }
+ }).exceptionally(ex -> {
+ // If the exception is not redirect exception we need to log it.
+ if (!isRedirectException(ex)) {
+ log.error("[{}] Failed to update subscription {} from topic {}",
+ clientAppId(), subName, topicName, ex);
+ }
Review Comment:
I will double check, this code is basically copy/pasted from resetCursor IIRC
--
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