{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.KinesisAnalyticsV2.Types.CheckpointConfiguration where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.KinesisAnalyticsV2.Types.ConfigurationType
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 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 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 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
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]
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
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. 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:
--
-- '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.
--
-- '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.
--
-- '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'
    { $sel:checkpointInterval:CheckpointConfiguration' :: Maybe Natural
checkpointInterval =
        forall a. Maybe a
Prelude.Nothing,
      $sel:checkpointingEnabled:CheckpointConfiguration' :: Maybe Bool
checkpointingEnabled = forall a. Maybe a
Prelude.Nothing,
      $sel:minPauseBetweenCheckpoints:CheckpointConfiguration' :: Maybe Natural
minPauseBetweenCheckpoints = forall a. Maybe a
Prelude.Nothing,
      $sel:configurationType:CheckpointConfiguration' :: ConfigurationType
configurationType = ConfigurationType
pConfigurationType_
    }

-- | 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 :: Lens' CheckpointConfiguration (Maybe Natural)
checkpointConfiguration_checkpointInterval = 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 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 :: Lens' CheckpointConfiguration (Maybe Bool)
checkpointConfiguration_checkpointingEnabled = 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 :: Lens' CheckpointConfiguration (Maybe Natural)
checkpointConfiguration_minPauseBetweenCheckpoints = 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 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 :: Lens' CheckpointConfiguration ConfigurationType
checkpointConfiguration_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 where
  hashWithSalt :: Int -> CheckpointConfiguration -> Int
hashWithSalt Int
_salt CheckpointConfiguration' {Maybe Bool
Maybe Natural
ConfigurationType
configurationType :: ConfigurationType
minPauseBetweenCheckpoints :: Maybe Natural
checkpointingEnabled :: Maybe Bool
checkpointInterval :: Maybe Natural
$sel:configurationType:CheckpointConfiguration' :: CheckpointConfiguration -> ConfigurationType
$sel:minPauseBetweenCheckpoints:CheckpointConfiguration' :: CheckpointConfiguration -> Maybe Natural
$sel:checkpointingEnabled:CheckpointConfiguration' :: CheckpointConfiguration -> Maybe Bool
$sel:checkpointInterval:CheckpointConfiguration' :: CheckpointConfiguration -> Maybe Natural
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
checkpointInterval
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
checkpointingEnabled
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
minPauseBetweenCheckpoints
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` ConfigurationType
configurationType

instance Prelude.NFData CheckpointConfiguration where
  rnf :: CheckpointConfiguration -> ()
rnf CheckpointConfiguration' {Maybe Bool
Maybe Natural
ConfigurationType
configurationType :: ConfigurationType
minPauseBetweenCheckpoints :: Maybe Natural
checkpointingEnabled :: Maybe Bool
checkpointInterval :: Maybe Natural
$sel:configurationType:CheckpointConfiguration' :: CheckpointConfiguration -> ConfigurationType
$sel:minPauseBetweenCheckpoints:CheckpointConfiguration' :: CheckpointConfiguration -> Maybe Natural
$sel:checkpointingEnabled:CheckpointConfiguration' :: CheckpointConfiguration -> Maybe Bool
$sel:checkpointInterval:CheckpointConfiguration' :: CheckpointConfiguration -> Maybe Natural
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
checkpointInterval
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
checkpointingEnabled
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
minPauseBetweenCheckpoints
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf ConfigurationType
configurationType

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