{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.KinesisAnalyticsV2.Types.CheckpointConfiguration
-- Copyright   : (c) 2013-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.KinesisAnalyticsV2.Types.CheckpointConfiguration where

import qualified Amazonka.Core as Core
import Amazonka.KinesisAnalyticsV2.Types.ConfigurationType
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Describes an application\'s checkpointing configuration. Checkpointing
-- is the process of persisting application state for fault tolerance. For
-- more information, see
-- <https://ci.apache.org/projects/flink/flink-docs-release-1.8/concepts/programming-model.html#checkpoints-for-fault-tolerance Checkpoints for Fault Tolerance>
-- in the
-- <https://ci.apache.org/projects/flink/flink-docs-release-1.8/ Apache Flink Documentation>.
--
-- /See:/ 'newCheckpointConfiguration' smart constructor.
data CheckpointConfiguration = CheckpointConfiguration'
  { -- | Describes whether checkpointing is enabled for a Flink-based Kinesis
    -- Data Analytics application.
    --
    -- If @CheckpointConfiguration.ConfigurationType@ is @DEFAULT@, the
    -- application will use a @CheckpointingEnabled@ value of @true@, even if
    -- this value is set to another value using this API or in application
    -- code.
    CheckpointConfiguration -> Maybe Bool
checkpointingEnabled :: Prelude.Maybe Prelude.Bool,
    -- | Describes the minimum time in milliseconds after a checkpoint operation
    -- completes that a new checkpoint operation can start. If a checkpoint
    -- operation takes longer than the @CheckpointInterval@, the application
    -- otherwise performs continual checkpoint operations. For more
    -- information, see
    -- <https://ci.apache.org/projects/flink/flink-docs-release-1.8/ops/state/large_state_tuning.html#tuning-checkpointing Tuning Checkpointing>
    -- in the
    -- <https://ci.apache.org/projects/flink/flink-docs-release-1.8/ Apache Flink Documentation>.
    --
    -- If @CheckpointConfiguration.ConfigurationType@ is @DEFAULT@, the
    -- application will use a @MinPauseBetweenCheckpoints@ value of 5000, even
    -- if this value is set using this API or in application code.
    CheckpointConfiguration -> Maybe Natural
minPauseBetweenCheckpoints :: Prelude.Maybe Prelude.Natural,
    -- | Describes the interval in milliseconds between checkpoint operations.
    --
    -- If @CheckpointConfiguration.ConfigurationType@ is @DEFAULT@, the
    -- application will use a @CheckpointInterval@ value of 60000, even if this
    -- value is set to another value using this API or in application code.
    CheckpointConfiguration -> Maybe Natural
checkpointInterval :: Prelude.Maybe Prelude.Natural,
    -- | Describes whether the application uses Kinesis Data Analytics\' default
    -- checkpointing behavior. You must set this property to @CUSTOM@ in order
    -- to set the @CheckpointingEnabled@, @CheckpointInterval@, or
    -- @MinPauseBetweenCheckpoints@ parameters.
    --
    -- If this value is set to @DEFAULT@, the application will use the
    -- following values, even if they are set to other values using APIs or
    -- application code:
    --
    -- -   __CheckpointingEnabled:__ true
    --
    -- -   __CheckpointInterval:__ 60000
    --
    -- -   __MinPauseBetweenCheckpoints:__ 5000
    CheckpointConfiguration -> ConfigurationType
configurationType :: ConfigurationType
  }
  deriving (CheckpointConfiguration -> CheckpointConfiguration -> Bool
(CheckpointConfiguration -> CheckpointConfiguration -> Bool)
-> (CheckpointConfiguration -> CheckpointConfiguration -> Bool)
-> Eq CheckpointConfiguration
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CheckpointConfiguration -> CheckpointConfiguration -> Bool
$c/= :: CheckpointConfiguration -> CheckpointConfiguration -> Bool
== :: CheckpointConfiguration -> CheckpointConfiguration -> Bool
$c== :: CheckpointConfiguration -> CheckpointConfiguration -> Bool
Prelude.Eq, ReadPrec [CheckpointConfiguration]
ReadPrec CheckpointConfiguration
Int -> ReadS CheckpointConfiguration
ReadS [CheckpointConfiguration]
(Int -> ReadS CheckpointConfiguration)
-> ReadS [CheckpointConfiguration]
-> ReadPrec CheckpointConfiguration
-> ReadPrec [CheckpointConfiguration]
-> Read CheckpointConfiguration
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CheckpointConfiguration]
$creadListPrec :: ReadPrec [CheckpointConfiguration]
readPrec :: ReadPrec CheckpointConfiguration
$creadPrec :: ReadPrec CheckpointConfiguration
readList :: ReadS [CheckpointConfiguration]
$creadList :: ReadS [CheckpointConfiguration]
readsPrec :: Int -> ReadS CheckpointConfiguration
$creadsPrec :: Int -> ReadS CheckpointConfiguration
Prelude.Read, Int -> CheckpointConfiguration -> ShowS
[CheckpointConfiguration] -> ShowS
CheckpointConfiguration -> String
(Int -> CheckpointConfiguration -> ShowS)
-> (CheckpointConfiguration -> String)
-> ([CheckpointConfiguration] -> ShowS)
-> Show CheckpointConfiguration
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CheckpointConfiguration] -> ShowS
$cshowList :: [CheckpointConfiguration] -> ShowS
show :: CheckpointConfiguration -> String
$cshow :: CheckpointConfiguration -> String
showsPrec :: Int -> CheckpointConfiguration -> ShowS
$cshowsPrec :: Int -> CheckpointConfiguration -> ShowS
Prelude.Show, (forall x.
 CheckpointConfiguration -> Rep CheckpointConfiguration x)
