All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.seeq.utilities.configuration.Configuration Maven / Gradle / Ivy

The newest version!
package com.seeq.utilities.configuration;

import java.lang.reflect.Modifier;
import java.util.Arrays;
import java.util.Map;
import java.util.TreeMap;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.function.Consumer;
import java.util.function.Supplier;
import java.util.stream.Collectors;

import javax.annotation.Nullable;

import org.jetbrains.annotations.NotNull;

import kotlin.Pair;

@SuppressWarnings("unused")
// SuppressWarnings unused here because the interfaces and fields are used to build {@code ALL_OPTIONS}. Some
// interfaces are indirectly instanced with {@Configuration.get(option)} when reading tokens from a file
// (e.g. SupervisorComponentConfigList)
public interface Configuration {

    interface Authentication {
        Option AutoLogin = booleanOption("Authentication/AutoLogin");
        Option DefaultProviderId = stringOption("Authentication/DefaultProviderId");
        Option DefaultSessionDuration = numberOption("Authentication/DefaultSessionDuration");
        Option HiddenProviderIds = stringOption("Authentication/HiddenProviderIds");
        Option WorkFactor = numberOption("Authentication/WorkFactor");

        interface AccessKey {
            Option ValidityWithoutUserLogin =
                    numberOption("Authentication/AccessKey/ValidityWithoutUserLogin");
        }

        interface SeeqDirectory {
            Option Enabled = booleanOption("Authentication/SeeqDirectory/Enabled");
            Option EnforcePasswordAge = booleanOption("Authentication/SeeqDirectory/EnforcePasswordAge");
            Option LoginAttemptLockout = numberOption("Authentication/SeeqDirectory/LoginAttemptLockout");
            Option MaxPasswordAge = numberOption("Authentication/SeeqDirectory/MaxPasswordAge");

            interface PasswordComplexity {
                Option RequireDigit =
                        booleanOption("Authentication/SeeqDirectory/PasswordComplexity/RequireDigit");
                Option RequireUppercase =
                        booleanOption("Authentication/SeeqDirectory/PasswordComplexity/RequireUppercase");
                Option RequireLowercase =
                        booleanOption("Authentication/SeeqDirectory/PasswordComplexity/RequireLowercase");
                Option RequireSpecialCharacter =
                        booleanOption("Authentication/SeeqDirectory/PasswordComplexity/RequireSpecialCharacter");
            }

            Option PasswordExpirationGracePeriod =
                    numberOption("Authentication/SeeqDirectory/PasswordExpirationGracePeriod");
            Option PasswordExpirationWarningPeriod =
                    numberOption("Authentication/SeeqDirectory/PasswordExpirationWarningPeriod");
            Option PasswordMinLength = numberOption("Authentication/SeeqDirectory/PasswordMinLength");
            Option SelfServicePasswordReset =
                    booleanOption("Authentication/SeeqDirectory/SelfServicePasswordReset");
        }
    }

    interface Cache {
        interface InMemory {
            Option Expiration = numberOption("Cache/InMemory/Expiration");
            Option UncertainDataExpiration = numberOption("Cache/InMemory/UncertainDataExpiration");
        }

        interface Persistent {
            interface Series {
                Option MaxSize = numberOption("Cache/Persistent/Series/MaxSize");
            }

            interface Quantity {
                Option MaxSize = numberOption("Cache/Persistent/Quantity/MaxSize");
            }
        }

        interface Pipeline {
            interface BatchSource {
                Option AllowedCursorFluctuation =
                        numberOption("Cache/Pipeline/BatchSource/AllowedCursorFluctuation");
            }

            Option LoopDetectionThreshold =
                    numberOption("Cache/Pipeline/LoopDetectionThreshold");

            Option ProgressInsuranceThreshold =
                    numberOption("Cache/Pipeline/ProgressInsuranceThreshold");
        }
    }

    interface Components {
        interface Appserver {
            Option Enabled = booleanOption("Components/Appserver/Enabled");

            interface Postgres {
                Option Enabled = booleanOption("Components/Appserver/Postgres/Enabled");
            }
        }

        interface CacheService {
            interface Series {
                interface Postgres {
                    Option Enabled = booleanOption("Components/CacheService/Series/Postgres/Enabled");
                }

                Option Enabled = booleanOption("Components/CacheService/Series/Enabled");
            }

            interface Quantity {
                interface Postgres {
                    Option Enabled = booleanOption("Components/CacheService/Quantity/Postgres/Enabled");
                }

                Option Enabled = booleanOption("Components/CacheService/Quantity/Enabled");
            }
        }

        interface ComputeService {
            Option Enabled = booleanOption("Components/ComputeService/Enabled");
        }

        interface DatasourceProxyService {
            Option Enabled = booleanOption("Components/DatasourceProxyService/Enabled");
        }

        interface DataLab {
            Option Enabled = booleanOption("Components/DataLab/Enabled");
        }

        interface EmailerService {
            Option Enabled = booleanOption("Components/EmailerService/Enabled");
        }

        interface FormulaSupport {
            Option Enabled = booleanOption("Components/FormulaSupport/Enabled");
        }

        interface JvmLink {
            Option Enabled = booleanOption("Components/JvmLink/Enabled");
        }

        interface MessagingService {
            Option Enabled = booleanOption("Components/MessagingService/Enabled");
        }

        interface NetLink {
            Option Enabled = booleanOption("Components/NetLink/Enabled");
            Option Architecture = stringOption("Components/NetLink/Architecture");
        }

