Module: Elasticsearch::API::Snapshot::Actions

Defined in:
lib/elasticsearch/api/actions/snapshot/get.rb,
lib/elasticsearch/api/actions/snapshot/clone.rb,
lib/elasticsearch/api/actions/snapshot/create.rb,
lib/elasticsearch/api/actions/snapshot/delete.rb,
lib/elasticsearch/api/actions/snapshot/status.rb,
lib/elasticsearch/api/actions/snapshot/restore.rb,
lib/elasticsearch/api/actions/snapshot/get_repository.rb,
lib/elasticsearch/api/actions/snapshot/create_repository.rb,
lib/elasticsearch/api/actions/snapshot/delete_repository.rb,
lib/elasticsearch/api/actions/snapshot/verify_repository.rb,
lib/elasticsearch/api/actions/snapshot/cleanup_repository.rb,
lib/elasticsearch/api/actions/snapshot/repository_analyze.rb

Instance Method Summary collapse

Instance Method Details

#cleanup_repository(arguments = {}) ⇒ Object

Clean up the snapshot repository. Trigger the review of the contents of a snapshot repository and delete any stale data not referenced by existing snapshots.

Parameters:

  • arguments (Hash) (defaults to: {})

    a customizable set of options

Options Hash (arguments):

  • :repository (String)

    The name of the snapshot repository to clean up. (Required)

  • :master_timeout (Time)

    The period to wait for a connection to the master node. If the master node is not available before the timeout expires, the request fails and returns an error. To indicate that the request should never timeout, set it to -1 Server default: 30s.

  • :timeout (Time)

    The period to wait for a response from all relevant nodes in the cluster after updating the cluster metadata. If no response is received before the timeout expires, the cluster metadata update still applies but the response will indicate that it was not completely acknowledged. To indicate that the request should never timeout, set it to -1. Server default: 30s.

  • :headers (Hash)

    Custom HTTP headers

Raises:

  • (ArgumentError)

See Also:



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/elasticsearch/api/actions/snapshot/cleanup_repository.rb', line 39

def cleanup_repository(arguments = {})
  request_opts = { endpoint: arguments[:endpoint] || 'snapshot.cleanup_repository' }

  defined_params = [:repository].each_with_object({}) do |variable, set_variables|
    set_variables[variable] = arguments[variable] if arguments.key?(variable)
  end
  request_opts[:defined_params] = defined_params unless defined_params.empty?

  raise ArgumentError, "Required argument 'repository' missing" unless arguments[:repository]

  arguments = arguments.clone
  headers = arguments.delete(:headers) || {}

  body = nil

  _repository = arguments.delete(:repository)

  method = Elasticsearch::API::HTTP_POST
  path   = "_snapshot/#{Utils.listify(_repository)}/_cleanup"
  params = Utils.process_params(arguments)

  Elasticsearch::API::Response.new(
    perform_request(method, path, params, body, headers, request_opts)
  )
end

#clone(arguments = {}) ⇒ Object

Clone a snapshot. Clone part of all of a snapshot into another snapshot in the same repository.

Parameters:

  • arguments (Hash) (defaults to: {})

    a customizable set of options

Options Hash (arguments):

  • :repository (String)

    The name of the snapshot repository that both source and target snapshot belong to. (Required)

  • :snapshot (String)

    The source snapshot name. (Required)

  • :target_snapshot (String)

    The target snapshot name. (Required)

  • :master_timeout (Time)

    The period to wait for the master node. If the master node is not available before the timeout expires, the request fails and returns an error. To indicate that the request should never timeout, set it to -1. Server default: 30s.

  • :headers (Hash)

    Custom HTTP headers

  • :body (Hash)

    request body

Raises:

  • (ArgumentError)

See Also:



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/elasticsearch/api/actions/snapshot/clone.rb', line 39

def clone(arguments = {})
  request_opts = { endpoint: arguments[:endpoint] || 'snapshot.clone' }

  defined_params = [:repository, :snapshot, :target_snapshot].each_with_object({}) do |variable, set_variables|
    set_variables[variable] = arguments[variable] if arguments.key?(variable)
  end
  request_opts[:defined_params] = defined_params unless defined_params.empty?

  raise ArgumentError, "Required argument 'body' missing" unless arguments[:body]
  raise ArgumentError, "Required argument 'repository' missing" unless arguments[:repository]
  raise ArgumentError, "Required argument 'snapshot' missing" unless arguments[:snapshot]
  raise ArgumentError, "Required argument 'target_snapshot' missing" unless arguments[:target_snapshot]

  arguments = arguments.clone
  headers = arguments.delete(:headers) || {}

  body = arguments.delete(:body)

  _repository = arguments.delete(:repository)

  _snapshot = arguments.delete(:snapshot)

  _target_snapshot = arguments.delete(:target_snapshot)

  method = Elasticsearch::API::HTTP_PUT
  path   = "_snapshot/#{Utils.listify(_repository)}/#{Utils.listify(_snapshot)}/_clone/#{Utils.listify(_target_snapshot)}"
  params = Utils.process_params(arguments)

  Elasticsearch::API::Response.new(
    perform_request(method, path, params, body, headers, request_opts)
  )
