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/02/04 15:01:57 UTC

[GitHub] [pulsar] mattisonchao opened a new pull request #14123: Make ``TenantsBase#createTenant`` to pure async

mattisonchao opened a new pull request #14123:
URL: https://github.com/apache/pulsar/pull/14123


   ### Motivation
   
   Make  ``TenantsBase#createTenant`` to pure async.
   
   ### Modifications
   
   - change sync method to async.
   
   ### Verifying this change
   
   - [x] Make sure that the change passes the CI checks.
   
   ### Documentation
   
   Check the box below or label this PR directly (if you have committer privilege).
   
   Need to update docs? 
   
   - [x] `no-need-doc` 
     
   
   
   


-- 
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 change in pull request #14123: Make ``TenantsBase#createTenant`` to pure async

Posted by GitBox <gi...@apache.org>.
eolivelli commented on a change in pull request #14123:
URL: https://github.com/apache/pulsar/pull/14123#discussion_r800096885



##########
File path: pulsar-broker/src/main/java/org/apache/pulsar/broker/web/PulsarWebResource.java
##########
@@ -1165,4 +1178,14 @@ public void validateTopicOperation(TopicName topicName, TopicOperation operation
         }
     }
 
+    protected Void handleCommonRestAsyncException(AsyncResponse asyncResponse, Throwable ex) {

Review comment:
       Nit: static 




-- 
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] RobertIndie commented on a change in pull request #14123: Make ``TenantsBase#createTenant`` to pure async

Posted by GitBox <gi...@apache.org>.
RobertIndie commented on a change in pull request #14123:
URL: https://github.com/apache/pulsar/pull/14123#discussion_r800266580



##########
File path: pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/TenantsBase.java
##########
@@ -120,58 +124,34 @@ public void getTenantAdmin(@Suspended final AsyncResponse asyncResponse,
     public void createTenant(@Suspended final AsyncResponse asyncResponse,
             @ApiParam(value = "The tenant name") @PathParam("tenant") String tenant,
             @ApiParam(value = "TenantInfo") TenantInfoImpl tenantInfo) {
-
-        final String clientAppId = clientAppId();
-        try {
-            validateSuperUserAccess();
-            validatePoliciesReadOnlyAccess();
-            validateClusters(tenantInfo);
-            NamedEntity.checkName(tenant);
-        } catch (IllegalArgumentException e) {
-            log.warn("[{}] Failed to create tenant with invalid name {}", clientAppId(), tenant, e);
-            asyncResponse.resume(new RestException(Status.PRECONDITION_FAILED, "Tenant name is not valid"));

Review comment:
       It seems that we have removed this exception. It will make users confused if will just throw the `IllegalArgumentException` without other information.




-- 
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] mattisonchao closed pull request #14123: Make ``TenantsBase#createTenant`` to pure async

Posted by GitBox <gi...@apache.org>.
mattisonchao closed pull request #14123:
URL: https://github.com/apache/pulsar/pull/14123


   


-- 
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] mattisonchao commented on pull request #14123: Make ``TenantsBase#createTenant`` to pure async

Posted by GitBox <gi...@apache.org>.
mattisonchao commented on pull request #14123:
URL: https://github.com/apache/pulsar/pull/14123#issuecomment-1030488696


   /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] mattisonchao commented on pull request #14123: Make ``TenantsBase#createTenant`` to pure async

Posted by GitBox <gi...@apache.org>.
mattisonchao commented on pull request #14123:
URL: https://github.com/apache/pulsar/pull/14123#issuecomment-1030568990


   /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] mattisonchao closed pull request #14123: Make ``TenantsBase#createTenant`` to pure async

Posted by GitBox <gi...@apache.org>.
mattisonchao closed pull request #14123:
URL: https://github.com/apache/pulsar/pull/14123


   


-- 
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] mattisonchao commented on a change in pull request #14123: Make ``TenantsBase#createTenant`` to pure async

Posted by GitBox <gi...@apache.org>.
mattisonchao commented on a change in pull request #14123:
URL: https://github.com/apache/pulsar/pull/14123#discussion_r800268328