        interface RemoteAgentUpdates {
            Option Enabled = booleanOption("Components/RemoteAgentUpdates/Enabled");
        }

        interface OpenTelemetry {
            interface CollectorAgent {
                Option Enabled = booleanOption("Components/OpenTelemetry/CollectorAgent/Enabled");
            }
        }

        interface Renderer {
            Option Enabled = booleanOption("Components/Renderer/Enabled");
        }

        interface ReverseProxy {
            Option Enabled = booleanOption("Components/ReverseProxy/Enabled");
        }

        interface SystemMonitor {
            Option Enabled = booleanOption("Components/SystemMonitor/Enabled");
        }
    }

    interface Cpu {
        Option Count = numberOption("Cpu/Count");
    }

    interface Database {
        interface Postgres {
            Option AdminUsername = stringOption("Database/Postgres/AdminUsername");
            Option DatabaseName = stringOption("Database/Postgres/DatabaseName");
            Option SearchTimeout = numberOption("Database/Postgres/SearchTimeout");
            Option ServerName = stringOption("Database/Postgres/ServerName");
        }
    }

    interface Datasource {
        interface Cache {
            Option Enabled = booleanOption("Datasource/Cache/Enabled");
        }

        interface Read {
            Option BlockSizeMax = numberOption("Datasource/Read/BlockSizeMax");
            Option BlockSizeMin = numberOption("Datasource/Read/BlockSizeMin");
            Option MaxRequests = numberOption("Datasource/Read/MaxRequests");
        }
    }

    interface Features {
        Option AgentNameSuffix = stringOption("Features/AgentNameSuffix");
        Option NumberFormat = stringOption("Features/NumberFormat");
        Option StringFormat = stringOption("Features/StringFormat");

        interface Announcements {
            Option Enabled = booleanOption("Features/Announcements/Enabled");
        }

        interface AutomaticItemDeletion {
            Option Enabled = booleanOption("Features/AutomaticItemDeletion/Enabled");
            Option Schedule = stringOption("Features/AutomaticItemDeletion/Schedule");
            Option DeletionAge = numberOption("Features/AutomaticItemDeletion/DeletionAge");
            Option MaxRuntime = numberOption("Features/AutomaticItemDeletion/MaxRuntime");
        }

        interface AclTreeLocking {
            Option Timeout = numberOption("Features/AclTreeLocking/Timeout");
        }

        interface AddOns {
            Option InstallAddOnsForSelf = stringOption("Features/AddOns/InstallAddOnsForSelf");
        }

        interface AddOnCalculations {
            interface Webhook {
                Option Enabled = booleanOption("Features/AddOnCalculations/Webhook/Enabled");
            }
        }

        interface AddOnTools {
            Option Enabled = booleanOption("Features/AddOnTools/Enabled");
        }

        interface AgentUserProvision {
            interface CleanupJob {
                Option Enabled = booleanOption("Features/AgentUserProvision/CleanupJob/Enabled");
                Option Schedule = stringOption("Features/AgentUserProvision/CleanupJob/Schedule");
                Option CleanupAge = numberOption("Features/AgentUserProvision/CleanupJob/CleanupAge");
            }
        }

        interface Annotations {
            interface UploadCleaner {
                Option Frequency = numberOption("Features/Annotations/UploadCleaner/Frequency");
                Option Count = numberOption("Features/Annotations/UploadCleaner/Count");
            }
        }

        interface Auditing {
            Option Enabled = booleanOption("Features/Auditing/Enabled");
            Option AllUsersCanRead = booleanOption("Features/Auditing/AllUsersCanRead");
        }

        interface GenAI {
            Option Enabled = booleanOption("Features/GenAI/Enabled");
            Option ModelConfiguration = stringOption("Features/GenAI/ModelConfiguration");
            Option Agents = stringOption("Features/GenAI/Agents");
        }

        interface CentralizedMetadataSync {
            Option Schedule = stringOption("Features/CentralizedMetadataSync/Schedule");
        }

        interface Colors {
            Option Priorities = stringOption("Features/Colors/Priorities");
        }

        interface ConditionTableCharts {
            Option Enabled = booleanOption("Features/ConditionTableCharts/Enabled");
        }

        interface DataConsumption {
            interface CsvOutput {
                Option Enabled = booleanOption("Features/DataConsumption/CsvOutput/Enabled");
                Option MaxDaysToKeep = numberOption("Features/DataConsumption/CsvOutput/MaxDaysToKeep");
            }

            Option CompactionDeadline = numberOption("Features/DataConsumption/CompactionDeadline");
            Option DataLabCollectionInterval = numberOption(
                    "Features/DataConsumption/DataLabCollectionInterval");
            Option GenAICollectionInterval = numberOption("Features/DataConsumption/GenAICollectionInterval");
            Option UpdateInterval = numberOption("Features/DataConsumption/UpdateInterval");
        }

        interface Database {
            Option IdleInTransactionKillerTimeoutMinutes =
                    numberOption("Features/Database/IdleInTransactionKillerTimeoutMinutes");
        }

        interface Datafiles {
            Option DelimiterDefault = stringOption("Features/Datafiles/DelimiterDefault");
            Option DayFirstDefault = booleanOption("Features/Datafiles/DayFirstDefault");
            Option ColumnLimit = numberOption("Features/Datafiles/ColumnLimit");
            Option DataLimit = numberOption("Features/Datafiles/DataLimit");
            Option FileSizeLimit = numberOption("Features/Datafiles/FileSizeLimit");
        }

        interface DataLab {
            interface Limits {
                Option Enabled = booleanOption("Features/DataLab/Limits/Enabled");
            }