end

#create(arguments = {}) ⇒ Object

Create a snapshot. Take a snapshot of a cluster or of data streams and indices.

Parameters:

  • arguments (Hash) (defaults to: {})

    a customizable set of options

Options Hash (arguments):

  • :repository (String)

    The name of the repository for the snapshot. (Required)

  • :snapshot (String)

    The name of the snapshot. It supportes date math. It must be unique in the repository. (Required)

  • :master_timeout (Time)

    The period to wait for a connection to the master node. If no response is received before the timeout expires, the request fails and returns an error. Server default: 30s.

  • :wait_for_completion (Boolean)

    If true, the request returns a response when the snapshot is complete. If false, the request returns a response when the snapshot initializes.

  • :headers (Hash)

    Custom HTTP headers

  • :body (Hash)

    request body

Raises:

  • (ArgumentError)

See Also:



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/elasticsearch/api/actions/snapshot/create.rb', line 41

def create(arguments = {})
  request_opts = { endpoint: arguments[:endpoint] || 'snapshot.create' }

  defined_params = [:repository, :snapshot].each_with_object({}) do |variable, set_variables|
    set_variables[variable] = arguments[variable] if arguments.key?(variable)
  end
  request_opts[:defined_params] = defined_params unless defined_params.empty?

  raise ArgumentError, "Required argument 'repository' missing" unless arguments[:repository]
  raise ArgumentError, "Required argument 'snapshot' missing" unless arguments[:snapshot]

  arguments = arguments.clone
  headers = arguments.delete(:headers) || {}

  body = arguments.delete(:body)

  _repository = arguments.delete(:repository)

  _snapshot = arguments.delete(:snapshot)

  method = Elasticsearch::API::HTTP_PUT
  path   = "_snapshot/#{Utils.listify(_repository)}/#{Utils.listify(_snapshot)}"
  params = Utils.process_params(arguments)

  Elasticsearch::API::Response.new(
    perform_request(method, path, params, body, headers, request_opts)
  )
end

#create_repository(arguments = {}) ⇒ Object

Create or update a snapshot repository. IMPORTANT: If you are migrating searchable snapshots, the repository name must be identical in the source and destination clusters. To register a snapshot repository, the cluster’s global metadata must be writeable. Ensure there are no cluster blocks (for example, cluster.blocks.read_only and clsuter.blocks.read_only_allow_delete settings) that prevent write access. Several options for this API can be specified using a query parameter or a request body parameter. If both parameters are specified, only the query parameter is used.

Parameters:

  • arguments (Hash) (defaults to: {})

    a customizable set of options

Options Hash (arguments):

  • :repository (String)

    The name of the snapshot repository to register or update. (Required)

  • :master_timeout (Time)

    The period to wait for the master node. If the master node is not available before the timeout expires, the request fails and returns an error. To indicate that the request should never timeout, set it to -1. Server default: 30s.

  • :timeout (Time)

    The period to wait for a response from all relevant nodes in the cluster after updating the cluster metadata. If no response is received before the timeout expires, the cluster metadata update still applies but the response will indicate that it was not completely acknowledged. To indicate that the request should never timeout, set it to -1. Server default: 30s.

  • :verify (Boolean)

    If true, the request verifies the repository is functional on all master and data nodes in the cluster. If false, this verification is skipped. You can also perform this verification with the verify snapshot repository API. Server default: true.

  • :headers (Hash)

    Custom HTTP headers

  • :body (Hash)

    repository

Raises:

  • (ArgumentError)

See Also:



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/elasticsearch/api/actions/snapshot/create_repository.rb', line 47

def create_repository(arguments = {})
  request_opts = { endpoint: arguments[:endpoint] || 'snapshot.create_repository' }

  defined_params = [:repository].each_with_object({}) do |variable, set_variables|
    set_variables[variable] = arguments[variable] if arguments.key?(variable)
  end
  request_opts[:defined_params] = defined_params unless defined_params.empty?

  raise ArgumentError, "Required argument 'body' missing" unless arguments[:body]
  raise ArgumentError, "Required argument 'repository' missing" unless arguments[:repository]

  arguments = arguments.clone
  headers = arguments.delete(:headers) || {}

  body = arguments.delete(:body)

  _repository = arguments.delete(:repository)

  method = Elasticsearch::API::HTTP_PUT
  path   = "_snapshot/#{Utils.listify(_repository)}"
  params = Utils.process_params(arguments)

  Elasticsearch::API::Response.new(
    perform_request(method, path, params, body, headers, request_opts)
  )
