private ClientConfig getConfigFor(ClientInfo clientInfo) { // take the first executor defined in the config return settings .getExecutors() .stream() .filter(ex -> clientInfo.executors().containsKey(ex)) .findFirst() .map(executor -> getConfig(executor, clientInfo)) .orElseGet( () -> { log.error("client has reported unsupported executors: {} ", clientInfo.executors()); return ClientConfig.empty(); }); }
private ClientConfig getConfig(String executor, ClientInfo clientInfo) { int executorCpuCount = clientInfo.executors().get(executor); int cpuSetSize = Math.min(executorCpuCount, settings.getCpuSetSize()); // this happens if the config says use 2 cpus but the machine has only 1. if (executorCpuCount < settings.getCpuSetSize()) { log.warning( "Client reported less cpus ({}) than CPU_SET_SIZE ({})", executorCpuCount, settings.getCpuSetSize()); } int numberOfExecutors = executorCpuCount / cpuSetSize; return ClientConfig.builder() .cpuSetSize(cpuSetSize) .executor(executor) .numberOfExecutors(numberOfExecutors) .build(); }