            interface ResourceSizes {
                Option Enabled = booleanOption("Features/DataLab/ResourceSizes/Enabled");
            }

            interface ScheduledNotebooks {
                Option Enabled = booleanOption("Features/DataLab/ScheduledNotebooks/Enabled");
                Option MinimumScheduleFrequency =
                        numberOption("Features/DataLab/ScheduledNotebooks/MinimumScheduleFrequency");
            }
        }

        interface Displays {
            Option Enabled = booleanOption("Features/Displays/Enabled");
        }

        interface EmailerService {
            Option Enabled = booleanOption("Features/EmailerService/Enabled");
        }

        interface Export {
            Option SensitivityLabel = stringOption("Features/Export/SensitivityLabel");
        }

        interface Feedback {
            Option Enabled = booleanOption("Features/Feedback/Enabled");
        }

        interface FileSignalDriver {
            Option MaintenancePeriod = numberOption("Features/FileSignalDriver/MaintenancePeriod");
        }

        interface HardwareInfo {
            Option Enabled = booleanOption("Features/HardwareInfo/Enabled");
        }

        interface HardwareWarnings {
            Option Enabled = booleanOption("Features/HardwareWarnings/Enabled");
        }

        interface LicenseWarning {
            Option Hidden = booleanOption("Features/LicenseWarning/Hidden");
        }

        interface HomeScreen {
            Option CustomSidebar = stringOption("Features/HomeScreen/CustomSidebar");

            interface OfficeHours {
                Option Enabled = booleanOption("Features/HomeScreen/OfficeHours/Enabled");
            }
        }

        interface I18n {
            Option Hostname = stringOption("Features/I18n/Hostname");
        }

        interface ItemFinders {
            Option Schedule = stringOption("Features/ItemFinders/Schedule");
        }

        interface Login {
            Option InfoMessage = stringOption("Features/Login/InfoMessage");
        }

        interface MLTools {
            interface SelfOrganizingMaps {
                Option Enabled = booleanOption("Features/MLTools/SelfOrganizingMaps/Enabled");
            }
        }

        interface Messages {
            Option SystemMessage = stringOption("Features/Messages/SystemMessage");
        }

        interface Mixpanel {
            Option Enabled = booleanOption("Features/Mixpanel/Enabled");
        }

        interface Monitors {
            Option FolderMonitoringPeriod = numberOption("Features/Monitors/FolderMonitoringPeriod");

            interface CsvOutput {
                Option Enabled = booleanOption("Features/Monitors/CsvOutput/Enabled");
                Option MaxDaysToKeep = numberOption("Features/Monitors/CsvOutput/MaxDaysToKeep");
                Option SampleRate = numberOption("Features/Monitors/CsvOutput/SampleRate");
            }

            interface Datasource {
                Option Enabled = booleanOption("Features/Monitors/Datasource/Enabled");
                Option MachineName = stringOption("Features/Monitors/Datasource/MachineName");
                Option SampleRate = numberOption("Features/Monitors/Datasource/SampleRate");
                Option ImportFrequency = numberOption("Features/Monitors/Datasource/ImportFrequency");
            }
        }


        interface Notifications {
            interface ConditionMonitors {
                Option AdminErrorNotificationEnabled =
                        booleanOption("Features/Notifications/ConditionMonitors/AdminErrorNotificationEnabled");
                Option Enabled = booleanOption("Features/Notifications/ConditionMonitors/Enabled");
                Option Schedule = stringOption("Features/Notifications/ConditionMonitors/Schedule");
                Option MinimumInterval =
                        numberOption("Features/Notifications/ConditionMonitors/MinimumInterval");
                Option OutgoingWebhookUrl =
                        stringOption("Features/Notifications/ConditionMonitors/OutgoingWebhookUrl");
                Option RetryDelay = numberOption("Features/Notifications/ConditionMonitors/RetryDelay");
            }
        }


        interface OData {
            interface Debug {
                Option Enabled = booleanOption("Features/OData/Debug/Enabled");
            }

            Option DefaultProtocol = numberOption("Features/OData/DefaultProtocol");
            Option StreamPageSize = numberOption("Features/OData/StreamPageSize");
        }


        interface OpenTelemetry {
            interface Appserver {
                Option CommandLine = stringOption("Features/OpenTelemetry/Appserver/CommandLine");
            }

            interface CollectorAgent {
                Option ConfigFilePath = stringOption("Features/OpenTelemetry/CollectorAgent/ConfigFilePath");
            }

            interface CollectorGateway {
                Option Endpoint = stringOption("Features/OpenTelemetry/CollectorGateway/Endpoint");

                interface TLS {
                    Option Insecure = booleanOption("Features/OpenTelemetry/CollectorGateway/TLS/Insecure");
                }
            }

            interface ComputeService {
                Option CommandLine = stringOption("Features/OpenTelemetry/ComputeService/CommandLine");
            }

            interface DatasourceProxyService {
                Option CommandLine = stringOption("Features/OpenTelemetry/DatasourceProxyService/CommandLine");
            }

            interface JvmLink {
                Option CommandLine = stringOption("Features/OpenTelemetry/JvmLink/CommandLine");
            }

            interface Reporter {
                Option Enabled = booleanOption("Features/OpenTelemetry/Reporter/Enabled");
                Option SampleRate = numberOption("Features/OpenTelemetry/Reporter/SampleRate");
            }

            interface SeriesCacheService {
                Option CommandLine = stringOption("Features/OpenTelemetry/SeriesCacheService/CommandLine");
            }