end

#delete(arguments = {}) ⇒ Object

Delete snapshots.

Parameters:

  • arguments (Hash) (defaults to: {})

    a customizable set of options

Options Hash (arguments):

  • :repository (String)

    The name of the repository to delete a snapshot from. (Required)

  • :snapshot (String)

    A comma-separated list of snapshot names to delete. It also accepts wildcards (+*+). (Required)

  • :master_timeout (Time)

    The period to wait for the master node. If the master node is not available before the timeout expires, the request fails and returns an error. To indicate that the request should never timeout, set it to -1. Server default: 30s.

  • :headers (Hash)

    Custom HTTP headers

Raises:

  • (ArgumentError)

See Also:



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/elasticsearch/api/actions/snapshot/delete.rb', line 37

def delete(arguments = {})
  request_opts = { endpoint: arguments[:endpoint] || 'snapshot.delete' }

  defined_params = [:repository, :snapshot].each_with_object({}) do |variable, set_variables|
    set_variables[variable] = arguments[variable] if arguments.key?(variable)
  end
  request_opts[:defined_params] = defined_params unless defined_params.empty?

  raise ArgumentError, "Required argument 'repository' missing" unless arguments[:repository]
  raise ArgumentError, "Required argument 'snapshot' missing" unless arguments[:snapshot]

  arguments = arguments.clone
  headers = arguments.delete(:headers) || {}

  body = nil

  _repository = arguments.delete(:repository)

  _snapshot = arguments.delete(:snapshot)

  method = Elasticsearch::API::HTTP_DELETE
  path   = "_snapshot/#{Utils.listify(_repository)}/#{Utils.listify(_snapshot)}"
  params = Utils.process_params(arguments)

  if Array(arguments[:ignore]).include?(404)
    Utils.rescue_from_not_found do
      Elasticsearch::API::Response.new(
        perform_request(method, path, params, body, headers, request_opts)
      )
    end
  else
    Elasticsearch::API::Response.new(
      perform_request(method, path, params, body, headers, request_opts)
    )
  end
end

#delete_repository(arguments = {}) ⇒ Object

Delete snapshot repositories. When a repository is unregistered, Elasticsearch removes only the reference to the location where the repository is storing the snapshots. The snapshots themselves are left untouched and in place.

Parameters:

  • arguments (Hash) (defaults to: {})

    a customizable set of options

Options Hash (arguments):

  • :repository (String, Array<String>)

    The ame of the snapshot repositories to unregister. Wildcard (+*+) patterns are supported. (Required)

  • :master_timeout (Time)

    The period to wait for the master node. If the master node is not available before the timeout expires, the request fails and returns an error. To indicate that the request should never timeout, set it to -1. Server default: 30s.

  • :timeout (Time)

    The period to wait for a response from all relevant nodes in the cluster after updating the cluster metadata. If no response is received before the timeout expires, the cluster metadata update still applies but the response will indicate that it was not completely acknowledged. To indicate that the request should never timeout, set it to -1. Server default: 30s.

  • :headers (Hash)

    Custom HTTP headers

Raises:

  • (ArgumentError)

See Also:



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/elasticsearch/api/actions/snapshot/delete_repository.rb', line 41

def delete_repository(arguments = {})
  request_opts = { endpoint: arguments[:endpoint] || 'snapshot.delete_repository' }

  defined_params = [:repository].each_with_object({}) do |variable, set_variables|
    set_variables[variable] = arguments[variable] if arguments.key?(variable)
  end
  request_opts[:defined_params] = defined_params unless defined_params.empty?

  raise ArgumentError, "Required argument 'repository' missing" unless arguments[:repository]

  arguments = arguments.clone
  headers = arguments.delete(:headers) || {}

  body = nil

  _repository = arguments.delete(:repository)

  method = Elasticsearch::API::HTTP_DELETE
  path   = "_snapshot/#{Utils.listify(_repository)}"
  params = Utils.process_params(arguments)

  if Array(arguments[:ignore]).include?(404)
    Utils.rescue_from_not_found do
      Elasticsearch::API::Response.new(
        perform_request(method, path, params, body, headers, request_opts)
      )
    end
  else
    Elasticsearch::API::Response.new(
      perform_request(method, path, params, body, headers, request_opts)
    )
  end
end

#get(arguments = {}) ⇒ Object

Get snapshot information. NOTE: The after parameter and next field enable you to iterate through snapshots with some consistency guarantees regarding concurrent creation or deletion of snapshots. It is guaranteed that any snapshot that exists at the beginning of the iteration and is not concurrently deleted will be seen during the iteration. Snapshots concurrently created may be seen during an iteration.

Parameters:

  • arguments (Hash) (defaults to: {})

    a customizable set of options

