/** * Gets a non-negative (can be 0) long value from the given map using the given key. * If there is no such key or if the value is negative, returns the default. */ private static long getNonNegativeLong(Map<String, String> map, String key, String description, long defaultVal) { Long val = getLong(map, key, description); if (val == null) { return defaultVal; } else if (val < 0) { LOG.warn("Ignoring invalid {} '{}' from runtime arguments. It must be a non-negative long.", description, val); return defaultVal; } return val; }
/** * Gets a non-negative (can be 0) long value from the given map using the given key. * If there is no such key or if the value is negative, returns the default. */ private static long getNonNegativeLong(Map<String, String> map, String key, String description, long defaultVal) { Long val = getLong(map, key, description); if (val == null) { return defaultVal; } else if (val < 0) { LOG.warn("Ignoring invalid {} '{}' from runtime arguments. It must be a non-negative long.", description, val); return defaultVal; } return val; }
/** * Returns the twill configurations to be used in {@link TwillPreparer#withConfiguration(Map)} based on the * runtime arguments. */ public static Map<String, String> getTwillApplicationConfigs(Map<String, String> args) { Map<String, String> result = new HashMap<>(); Integer maxAttempts = getPositiveInt(args, YARN_MAX_APP_ATTEMPTS, YARN_MAX_APP_ATTEMPTS); if (maxAttempts != null) { result.put(Configs.Keys.YARN_MAX_APP_ATTEMPTS, maxAttempts.toString()); } Long failureValidityInterval = getLong(args, YARN_ATTEMPT_FAILURES_VALIDITY_INTERVAL, YARN_ATTEMPT_FAILURES_VALIDITY_INTERVAL); if (failureValidityInterval != null) { result.put(Configs.Keys.YARN_ATTEMPT_FAILURES_VALIDITY_INTERVAL, failureValidityInterval.toString()); } return result; }
/** * Returns the twill configurations to be used in {@link TwillPreparer#withConfiguration(Map)} based on the * runtime arguments. */ public static Map<String, String> getTwillApplicationConfigs(Map<String, String> args) { Map<String, String> result = new HashMap<>(); Integer maxAttempts = getPositiveInt(args, YARN_MAX_APP_ATTEMPTS, YARN_MAX_APP_ATTEMPTS); if (maxAttempts != null) { result.put(Configs.Keys.YARN_MAX_APP_ATTEMPTS, maxAttempts.toString()); } Long failureValidityInterval = getLong(args, YARN_ATTEMPT_FAILURES_VALIDITY_INTERVAL, YARN_ATTEMPT_FAILURES_VALIDITY_INTERVAL); if (failureValidityInterval != null) { result.put(Configs.Keys.YARN_ATTEMPT_FAILURES_VALIDITY_INTERVAL, failureValidityInterval.toString()); } return result; }
/** * Configures a {@link NettyHttpService.Builder} based on the given arguments. * * @param args the arguments to use for looking up http service configurations * @param builder a {@link NettyHttpService.Builder} to configure * @param <T> type of the {@link NettyHttpService.Builder} * @return the builder instance as provided through the {@code builder} argument */ public static <T extends NettyHttpService.Builder> T configureNettyHttpService(Map<String, String> args, T builder) { Integer threads = getInt(args, SERVICE_THREADS, "http service executor thread pool size"); if (threads != null) { builder.setExecThreadPoolSize(threads); } Long keepAliveSecs = getLong(args, SERVICE_THREAD_KEEPALIVE_SECS, "http service executor keep alive seconds"); if (keepAliveSecs != null) { builder.setExecThreadKeepAliveSeconds(keepAliveSecs); } return builder; }
/** * Configures a {@link NettyHttpService.Builder} based on the given arguments. * * @param args the arguments to use for looking up http service configurations * @param builder a {@link NettyHttpService.Builder} to configure * @param <T> type of the {@link NettyHttpService.Builder} * @return the builder instance as provided through the {@code builder} argument */ public static <T extends NettyHttpService.Builder> T configureNettyHttpService(Map<String, String> args, T builder) { Integer threads = getInt(args, SERVICE_THREADS, "http service executor thread pool size"); if (threads != null) { builder.setExecThreadPoolSize(threads); } Long keepAliveSecs = getLong(args, SERVICE_THREAD_KEEPALIVE_SECS, "http service executor keep alive seconds"); if (keepAliveSecs != null) { builder.setExecThreadKeepAliveSeconds(keepAliveSecs); } return builder; }