            interface QuantityCacheService {
                Option CommandLine = stringOption("Features/OpenTelemetry/QuantityCacheService/CommandLine");
            }
        }

        interface Plugins {
            Option Enabled = booleanOption("Features/Plugins/Enabled");
        }

        interface RemoteAgentUpdates {
            Option RunVersion = stringOption("Features/RemoteAgentUpdates/RunVersion");
            Option StageInstaller = stringOption("Features/RemoteAgentUpdates/StageInstaller");
            Option SeeqDownloadURL = stringOption("Features/RemoteAgentUpdates/SeeqDownloadURL");
        }

        interface Reprioritizer {
            Option Enabled = booleanOption("Features/Reprioritizer/Enabled");
            Option MaximumRestartCount = numberOption("Features/Reprioritizer/MaximumRestartCount");
            Option QueuedTooLongDuration = numberOption("Features/Reprioritizer/QueuedTooLongDuration");
            Option RunningTooLongDuration = numberOption("Features/Reprioritizer/RunningTooLongDuration");
        }

        interface RequestProfiling {
            Option Enabled = booleanOption("Features/RequestProfiling/Enabled");
        }

        interface RestrictLogs {
            Option Enabled = booleanOption("Features/RestrictLogs/Enabled");
        }

        interface ScatterPlot {
            Option MaxPoints = numberOption("Features/ScatterPlot/MaxPoints");
        }

        interface SeeqPreview {
            Option Enabled = booleanOption("Features/SeeqPreview/Enabled");
        }

        interface Telemetry {
            Option Anonymized = booleanOption("Features/Telemetry/Anonymized");
            Option Enabled = booleanOption("Features/Telemetry/Enabled");
        }

        interface Template {
            Option Journal = stringOption("Features/Template/Journal");
            Option Topic = stringOption("Features/Template/Topic");
        }

        interface UserRegistration {
            Option Enabled = booleanOption("Features/UserRegistration/Enabled");
        }

        interface UsersQueriesAdminOnly {
            Option Enabled = booleanOption("Features/UsersQueriesAdminOnly/Enabled");
        }

        interface WebSocketPool {
            Option ConnectedOnDegradedState = booleanOption("Features/WebSocketPool/ConnectedOnDegradedState");
            Option Size = numberOption("Features/WebSocketPool/Size");
        }

        interface Workbook {
            Option MaximumRecentlyAccessed = numberOption("Features/Workbook/MaximumRecentlyAccessed");

            interface TableBuilder {
                Option RefreshRate = numberOption("Features/Workbook/TableBuilder/RefreshRate");
            }

            interface Locking {
                Option Enabled = booleanOption("Features/Workbook/Locking/Enabled");
            }
        }

        interface Worksteps {
            Option MaximumPerWorksheet = numberOption("Features/Worksteps/MaximumPerWorksheet");
        }

        interface AdvancedDateRangeSwap {
            Option Enabled = booleanOption("Features/AdvancedDateRangeSwap/Enabled");
        }

        interface TableDefinitionEditor {
            Option Enabled = booleanOption("Features/TableDefinitionEditor/Enabled");
        }

        interface ValueCapture {
            Option Enabled = booleanOption("Features/ValueCapture/Enabled");
        }

        interface Training {
            Option BranchCode = stringOption("Features/Training/BranchCode");
        }

        interface Vantage {
            Option Enabled = booleanOption("Features/Vantage/Enabled");
        }
    }

    interface Folders {
        Option Backup = stringOption("Folders/Backup");
        Option Data = stringOption("Folders/Data");
        Option FileSignalStoragePath = stringOption("Folders/FileSignalStoragePath");
        Option Global = stringOption("Folders/Global");
        Option Install = stringOption("Folders/Install");
        Option Installers = stringOption("Folders/Installers");
    }

    interface Installation {
        Option PreviousVersion = stringOption("Installation/PreviousVersion");
        Option ReleaseIdentifier = stringOption("Installation/ReleaseIdentifier");
        Option RunAsService = booleanOption("Installation/RunAsService");
        Option SemanticVersion = stringOption("Installation/SemanticVersion");
        Option ServerType = stringOption("Installation/ServerType");
        Option Timestamp = stringOption("Installation/Timestamp");
        Option Version = stringOption("Installation/Version");

        interface AdminContact {
            Option Email = stringOption("Installation/AdminContact/Email");
            Option Name = stringOption("Installation/AdminContact/Name");
        }
    }

    interface Logs {
        Option MaxHistory = numberOption("Logs/MaxHistory");

        interface Appserver {
            Option TotalSizeCap = numberOption("Logs/Appserver/TotalSizeCap");

            interface GarbageCollection {
                Option Count = numberOption("Logs/Appserver/GarbageCollection/Count");
            }

            interface IntervalAnalysis {
                Option Level = stringOption("Logs/Appserver/IntervalAnalysis/Level");
                Option TotalSizeCap = numberOption("Logs/Appserver/IntervalAnalysis/TotalSizeCap");
            }

            interface Levels {
                Option Default = stringOption("Logs/Appserver/Levels/Default");
                Option FileSignalDriver = stringOption("Logs/Appserver/Levels/FileSignalDriver");
                Option MessagingClient = stringOption("Logs/Appserver/Levels/MessagingClient");
            }

            interface RequestMonitors {
                Option TotalSizeCap = numberOption("Logs/Appserver/RequestMonitors/TotalSizeCap");
            }

            interface Requests {
                Option TotalSizeCap = numberOption("Logs/Appserver/Requests/TotalSizeCap");
            }

