shuwenwei commented on code in PR #12656:
URL: https://github.com/apache/iotdb/pull/12656#discussion_r1626847297
##########
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/ConfigNodeClient.java:
##########
@@ -1116,4 +1129,37 @@ public boolean validateObject(
.orElse(false);
}
}
+
+ private class Cursor {
+ private int value;
+ private boolean locked = false;
+
+ public Cursor(int value) {
+ this.value = value;
+ }
+
+ public int get() {
+ return value;
+ }
+
+ public void set(int value) {
+ if (!locked) {
+ this.value = value;
+ } else {
+ logger.warn(
+ "ConfigNodeClient cursor will keep {} and won't change to {},
because it has been locked.",
+ configNodeEndPoints.get(this.value),
+ configNodeEndPoints.get(value));
+ }
+ }
+
+ public void setAndLock(int value) {
+ set(value);
+ locked = true;
+ }
+
+ public void unlock() {
+ locked = false;
+ }
Review Comment:
Is it necessary to change the value back when unlocking?
--
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]