def enable_checkpointing(self, interval: int, mode: CheckpointingMode = None) \ -> 'StreamExecutionEnvironment': """ Enables checkpointing for the streaming job. The distributed state of the streaming dataflow will be periodically snapshotted. In case of a failure, the streaming dataflow will be restarted from the latest completed checkpoint. The job draws checkpoints periodically, in the given interval. The system uses the given :class:`~pyflink.datastream.CheckpointingMode` for the checkpointing ("exactly once" vs "at least once"). The state will be stored in the configured state backend. .. note:: Checkpointing iterative streaming dataflows in not properly supported at the moment. For that reason, iterative jobs will not be started if used with enabled checkpointing. Example: :: >>> env.enable_checkpointing(300000, CheckpointingMode.AT_LEAST_ONCE) :param interval: Time interval between state checkpoints in milliseconds. :param mode: The checkpointing mode, selecting between "exactly once" and "at least once" guaranteed. :return: This object. """ if mode is None: self._j_stream_execution_environment = \ self._j_stream_execution_environment.enableCheckpointing(interval) else: j_checkpointing_mode = CheckpointingMode._to_j_checkpointing_mode(mode) self._j_stream_execution_environment.enableCheckpointing( interval, j_checkpointing_mode) return self
def get_checkpointing_mode(self) -> CheckpointingMode: """ Returns the checkpointing mode (exactly-once vs. at-least-once). Shorthand for get_checkpoint_config().get_checkpointing_mode(). :return: The :class:`~pyflink.datastream.CheckpointingMode`. """ j_checkpointing_mode = self._j_stream_execution_environment.getCheckpointingMode() return CheckpointingMode._from_j_checkpointing_mode(j_checkpointing_mode)
def get_checkpointing_mode(self) -> CheckpointingMode: """ Gets the checkpointing mode (exactly-once vs. at-least-once). .. seealso:: :func:`set_checkpointing_mode` :return: The :class:`CheckpointingMode`. """ return CheckpointingMode._from_j_checkpointing_mode( self._j_checkpoint_config.getCheckpointingMode())
def set_checkpointing_mode(self, checkpointing_mode): """ Sets the checkpointing mode (:data:`CheckpointingMode.EXACTLY_ONCE` vs. :data:`CheckpointingMode.AT_LEAST_ONCE`). Example: :: >>> config.set_checkpointing_mode(CheckpointingMode.AT_LEAST_ONCE) :param checkpointing_mode: The :class:`CheckpointingMode`. """ self._j_checkpoint_config.setCheckpointingMode( CheckpointingMode._to_j_checkpointing_mode(checkpointing_mode))