            interface ThreadDump {
                Option TotalSizeCap = numberOption("Logs/Appserver/ThreadDump/TotalSizeCap");
            }
        }

        interface ComputeService {
            Option Count = numberOption("Logs/ComputeService/Count");
            Option TotalSizeCap = numberOption("Logs/ComputeService/TotalSizeCap");
        }

        interface JvmLink {
            interface GarbageCollection {
                Option Count = numberOption("Logs/JvmLink/GarbageCollection/Count");
            }
        }

        interface RemoteAgent {
            Option TotalSizeCap = numberOption("Logs/RemoteAgent/TotalSizeCap");
        }
    }

    interface Memory {
        interface System {
            Option Total = numberOption("Memory/System/Total");
        }

        interface Auth {
            interface Postgres {
                Option Size = numberOption("Memory/Auth/Postgres/Size");
            }
        }

        interface Appserver {
            Option Size = numberOption("Memory/Appserver/Size");

            interface Export {
                Option MaxEstimatedMemoryUtilization =
                        numberOption("Memory/Appserver/Export/MaxEstimatedMemoryUtilization");
            }

            interface GarbageCollection {
                Option MaxGCPauseMillis =
                        numberOption("Memory/Appserver/GarbageCollection/MaxGCPauseMillis");
            }

            interface OData {
                Option MaxEstimatedMemoryUtilization =
                        numberOption("Memory/Appserver/OData/MaxEstimatedMemoryUtilization");
            }
        }

        interface CacheService {

            interface Series {
                interface Postgres {
                    Option Size = numberOption("Memory/CacheService/Series/Postgres/Size");
                }

                Option Size = numberOption("Memory/CacheService/Series/Size");
            }

            interface Quantity {
                interface Postgres {
                    Option Size = numberOption("Memory/CacheService/Quantity/Postgres/Size");
                }

                Option Size = numberOption("Memory/CacheService/Quantity/Size");
            }
        }

        interface ComputeService {
            interface GarbageCollection {
                Option SoftRefLRUPolicyMSPerMB =
                        numberOption("Memory/ComputeService/GarbageCollection/SoftRefLRUPolicyMSPerMB");
            }

            Option Size = numberOption("Memory/ComputeService/Size");
        }

        interface DatasourceProxyService {
            Option Size = numberOption("Memory/DatasourceProxyService/Size");
        }

        interface EmailerService {
            Option Size = numberOption("Memory/EmailerService/Size");
        }

        interface JvmLink {
            Option Size = numberOption("Memory/JvmLink/Size");

            interface GarbageCollection {
                Option MaxGCPauseMillis = numberOption("Memory/JvmLink/GarbageCollection/MaxGCPauseMillis");
            }
        }

        interface FormulaSupport {
            Option Size = numberOption("Memory/FormulaSupport/Size");
        }

        interface MessagingService {
            Option Size = numberOption("Memory/MessagingService/Size");
        }

        interface Permitter {
            Option CurtailmentStartThreshold = numberOption("Memory/Permitter/CurtailmentStartThreshold");
            Option MaxCurtailmentThreshold = numberOption("Memory/Permitter/MaxCurtailmentThreshold");
        }
    }

    interface Migration {
        interface Async {
            interface StatusJob {
                Option Frequency = numberOption("Migration/Async/StatusJob/Frequency");
            }

        }
    }

    interface Network {
        Option CORSImageProxy = stringOption("Network/CORSImageProxy");
        Option Hostname = stringOption("Network/Hostname");

        interface Agents {
            Option Remote = booleanOption("Network/Agents/Remote");

            interface SeeqApi {
                Option Url = stringOption("Network/Agents/SeeqApi/Url");
            }

            interface WebSocket {
                Option Url = stringOption("Network/Agents/WebSocket/Url");
            }
        }

        interface Appserver {
            interface Grpc {
                Option Hostname = stringOption("Network/Appserver/Grpc/Hostname");
                Option MaxInboundMessageSize = numberOption("Network/Appserver/Grpc/MaxInboundMessageSize");
                Option Port = numberOption("Network/Appserver/Grpc/Port");
            }

            Option Hostname = stringOption("Network/Appserver/Hostname");
        }

        interface Async {
            Option Enabled = booleanOption("Network/Async/Enabled");
        }

        interface CacheService {

            interface Series {
                Option Hostname = stringOption("Network/CacheService/Series/Hostname");
                Option ListenAddress = stringOption("Network/CacheService/Series/ListenAddress");
                Option Port = numberOption("Network/CacheService/Series/Port");
                Option Timeout = numberOption("Network/CacheService/Series/Timeout");

                interface Postgres {
                    Option AdminUsername = stringOption("Network/CacheService/Series/Postgres/AdminUsername");
                    Option DatabaseName = stringOption("Network/CacheService/Series/Postgres/DatabaseName");
                    Option Hostname = stringOption("Network/CacheService/Series/Postgres/Hostname");
                    Option Port = numberOption("Network/CacheService/Series/Postgres/Port");
                }
            }

            interface Quantity {
                Option Hostname = stringOption("Network/CacheService/Quantity/Hostname");
                Option ListenAddress = stringOption("Network/CacheService/Quantity/ListenAddress");
                Option Port = numberOption("Network/CacheService/Quantity/Port");
                Option Timeout = numberOption("Network/CacheService/Quantity/Timeout");

