You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flink.apache.org by pn...@apache.org on 2021/09/03 13:53:37 UTC
[flink] 01/02: [FLINK-23916][python] Add python API to set
tolerable checkpoint failure number
This is an automated email from the ASF dual-hosted git repository.
pnowojski pushed a commit to branch release-1.14
in repository https://gitbox.apache.org/repos/asf/flink.git
commit e24ebeac78afc6df9842b3ee6419af1c752d603b
Author: Piotr Nowojski <pi...@gmail.com>
AuthorDate: Wed Sep 1 15:54:32 2021 +0200
[FLINK-23916][python] Add python API to set tolerable checkpoint failure number
---
.../pyflink/datastream/checkpoint_config.py | 29 ++++++++++++++++++++++
.../datastream/tests/test_check_point_config.py | 8 ++++++
2 files changed, 37 insertions(+)
diff --git a/flink-python/pyflink/datastream/checkpoint_config.py b/flink-python/pyflink/datastream/checkpoint_config.py
index 8ab2918..4119a91 100644
--- a/flink-python/pyflink/datastream/checkpoint_config.py
+++ b/flink-python/pyflink/datastream/checkpoint_config.py
@@ -214,6 +214,35 @@ class CheckpointConfig(object):
self._j_checkpoint_config.setFailOnCheckpointingErrors(fail_on_checkpointing_errors)
return self
+ def get_tolerable_checkpoint_failure_number(self) -> int:
+ """
+ Get the defined number of consecutive checkpoint failures that will be tolerated, before the
+ whole job is failed over.
+
+ :return: The maximum number of tolerated checkpoint failures.
+ """
+ return self._j_checkpoint_config.getTolerableCheckpointFailureNumber()
+
+ def set_tolerable_checkpoint_failure_number(self,
+ tolerable_checkpoint_failure_number: int
+ ) -> 'CheckpointConfig':
+ """
+ This defines how many consecutive checkpoint failures will be tolerated, before the whole
+ job is failed over. The default value is `0`, which means no checkpoint failures will be
+ tolerated, and the job will fail on first reported checkpoint failure.
+
+ Example:
+ ::
+
+ >>> config.set_tolerable_checkpoint_failure_number(2)
+
+ :param tolerable_checkpoint_failure_number: The maximum number of tolerated checkpoint
+ failures.
+ """
+ self._j_checkpoint_config.setTolerableCheckpointFailureNumber(
+ tolerable_checkpoint_failure_number)
+ return self
+
def enable_externalized_checkpoints(
self,
cleanup_mode: 'ExternalizedCheckpointCleanup') -> 'CheckpointConfig':
diff --git a/flink-python/pyflink/datastream/tests/test_check_point_config.py b/flink-python/pyflink/datastream/tests/test_check_point_config.py
index d4fcb9c..11420f1 100644
--- a/flink-python/pyflink/datastream/tests/test_check_point_config.py
+++ b/flink-python/pyflink/datastream/tests/test_check_point_config.py
@@ -109,6 +109,14 @@ class CheckpointConfigTests(PyFlinkTestCase):
self.assertFalse(self.checkpoint_config.is_fail_on_checkpointing_errors())
+ def test_get_set_tolerable_checkpoint_failure_number(self):
+
+ self.assertEqual(self.checkpoint_config.get_tolerable_checkpoint_failure_number(), 0)
+
+ self.checkpoint_config.set_tolerable_checkpoint_failure_number(2)
+
+ self.assertEqual(self.checkpoint_config.get_tolerable_checkpoint_failure_number(), 2)
+
def test_get_set_externalized_checkpoints_cleanup(self):
self.assertFalse(self.checkpoint_config.is_externalized_checkpoints_enabled())