javeme commented on code in PR #2151:
URL:
https://github.com/apache/incubator-hugegraph/pull/2151#discussion_r1132300569
##########
hugegraph-core/src/main/java/org/apache/hugegraph/masterelection/StandardStateMachineCallback.java:
##########
@@ -94,12 +94,12 @@ public void error(StateMachineContext context, Throwable e)
{
public void initGlobalMasterInfo(StateMachineContext context) {
StateMachineContext.MasterServerInfo master = context.master();
if (master == null) {
- this.globalMasterInfo.set(false, null);
+ this.globalMasterInfo.info(false, null);
return;
}
boolean isMaster = Objects.equals(context.node(), master.node());
String url = master.url();
- this.globalMasterInfo.set(isMaster, url);
+ this.globalMasterInfo.info(isMaster, url);
Review Comment:
how frequently the initGlobalMasterInfo() to be called?
##########
hugegraph-core/src/main/java/org/apache/hugegraph/masterelection/StandardStateMachineCallback.java:
##########
@@ -94,12 +94,12 @@ public void error(StateMachineContext context, Throwable e)
{
public void initGlobalMasterInfo(StateMachineContext context) {
StateMachineContext.MasterServerInfo master = context.master();
if (master == null) {
- this.globalMasterInfo.set(false, null);
+ this.globalMasterInfo.info(false, null);
Review Comment:
keep consistent with the GlobalMasterInfo() let url = ""?
##########
hugegraph-core/src/main/java/org/apache/hugegraph/masterelection/GlobalMasterInfo.java:
##########
@@ -19,26 +19,20 @@
public class GlobalMasterInfo {
- private boolean isMaster;
- private String url;
-
+ private volatile Info info;
private volatile boolean featureSupport;
public GlobalMasterInfo() {
this.featureSupport = false;
+ this.info = new Info(false, "");
}
- public synchronized void set(boolean isMaster, String url) {
- this.isMaster = isMaster;
- this.url = url;
- }
-
- public synchronized boolean isMaster() {
- return this.isMaster;
+ public void info(boolean isMaster, String url) {
Review Comment:
"info" may be an too generic word, I think `nodeInfo(isMaster, url)` is
good, and also rename class Info to NodeInfo
--
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]