Jackie-Jiang commented on a change in pull request #4952: URL: https://github.com/apache/incubator-pinot/pull/4952#discussion_r446448650
########## File path: pinot-controller/src/main/java/org/apache/pinot/controller/helix/core/PinotHelixResourceManager.java ########## @@ -361,6 +361,23 @@ public synchronized PinotResourceManagerResponse addInstance(Instance instance) } } + /** + * Update a given instance for the specified Instance ID + */ + public synchronized PinotResourceManagerResponse updateInstance(String instanceIdToUpdate, Instance newInstance) { + List<String> instances = getAllInstances(); + if (!instances.contains(instanceIdToUpdate)) { + return PinotResourceManagerResponse.failure("Instance " + instanceIdToUpdate + " does not exists"); + } else { + InstanceConfig newConfig = InstanceUtils.toHelixInstanceConfig(newInstance); + if(!_helixZkManager.getHelixDataAccessor().setProperty( + _helixZkManager.getHelixDataAccessor().keyBuilder().instanceConfig(instanceIdToUpdate), newConfig)) { Review comment: For performance and simplicity: ```suggestion if (getHelixInstanceConfig(instanceIdToUpdate) == null) { return PinotResourceManagerResponse.failure("Instance " + instanceIdToUpdate + " does not exists"); } else { InstanceConfig newConfig = InstanceUtils.toHelixInstanceConfig(newInstance); if(!_helixDataAccessor.setProperty(_keyBuilder.instanceConfig(instanceIdToUpdate), newConfig)) { ``` ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org For additional commands, e-mail: commits-h...@pinot.apache.org