Restore Class¶
Restore¶
- class es_wait.restore.Restore(client: Elasticsearch, pause: float = 9.0, timeout: float = 7200.0, max_exceptions: int = 10, index_list: Sequence[str] | None = None)¶
Bases:
WaiterWait for a snapshot to restore
- add_exception(value: Exception) None¶
This method appends value the exceptions list.
- Parameters:
value (Exception) – An exception to add
- announce() None¶
This method is called when the Waiter class is initialized. It logs a level 1 debug message using
waitstr.
- check() bool¶
Iterates over a list of indices in batched chunks, and calls
get_recovery()for each batch, updating a localresponsedict with each successive result.For each entry in
responseit will evaluate the shards from each index for which stage they are.The method will return
Trueif all shards for all indices inindex_listare at stageDONE, andFalseotherwise.This check is designed to fail fast: if a single shard is encountered that is still recovering (not in
DONEstage), it will immediately returnFalse, rather than complete iterating over the rest of the response.- Getter:
Returns if the check was complete
- Type:
- client¶
An
Elasticsearchclient instance
- do_health_report¶
Only changes to True in certain circumstances
- property exception_count_msg: str¶
This property returns a messgage showing the current number of exceptions raised and the maximum number of exceptions allowed.
- Getter:
Returns ‘X exceptions raised out of Y allowed’
- Type:
- property exceptions: list¶
This property returns a list of exceptions raised during the wait.
- Getter:
Returns a list of exceptions raised
- Type:
- exceptions_raised¶
The number of exceptions raised
- get_recovery(chunk: Sequence[str]) Dict¶
Calls
indices.recovery()with a list of indices to check for complete recovery.Returns the response, or raises a
ValueErrorif it is unable to get a response.- Parameters:
chunk (list) – A list of index names
- Raises:
ValueError – If the indices are not recoverable
- Returns:
The response from the recovery API for the provided chunk
- Return type:
- index_list¶
The list of indices being restored
- property index_list_chunks: Sequence[Sequence[str]]¶
This utility chunks very large index lists into 3KB chunks. It measures the size as a csv string, then converts back into a list for the return value.
Pulls this data from
index_list- Getter:
Returns a list of smaller chunks of
index_listin lists- Type:
- max_exceptions¶
The maximum number of exceptions to allow
- pause¶
The delay between checks for completion
- timeout¶
The number of seconds before giving up. -1 means no timeout.
- too_many_exceptions() None¶
If the number of exceptions raised is greater than or equal to the maximum number of exceptions allowed, then a
ExceptionCountwill be raised.
- wait(frequency: int = 5) None¶
This method is where the actual waiting occurs. Depending on what frequency is set to, you should see non-DEBUG level logs no more than every frequency seconds.
If
timeouthas been reached withoutcheck()returning asTrue, then aTimeoutErrorwill be raised.If
check()returnsFalse, then the method will waitpauseseconds before callingcheck()again.Elapsed time will be logged every frequency seconds, when
check()isTrue, or whentimeoutis reached.If
do_health_reportisTrue, then callclient.health_report()and pass the results toutils.health_report().- Parameters:
frequency – The number of seconds between log reports on progress.