##########
File path: pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/TenantsBase.java
##########
@@ -120,58 +124,34 @@ public void getTenantAdmin(@Suspended final AsyncResponse asyncResponse,
     public void createTenant(@Suspended final AsyncResponse asyncResponse,
             @ApiParam(value = "The tenant name") @PathParam("tenant") String tenant,
             @ApiParam(value = "TenantInfo") TenantInfoImpl tenantInfo) {
-
-        final String clientAppId = clientAppId();
-        try {
-            validateSuperUserAccess();
-            validatePoliciesReadOnlyAccess();
-            validateClusters(tenantInfo);
-            NamedEntity.checkName(tenant);
-        } catch (IllegalArgumentException e) {
-            log.warn("[{}] Failed to create tenant with invalid name {}", clientAppId(), tenant, e);
-            asyncResponse.resume(new RestException(Status.PRECONDITION_FAILED, "Tenant name is not valid"));

Review comment:
       Good catch! 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] mattisonchao commented on pull request #14123: Make ``TenantsBase#createTenant`` to pure async

Posted by GitBox <gi...@apache.org>.
mattisonchao commented on pull request #14123:
URL: https://github.com/apache/pulsar/pull/14123#issuecomment-1031035708


   /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] mattisonchao closed pull request #14123: Make ``TenantsBase#createTenant`` to pure async

Posted by GitBox <gi...@apache.org>.
mattisonchao closed pull request #14123:
URL: https://github.com/apache/pulsar/pull/14123


   


-- 
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] mattisonchao commented on a change in pull request #14123: Make ``TenantsBase#createTenant`` to pure async

Posted by GitBox <gi...@apache.org>.
mattisonchao commented on a change in pull request #14123:
URL: https://github.com/apache/pulsar/pull/14123#discussion_r800176465



##########
File path: pulsar-broker/src/main/java/org/apache/pulsar/broker/web/PulsarWebResource.java
##########
@@ -1166,7 +1178,7 @@ public void validateTopicOperation(TopicName topicName, TopicOperation operation
         }
     }
 
-    protected Void handleCommonRestAsyncException(AsyncResponse asyncResponse, Throwable ex) {
+    protected static Void handleCommonRestAsyncException(AsyncResponse asyncResponse, Throwable ex) {

Review comment:
       Could we use it in ``exceptionally`` to avoid unnecessary ``return null``?
   
   Use ``Avoid`` return type
   ```java
   //....
   .exceptionally(ex -> {
        return handleCommonRestAsyncException(asyncResponse, ex);
   })
   ```
   Don't use ``Avoid`` return type
   ```java
   //....
   .exceptionally(ex -> {
        handleCommonRestAsyncException(asyncResponse, ex);
        return null;
   })
   ```
   




-- 
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] mattisonchao commented on a change in pull request #14123: Make ``TenantsBase#createTenant`` to pure async

Posted by GitBox <gi...@apache.org>.
mattisonchao commented on a change in pull request #14123:
URL: https://github.com/apache/pulsar/pull/14123#discussion_r800110465



##########
File path: pulsar-broker/src/main/java/org/apache/pulsar/broker/web/PulsarWebResource.java
##########
@@ -1165,4 +1178,14 @@ public void validateTopicOperation(TopicName topicName, TopicOperation operation
         }
     }
 
+    protected Void handleCommonRestAsyncException(AsyncResponse asyncResponse, Throwable ex) {

Review comment:
       fixed. PTAL :-)




-- 
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 change in pull request #14123: Make ``TenantsBase#createTenant`` to pure async

Posted by GitBox <gi...@apache.org>.
eolivelli commented on a change in pull request #14123:
URL: https://github.com/apache/pulsar/pull/14123#discussion_r800175335



##########
File path: pulsar-broker/src/main/java/org/apache/pulsar/broker/web/PulsarWebResource.java
##########
@@ -1166,7 +1178,7 @@ public void validateTopicOperation(TopicName topicName, TopicOperation operation
         }
     }
 
-    protected Void handleCommonRestAsyncException(AsyncResponse asyncResponse, Throwable ex) {
+    protected static Void handleCommonRestAsyncException(AsyncResponse asyncResponse, Throwable ex) {

Review comment:
       Sorry I didn't see that the return type is Void.
   
   Please it to 'void'




-- 
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] mattisonchao removed a comment on pull request #14123: Make ``TenantsBase#createTenant`` to pure async

Posted by GitBox <gi...@apache.org>.
mattisonchao removed a comment on pull request #14123:
URL: https://github.com/apache/pulsar/pull/14123#issuecomment-1030488696


   /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] mattisonchao commented on pull request #14123: Make ``TenantsBase#createTenant`` to pure async

Posted by GitBox <gi...@apache.org>.
mattisonchao commented on pull request #14123:
URL: https://github.com/apache/pulsar/pull/14123#issuecomment-1030986422


   @codelipenghui  @eolivelli  @Technoboy- @Jason918 @Shoothzj @RobertIndie @nodece 
   
   PTAL, when you have time. :)


-- 
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