/** * Gets a positive integer value from the given map using the given key. * If there is no such key or if the value is not positive, returns {@code null}. */ private static Integer getPositiveInt(Map<String, String> map, String key, String description) { Integer val = getInt(map, key, description); if (val != null && val <= 0) { LOG.warn("Ignoring invalid {} '{}' from runtime arguments. It must be a positive integer.", description, val); return null; } return val; }
/** * Gets a positive integer value from the given map using the given key. * If there is no such key or if the value is not positive, returns {@code null}. */ private static Integer getPositiveInt(Map<String, String> map, String key, String description) { Integer val = getInt(map, key, description); if (val != null && val <= 0) { LOG.warn("Ignoring invalid {} '{}' from runtime arguments. It must be a positive integer.", description, val); return null; } return val; }
/** * Gets a non-negative (can be 0) integer 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 int getNonNegativeInt(Map<String, String> map, String key, String description, int defaultVal) { Integer val = getInt(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 integer.", description, val); return defaultVal; } return val; }
/** * Gets a non-negative (can be 0) integer 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 int getNonNegativeInt(Map<String, String> map, String key, String description, int defaultVal) { Integer val = getInt(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 integer.", description, val); return defaultVal; } return val; }
/** * 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; }