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/09 13:28:30 UTC
[GitHub] [iotdb] wangchao316 commented on a change in pull request #5188: [To new_cluster] [IOTDB-2683] Hash algorithm for device group
wangchao316 commented on a change in pull request #5188:
URL: https://github.com/apache/iotdb/pull/5188#discussion_r822644541
##########
File path: confignode/src/main/java/org/apache/iotdb/confignode/manager/ConfigManager.java
##########
@@ -30,20 +40,48 @@
*/
public class ConfigManager {
- private final Lock partitionTableLock;
- private final PartitionTable partitionTable;
+ private static final Logger LOGGER = LoggerFactory.getLogger(ConfigManager.class);
+
+ private DeviceGroupHashExecutor hashExecutor;
+
+ private Lock partitionTableLock;
+ private PartitionTable partitionTable;
- private final LoadBalancer loadBalancer;
+ private LoadBalancer loadBalancer;
+
+ public ConfigManager(String hashType, int deviceGroupCount) {
+ setHashExecutor(hashType, deviceGroupCount);
+ }
public ConfigManager() {
+ ConfigNodeConf config = ConfigNodeDescriptor.getInstance().getConf();
+
+ setHashExecutor(config.getDeviceGroupHashAlgorithm(), config.getDeviceGroupCount());
+
this.partitionTableLock = new ReentrantLock();
this.partitionTable = new PartitionTable();
this.loadBalancer = new LoadBalancer(partitionTableLock, partitionTable);
}
+ private void setHashExecutor(String hashAlgorithm, int deviceGroupCount) {
+ switch (hashAlgorithm) {
+ case "BKDR":
+ hashExecutor = new BKDRHashExecutor(deviceGroupCount);
+ break;
+ case "AP":
+ hashExecutor = new APHashExecutor(deviceGroupCount);
+ break;
+ case "JS":
+ hashExecutor = new JSHash(deviceGroupCount);
+ break;
+ case "SDBM":
+ hashExecutor = new SDBMHash(deviceGroupCount);
Review comment:
add case default, throw a exception("does not support Hash......")
--
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