/* 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.
*/
namespace OpenSearch.Client
{
public interface IShardAllocationSettings
{
/// Enable or disable allocation for specific kinds of shards, defaults to all
AllocationEnable? AllocationEnable { get; set; }
/// How many concurrent shard recoveries are allowed to happen on a node. Defaults to 2.
int? NodeConcurrentRecoveries { get; set; }
///
/// While the recovery of replicas happens over the network, the recovery of an unassigned primary after node restart uses
/// data from the local disk. These should be fast so more initial primary recoveries can happen in
/// parallel on the same node. Defaults to 4.
///
int? NodeInitialPrimariesRecoveries { get; set; }
///
/// Allows to perform a check to prevent allocation of multiple instances of
/// the same shard on a single host, based on host name and host address.
/// Defaults to false, meaning that no check is performed by default. This setting only
/// applies if multiple nodes are started on the same machine.
///
bool? SameShardHost { get; set; }
}
public class ShardAllocationSettings : IShardAllocationSettings
{
///
public AllocationEnable? AllocationEnable { get; set; }
///
public int? NodeConcurrentRecoveries { get; set; }
///
public int? NodeInitialPrimariesRecoveries { get; set; }
///
public bool? SameShardHost { get; set; }
}
public class ShardAllocationSettingsDescriptor
: DescriptorBase, IShardAllocationSettings
{
AllocationEnable? IShardAllocationSettings.AllocationEnable { get; set; }
int? IShardAllocationSettings.NodeConcurrentRecoveries { get; set; }
int? IShardAllocationSettings.NodeInitialPrimariesRecoveries { get; set; }
bool? IShardAllocationSettings.SameShardHost { get; set; }
///
public ShardAllocationSettingsDescriptor AllocationEnable(AllocationEnable? enable) => Assign(enable, (a, v) => a.AllocationEnable = v);
///
public ShardAllocationSettingsDescriptor NodeConcurrentRecoveries(int? concurrent) => Assign(concurrent, (a, v) => a.NodeConcurrentRecoveries = v);
///
public ShardAllocationSettingsDescriptor NodeInitialPrimariesRecoveries(int? initial) =>
Assign(initial, (a, v) => a.NodeInitialPrimariesRecoveries = v);
///
public ShardAllocationSettingsDescriptor SameShardHost(bool? same = true) => Assign(same, (a, v) => a.SameShardHost = v);
}
}