You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@iotdb.apache.org by GitBox <gi...@apache.org> on 2022/03/22 11:37:20 UTC

[GitHub] [iotdb] neuyilan commented on a change in pull request #5308: [IOTDB-2686] Region allocation policy

neuyilan commented on a change in pull request #5308:
URL: https://github.com/apache/iotdb/pull/5308#discussion_r832040101



##########
File path: confignode/src/main/java/org/apache/iotdb/confignode/consensus/response/DataNodesInfoDataSet.java
##########
@@ -0,0 +1,50 @@
+/*
+ * 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 org.apache.iotdb.confignode.consensus.response;
+
+import org.apache.iotdb.confignode.partition.DataNodeInfo;
+import org.apache.iotdb.consensus.common.DataSet;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public class DataNodesInfoDataSet implements DataSet {
+
+  private final Map<Integer, DataNodeInfo> infoMap;
+
+  public DataNodesInfoDataSet() {
+    this.infoMap = new HashMap<>();
+  }
+
+  public void addDataNodeInfo(int dataNodeID, DataNodeInfo info) {
+    this.infoMap.put(dataNodeID, info);
+  }
+
+  public Map<Integer, DataNodeInfo> getInfoMap() {
+    return this.infoMap;
+  }
+
+  public DataNodeInfo getInfoWithMaximumID() {
+    int maxKey = Integer.MIN_VALUE;
+    for (int key : infoMap.keySet()) {
+      maxKey = Math.max(maxKey, key);
+    }
+    return infoMap.get(maxKey);
+  }
+}

Review comment:
       When the method will be used?
   

##########
File path: thrift-confignode/src/main/thrift/confignode.thrift
##########
@@ -21,6 +21,20 @@ include "rpc.thrift"
 namespace java org.apache.iotdb.confignode.rpc.thrift
 namespace py iotdb.thrift.confignode
 
+struct DataNodeRegisterReq {
+    1: required rpc.EndPoint endPoint
+}
+
+struct DataNodeRegisterResp {
+    1: required rpc.TSStatus registerResult
+    2: optional i32 dataNodeID
+}
+
+struct DataNodeInfo {
+  1: required i32 dataNodeID
+  2: required rpc.EndPoint endPoint
+}

Review comment:
       This struct may conflict with the `confignode/src/main/java/org/apache/iotdb/confignode/partition/DataNodeInfo.java,`
   Actually, it confuses me.

##########
File path: confignode/src/main/java/org/apache/iotdb/confignode/consensus/response/DataNodesInfoDataSet.java
##########
@@ -0,0 +1,50 @@
+/*
+ * 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 org.apache.iotdb.confignode.consensus.response;
+
+import org.apache.iotdb.confignode.partition.DataNodeInfo;
+import org.apache.iotdb.consensus.common.DataSet;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public class DataNodesInfoDataSet implements DataSet {
+
+  private final Map<Integer, DataNodeInfo> infoMap;
+
+  public DataNodesInfoDataSet() {
+    this.infoMap = new HashMap<>();
+  }
+
+  public void addDataNodeInfo(int dataNodeID, DataNodeInfo info) {
+    this.infoMap.put(dataNodeID, info);
+  }
+
+  public Map<Integer, DataNodeInfo> getInfoMap() {
+    return this.infoMap;
+  }
+
+  public DataNodeInfo getInfoWithMaximumID() {
+    int maxKey = Integer.MIN_VALUE;

Review comment:
       Do we need one method like this `getDataNodeInfo(int dataNodeID)?`




-- 
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: reviews-unsubscribe@iotdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org