A policy that describes whether to retry, rethrow, or ignore coordinator timeout and unavailable failures. These are failures reported from the server side. Timeouts are configured by `settings in cassandra.yaml <https://github.com/apache/cassandra/blob/cassandra-2.1.4/conf/cassandr
| 712 | |
| 713 | |
| 714 | class RetryPolicy(object): |
| 715 | """ |
| 716 | A policy that describes whether to retry, rethrow, or ignore coordinator |
| 717 | timeout and unavailable failures. These are failures reported from the |
| 718 | server side. Timeouts are configured by |
| 719 | `settings in cassandra.yaml <https://github.com/apache/cassandra/blob/cassandra-2.1.4/conf/cassandra.yaml#L568-L584>`_. |
| 720 | Unavailable failures occur when the coordinator cannot achieve the consistency |
| 721 | level for a request. For further information see the method descriptions |
| 722 | below. |
| 723 | |
| 724 | To specify a default retry policy, set the |
| 725 | :attr:`.Cluster.default_retry_policy` attribute to an instance of this |
| 726 | class or one of its subclasses. |
| 727 | |
| 728 | To specify a retry policy per query, set the :attr:`.Statement.retry_policy` |
| 729 | attribute to an instance of this class or one of its subclasses. |
| 730 | |
| 731 | If custom behavior is needed for retrying certain operations, |
| 732 | this class may be subclassed. |
| 733 | """ |
| 734 | |
| 735 | RETRY = 0 |
| 736 | """ |
| 737 | This should be returned from the below methods if the operation |
| 738 | should be retried on the same connection. |
| 739 | """ |
| 740 | |
| 741 | RETHROW = 1 |
| 742 | """ |
| 743 | This should be returned from the below methods if the failure |
| 744 | should be propagated and no more retries attempted. |
| 745 | """ |
| 746 | |
| 747 | IGNORE = 2 |
| 748 | """ |
| 749 | This should be returned from the below methods if the failure |
| 750 | should be ignored but no more retries should be attempted. |
| 751 | """ |
| 752 | |
| 753 | RETRY_NEXT_HOST = 3 |
| 754 | """ |
| 755 | This should be returned from the below methods if the operation |
| 756 | should be retried on another connection. |
| 757 | """ |
| 758 | |
| 759 | def on_read_timeout(self, query, consistency, required_responses, |
| 760 | received_responses, data_retrieved, retry_num): |
| 761 | """ |
| 762 | This is called when a read operation times out from the coordinator's |
| 763 | perspective (i.e. a replica did not respond to the coordinator in time). |
| 764 | It should return a tuple with two items: one of the class enums (such |
| 765 | as :attr:`.RETRY`) and a :class:`.ConsistencyLevel` to retry the |
| 766 | operation at or :const:`None` to keep the same consistency level. |
| 767 | |
| 768 | `query` is the :class:`.Statement` that timed out. |
| 769 | |
| 770 | `consistency` is the :class:`.ConsistencyLevel` that the operation was |
| 771 | attempted at. |
no outgoing calls