GitHub user StefanRRichter opened a pull request:
https://github.com/apache/flink/pull/6159
[FLINK-9487] Prepare InternalTimerHeap for asynchronous snapshots
## What is the purpose of the change
This PR is the first step in the context of FLINK-9485. Purpose of this PR
is to enhance ``InternalTimerHeap`` with the capability to produce asynchronous
snapshots. This is very similar to the approach of asynchronous snapshots for
the ``CopyOnWriteStateTable`` and we want to reuse as much of the existing code
as possible to power both instances of snapshots.
## Brief change log
The first commit generalizes the key-group-partitioning algorithm for async
snapshots from the ``CopyOnWriteStateTable``. The newly introduced
``StateSnapshot`` interface outlines the asynchronous snapshot life-cycle,
which typically looks as follows. In the synchronous part of a checkpoint, an
instance of {StateSnapshot} is produced for a state and captures the state at
this point in time. Then, in the asynchronous part of the checkpoint, the user
calls `` #partitionByKeyGroup()`` to ensure that the snapshot is partitioned
into key-groups. For state that is already partitioned, this can be a NOP. The
returned ``KeyGroupPartitionedSnapshot`` can be used by the caller to write the
state by key-group. As a last step, when the state is completely written, the
user calls ``#release()``.
The partitioning algorithm is also slightly modified to cache computed
key-group-ids per element. This is improves runtime at the cost of some
additional memory.
The second commit introduced an implementation of ``StateSnapshot`` for the
``InternalTimerHeap`` data structure.
## Verifying this change
This change added tests: ``TimerPartitionerTest`` ,
``StateTableKeyGroupPartitionerTest``,
``AbstractKeyGroupPartitionedSnapshotTest``
## Does this pull request potentially affect one of the following parts:
- Dependencies (does it add or upgrade a dependency): (no)
- The public API, i.e., is any changed class annotated with
`@Public(Evolving)`: (no)
- The serializers: (no)
- The runtime per-record code paths (performance sensitive): (no)
- Anything that affects deployment or recovery: JobManager (and its
components), Checkpointing, Yarn/Mesos, ZooKeeper: (yes)
- The S3 file system connector: (no)
## Documentation
- Does this pull request introduce a new feature? (yes)
- If yes, how is the feature documented? (not applicable)
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/StefanRRichter/flink FLINK-9487
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/flink/pull/6159.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #6159
----
commit 9e95e1a5f36b6c4f0b021f38b2a2a4c2f8dacf3a
Author: Stefan Richter <s.richter@...>
Date: 2018-06-11T12:48:06Z
Refactor/generalize key-group partitioning.
commit 800abd9743c5483f50835d0cf938ad50f550ae49
Author: Stefan Richter <s.richter@...>
Date: 2018-06-11T15:44:10Z
Introduce TimerHeap snapshots and key-group-partitioning
----
---