-> (forall x.
    Rep CheckpointConfiguration x -> CheckpointConfiguration)
-> Generic CheckpointConfiguration
forall x. Rep CheckpointConfiguration x -> CheckpointConfiguration
forall x. CheckpointConfiguration -> Rep CheckpointConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CheckpointConfiguration x -> CheckpointConfiguration
$cfrom :: forall x. CheckpointConfiguration -> Rep CheckpointConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'CheckpointConfiguration' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'checkpointingEnabled', 'checkpointConfiguration_checkpointingEnabled' - Describes whether checkpointing is enabled for a Flink-based Kinesis
-- Data Analytics application.
--
-- If @CheckpointConfiguration.ConfigurationType@ is @DEFAULT@, the
-- application will use a @CheckpointingEnabled@ value of @true@, even if
-- this value is set to another value using this API or in application
-- code.
--
-- 'minPauseBetweenCheckpoints', 'checkpointConfiguration_minPauseBetweenCheckpoints' - Describes the minimum time in milliseconds after a checkpoint operation
-- completes that a new checkpoint operation can start. If a checkpoint
-- operation takes longer than the @CheckpointInterval@, the application
-- otherwise performs continual checkpoint operations. For more
-- information, see
-- <https://ci.apache.org/projects/flink/flink-docs-release-1.8/ops/state/large_state_tuning.html#tuning-checkpointing Tuning Checkpointing>
-- in the
-- <https://ci.apache.org/projects/flink/flink-docs-release-1.8/ Apache Flink Documentation>.
--
-- If @CheckpointConfiguration.ConfigurationType@ is @DEFAULT@, the
-- application will use a @MinPauseBetweenCheckpoints@ value of 5000, even
-- if this value is set using this API or in application code.
--
-- 'checkpointInterval', 'checkpointConfiguration_checkpointInterval' - Describes the interval in milliseconds between checkpoint operations.
--
-- If @CheckpointConfiguration.ConfigurationType@ is @DEFAULT@, the
-- application will use a @CheckpointInterval@ value of 60000, even if this
-- value is set to another value using this API or in application code.
--
-- 'configurationType', 'checkpointConfiguration_configurationType' - Describes whether the application uses Kinesis Data Analytics\' default
-- checkpointing behavior. You must set this property to @CUSTOM@ in order
-- to set the @CheckpointingEnabled@, @CheckpointInterval@, or
-- @MinPauseBetweenCheckpoints@ parameters.
--
-- If this value is set to @DEFAULT@, the application will use the
-- following values, even if they are set to other values using APIs or
-- application code:
--
-- -   __CheckpointingEnabled:__ true
--
-- -   __CheckpointInterval:__ 60000
--
-- -   __MinPauseBetweenCheckpoints:__ 5000
newCheckpointConfiguration ::
  -- | 'configurationType'
  ConfigurationType ->
  CheckpointConfiguration
newCheckpointConfiguration :: ConfigurationType -> CheckpointConfiguration
newCheckpointConfiguration ConfigurationType
pConfigurationType_ =
  CheckpointConfiguration' :: Maybe Bool
