You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by GitBox <gi...@apache.org> on 2020/01/14 15:32:58 UTC

[GitHub] [flink] TisonKun commented on a change in pull request #10754: [FLINK-14091][coordination] Allow updates to connection state when ZKCheckpointIDCounter reconnects to ZK

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:
users@infra.apache.org


With regards,
Apache Git Services