                interface Postgres {
                    Option AdminUsername = stringOption("Network/CacheService/Quantity/Postgres/AdminUsername");
                    Option DatabaseName = stringOption("Network/CacheService/Quantity/Postgres/DatabaseName");
                    Option Hostname = stringOption("Network/CacheService/Quantity/Postgres/Hostname");
                    Option Port = numberOption("Network/CacheService/Quantity/Postgres/Port");
                }
            }
        }

        interface ComputeService {
            interface Grpc {
                Option Port = numberOption("Network/ComputeService/Grpc/Port");
            }

            Option Hostname = stringOption("Network/ComputeService/Hostname");
        }

        interface DatasourceProxyService {
            interface Grpc {
                Option Hostname = stringOption("Network/DatasourceProxyService/Grpc/Hostname");
                Option ListenAddress = stringOption("Network/DatasourceProxyService/Grpc/ListenAddress");
                Option Port = numberOption("Network/DatasourceProxyService/Grpc/Port");
            }

            interface Webserver {
                Option ListenAddress = stringOption("Network/DatasourceProxyService/Webserver/ListenAddress");
                Option Port = numberOption("Network/DatasourceProxyService/Webserver/Port");
            }
        }

        interface DataLab {
            Option Hostname = stringOption("Network/DataLab/Hostname");
            Option Port = numberOption("Network/DataLab/Port");
            Option Url = stringOption("Network/DataLab/Url");
        }

        interface EmailerService {
            Option Hostname = stringOption("Network/EmailerService/Hostname");
            Option DebugPort = numberOption("Network/EmailerService/DebugPort");

            interface Webserver {
                Option Port = numberOption("Network/EmailerService/Webserver/Port");
            }
        }

        interface Http {
            Option AgentStatusTimeout = numberOption("Network/Http/AgentStatusTimeout");
            Option AllowedOrigins = stringOption("Network/Http/AllowedOrigins");
            Option MaxHeaderSize = numberOption("Network/Http/MaxHeaderSize");
            Option OutboundContentLengthBuffer = numberOption("Network/Http/OutboundContentLengthBuffer");
            Option XFrameOptions = stringOption("Network/Http/XFrameOptions");
            Option XFrameDomain = stringOption("Network/Http/XFrameDomain");

            interface ClientWebSocket {
                Option CompressionThreshold = numberOption("Network/Http/ClientWebSocket/CompressionThreshold");
            }
        }

        interface ListenAddress {
            Option Appserver = stringOption("Network/ListenAddress/Appserver");
        }

        interface MessagingService {
            Option ListenAddress = stringOption("Network/MessagingService/ListenAddress");
            Option DebugPort = numberOption("Network/MessagingService/DebugPort");

            Option Hostname = stringOption("Network/MessagingService/Hostname");
            Option Port = numberOption("Network/MessagingService/Port");
            Option TLS = booleanOption("Network/MessagingService/TLS");
        }

        interface FormulaSupport {
            Option DebugPort = numberOption("Network/FormulaSupport/DebugPort");

            interface Grpc {
                Option Port = numberOption("Network/FormulaSupport/Grpc/Port");
            }

            Option Hostname = stringOption("Network/FormulaSupport/Hostname");
        }

        interface GenAI {
            Option Hostname = stringOption("Network/GenAI/Hostname");

            interface Http {
                Option Port = numberOption("Network/GenAI/Http/Port");
            }
        }

        interface MLService {
            Option Hostname = stringOption("Network/MLService/Hostname");
            Option Port = numberOption("Network/MLService/Port");
            Option Url = stringOption("Network/MLService/Url");
        }

        interface Ports {
            Option Appserver = numberOption("Network/Ports/Appserver");
            Option AppserverDebug = numberOption("Network/Ports/AppserverDebug");
            Option DatasourceProxyServiceDebug = numberOption("Network/Ports/DatasourceProxyServiceDebug");
            Option SeriesCacheServiceDebug = numberOption("Network/Ports/SeriesCacheServiceDebug");
            Option QuantityCacheServiceDebug = numberOption("Network/Ports/QuantityCacheServiceDebug");
            Option IgnitionDebug = numberOption("Network/Ports/IgnitionDebug");
            Option JvmLinkDebug = numberOption("Network/Ports/JvmLinkDebug");
            Option Postgres = numberOption("Network/Ports/Postgres");
            Option Renderer = numberOption("Network/Ports/Renderer");
            Option StartingPort = numberOption("Network/Ports/StartingPort");
            Option SupervisorCoreDebug = numberOption("Network/Ports/SupervisorCoreDebug");
            Option SupervisorCoreRest = numberOption("Network/Ports/SupervisorCoreRest");
            Option SupervisorCoreSingleInstance = numberOption("Network/Ports/SupervisorCoreSingleInstance");
            Option SupervisorUiDebug = numberOption("Network/Ports/SupervisorUiDebug");
            Option SupervisorUiRest = numberOption("Network/Ports/SupervisorUiRest");
            Option SupervisorUiSingleInstance = numberOption("Network/Ports/SupervisorUiSingleInstance");
        }

        interface Renderer {
            Option AppserverPool = stringOption("Network/Renderer/AppserverPool");
            Option Hostname = stringOption("Network/Renderer/Hostname");
            Option Port = numberOption("Network/Renderer/Port");
        }

        interface Webserver {
            Option PrivateUrl = stringOption("Network/Webserver/PrivateUrl");
            Option Port = numberOption("Network/Webserver/Port");
            Option SecurePort = numberOption("Network/Webserver/SecurePort");
            Option Url = stringOption("Network/Webserver/Url");
        }
    }

    interface Process {
        interface Appserver {
            Option AdditionalVMOptions = stringOption("Process/Appserver/AdditionalVMOptions");
            Option RemoteDebugVMOptions = stringOption("Process/Appserver/RemoteDebugVMOptions");
        }

