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/17 06:30:14 UTC
[GitHub] [pulsar] hangc0276 commented on a change in pull request #14336: Validate rack name
hangc0276 commented on a change in pull request #14336:
URL: https://github.com/apache/pulsar/pull/14336#discussion_r808712550
##########
File path: pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v2/Bookies.java
##########
@@ -162,6 +164,15 @@ public void updateBookieRackInfo(@Suspended final AsyncResponse asyncResponse,
throw new RestException(Status.PRECONDITION_FAILED, "Bookie 'group' parameters is missing");
}
+ // validate rack name
+ int separatorCnt = StringUtils.countMatches(
+ StringUtils.strip(bookieInfo.getRack(), PATH_SEPARATOR), PATH_SEPARATOR);
+ boolean isRackEnabled = pulsar().getConfiguration().isBookkeeperClientRackawarePolicyEnabled();
+ boolean isRegionEnabled = pulsar().getConfiguration().isBookkeeperClientRegionawarePolicyEnabled();
+ if (isRackEnabled && ((isRegionEnabled && separatorCnt != 1) || (!isRegionEnabled && separatorCnt != 0))) {
+ asyncResponse.resume(new RestException(Status.PRECONDITION_FAILED, "Bookie 'rack' parameter is invalid"));
Review comment:
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