-> Maybe Natural
-> Maybe Natural
-> ConfigurationType
-> CheckpointConfiguration
CheckpointConfiguration'
    { $sel:checkpointingEnabled:CheckpointConfiguration' :: Maybe Bool
checkpointingEnabled =
        Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:minPauseBetweenCheckpoints:CheckpointConfiguration' :: Maybe Natural
minPauseBetweenCheckpoints = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:checkpointInterval:CheckpointConfiguration' :: Maybe Natural
checkpointInterval = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:configurationType:CheckpointConfiguration' :: ConfigurationType
configurationType = ConfigurationType
pConfigurationType_
    }

-- | Describes whether checkpointing is enabled for a Flink-based Kinesis
-- Data Analytics application.
--
-- If @CheckpointConfiguration.ConfigurationType@ is @DEFAULT@, the
-- application will use a @CheckpointingEnabled@ value of @true@, even if
-- this value is set to another value using this API or in application
-- code.
checkpointConfiguration_checkpointingEnabled :: Lens.Lens' CheckpointConfiguration (Prelude.Maybe Prelude.Bool)
checkpointConfiguration_checkpointingEnabled :: (Maybe Bool -> f (Maybe Bool))
-> CheckpointConfiguration -> f CheckpointConfiguration
checkpointConfiguration_checkpointingEnabled = (CheckpointConfiguration -> Maybe Bool)
-> (CheckpointConfiguration
    -> Maybe Bool -> CheckpointConfiguration)
-> Lens
     CheckpointConfiguration
     CheckpointConfiguration
     (Maybe Bool)
     (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CheckpointConfiguration' {Maybe Bool
checkpointingEnabled :: Maybe Bool
$sel:checkpointingEnabled:CheckpointConfiguration' :: CheckpointConfiguration -> Maybe Bool
checkpointingEnabled} -> Maybe Bool
checkpointingEnabled) (\s :: CheckpointConfiguration
s@CheckpointConfiguration' {} Maybe Bool
a -> CheckpointConfiguration
s {$sel:checkpointingEnabled:CheckpointConfiguration' :: Maybe Bool
checkpointingEnabled = Maybe Bool
a} :: CheckpointConfiguration)

-- | Describes the minimum time in milliseconds after a checkpoint operation
-- completes that a new checkpoint operation can start. If a checkpoint
-- operation takes longer than the @CheckpointInterval@, the application
-- otherwise performs continual checkpoint operations. For more
-- information, see
-- <https://ci.apache.org/projects/flink/flink-docs-release-1.8/ops/state/large_state_tuning.html#tuning-checkpointing Tuning Checkpointing>
-- in the
-- <https://ci.apache.org/projects/flink/flink-docs-release-1.8/ Apache Flink Documentation>.
--
-- If @CheckpointConfiguration.ConfigurationType@ is @DEFAULT@, the
-- application will use a @MinPauseBetweenCheckpoints@ value of 5000, even
-- if this value is set using this API or in application code.
checkpointConfiguration_minPauseBetweenCheckpoints :: Lens.Lens' CheckpointConfiguration (Prelude.Maybe Prelude.Natural)
checkpointConfiguration_minPauseBetweenCheckpoints :: (Maybe Natural -> f (Maybe Natural))
-> CheckpointConfiguration -> f CheckpointConfiguration
checkpointConfiguration_minPauseBetweenCheckpoints = (CheckpointConfiguration -> Maybe Natural)
-> (CheckpointConfiguration
    -> Maybe Natural -> CheckpointConfiguration)
-> Lens
     CheckpointConfiguration
     CheckpointConfiguration
     (Maybe Natural)
     (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CheckpointConfiguration' {Maybe Natural
minPauseBetweenCheckpoints :: Maybe Natural
$sel:minPauseBetweenCheckpoints:CheckpointConfiguration' :: CheckpointConfiguration -> Maybe Natural
minPauseBetweenCheckpoints} -> Maybe Natural
minPauseBetweenCheckpoints) (\s :: CheckpointConfiguration
s@CheckpointConfiguration' {} Maybe Natural
a -> CheckpointConfiguration
s {$sel:minPauseBetweenCheckpoints:CheckpointConfiguration' :: Maybe Natural
minPauseBetweenCheckpoints = Maybe Natural
a} :: CheckpointConfiguration)