Options Hash (arguments):

  • :repository (String)

    A comma-separated list of snapshot repository names used to limit the request. Wildcard (+*+) expressions are supported. (Required)

  • :snapshot (String, Array<String>)

    A comma-separated list of snapshot names to retrieve Wildcards (+*+) are supported.

    • To get information about all snapshots in a registered repository, use a wildcard (+*+) or _all.

    • To get information about any snapshots that are currently running, use _current. (Required)

  • :after (String)

    An offset identifier to start pagination from as returned by the next field in the response body.

  • :from_sort_value (String)

    The value of the current sort column at which to start retrieval. It can be a string snapshot- or a repository name when sorting by snapshot or repository name. It can be a millisecond time value or a number when sorting by index- or shard count.

  • :ignore_unavailable (Boolean)

    If false, the request returns an error for any snapshots that are unavailable.

  • :index_details (Boolean)

    If true, the response includes additional information about each index in the snapshot comprising the number of shards in the index, the total size of the index in bytes, and the maximum number of segments per shard in the index. The default is false, meaning that this information is omitted.

  • :index_names (Boolean)

    If true, the response includes the name of each index in each snapshot. Server default: true.

  • :include_repository (Boolean)

    If true, the response includes the repository name in each snapshot. Server default: true.

  • :master_timeout (Time)

    The period to wait for a connection to the master node. If no response is received before the timeout expires, the request fails and returns an error. Server default: 30s.

  • :order (String)

    The sort order. Valid values are asc for ascending and desc for descending order. The default behavior is ascending order. Server default: asc.

  • :offset (Integer)

    Numeric offset to start pagination from based on the snapshots matching this request. Using a non-zero value for this parameter is mutually exclusive with using the after parameter. Defaults to 0. Server default: 0.

  • :size (Integer)

    The maximum number of snapshots to return. The default is 0, which means to return all that match the request without limit. Server default: 0.

  • :slm_policy_filter (String)

    Filter snapshots by a comma-separated list of snapshot lifecycle management (SLM) policy names that snapshots belong to.You can use wildcards (+*+) and combinations of wildcards followed by exclude patterns starting with -. For example, the pattern *,-policy-a-* will return all snapshots except for those that were created by an SLM policy with a name starting with policy-a-. Note that the wildcard pattern * matches all snapshots created by an SLM policy but not those snapshots that were not created by an SLM policy. To include snapshots that were not created by an SLM policy, you can use the special pattern _none that will match all snapshots without an SLM policy.

  • :sort (String)

    The sort order for the result. The default behavior is sorting by snapshot start time stamp. Server default: start_time.

  • :verbose (Boolean)

    If true, returns additional information about each snapshot such as the version of Elasticsearch which took the snapshot, the start and end times of the snapshot, and the number of shards snapshotted.NOTE: The parameters size, order, after, from_sort_value, offset, slm_policy_filter, and sort are not supported when you set verbose=false and the sort order for requests with verbose=false is undefined. Server default: true.

  • :headers (Hash)

    Custom HTTP headers

Raises:

  • (ArgumentError)

See Also:



64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# File 'lib/elasticsearch/api/actions/snapshot/get.rb', line 64

def get(arguments = {})
  request_opts = { endpoint: arguments[:endpoint] || 'snapshot.get' }

  defined_params = [:repository, :snapshot].each_with_object({}) do |variable, set_variables|
    set_variables[variable] = arguments[variable] if arguments.key?(variable)
  end
  request_opts[:defined_params] = defined_params unless defined_params.empty?

  raise ArgumentError, "Required argument 'repository' missing" unless arguments[:repository]
  raise ArgumentError, "Required argument 'snapshot' missing" unless arguments[:snapshot]

  arguments = arguments.clone
  headers = arguments.delete(:headers) || {}

  body = nil

  _repository = arguments.delete(:repository)

  _snapshot = arguments.delete(:snapshot)

  method = Elasticsearch::API::HTTP_GET
  path   = "_snapshot/#{Utils.listify(_repository)}/#{Utils.listify(_snapshot)}"
  params = Utils.process_params(arguments)

  if Array(arguments[:ignore]).include?(404)
    Utils.rescue_from_not_found do
      Elasticsearch::API::Response.new(
        perform_request(method, path, params, body, headers, request_opts)
      )
    end
  else
    Elasticsearch::API::Response.new(
      perform_request(method, path, params, body, headers, request_opts)
    )
  end
end

#get_repository(arguments = {}) ⇒ Object

Get snapshot repository information.

Parameters:

  • arguments (Hash) (defaults to: {})

    a customizable set of options

