Relocate Class¶
Relocate¶
- class es_wait.relocate.Relocate(client: Elasticsearch, pause: float = 9.0, timeout: float = 3600.0, max_exceptions: int = 10, name: str | None = None)¶
Bases:
WaiterWait for an index to relocate
The
Relocateclass is a subclass ofWaiterand is used to wait for an index to finish relocating.- Note:
See defaults.py for default values.
- Parameters:
client (Elasticsearch client) – The Elasticsearch client
pause (float) – The pause time between checks (default is defaults.RELOCATE_PAUSE seconds)
timeout (float) – The time to wait before giving up (default is defaults.RELOCATE_TIMEOUT seconds)
max_exceptions (int) – The maximum number of exceptions to allow (default is defaults.MAX_EXCEPTIONS)
name (str) – The index name
- Raises:
ValueError – If the index name is not provided
- 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¶
This method gets the value from property
finished_state()and returns that value.- Returns:
Returns if the check was complete
- Return 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
- property finished_state: bool¶
Return the boolean state of whether all shards in the index are ‘STARTED’
The
all()function returns True if all items in an iterable are true, otherwise it returns False. We use it twice here, nested.Gets this from property
routing_table()- Getter:
Returns whether the shards are all
STARTED- Type:
- max_exceptions¶
The maximum number of exceptions to allow
- name¶
The index name
- pause¶
The delay between checks for completion
- routing_table() Dict[str, List[Dict[str, str]]]¶
This method calls
cluster.state()to get the shard routing table. As the cluster state API result can be quite large, it uses afilter_pathto drastically reduce the result size. This path is:f'routing_table.indices.{self.name}'
It will raise a
ValueErroron an exception to this API call.It will then try to return
return result['routing_table']['indices'][self.name]['shards']
- 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.