Technoboy- commented on code in PR #15318:
URL: https://github.com/apache/pulsar/pull/15318#discussion_r858227831


##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/ClustersBase.java:
##########
@@ -158,27 +151,25 @@ public void createCluster(
                         + "}"
                 )
             )
-        )
-                ClusterDataImpl clusterData
-    ) {
-        validateSuperUserAccess();
-        validatePoliciesReadOnlyAccess();
-
-        try {
-            NamedEntity.checkName(cluster);
-            if (clusterResources().getCluster(cluster).isPresent()) {
-                log.warn("[{}] Failed to create already existing cluster {}", 
clientAppId(), cluster);
-                throw new RestException(Status.CONFLICT, "Cluster already 
exists");
-            }
-            clusterResources().createCluster(cluster, clusterData);
-            log.info("[{}] Created cluster {}", clientAppId(), cluster);
-        } catch (IllegalArgumentException e) {
-            log.warn("[{}] Failed to create cluster with invalid name {}", 
clientAppId(), cluster, e);
-            throw new RestException(Status.PRECONDITION_FAILED, "Cluster name 
is not valid");
-        } catch (Exception e) {
-            log.error("[{}] Failed to create cluster {}", clientAppId(), 
cluster, e);
-            throw new RestException(e);
-        }
+        ) ClusterDataImpl clusterData) {
+        validateSuperUserAccessAsync()
+                .thenCompose(__ -> validatePoliciesReadOnlyAccessAsync())
+                .thenCompose(__ -> {
+                    NamedEntity.checkName(cluster);
+                    return clusterResources().getClusterAsync(cluster);
+                }).thenCompose(clusterOpt -> {
+                    if (clusterOpt.isPresent()) {
+                        throw new RestException(Status.CONFLICT, "Cluster 
already exists");
+                    }
+                    return clusterResources().createClusterAsync(cluster, 
clusterData);
+                }).thenAccept(__ -> {
+                    log.info("[{}] Successfully to created cluster {}", 
clientAppId(), cluster);

Review Comment:
   `Successfully to created cluster` -> `Created cluster`
   Keep the original log.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to