<commit_before>/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */
package org.apache.hyracks.control.common.controllers;

import static org.apache.hyracks.control.common.config.OptionTypes.BOOLEAN;
import static org.apache.hyracks.control.common.config.OptionTypes.INTEGER;
import static org.apache.hyracks.control.common.config.OptionTypes.INTEGER_BYTE_UNIT;
import static org.apache.hyracks.control.common.config.OptionTypes.LONG;
import static org.apache.hyracks.control.common.config.OptionTypes.POSITIVE_INTEGER;
import static org.apache.hyracks.control.common.config.OptionTypes.STRING;
import static org.apache.hyracks.control.common.config.OptionTypes.STRING_ARRAY;
import static org.apache.hyracks.control.common.config.OptionTypes.UNSIGNED_INTEGER;

import java.net.InetAddress;
import java.util.ArrayList;
import java.util.List;
import java.util.function.Function;

import org.apache.hyracks.api.config.IApplicationConfig;
import org.apache.hyracks.api.config.IOption;
import org.apache.hyracks.api.config.IOptionType;
import org.apache.hyracks.api.config.Section;
import org.apache.hyracks.control.common.config.ConfigManager;
import org.apache.hyracks.control.common.config.OptionTypes;
import org.apache.hyracks.util.file.FileUtil;

public class NCConfig extends ControllerConfig {
    private static final long serialVersionUID = 3L;

    public enum Option implements IOption {
        ADDRESS(STRING, InetAddress.getLoopbackAddress().getHostAddress()),
        PUBLIC_ADDRESS(STRING, ADDRESS),
        CLUSTER_LISTEN_ADDRESS(STRING, ADDRESS),
        CLUSTER_LISTEN_PORT(UNSIGNED_INTEGER, 0),
        NCSERVICE_ADDRESS(STRING, PUBLIC_ADDRESS),
        NCSERVICE_PORT(INTEGER, 9090),
        CLUSTER_ADDRESS(STRING, (String) null),
        CLUSTER_PORT(UNSIGNED_INTEGER, 1099),
        CLUSTER_PUBLIC_ADDRESS(STRING, PUBLIC_ADDRESS),
        CLUSTER_PUBLIC_PORT(UNSIGNED_INTEGER, CLUSTER_LISTEN_PORT),
        NODE_ID(STRING, (String) null),
        DATA_LISTEN_ADDRESS(STRING, ADDRESS),
        DATA_LISTEN_PORT(UNSIGNED_INTEGER, 0),
        DATA_PUBLIC_ADDRESS(STRING, PUBLIC_ADDRESS),
        DATA_PUBLIC_PORT(UNSIGNED_INTEGER, DATA_LISTEN_PORT),
        RESULT_LISTEN_ADDRESS(STRING, ADDRESS),
        RESULT_LISTEN_PORT(UNSIGNED_INTEGER, 0),
        RESULT_PUBLIC_ADDRESS(STRING, PUBLIC_ADDRESS),
        RESULT_PUBLIC_PORT(UNSIGNED_INTEGER, RESULT_LISTEN_PORT),
        MESSAGING_LISTEN_ADDRESS(STRING, ADDRESS),
        MESSAGING_LISTEN_PORT(UNSIGNED_INTEGER, 0),
        MESSAGING_PUBLIC_ADDRESS(STRING, PUBLIC_ADDRESS),
        MESSAGING_PUBLIC_PORT(UNSIGNED_INTEGER, MESSAGING_LISTEN_PORT),
        REPLICATION_LISTEN_ADDRESS(STRING, ADDRESS),
        REPLICATION_LISTEN_PORT(UNSIGNED_INTEGER, 2000),
        REPLICATION_PUBLIC_ADDRESS(STRING, PUBLIC_ADDRESS),
        REPLICATION_PUBLIC_PORT(UNSIGNED_INTEGER, REPLICATION_LISTEN_PORT),
        CLUSTER_CONNECT_RETRIES(UNSIGNED_INTEGER, 5),
        IODEVICES(
                STRING_ARRAY,
                appConfig -> new String[] {
                        FileUtil.joinPath(appConfig.getString(ControllerConfig.Option.DEFAULT_DIR), "iodevice") },
                "<value of " + ControllerConfig.Option.DEFAULT_DIR.cmdline() + ">/iodevice"),
        NET_THREAD_COUNT(POSITIVE_INTEGER, 1),
        NET_BUFFER_COUNT(POSITIVE_INTEGER, 1),
        RESULT_TTL(LONG, 86400000L),
        RESULT_SWEEP_THRESHOLD(LONG, 60000L),
        RESULT_MANAGER_MEMORY(INTEGER_BYTE_UNIT, -1),
        @SuppressWarnings("RedundantCast") // not redundant- false positive from IDEA
        APP_CLASS(STRING, (String) null),
        NCSERVICE_PID(INTEGER, -1),
        COMMAND(STRING, "hyracksnc"),
        JVM_ARGS(STRING, (String) null),
        TRACE_CATEGORIES(STRING_ARRAY, new String[0]),
        KEY_STORE_PATH(STRING, (String) null),
        TRUST_STORE_PATH(STRING, (String) null),
        KEY_STORE_PASSWORD(STRING, (String) null),
        IO_WORKERS_PER_PARTITION(POSITIVE_INTEGER, 2),
        IO_QUEUE_SIZE(POSITIVE_INTEGER, 10),
        PYTHON_CMD(STRING, (String) null),
        PYTHON_ADDITIONAL_PACKAGES(STRING_ARRAY, (String[]) null),
        PYTHON_USE_BUNDLED_MSGPACK(BOOLEAN, true),
        PYTHON_ARGS(STRING_ARRAY, (String[]) null),
        CREDENTIAL_FILE(
                OptionTypes.STRING,
                (Function<IApplicationConfig, String>) appConfig -> FileUtil
                        .joinPath(appConfig.getString(ControllerConfig.Option.DEFAULT_DIR), "passwd"),
                ControllerConfig.Option.DEFAULT_DIR.cmdline() + "/passwd");

