slfan1989 commented on code in PR #13795:
URL: https://github.com/apache/iceberg/pull/13795#discussion_r2272074728
##########
flink/v2.0/flink/src/main/java/org/apache/iceberg/flink/maintenance/api/ZkLockFactory.java:
##########
@@ -90,26 +104,45 @@ public void open() {
throw new IllegalStateException("Connection to Zookeeper timed out");
}
- this.taskSharedCount = new SharedCount(client, LOCK_BASE_PATH + lockId +
"/task", 0);
- this.recoverySharedCount = new SharedCount(client, LOCK_BASE_PATH +
lockId + "/recovery", 0);
+ this.taskSharedCount = new SharedCount(client, getTaskSharePath(), 0);
+ this.recoverySharedCount = new SharedCount(client,
getRecoverySharedPath(), 0);
taskSharedCount.start();
recoverySharedCount.start();
+ isOpen = true;
+ LOG.info("ZkLockFactory initialized for lockId: {}.", lockId);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new RuntimeException("Interrupted while connecting to Zookeeper",
e);
} catch (Exception e) {
+ closeQuietly();
throw new RuntimeException("Failed to initialize SharedCount", e);
}
}
+ private String getTaskSharePath() {
+ return LOCK_BASE_PATH + lockId + "/task";
+ }
+
+ private String getRecoverySharedPath() {
+ return LOCK_BASE_PATH + lockId + "/recovery";
+ }
+
+ private void closeQuietly() {
+ try {
+ close();
+ } catch (Exception e) {
+ LOG.warn("Failed to close ZkLockFactory for lockId: {}.", lockId, e);
+ }
+ }
+
@Override
public Lock createLock() {
- return new ZkLock(taskSharedCount);
+ return new ZkLock(lockId, "taskShare", getTaskSharePath(),
taskSharedCount);
Review Comment:
The code has been updated.
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]