Options Hash (arguments):

  • :repository (String, Array<String>)

    A comma-separated list of snapshot repository names used to limit the request. Wildcard (+*+) expressions are supported including combining wildcards with exclude patterns starting with -.To get information about all snapshot repositories registered in the cluster, omit this parameter or use * or _all.

  • :local (Boolean)

    If true, the request gets information from the local node only. If false, the request gets information from the master node.

  • :master_timeout (Time)

    The period to wait for the master node. If the master node is not available before the timeout expires, the request fails and returns an error. To indicate that the request should never timeout, set it to -1. Server default: to 30s.

  • :headers (Hash)

    Custom HTTP headers

See Also:



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/elasticsearch/api/actions/snapshot/get_repository.rb', line 38

def get_repository(arguments = {})
  request_opts = { endpoint: arguments[:endpoint] || 'snapshot.get_repository' }

  defined_params = [:repository].each_with_object({}) do |variable, set_variables|
    set_variables[variable] = arguments[variable] if arguments.key?(variable)
  end
  request_opts[:defined_params] = defined_params unless defined_params.empty?

  arguments = arguments.clone
  headers = arguments.delete(:headers) || {}

  body = nil

  _repository = arguments.delete(:repository)

  method = Elasticsearch::API::HTTP_GET
  path   = if _repository
             "_snapshot/#{Utils.listify(_repository)}"
           else
             '_snapshot'
           end
  params = Utils.process_params(arguments)

  if Array(arguments[:ignore]).include?(404)
    Utils.rescue_from_not_found do
      Elasticsearch::API::Response.new(
        perform_request(method, path, params, body, headers, request_opts)
      )
    end
  else
    Elasticsearch::API::Response.new(
      perform_request(method, path, params, body, headers, request_opts)
    )
  end
end

#repository_analyze(arguments = {}) ⇒ Object

Analyze a snapshot repository. Analyze the performance characteristics and any incorrect behaviour found in a repository. The response exposes implementation details of the analysis which may change from version to version. The response body format is therefore not considered stable and may be different in newer versions. There are a large number of third-party storage systems available, not all of which are suitable for use as a snapshot repository by Elasticsearch. Some storage systems behave incorrectly, or perform poorly, especially when accessed concurrently by multiple clients as the nodes of an Elasticsearch cluster do. This API performs a collection of read and write operations on your repository which are designed to detect incorrect behaviour and to measure the performance characteristics of your storage system. The default values for the parameters are deliberately low to reduce the impact of running an analysis inadvertently and to provide a sensible starting point for your investigations. Run your first analysis with the default parameter values to check for simple problems. If successful, run a sequence of increasingly large analyses until you encounter a failure or you reach a blob_count of at least 2000, a max_blob_size of at least 2gb, a max_total_data_size of at least 1tb, and a register_operation_count of at least 100. Always specify a generous timeout, possibly 1h or longer, to allow time for each analysis to run to completion. Perform the analyses using a multi-node cluster of a similar size to your production cluster so that it can detect any problems that only arise when the repository is accessed by many nodes at once. If the analysis fails, Elasticsearch detected that your repository behaved unexpectedly. This usually means you are using a third-party storage system with an incorrect or incompatible implementation of the API it claims to support. If so, this storage system is not suitable for use as a snapshot repository. You will need to work with the supplier of your storage system to address the incompatibilities that Elasticsearch detects. If the analysis is successful, the API returns details of the testing process, optionally including how long each operation took. You can use this information to determine the performance of your storage system. If any operation fails or returns an incorrect result, the API returns an error. If the API returns an error, it may not have removed all the data it wrote to the repository. The error will indicate the location of any leftover data and this path is also recorded in the Elasticsearch logs. You should verify that this location has been cleaned up correctly. If there is still leftover data at the specified location, you should manually remove it. If the connection from your client to Elasticsearch is closed while the client is waiting for the result of the analysis, the test is cancelled. Some clients are configured to close their connection if no response is received within a certain timeout. An analysis takes a long time to complete so you might need to relax any such client-side timeouts. On cancellation the analysis attempts to clean up the data it was writing, but it may not be able to remove it all. The path to the leftover data is recorded in the Elasticsearch logs. You should verify that this location has been cleaned up correctly. If there is still leftover data at the specified location, you should manually remove it. If the analysis is successful then it detected no incorrect behaviour, but this does not mean that correct behaviour is guaranteed. The analysis attempts to detect common bugs but it does not offer 100% coverage. Additionally, it does not test the following:

  • Your repository must perform durable writes. Once a blob has been written it must remain in place until it is deleted, even after a power loss or similar disaster.

  • Your repository must not suffer from silent data corruption. Once a blob has been written, its contents must remain unchanged until it is deliberately modified or deleted.

  • Your repository must behave correctly even if connectivity from the cluster is disrupted. Reads and writes may fail in this case, but they must not return incorrect results.

