Ethanlm commented on a change in pull request #3302: URL: https://github.com/apache/storm/pull/3302#discussion_r450405032
########## File path: storm-server/src/main/java/org/apache/storm/daemon/nimbus/Nimbus.java ########## @@ -2676,6 +2676,14 @@ private void assertTopoActive(String topoName, boolean expectActive) throws NotA return tryReadTopoConf(topoId, topoCache); } + private StormTopology tryReadTopologyFromName(final String topoName) throws NotAliveException, + AuthorizationException, IOException { + IStormClusterState state = stormClusterState; Review comment: This seems redundant ########## File path: storm-server/src/main/java/org/apache/storm/daemon/nimbus/Nimbus.java ########## @@ -3370,8 +3378,18 @@ public void rebalance(String topoName, RebalanceOptions options) checkAuthorization(topoName, topoConf, operation); // Set principal in RebalanceOptions to nil because users are not suppose to set this options.set_principal(null); + // check if executor counts are correctly specified + StormTopology stormTopology = tryReadTopologyFromName(topoName); + Set<String> comps = new HashSet<>(); + comps.addAll(stormTopology.get_spouts().keySet()); + comps.addAll(stormTopology.get_bolts().keySet()); Map<String, Integer> execOverrides = options.is_set_num_executors() ? options.get_num_executors() : Collections.emptyMap(); - for (Integer value : execOverrides.values()) { + for (Map.Entry<String, Integer> e: execOverrides.entrySet()) { + String comp = e.getKey(); + Integer value = e.getValue(); + if (!comps.contains(comp)) { + throw new WrappedInvalidTopologyException(String.format("Component %s does not exist in topology %s", comp, topoName)); Review comment: This feels more like a `IllegalArgumentException`? ---------------------------------------------------------------- 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