        private final IOptionType parser;
        private final String defaultValueDescription;
        private Object defaultValue;

        <T> Option(IOptionType<T> parser, Option defaultOption) {
            this.parser = parser;
            this.defaultValue = defaultOption;
            defaultValueDescription = null;
        }

        <T> Option(IOptionType<T> parser, T defaultValue) {
            this.parser = parser;
            this.defaultValue = defaultValue;
            defaultValueDescription = null;
        }

        <T> Option(IOptionType<T> parser, Function<IApplicationConfig, T> defaultValue,
                String defaultValueDescription) {
            this.parser = parser;
            this.defaultValue = defaultValue;
            this.defaultValueDescription = defaultValueDescription;
        }
<commit_msg>[NO ISSUE] Fix additional packages default value<commit_after>/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */
package org.apache.hyracks.control.common.controllers;

import static org.apache.hyracks.control.common.config.OptionTypes.BOOLEAN;
import static org.apache.hyracks.control.common.config.OptionTypes.INTEGER;
import static org.apache.hyracks.control.common.config.OptionTypes.INTEGER_BYTE_UNIT;
import static org.apache.hyracks.control.common.config.OptionTypes.LONG;
import static org.apache.hyracks.control.common.config.OptionTypes.POSITIVE_INTEGER;
import static org.apache.hyracks.control.common.config.OptionTypes.STRING;
import static org.apache.hyracks.control.common.config.OptionTypes.STRING_ARRAY;
import static org.apache.hyracks.control.common.config.OptionTypes.UNSIGNED_INTEGER;

import java.net.InetAddress;
import java.util.ArrayList;
import java.util.List;
import java.util.function.Function;

import org.apache.hyracks.api.config.IApplicationConfig;
import org.apache.hyracks.api.config.IOption;
import org.apache.hyracks.api.config.IOptionType;
import org.apache.hyracks.api.config.Section;
import org.apache.hyracks.control.common.config.ConfigManager;
import org.apache.hyracks.control.common.config.OptionTypes;
import org.apache.hyracks.util.file.FileUtil;

public class NCConfig extends ControllerConfig {
    private static final long serialVersionUID = 3L;

