/* 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 System.Runtime.Serialization; using OpenSearch.Net.Utf8Json; namespace OpenSearch.Client.Specification.SnapshotApi { /// /// A snapshot repository that stores snapshot data within a Hadoop HDFS filesystem /// /// Requires the repository-hdfs plugin to be installed on the cluster /// public interface IHdfsRepository : IRepository { } /// public class HdfsRepository : IHdfsRepository { public HdfsRepository(HdfsRepositorySettings settings) => Settings = settings; public IHdfsRepositorySettings Settings { get; set; } object IRepositoryWithSettings.DelegateSettings => Settings; public string Type { get; } = "hdfs"; } /// /// Snapshot repository settings for /// public interface IHdfsRepositorySettings : IRepositorySettings { /// /// Big files can be broken down into chunks during snapshotting if needed. /// The chunk size can be specified in bytes or by using size value notation, /// i.e. 1g, 10m, 5k. Disabled by default /// [DataMember(Name ="chunk_size")] string ChunkSize { get; set; } /// /// When set to true metadata files are stored in compressed format. This setting doesn't /// affect index files that are already compressed by default. Defaults to false. /// [DataMember(Name ="compress")] [JsonFormatter(typeof(NullableStringBooleanFormatter))] bool? Compress { get; set; } /// /// Throttles the number of streams (per node) preforming snapshot operation. Defaults to 5 /// [DataMember(Name ="concurrent_streams")] [JsonFormatter(typeof(NullableStringIntFormatter))] int? ConcurrentStreams { get; set; } /// /// Hadoop configuration XML to be loaded (use commas for multi values) /// [DataMember(Name ="conf_location")] string ConfigurationLocation { get; set; } /// /// 'inlined' key=value added to the Hadoop configuration /// [IgnoreDataMember] Dictionary InlineHadoopConfiguration { get; set; } /// /// Whether to load the default Hadoop configuration (default) or not /// [DataMember(Name ="load_defaults")] [JsonFormatter(typeof(NullableStringBooleanFormatter))] bool? LoadDefaults { get; set; } /// /// The path with the file-system where data is stored/loaded. Required /// [DataMember(Name ="path")] string Path { get; set; } /// /// The Hadoop file-system URI. Optional /// [DataMember(Name ="uri")] string Uri { get; set; } } /// public class HdfsRepositorySettings : IHdfsRepositorySettings { internal HdfsRepositorySettings() { } public HdfsRepositorySettings(string path) => Path = path; /// public string ChunkSize { get; set; } /// public bool? Compress { get; set; } /// public int? ConcurrentStreams { get; set; } /// public string ConfigurationLocation { get; set; } /// public Dictionary InlineHadoopConfiguration { get; set; } /// public bool? LoadDefaults { get; set; } /// public string Path { get; set; } /// public string Uri { get; set; } } /// public class HdfsRepositorySettingsDescriptor : DescriptorBase, IHdfsRepositorySettings { string IHdfsRepositorySettings.ChunkSize { get; set; } bool? IHdfsRepositorySettings.Compress { get; set; } int? IHdfsRepositorySettings.ConcurrentStreams { get; set; } string IHdfsRepositorySettings.ConfigurationLocation { get; set; } Dictionary IHdfsRepositorySettings.InlineHadoopConfiguration { get; set; } bool? IHdfsRepositorySettings.LoadDefaults { get; set; } string IHdfsRepositorySettings.Path { get; set; } string IHdfsRepositorySettings.Uri { get; set; } /// public HdfsRepositorySettingsDescriptor Uri(string uri) => Assign(uri, (a, v) => a.Uri = v); /// public HdfsRepositorySettingsDescriptor Path(string path) => Assign(path, (a, v) => a.Path = v); /// public HdfsRepositorySettingsDescriptor LoadDefaults(bool? loadDefaults = true) => Assign(loadDefaults, (a, v) => a.LoadDefaults = v); /// public HdfsRepositorySettingsDescriptor ConfigurationLocation(string configurationLocation) => Assign(configurationLocation, (a, v) => a.ConfigurationLocation = v); /// public HdfsRepositorySettingsDescriptor InlinedHadoopConfiguration( Func, FluentDictionary> inlineConfig ) => Assign(inlineConfig, (a, v) => a.InlineHadoopConfiguration = v(new FluentDictionary())); /// public HdfsRepositorySettingsDescriptor Compress(bool? compress = true) => Assign(compress, (a, v) => a.Compress = v); /// public HdfsRepositorySettingsDescriptor ConcurrentStreams(int? concurrentStreams) => Assign(concurrentStreams, (a, v) => a.ConcurrentStreams = v); /// public HdfsRepositorySettingsDescriptor ChunkSize(string chunkSize) => Assign(chunkSize, (a, v) => a.ChunkSize = v); } /// public class HdfsRepositoryDescriptor : DescriptorBase, IHdfsRepository { IHdfsRepositorySettings IRepository.Settings { get; set; } object IRepositoryWithSettings.DelegateSettings => Self.Settings; string ISnapshotRepository.Type => "hdfs"; /// public HdfsRepositoryDescriptor Settings(string path, Func settingsSelector = null ) => Assign(settingsSelector.InvokeOrDefault(new HdfsRepositorySettingsDescriptor().Path(path)), (a, v) => a.Settings = v); } }