        interface ComputeService {
            Option AdditionalVMOptions = stringOption("Process/ComputeService/AdditionalVMOptions");
            Option RemoteDebugVMOptions = stringOption("Process/ComputeService/RemoteDebugVMOptions");
        }

        interface DatasourceProxyService {
            Option AdditionalVMOptions = stringOption("Process/DatasourceProxyService/AdditionalVMOptions");
            Option RemoteDebugVMOptions = stringOption("Process/DatasourceProxyService/RemoteDebugVMOptions");
        }

        interface EmailerService {
            Option AdditionalVMOptions = stringOption("Process/EmailerService/AdditionalVMOptions");
            Option RemoteDebugVMOptions = stringOption("Process/EmailerService/RemoteDebugVMOptions");
        }

        interface FormulaSupportService {
            Option AdditionalVMOptions = stringOption("Process/FormulaSupportService/AdditionalVMOptions");
            Option RemoteDebugVMOptions = stringOption("Process/FormulaSupportService/RemoteDebugVMOptions");
        }

        interface JvmLink {
            Option AdditionalVMOptions = stringOption("Process/JvmLink/AdditionalVMOptions");
            Option RemoteDebugVMOptions = stringOption("Process/JvmLink/RemoteDebugVMOptions");
        }

        interface MessagingService {
            Option AdditionalVMOptions = stringOption("Process/MessagingService/AdditionalVMOptions");
            Option RemoteDebugVMOptions = stringOption("Process/MessagingService/RemoteDebugVMOptions");
        }

        interface SeriesCacheService {
            Option AdditionalVMOptions = stringOption("Process/SeriesCacheService/AdditionalVMOptions");
            Option RemoteDebugVMOptions = stringOption("Process/SeriesCacheService/RemoteDebugVMOptions");
        }

        interface QuantityCacheService {
            Option AdditionalVMOptions = stringOption("Process/QuantityCacheService/AdditionalVMOptions");
            Option RemoteDebugVMOptions = stringOption("Process/QuantityCacheService/RemoteDebugVMOptions");
        }
    }

    interface Threads {
        interface AgentWebSocket {
            interface Messages {
                Option Count = numberOption("Threads/AgentWebSocket/Messages/Count");
                Option QueueSize = numberOption("Threads/AgentWebSocket/Messages/QueueSize");
            }
        }

        interface CalcEngine {
            interface Parallelization {
                Option Count = numberOption("Threads/CalcEngine/Parallelization/Count");
                Option MaxThreadsPerTablesAcrossAssets =
                        numberOption("Threads/CalcEngine/Parallelization/MaxThreadsPerTablesAcrossAssets");

                Option MaxThreadsPerConditionMonitors =
                        numberOption("Threads/CalcEngine/Parallelization/MaxThreadsPerConditionMonitors");
                Option MaxThreadsPerTreemap =
                        numberOption("Threads/CalcEngine/Parallelization/MaxThreadsPerTreemap");
                Option QueueSize = numberOption("Threads/CalcEngine/Parallelization/QueueSize");
            }
        }

        interface ClientWebSocket {
            interface Messages {
                Option Count = numberOption("Threads/ClientWebSocket/Messages/Count");
                Option QueueSize = numberOption("Threads/ClientWebSocket/Messages/QueueSize");
            }
        }

        interface HttpServer {

            interface AuthValidate {
                Option Count = numberOption("Threads/HttpServer/AuthValidate/Count");
                Option QueueSize = numberOption("Threads/HttpServer/AuthValidate/QueueSize");
            }

            interface Indexing {
                Option Count = numberOption("Threads/HttpServer/Indexing/Count");
                Option QueueSize = numberOption("Threads/HttpServer/Indexing/QueueSize");
            }

            interface Initialization {
                Option Count = numberOption("Threads/HttpServer/Initialization/Count");
                Option QueueSize = numberOption("Threads/HttpServer/Initialization/QueueSize");
            }

            interface Default {
                Option Count = numberOption("Threads/HttpServer/Default/Count");
                Option QueueSize = numberOption("Threads/HttpServer/Default/QueueSize");
            }

            interface Jobs {
                Option Count = numberOption("Threads/HttpServer/Jobs/Count");
                Option QueueSize = numberOption("Threads/HttpServer/Jobs/QueueSize");
            }

            interface LongRunning {
                Option Count = numberOption("Threads/HttpServer/LongRunning/Count");
                Option QueueSize = numberOption("Threads/HttpServer/LongRunning/QueueSize");
            }

            interface Request {
                Option Count = numberOption("Threads/HttpServer/Request/Count");
                Option QueueSize = numberOption("Threads/HttpServer/Request/QueueSize");
                Option ThreadDumpDelay = numberOption("Threads/HttpServer/Request/ThreadDumpDelay");
            }

            Option MaxRequestsPerUser = numberOption("Threads/HttpServer/MaxRequestsPerUser");
            Option RestartDelay = numberOption("Threads/HttpServer/RestartDelay");
        }

        interface Jobs {
            interface User {
                Option Count = numberOption("Threads/Jobs/User/Count");
                Option QueueSize = numberOption("Threads/Jobs/User/QueueSize");
                Option ReportIsolationThreshold = numberOption("Threads/Jobs/User/ReportIsolationThreshold");
            }

            interface System {
                Option Count = numberOption("Threads/Jobs/System/Count");
            }

            interface Migration {
                Option Count = numberOption("Threads/Jobs/Migration/Count");
            }
        }

