javeme commented on code in PR #1943:
URL: 
https://github.com/apache/incubator-hugegraph/pull/1943#discussion_r947398059


##########
hugegraph-core/src/main/java/com/baidu/hugegraph/election/RoleElectionStateMachineImpl.java:
##########
@@ -244,10 +246,10 @@ public RoleState transform(StateMachineContext context) {
             RoleStateData stateData = new 
RoleStateData(context.config().node(), epoch);
             //failover to master success
             context.epoch(stateData.epoch());
-            if (context.adapter().delayIfNodePresent(stateData, -1)) {
+            if (context.adapter().updateIfNodePresent(stateData)) {
                 return new MasterState(stateData);
             } else {
-                return new WorkerState(stateData);
+                return new UnKnownState(epoch).transform(context);

Review Comment:
   UnKnown => Unknown



##########
hugegraph-core/src/main/java/com/baidu/hugegraph/election/RoleElectionStateMachineImpl.java:
##########
@@ -183,10 +184,11 @@ public Callback callback(StateMachineCallback callback) {
     private static class WorkerState implements RoleState {
 
         private RoleStateData stateData;
-        private int count = 0;
+        private int count;

Review Comment:
   also rename to clock?



##########
hugegraph-core/src/main/java/com/baidu/hugegraph/election/RoleTypeDataAdapter.java:
##########
@@ -0,0 +1,29 @@
+/*
+ * Copyright 2017 HugeGraph Authors
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ */
+
+package com.baidu.hugegraph.election;
+
+import java.util.Optional;
+
+public interface RoleTypeDataAdapter {

Review Comment:
   keep the name style consistent: RoleTypeDataAdapter and RoleStateData



##########
hugegraph-test/src/main/java/com/baidu/hugegraph/core/RoleElectionStateMachineTest.java:
##########
@@ -68,11 +68,12 @@ public LogEntry(Integer epoch, String node, Role role) {
         }
 
         @Override
-        public boolean equals(Object o) {
-            if (this == o) return true;
-            if (!(o instanceof LogEntry)) return false;
-            LogEntry logEntry = (LogEntry) o;
-            return Objects.equals(epoch, logEntry.epoch) && 
Objects.equals(node, logEntry.node) && role == logEntry.role;
+        public boolean equals(Object obj) {
+            if (this == obj) return true;

Review Comment:
   add "{}" and wrap line 



-- 
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]

Reply via email to