def test_get_set_restart_strategy(self):

        self.execution_config.set_restart_strategy(
            RestartStrategies.no_restart())

        self.assertEqual(self.execution_config.get_restart_strategy(),
                         RestartStrategies.no_restart())

        self.execution_config.set_restart_strategy(
            RestartStrategies.failure_rate_restart(5, 10000, 5000))

        self.assertIsInstance(
            self.execution_config.get_restart_strategy(),
            RestartStrategies.FailureRateRestartStrategyConfiguration)

        self.execution_config.set_restart_strategy(
            RestartStrategies.fixed_delay_restart(4, 10000))

        self.assertIsInstance(
            self.execution_config.get_restart_strategy(),
            RestartStrategies.FixedDelayRestartStrategyConfiguration)

        self.execution_config.set_restart_strategy(
            RestartStrategies.fall_back_restart())

        self.assertEqual(self.execution_config.get_restart_strategy(),
                         RestartStrategies.fall_back_restart())
def env_setting(env: StreamExecutionEnvironment):
    """
    设置环境
    :param env:
    :return:
    """
    # 配置检查点周期5分钟, 至少一次
    env.enable_checkpointing(60 * 1000 * 5, CheckpointingMode.AT_LEAST_ONCE)
    # 上一个检查点与下一个检查点之间必须间隔 3 分钟启动
    env.get_checkpoint_config().set_min_pause_between_checkpoints(60 * 1000 *
                                                                  3)
    # 设置检查点超时40分钟
    env.get_checkpoint_config().set_checkpoint_timeout(60 * 1000 * 40)
    # 固定间隔重启策略 5分钟内若失败了3次则认为该job失败,重试间隔为30s
    env.set_restart_strategy(
        RestartStrategies.failure_rate_restart(3, timedelta(minutes=5),
                                               timedelta(seconds=30)))