chenboat commented on code in PR #10993:
URL: https://github.com/apache/pinot/pull/10993#discussion_r1248389459
##########
pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/PinotTenantRestletResource.java:
##########
@@ -276,27 +292,17 @@ private String toggleTenantState(String tenantName,
String stateStr, @Nullable S
Set<String> allInstances = new HashSet<String>(serverInstances);
allInstances.addAll(brokerInstances);
- if (StateType.DROP.name().equalsIgnoreCase(stateStr)) {
- if (!allInstances.isEmpty()) {
- throw new ControllerApplicationException(LOGGER,
- "Error: Tenant " + tenantName + " has live instances, cannot be
dropped.", Response.Status.BAD_REQUEST);
+ if (StateType.DISABLE.name().equalsIgnoreCase(stateStr)) {
+ for (String instance : allInstances) {
+ instanceResult.put(instance,
JsonUtils.objectToJsonNode(_pinotHelixResourceManager.disableInstance(instance)));
}
- _pinotHelixResourceManager.deleteBrokerTenantFor(tenantName);
- _pinotHelixResourceManager.deleteOfflineServerTenantFor(tenantName);
- _pinotHelixResourceManager.deleteRealtimeServerTenantFor(tenantName);
- return new SuccessResponse("Dropped tenant " + tenantName + "
successfully.").toString();
}
-
- boolean enable = StateType.ENABLE.name().equalsIgnoreCase(stateStr) ? true
: false;
- for (String instance : allInstances) {
- if (enable) {
+ if (StateType.ENABLE.name().equalsIgnoreCase(stateStr)) {
+ for (String instance : allInstances) {
instanceResult.put(instance,
JsonUtils.objectToJsonNode(_pinotHelixResourceManager.enableInstance(instance)));
- } else {
- instanceResult.put(instance,
JsonUtils.objectToJsonNode(_pinotHelixResourceManager.disableInstance(instance)));
}
}
-
- return null;
+ return new SuccessResponse("Changed state of tenant " + tenantName + " to
" + stateStr + " successfully.");
Review Comment:
There are three states: can we add the from state to the response?
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]