IMPORTANT: An analysis writes a substantial amount of data to your repository and then reads it back again. This consumes bandwidth on the network between the cluster and the repository, and storage space and I/O bandwidth on the repository itself. You must ensure this load does not affect other users of these systems. Analyses respect the repository settings max_snapshot_bytes_per_sec and max_restore_bytes_per_sec if available and the cluster setting indices.recovery.max_bytes_per_sec which you can use to limit the bandwidth they consume. NOTE: This API is intended for exploratory use by humans. You should expect the request parameters and the response format to vary in future versions. NOTE: Different versions of Elasticsearch may perform different checks for repository compatibility, with newer versions typically being stricter than older ones. A storage system that passes repository analysis with one version of Elasticsearch may fail with a different version. This indicates it behaves incorrectly in ways that the former version did not detect. You must work with the supplier of your storage system to address the incompatibilities detected by the repository analysis API in any version of Elasticsearch. NOTE: This API may not work correctly in a mixed-version cluster. *Implementation details* NOTE: This section of documentation describes how the repository analysis API works in this version of Elasticsearch, but you should expect the implementation to vary between versions. The request parameters and response format depend on details of the implementation so may also be different in newer versions. The analysis comprises a number of blob-level tasks, as set by the blob_count parameter and a number of compare-and-exchange operations on linearizable registers, as set by the register_operation_count parameter. These tasks are distributed over the data and master-eligible nodes in the cluster for execution. For most blob-level tasks, the executing node first writes a blob to the repository and then instructs some of the other nodes in the cluster to attempt to read the data it just wrote. The size of the blob is chosen randomly, according to the max_blob_size and max_total_data_size parameters. If any of these reads fails then the repository does not implement the necessary read-after-write semantics that Elasticsearch requires. For some blob-level tasks, the executing node will instruct some of its peers to attempt to read the data before the writing process completes. These reads are permitted to fail, but must not return partial data. If any read returns partial data then the repository does not implement the necessary atomicity semantics that Elasticsearch requires. For some blob-level tasks, the executing node will overwrite the blob while its peers are reading it. In this case the data read may come from either the original or the overwritten blob, but the read operation must not return partial data or a mix of data from the two blobs. If any of these reads returns partial data or a mix of the two blobs then the repository does not implement the necessary atomicity semantics that Elasticsearch requires for overwrites. The executing node will use a variety of different methods to write the blob. For instance, where applicable, it will use both single-part and multi-part uploads. Similarly, the reading nodes will use a variety of different methods to read the data back again. For instance they may read the entire blob from start to end or may read only a subset of the data. For some blob-level tasks, the executing node will cancel the write before it is complete. In this case, it still instructs some of the other nodes in the cluster to attempt to read the blob but all of these reads must fail to find the blob. Linearizable registers are special blobs that Elasticsearch manipulates using an atomic compare-and-exchange operation. This operation ensures correct and strongly-consistent behavior even when the blob is accessed by multiple nodes at the same time. The detailed implementation of the compare-and-exchange operation on linearizable registers varies by repository type. Repository analysis verifies that that uncontended compare-and-exchange operations on a linearizable register blob always succeed. Repository analysis also verifies that contended operations either succeed or report the contention but do not return incorrect results. If an operation fails due to contention, Elasticsearch retries the operation until it succeeds. Most of the compare-and-exchange operations performed by repository analysis atomically increment a counter which is represented as an 8-byte blob. Some operations also verify the behavior on small blobs with sizes other than 8 bytes.

Parameters:

  • arguments (Hash) (defaults to: {})

    a customizable set of options

Options Hash (arguments):

  • :repository (String)

    The name of the repository. (Required)

  • :blob_count (Integer)

    The total number of blobs to write to the repository during the test. For realistic experiments, you should set it to at least 2000. Server default: 100.

  • :concurrency (Integer)

    The number of operations to run concurrently during the test. Server default: 10.

  • :detailed (Boolean)

    Indicates whether to return detailed results, including timing information for every operation performed during the analysis. If false, it returns only a summary of the analysis.

  • :early_read_node_count (Integer)

    The number of nodes on which to perform an early read operation while writing each blob. Early read operations are only rarely performed. Server default: 2.

  • :max_blob_size (Integer, String)

    The maximum size of a blob to be written during the test. For realistic experiments, you should set it to at least 2gb. Server default: 10mb.

  • :max_total_data_size (Integer, String)

    An upper limit on the total size of all the blobs written during the test. For realistic experiments, you should set it to at least 1tb. Server default: 1gb.

  • :rare_action_probability (Float)

    The probability of performing a rare action such as an early read, an overwrite, or an aborted write on each blob. Server default: 0.02.

  • :rarely_abort_writes (Boolean)

    Indicates whether to rarely cancel writes before they complete. Server default: true.

  • :read_node_count (Integer)

    The number of nodes on which to read a blob after writing. Server default: 10.

  • :register_operation_count (Integer)

    The minimum number of linearizable register operations to perform in total. For realistic experiments, you should set it to at least 100. Server default: 10.

  • :seed (Integer)

    The seed for the pseudo-random number generator used to generate the list of operations performed during the test. To repeat the same set of operations in multiple experiments, use the same seed in each experiment. Note that the operations are performed concurrently so might not always happen in the same order on each run.

  • :timeout (Time)

    The period of time to wait for the test to complete. If no response is received before the timeout expires, the test is cancelled and returns an error. Server default: 30s.

  • :headers (Hash)

    Custom HTTP headers