        interface OData {
            interface Initialization {
                Option Count = numberOption("Threads/OData/Initialization/Count");
                Option QueueSize = numberOption("Threads/OData/Initialization/QueueSize");
            }

            interface Processing {
                Option Count = numberOption("Threads/OData/Processing/Count");
                Option QueueSize = numberOption("Threads/OData/Processing/QueueSize");
                Option MaximumRestartCount = numberOption("Threads/OData/Processing/MaximumRestartCount");
            }
        }
    }

    /**
     * Retrieve the currently configured value of the provided option. Note, this operation involves a map lookup
     * and shouldn't be used in performance critical or frequently accessed code paths. In such instances, prefer
     * instead {@link #getValueSupplier(Option)} or one of the other functions that returns a supplier.
     */
     T get(Option option);

    /**
     * Retrieve a supplier that is always up to date with the latest configured value. Retrieving the value from the
     * returned supplier is quick and can be used in performance critical areas.
     */
     Supplier getValueSupplier(Option option);

    /**
     * Retrieve a supplier that is always up to date with the latest configured value. Retrieving the value from the
     * returned supplier is quick and can be used in performance critical areas.
     */
    Supplier getIntSupplier(Option option);

    /**
     * Retrieve a supplier that is always up to date with the latest configured value. Retrieving the value from the
     * returned supplier is quick and can be used in performance critical areas.
     */
    Supplier getLongSupplier(Option option);

    /**
     * Retrieve a supplier that is always up to date with the latest configured value. Retrieving the value from the
     * returned supplier is quick and can be used in performance critical areas.
     */
    Supplier getDoubleSupplier(Option option);

    /**
     * Register a consumer to be invoked when the given configuration option changes value. Note that the consumer
     * is held as a strong reference, so do not register a consumer that is expected to fall out of scope. Because
     * of this restriction, use this method only when the other forms of access are insufficient.
     *
     * @param option
     *         The configuration option to listen to for changes.
     * @param listener
     *         The callback to run when the option changes.
     * @param sendImmediately
     *         If true, the consumer will be immediately invoked with the current value of the configuration option.
     */
     void listen(Option option, Consumer listener, Boolean sendImmediately);

    default  void listen(Option option, Consumer listener) {
        this.listen(option, listener, true);
    }

    interface Listener {
         void changed(Option option, @Nullable T previousValue, T newValue);
    }

    /**
     * Register a callback that will be invoked when any configuration option changes value. Note that the listener is
     * held as a strong reference, so do not register a listener that is expected to fall out of scope. Because
     * of this restriction, use this method only when the other forms of access are insufficient.
     *
     * Note: The listener will _not_ be immediately invoked with the current value of any configuration options.
     * Rather, the listener will be invoked on any changes going forward.
     */
    void listenToAll(Listener listener);

    class Option {
        private final String path;
        private final Class type;

        private Option(@NotNull String path, @NotNull Class type) {
            this.path = path;
            this.type = type;
        }

        public String getPath() {return this.path;}

        public Class getType() {return this.type;}

        @Override
        public boolean equals(Object other) {
            return (other instanceof Option && ((Option) other).path.equals(this.path));
        }

        @Override
        public int hashCode() {
            return this.path.hashCode();
        }

        @Override
        public String toString() {
            return this.getPath();
        }
    }

    static Option stringOption(String path) {
        return new Option<>(path, String.class);
    }

    static Option numberOption(String path) {
        return new Option<>(path, Number.class);
    }

    static Option booleanOption(String path) {
        return new Option<>(path, Boolean.class);
    }

    default void wireThreadPoolSizeToConfiguration(Option option, ThreadPoolExecutor pool) {
        this.listen(option, newSize -> {
            int newSizeInt = newSize.intValue();

            // The order that we set the core pool and max pool sizes matters because an exception
            // will be thrown if we set the core pool size greater than the maximum pool size.
            // NOTE: The core pool and max pool are set to the same value to create a fixed-size pool
            if (pool.getMaximumPoolSize() > newSizeInt) {
                pool.setCorePoolSize(newSizeInt);
                pool.setMaximumPoolSize(newSizeInt);
            } else {
                pool.setMaximumPoolSize(newSizeInt);
                pool.setCorePoolSize(newSizeInt);
            }
        });
    }


    static Map> getAllOptions() {
        return AllOptionsHolder.ALL_OPTIONS;
    }
}

/**
 * This holder exists to avoid circular dependencies between Configuration and its nested interfaces.
 * Without this holder, we could observe uninitialized Option fields, depending on which class is referenced first.
 */
interface AllOptionsHolder {
    Map> ALL_OPTIONS = getOptionsFromClass(Configuration.class);

    static Map> getOptionsFromClass(Class clazz) {
        Map> options = new TreeMap<>(Arrays.stream(clazz.getFields())
                .filter(f -> f.getType().equals(Configuration.Option.class))
                .filter(f -> (f.getModifiers() & Modifier.STATIC) != 0)
                .map(f -> {
                    try {
                        return new Pair<>(f.getName(), (Configuration.Option) f.get(null));
                    } catch (IllegalAccessException e) {
                        throw new IllegalStateException(e);
                    }
                })
                .collect(Collectors.toMap(Pair::getFirst, Pair::getSecond)));

        for (Class c : clazz.getDeclaredClasses()) {
            options.putAll(getOptionsFromClass(c).entrySet().stream()
                    .collect(Collectors.toMap(e -> c.getSimpleName() + "." + e.getKey(), Map.Entry::getValue)));
        }

        return options;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy