You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flink.apache.org by se...@apache.org on 2016/08/09 08:26:44 UTC
[2/4] flink git commit: [hotfix] [distributed runtime] Add overflow
check for ZooKeeper checkpoint ID counter.
[hotfix] [distributed runtime] Add overflow check for ZooKeeper checkpoint ID counter.
Project: http://git-wip-us.apache.org/repos/asf/flink/repo
Commit: http://git-wip-us.apache.org/repos/asf/flink/commit/862e7f0e
Tree: http://git-wip-us.apache.org/repos/asf/flink/tree/862e7f0e
Diff: http://git-wip-us.apache.org/repos/asf/flink/diff/862e7f0e
Branch: refs/heads/master
Commit: 862e7f0e9b11c8c218b0fe35fcdb192ea205e2fa
Parents: f1e9dae
Author: Stephan Ewen <se...@apache.org>
Authored: Fri Aug 5 19:16:51 2016 +0200
Committer: Stephan Ewen <se...@apache.org>
Committed: Mon Aug 8 19:27:10 2016 +0200
----------------------------------------------------------------------
.../runtime/checkpoint/ZooKeeperCheckpointIDCounter.java | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flink/blob/862e7f0e/flink-runtime/src/main/java/org/apache/flink/runtime/checkpoint/ZooKeeperCheckpointIDCounter.java
----------------------------------------------------------------------
diff --git a/flink-runtime/src/main/java/org/apache/flink/runtime/checkpoint/ZooKeeperCheckpointIDCounter.java b/flink-runtime/src/main/java/org/apache/flink/runtime/checkpoint/ZooKeeperCheckpointIDCounter.java
index c71eb7b..12839c1 100644
--- a/flink-runtime/src/main/java/org/apache/flink/runtime/checkpoint/ZooKeeperCheckpointIDCounter.java
+++ b/flink-runtime/src/main/java/org/apache/flink/runtime/checkpoint/ZooKeeperCheckpointIDCounter.java
@@ -131,8 +131,13 @@ public class ZooKeeperCheckpointIDCounter implements CheckpointIDCounter {
}
VersionedValue<Integer> current = sharedCount.getVersionedValue();
+ int newCount = current.getValue() + 1;
- Integer newCount = current.getValue() + 1;
+ if (newCount < 0) {
+ // overflow and wrap around
+ throw new Exception("Checkpoint counter overflow. ZooKeeper checkpoint counter only supports " +
+ "checkpoints Ids up to " + Integer.MAX_VALUE);
+ }
if (sharedCount.trySetCount(current, newCount)) {
return current.getValue();
@@ -161,7 +166,7 @@ public class ZooKeeperCheckpointIDCounter implements CheckpointIDCounter {
* Connection state listener. In case of {@link ConnectionState#SUSPENDED} or {@link
* ConnectionState#LOST} we are not guaranteed to read a current count from ZooKeeper.
*/
- private class SharedCountConnectionStateListener implements ConnectionStateListener {
+ private static class SharedCountConnectionStateListener implements ConnectionStateListener {
private volatile ConnectionState lastState;