Raises:

  • (ArgumentError)

See Also:



124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
# File 'lib/elasticsearch/api/actions/snapshot/repository_analyze.rb', line 124

def repository_analyze(arguments = {})
  request_opts = { endpoint: arguments[:endpoint] || 'snapshot.repository_analyze' }

  defined_params = [:repository].each_with_object({}) do |variable, set_variables|
    set_variables[variable] = arguments[variable] if arguments.key?(variable)
  end
  request_opts[:defined_params] = defined_params unless defined_params.empty?

  raise ArgumentError, "Required argument 'repository' missing" unless arguments[:repository]

  arguments = arguments.clone
  headers = arguments.delete(:headers) || {}

  body = nil

  _repository = arguments.delete(:repository)

  method = Elasticsearch::API::HTTP_POST
  path   = "_snapshot/#{Utils.listify(_repository)}/_analyze"
  params = Utils.process_params(arguments)

  Elasticsearch::API::Response.new(
    perform_request(method, path, params, body, headers, request_opts)
  )
end

#restore(arguments = {}) ⇒ Object

Restore a snapshot. Restore a snapshot of a cluster or data streams and indices. You can restore a snapshot only to a running cluster with an elected master node. The snapshot repository must be registered and available to the cluster. The snapshot and cluster versions must be compatible. To restore a snapshot, the cluster’s global metadata must be writable. Ensure there are’t any cluster blocks that prevent writes. The restore operation ignores index blocks. Before you restore a data stream, ensure the cluster contains a matching index template with data streams enabled. To check, use the index management feature in Kibana or the get index template API: + GET _index_template/*?filter_path=index_templates.name,index_templates.index_template.index_patterns,index_templates.index_template.data_stream + If no such template exists, you can create one or restore a cluster state that contains one. Without a matching index template, a data stream can’t roll over or create backing indices. If your snapshot contains data from App Search or Workplace Search, you must restore the Enterprise Search encryption key before you restore the snapshot.

Parameters:

  • arguments (Hash) (defaults to: {})

    a customizable set of options

Options Hash (arguments):

  • :repository (String)

    The name of the repository to restore a snapshot from. (Required)

  • :snapshot (String)

    The name of the snapshot to restore. (Required)

  • :master_timeout (Time)

    The period to wait for the master node. If the master node is not available before the timeout expires, the request fails and returns an error. To indicate that the request should never timeout, set it to -1. Server default: 30s.

  • :wait_for_completion (Boolean)

    If true, the request returns a response when the restore operation completes. The operation is complete when it finishes all attempts to recover primary shards for restored indices. This applies even if one or more of the recovery attempts fail.If false, the request returns a response when the restore operation initializes.

  • :headers (Hash)

    Custom HTTP headers

  • :body (Hash)

    request body

Raises:

  • (ArgumentError)

See Also:



51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# File 'lib/elasticsearch/api/actions/snapshot/restore.rb', line 51

def restore(arguments = {})
  request_opts = { endpoint: arguments[:endpoint] || 'snapshot.restore' }

  defined_params = [:repository, :snapshot].each_with_object({}) do |variable, set_variables|
    set_variables[variable] = arguments[variable] if arguments.key?(variable)
  end
  request_opts[:defined_params] = defined_params unless defined_params.empty?

  raise ArgumentError, "Required argument 'repository' missing" unless arguments[:repository]
  raise ArgumentError, "Required argument 'snapshot' missing" unless arguments[:snapshot]

  arguments = arguments.clone
  headers = arguments.delete(:headers) || {}

  body = arguments.delete(:body)

  _repository = arguments.delete(:repository)

  _snapshot = arguments.delete(:snapshot)

  method = Elasticsearch::API::HTTP_POST
  path   = "_snapshot/#{Utils.listify(_repository)}/#{Utils.listify(_snapshot)}/_restore"
  params = Utils.process_params(arguments)

  Elasticsearch::API::Response.new(
    perform_request(method, path, params, body, headers, request_opts)
  )
end

#status(arguments = {}) ⇒ Object

Get the snapshot status. Get a detailed description of the current state for each shard participating in the snapshot. Note that this API should be used only to obtain detailed shard-level information for ongoing snapshots. If this detail is not needed or you want to obtain information about one or more existing snapshots, use the get snapshot API. If you omit the <snapshot> request path parameter, the request retrieves information only for currently running snapshots. This usage is preferred. If needed, you can specify <repository> and <snapshot> to retrieve information for specific snapshots, even if they’re not currently running. WARNING: Using the API to return the status of any snapshots other than currently running snapshots can be expensive. The API requires a read from the repository for each shard in each snapshot. For example, if you have 100 snapshots with 1,000 shards each, an API request that includes all snapshots will require 100,000 reads (100 snapshots x 1,000 shards). Depending on the latency of your storage, such requests can take an extremely long time to return results. These requests can also tax machine resources and, when using cloud storage, incur high processing costs.

Parameters:

  • arguments (Hash) (defaults to: {})

    a customizable set of options

Options Hash (arguments):

  • :repository (String)

    The snapshot repository name used to limit the request. It supports wildcards (+*+) if <snapshot> isn’t specified.

  • :snapshot (String, Array<String>)

    A comma-separated list of snapshots to retrieve status for. The default is currently running snapshots. Wildcards (+*+) are not supported.

  • :ignore_unavailable (Boolean)

    If false, the request returns an error for any snapshots that are unavailable. If true, the request ignores snapshots that are unavailable, such as those that are corrupted or temporarily cannot be returned.

  • :master_timeout (Time)

    The period to wait for the master node. If the master node is not available before the timeout expires, the request fails and returns an error. To indicate that the request should never timeout, set it to -1. Server default: 30s.

  • :headers (Hash)

    Custom HTTP headers

See Also:



52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# File 'lib/elasticsearch/api/actions/snapshot/status.rb', line 52

def status(arguments = {})
  request_opts = { endpoint: arguments[:endpoint] || 'snapshot.status' }

  defined_params = [:repository, :snapshot].each_with_object({}) do |variable, set_variables|
    set_variables[variable] = arguments[variable] if arguments.key?(variable)
  end
  request_opts[:defined_params] = defined_params unless defined_params.empty?

  arguments = arguments.clone
  headers = arguments.delete(:headers) || {}

  body = nil

  _repository = arguments.delete(:repository)

  _snapshot = arguments.delete(:snapshot)

  method = Elasticsearch::API::HTTP_GET
  path   = if _repository && _snapshot
             "_snapshot/#{Utils.listify(_repository)}/#{Utils.listify(_snapshot)}/_status"
           elsif _repository
             "_snapshot/#{Utils.listify(_repository)}/_status"
           else
             '_snapshot/_status'
           end
  params = Utils.process_params(arguments)

  if Array(arguments[:ignore]).include?(404)
    Utils.rescue_from_not_found do
      Elasticsearch::API::Response.new(
        perform_request(method, path, params, body, headers, request_opts)
      )
    end
  else
    Elasticsearch::API::Response.new(
      perform_request(method, path, params, body, headers, request_opts)
    )
  end
end

#verify_repository(arguments = {}) ⇒ Object

Verify a snapshot repository. Check for common misconfigurations in a snapshot repository.

Parameters:

  • arguments (Hash) (defaults to: {})

    a customizable set of options

Options Hash (arguments):

  • :repository (String)

    The name of the snapshot repository to verify. (Required)

  • :master_timeout (Time)

    The period to wait for the master node. If the master node is not available before the timeout expires, the request fails and returns an error. To indicate that the request should never timeout, set it to -1. Server default: 30s.

  • :timeout (Time)

    The period to wait for a response from all relevant nodes in the cluster after updating the cluster metadata. If no response is received before the timeout expires, the cluster metadata update still applies but the response will indicate that it was not completely acknowledged. To indicate that the request should never timeout, set it to -1. Server default: 30s.

  • :headers (Hash)

    Custom HTTP headers

Raises:

  • (ArgumentError)

See Also:



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/elasticsearch/api/actions/snapshot/verify_repository.rb', line 39

def verify_repository(arguments = {})
  request_opts = { endpoint: arguments[:endpoint] || 'snapshot.verify_repository' }

  defined_params = [:repository].each_with_object({}) do |variable, set_variables|
    set_variables[variable] = arguments[variable] if arguments.key?(variable)
  end
  request_opts[:defined_params] = defined_params unless defined_params.empty?

  raise ArgumentError, "Required argument 'repository' missing" unless arguments[:repository]

  arguments = arguments.clone
  headers = arguments.delete(:headers) || {}

  body = nil

  _repository = arguments.delete(:repository)

  method = Elasticsearch::API::HTTP_POST
  path   = "_snapshot/#{Utils.listify(_repository)}/_verify"
  params = Utils.process_params(arguments)

  Elasticsearch::API::Response.new(
    perform_request(method, path, params, body, headers, request_opts)
  )
end