    public enum Option implements IOption {
        ADDRESS(STRING, InetAddress.getLoopbackAddress().getHostAddress()),
        PUBLIC_ADDRESS(STRING, ADDRESS),
        CLUSTER_LISTEN_ADDRESS(STRING, ADDRESS),
        CLUSTER_LISTEN_PORT(UNSIGNED_INTEGER, 0),
        NCSERVICE_ADDRESS(STRING, PUBLIC_ADDRESS),
        NCSERVICE_PORT(INTEGER, 9090),
        CLUSTER_ADDRESS(STRING, (String) null),
        CLUSTER_PORT(UNSIGNED_INTEGER, 1099),
        CLUSTER_PUBLIC_ADDRESS(STRING, PUBLIC_ADDRESS),
        CLUSTER_PUBLIC_PORT(UNSIGNED_INTEGER, CLUSTER_LISTEN_PORT),
        NODE_ID(STRING, (String) null),
        DATA_LISTEN_ADDRESS(STRING, ADDRESS),
        DATA_LISTEN_PORT(UNSIGNED_INTEGER, 0),
        DATA_PUBLIC_ADDRESS(STRING, PUBLIC_ADDRESS),
        DATA_PUBLIC_PORT(UNSIGNED_INTEGER, DATA_LISTEN_PORT),
        RESULT_LISTEN_ADDRESS(STRING, ADDRESS),
        RESULT_LISTEN_PORT(UNSIGNED_INTEGER, 0),
        RESULT_PUBLIC_ADDRESS(STRING, PUBLIC_ADDRESS),
        RESULT_PUBLIC_PORT(UNSIGNED_INTEGER, RESULT_LISTEN_PORT),
        MESSAGING_LISTEN_ADDRESS(STRING, ADDRESS),
        MESSAGING_LISTEN_PORT(UNSIGNED_INTEGER, 0),
        MESSAGING_PUBLIC_ADDRESS(STRING, PUBLIC_ADDRESS),
        MESSAGING_PUBLIC_PORT(UNSIGNED_INTEGER, MESSAGING_LISTEN_PORT),
        REPLICATION_LISTEN_ADDRESS(STRING, ADDRESS),
        REPLICATION_LISTEN_PORT(UNSIGNED_INTEGER, 2000),
        REPLICATION_PUBLIC_ADDRESS(STRING, PUBLIC_ADDRESS),
        REPLICATION_PUBLIC_PORT(UNSIGNED_INTEGER, REPLICATION_LISTEN_PORT),
        CLUSTER_CONNECT_RETRIES(UNSIGNED_INTEGER, 5),
        IODEVICES(
                STRING_ARRAY,
                appConfig -> new String[] {
                        FileUtil.joinPath(appConfig.getString(ControllerConfig.Option.DEFAULT_DIR), "iodevice") },
                "<value of " + ControllerConfig.Option.DEFAULT_DIR.cmdline() + ">/iodevice"),
        NET_THREAD_COUNT(POSITIVE_INTEGER, 1),
        NET_BUFFER_COUNT(POSITIVE_INTEGER, 1),
        RESULT_TTL(LONG, 86400000L),
        RESULT_SWEEP_THRESHOLD(LONG, 60000L),
        RESULT_MANAGER_MEMORY(INTEGER_BYTE_UNIT, -1),
        @SuppressWarnings("RedundantCast") // not redundant- false positive from IDEA
        APP_CLASS(STRING, (String) null),
        NCSERVICE_PID(INTEGER, -1),
        COMMAND(STRING, "hyracksnc"),
        JVM_ARGS(STRING, (String) null),
        TRACE_CATEGORIES(STRING_ARRAY, new String[0]),
        KEY_STORE_PATH(STRING, (String) null),
        TRUST_STORE_PATH(STRING, (String) null),
        KEY_STORE_PASSWORD(STRING, (String) null),
        IO_WORKERS_PER_PARTITION(POSITIVE_INTEGER, 2),
        IO_QUEUE_SIZE(POSITIVE_INTEGER, 10),
        PYTHON_CMD(STRING, (String) null),
        PYTHON_ADDITIONAL_PACKAGES(STRING_ARRAY, new String[0]),
        PYTHON_USE_BUNDLED_MSGPACK(BOOLEAN, true),
        PYTHON_ARGS(STRING_ARRAY, (String[]) null),
        CREDENTIAL_FILE(
                OptionTypes.STRING,
                (Function<IApplicationConfig, String>) appConfig -> FileUtil
                        .joinPath(appConfig.getString(ControllerConfig.Option.DEFAULT_DIR), "passwd"),
                ControllerConfig.Option.DEFAULT_DIR.cmdline() + "/passwd");

        private final IOptionType parser;
        private final String defaultValueDescription;
        private Object defaultValue;

        <T> Option(IOptionType<T> parser, Option defaultOption) {
            this.parser = parser;
            this.defaultValue = defaultOption;
            defaultValueDescription = null;
        }

        <T> Option(IOptionType<T> parser, T defaultValue) {
            this.parser = parser;
            this.defaultValue = defaultValue;
            defaultValueDescription = null;
        }

        <T> Option(IOptionType<T> parser, Function<IApplicationConfig, T> defaultValue,
                String defaultValueDescription) {
            this.parser = parser;
            this.defaultValue = defaultValue;
            this.defaultValueDescription = defaultValueDescription;
        }

{'fraction_non_alphanumeric': 0.08829518612038771, 'fraction_numerical': 0.00708642176427466, 'mean_word_length': 3.5796344647519582, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2899601', 'n_tokens_mistral': 3801, 'n_tokens_neox': 3624, 'n_words': 720}