|
| 1 | +# Licensed to Elasticsearch B.V. under one or more contributor |
| 2 | +# license agreements. See the NOTICE file distributed with |
| 3 | +# this work for additional information regarding copyright |
| 4 | +# ownership. Elasticsearch B.V. licenses this file to you under |
| 5 | +# the Apache License, Version 2.0 (the "License"); you may |
| 6 | +# not use this file except in compliance with the License. |
| 7 | +# You may obtain a copy of the License at |
| 8 | +# |
| 9 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | +# |
| 11 | +# Unless required by applicable law or agreed to in writing, |
| 12 | +# software distributed under the License is distributed on an |
| 13 | +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 14 | +# KIND, either express or implied. See the License for the |
| 15 | +# specific language governing permissions and limitations |
| 16 | +# under the License. |
| 17 | + |
| 18 | +module Elasticsearch |
| 19 | + module API |
| 20 | + module Snapshot |
| 21 | + module Actions |
| 22 | + # Analyzes a repository for correctness and performance |
| 23 | + # |
| 24 | + # @option arguments [String] :repository A repository name |
| 25 | + # @option arguments [Number] :blob_count Number of blobs to create during the test. Defaults to 100. |
| 26 | + # @option arguments [Number] :concurrency Number of operations to run concurrently during the test. Defaults to 10. |
| 27 | + # @option arguments [Number] :read_node_count Number of nodes on which to read a blob after writing. Defaults to 10. |
| 28 | + # @option arguments [Number] :early_read_node_count Number of nodes on which to perform an early read on a blob, i.e. before writing has completed. Early reads are rare actions so the 'rare_action_probability' parameter is also relevant. Defaults to 2. |
| 29 | + # @option arguments [Number] :seed Seed for the random number generator used to create the test workload. Defaults to a random value. |
| 30 | + # @option arguments [Number] :rare_action_probability Probability of taking a rare action such as an early read or an overwrite. Defaults to 0.02. |
| 31 | + # @option arguments [String] :max_blob_size Maximum size of a blob to create during the test, e.g '1gb' or '100mb'. Defaults to '10mb'. |
| 32 | + # @option arguments [String] :max_total_data_size Maximum total size of all blobs to create during the test, e.g '1tb' or '100gb'. Defaults to '1gb'. |
| 33 | + # @option arguments [Time] :timeout Explicit operation timeout. Defaults to '30s'. |
| 34 | + # @option arguments [Boolean] :detailed Whether to return detailed results or a summary. Defaults to 'false' so that only the summary is returned. |
| 35 | + # @option arguments [Boolean] :rarely_abort_writes Whether to rarely abort writes before they complete. Defaults to 'true'. |
| 36 | + # @option arguments [Hash] :headers Custom HTTP headers |
| 37 | + # |
| 38 | + # @see https://www.elastic.co/guide/en/elasticsearch/reference/master/modules-snapshots.html |
| 39 | + # |
| 40 | + def repository_analyze(arguments = {}) |
| 41 | + raise ArgumentError, "Required argument 'repository' missing" unless arguments[:repository] |
| 42 | + |
| 43 | + headers = arguments.delete(:headers) || {} |
| 44 | + |
| 45 | + arguments = arguments.clone |
| 46 | + |
| 47 | + _repository = arguments.delete(:repository) |
| 48 | + |
| 49 | + method = Elasticsearch::API::HTTP_POST |
| 50 | + path = "_snapshot/#{Utils.__listify(_repository)}/_analyze" |
| 51 | + params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__) |
| 52 | + |
| 53 | + body = nil |
| 54 | + perform_request(method, path, params, body, headers).body |
| 55 | + end |
| 56 | + |
| 57 | + # Register this action with its valid params when the module is loaded. |
| 58 | + # |
| 59 | + # @since 6.2.0 |
| 60 | + ParamsRegistry.register(:repository_analyze, [ |
| 61 | + :blob_count, |
| 62 | + :concurrency, |
| 63 | + :read_node_count, |
| 64 | + :early_read_node_count, |
| 65 | + :seed, |
| 66 | + :rare_action_probability, |
| 67 | + :max_blob_size, |
| 68 | + :max_total_data_size, |
| 69 | + :timeout, |
| 70 | + :detailed, |
| 71 | + :rarely_abort_writes |
| 72 | + ].freeze) |
| 73 | + end |
| 74 | + end |
| 75 | + end |
| 76 | +end |
0 commit comments