TisonKun commented on a change in pull request #10754:
[FLINK-14091][coordination] Allow updates to connection state when
ZKCheckpointIDCounter reconnects to ZK
URL: https://github.com/apache/flink/pull/10754#discussion_r366406377
##########
File path:
flink-runtime/src/main/java/org/apache/flink/runtime/checkpoint/ZooKeeperCheckpointIDCounter.java
##########
@@ -77,14 +84,26 @@ public ZooKeeperCheckpointIDCounter(CuratorFramework
client, String counterPath)
this.client = checkNotNull(client, "Curator client");
this.counterPath = checkNotNull(counterPath, "Counter path");
this.sharedCount = new SharedCount(client, counterPath, 1);
+
+ this.connectionStateListeners = new ArrayList<>();
+ this.connectionStateListeners.add((ignore, newState) ->
lastState = newState);
+ }
+
+ @VisibleForTesting
+ ZooKeeperCheckpointIDCounter(CuratorFramework client, String
counterPath, Collection<ConnectionStateListener> listeners) {
+ this(client, counterPath);
+ this.connectionStateListeners.addAll(listeners);
}
@Override
public void start() throws Exception {
synchronized (startStopLock) {
if (!isStarted) {
sharedCount.start();
-
client.getConnectionStateListenable().addListener(connStateListener);
+
+ for (ConnectionStateListener listener :
connectionStateListeners) {
+
client.getConnectionStateListenable().addListener(listener);
Review comment:
Nice catch!
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services