Github user d2r commented on a diff in the pull request: https://github.com/apache/storm/pull/2881#discussion_r227974287 --- Diff: storm-client/src/jvm/org/apache/storm/utils/Utils.java --- @@ -119,15 +120,81 @@ // tests by subclassing. private static Utils _instance = new Utils(); private static String memoizedLocalHostnameString = null; - public static final Pattern TOPOLOGY_KEY_PATTERN = Pattern.compile("^[\\w \\t\\._-]+$", Pattern.UNICODE_CHARACTER_CLASS); + public static final Pattern TOPOLOGY_KEY_PATTERN = + Pattern.compile("^[\\w \\t\\._-]+$", Pattern.UNICODE_CHARACTER_CLASS); + + public static final String NUMA_MEMORY_IN_MB = "memory.mb"; + public static final String NUMA_CORES = "cores"; + public static final String NUMAS_PORTS = "ports"; + public static final String NUMA_ID = "node_id"; + public static final String NUMAS_BASE = "numas"; static { localConf = readStormConfig(); serializationDelegate = getSerializationDelegate(localConf); } /** - * Provide an instance of this class for delegates to use. To mock out delegated methods, provide an instance of a subclass that + * Validate supervisor numa configuration. + * @param stormConf stormConf + * @return getValidatedNumaMap + * @throws KeyNotFoundException + */ + public static Map<String, Object> getValidatedNumaMap(Map<String, Object> stormConf) throws KeyNotFoundException { + Map<String, Object> validatedNumaMap = new HashMap(); + Map<String, Object> supervisorNumaMap = + (Map<String, Object>) stormConf.get(Config.SUPERVISOR_NUMA_META); + if (supervisorNumaMap == null) { + return validatedNumaMap; + } + if (!supervisorNumaMap.containsKey(NUMAS_BASE)) { + throw new KeyNotFoundException( + "The numa configurations [" + NUMAS_BASE + "] is missing!" + ); + } + List<Map> numaEntries = (List<Map>) supervisorNumaMap.get(NUMAS_BASE); + if (numaEntries == null) return validatedNumaMap; + for (Map numa : numaEntries) { + for (String key : new String[]{NUMA_ID, NUMA_CORES, NUMA_MEMORY_IN_MB, NUMAS_PORTS}) { + if (!numa.containsKey(key)) { + throw new KeyNotFoundException( + "The numa configuration key [" + key + "] is missing!" + ); + } + } + validatedNumaMap.put((String) numa.get(NUMA_ID), numa); + } + return validatedNumaMap; + } --- End diff -- Should this be a custom map validator as with [`nimbus.impersonation.acl`](https://github.com/apache/storm/blob/730c1a302d857121542ce27b6a40b05b90f7f3ed/storm-client/src/jvm/org/apache/storm/Config.java#L1414-L1416)?
---