/* SPDX-License-Identifier: Apache-2.0 * * The OpenSearch Contributors require contributions made to * this file be licensed under the Apache-2.0 license or a * compatible open source license. */ /* * Modifications Copyright OpenSearch Contributors. See * GitHub history for details. * * Licensed to Elasticsearch B.V. under one or more contributor * license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright * ownership. Elasticsearch B.V. 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. */ using System; using System.Collections.Generic; using OpenSearch.Client.Specification.IndicesApi; namespace OpenSearch.Client { /// Settings to control where, when, and how shards are allocated to nodes. public interface IClusterModuleSettings { /// IAllocationAwarenessSettings AllocationAwareness { get; set; } /// IAllocationFilteringSettings AllocationFiltering { get; set; } /// IDiskBasedShardAllocationSettings DiskBasedShardAllocation { get; set; } /// IDictionary Logger { get; set; } /// bool? ReadOnly { get; set; } /// IShardAllocationSettings ShardAllocation { get; set; } /// IShardBalancingHeuristicsSettings ShardBalancingHeuristics { get; set; } /// IShardRebalancingSettings ShardRebalancing { get; set; } } /// public class ClusterModuleSettings : IClusterModuleSettings { /// public IAllocationAwarenessSettings AllocationAwareness { get; set; } /// public IAllocationFilteringSettings AllocationFiltering { get; set; } /// public IDiskBasedShardAllocationSettings DiskBasedShardAllocation { get; set; } /// public IDictionary Logger { get; set; } /// public bool? ReadOnly { get; set; } /// public IShardAllocationSettings ShardAllocation { get; set; } /// public IShardBalancingHeuristicsSettings ShardBalancingHeuristics { get; set; } /// public IShardRebalancingSettings ShardRebalancing { get; set; } } /// public class ClusterModuleSettingsDescriptor : DescriptorBase, IClusterModuleSettings { IAllocationAwarenessSettings IClusterModuleSettings.AllocationAwareness { get; set; } IAllocationFilteringSettings IClusterModuleSettings.AllocationFiltering { get; set; } IDiskBasedShardAllocationSettings IClusterModuleSettings.DiskBasedShardAllocation { get; set; } IDictionary IClusterModuleSettings.Logger { get; set; } bool? IClusterModuleSettings.ReadOnly { get; set; } IShardAllocationSettings IClusterModuleSettings.ShardAllocation { get; set; } IShardBalancingHeuristicsSettings IClusterModuleSettings.ShardBalancingHeuristics { get; set; } IShardRebalancingSettings IClusterModuleSettings.ShardRebalancing { get; set; } /// public ClusterModuleSettingsDescriptor ShardRebalancing(bool? readOnly = true) => Assign(readOnly, (a, v) => a.ReadOnly = v); /// public ClusterModuleSettingsDescriptor Logger(IDictionary logger) => Assign(logger, (a, v) => a.Logger = v); /// public ClusterModuleSettingsDescriptor Logger(Func, FluentDictionary> selector) => Assign(selector, (a, v) => a.Logger = v?.Invoke(new FluentDictionary())); /// public ClusterModuleSettingsDescriptor AllocationAwareness(Func selector) => Assign(selector, (a, v) => a.AllocationAwareness = v?.Invoke(new AllocationAwarenessSettings())); /// public ClusterModuleSettingsDescriptor AllocationFiltering(Func selector) => Assign(selector, (a, v) => a.AllocationFiltering = v?.Invoke(new AllocationFilteringSettingsDescriptor())); /// public ClusterModuleSettingsDescriptor DiskBasedShardAllocation( Func selector ) => Assign(selector, (a, v) => a.DiskBasedShardAllocation = v?.Invoke(new DiskBasedShardAllocationSettingsDescriptor())); /// public ClusterModuleSettingsDescriptor ShardAllocation(Func selector) => Assign(selector, (a, v) => a.ShardAllocation = v?.Invoke(new ShardAllocationSettingsDescriptor())); /// public ClusterModuleSettingsDescriptor ShardBalancingHeuristics( Func selector ) => Assign(selector, (a, v) => a.ShardBalancingHeuristics = v?.Invoke(new ShardBalancingHeuristicsSettingsDescriptor())); /// public ClusterModuleSettingsDescriptor ShardRebalancing(Func selector) => Assign(selector, (a, v) => a.ShardRebalancing = v?.Invoke(new ShardRebalancingSettingsDescriptor())); } }