-- | Describes the interval in milliseconds between checkpoint operations.
--
-- If @CheckpointConfiguration.ConfigurationType@ is @DEFAULT@, the
-- application will use a @CheckpointInterval@ value of 60000, even if this
-- value is set to another value using this API or in application code.
checkpointConfiguration_checkpointInterval :: Lens.Lens' CheckpointConfiguration (Prelude.Maybe Prelude.Natural)
checkpointConfiguration_checkpointInterval :: (Maybe Natural -> f (Maybe Natural))
-> CheckpointConfiguration -> f CheckpointConfiguration
checkpointConfiguration_checkpointInterval = (CheckpointConfiguration -> Maybe Natural)
-> (CheckpointConfiguration
    -> Maybe Natural -> CheckpointConfiguration)
-> Lens
     CheckpointConfiguration
     CheckpointConfiguration
     (Maybe Natural)
     (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CheckpointConfiguration' {Maybe Natural
checkpointInterval :: Maybe Natural
$sel:checkpointInterval:CheckpointConfiguration' :: CheckpointConfiguration -> Maybe Natural
checkpointInterval} -> Maybe Natural
checkpointInterval) (\s :: CheckpointConfiguration
s@CheckpointConfiguration' {} Maybe Natural
a -> CheckpointConfiguration
s {$sel:checkpointInterval:CheckpointConfiguration' :: Maybe Natural
checkpointInterval = Maybe Natural
a} :: CheckpointConfiguration)

-- | Describes whether the application uses Kinesis Data Analytics\' default
-- checkpointing behavior. You must set this property to @CUSTOM@ in order
-- to set the @CheckpointingEnabled@, @CheckpointInterval@, or
-- @MinPauseBetweenCheckpoints@ parameters.
--
-- If this value is set to @DEFAULT@, the application will use the
-- following values, even if they are set to other values using APIs or
-- application code:
--
-- -   __CheckpointingEnabled:__ true
--
-- -   __CheckpointInterval:__ 60000
--
-- -   __MinPauseBetweenCheckpoints:__ 5000
checkpointConfiguration_configurationType :: Lens.Lens' CheckpointConfiguration ConfigurationType
checkpointConfiguration_configurationType :: (ConfigurationType -> f ConfigurationType)
-> CheckpointConfiguration -> f CheckpointConfiguration
checkpointConfiguration_configurationType = (CheckpointConfiguration -> ConfigurationType)
-> (CheckpointConfiguration
    -> ConfigurationType -> CheckpointConfiguration)
-> Lens
     CheckpointConfiguration
     CheckpointConfiguration
     ConfigurationType
     ConfigurationType
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CheckpointConfiguration' {ConfigurationType
configurationType :: ConfigurationType
$sel:configurationType:CheckpointConfiguration' :: CheckpointConfiguration -> ConfigurationType
configurationType} -> ConfigurationType
configurationType) (\s :: CheckpointConfiguration
s@CheckpointConfiguration' {} ConfigurationType
a -> CheckpointConfiguration
s {$sel:configurationType:CheckpointConfiguration' :: ConfigurationType
configurationType = ConfigurationType
a} :: CheckpointConfiguration)

instance Prelude.Hashable CheckpointConfiguration

instance Prelude.NFData CheckpointConfiguration

instance Core.ToJSON CheckpointConfiguration where
  toJSON :: CheckpointConfiguration -> Value
toJSON CheckpointConfiguration' {Maybe Bool
Maybe Natural
ConfigurationType
configurationType :: ConfigurationType
checkpointInterval :: Maybe Natural
minPauseBetweenCheckpoints :: Maybe Natural
checkpointingEnabled :: Maybe Bool
$sel:configurationType:CheckpointConfiguration' :: CheckpointConfiguration -> ConfigurationType
$sel:checkpointInterval:CheckpointConfiguration' :: CheckpointConfiguration -> Maybe Natural
$sel:minPauseBetweenCheckpoints:CheckpointConfiguration' :: CheckpointConfiguration -> Maybe Natural
$sel:checkpointingEnabled:CheckpointConfiguration' :: CheckpointConfiguration -> Maybe Bool
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"CheckpointingEnabled" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Bool -> Pair) -> Maybe Bool -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
checkpointingEnabled,
            (Text
"MinPauseBetweenCheckpoints" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Natural -> Pair) -> Maybe Natural -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
minPauseBetweenCheckpoints,
            (Text
"CheckpointInterval" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Natural -> Pair) -> Maybe Natural -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
checkpointInterval,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"ConfigurationType" Text -> ConfigurationType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= ConfigurationType
configurationType)
          ]
      )