mattisonchao commented on code in PR #15318:
URL: https://github.com/apache/pulsar/pull/15318#discussion_r862271481
##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/ClustersBase.java:
##########
@@ -158,27 +152,31 @@ 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");
Review Comment:
In the original logic, they will print warn log and error log, I think it's
duplicated
Because we have a global error log, I think we don't need to print a
duplicate warn 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]