You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dolphinscheduler.apache.org by GitBox <gi...@apache.org> on 2021/07/14 02:57:59 UTC

[GitHub] [dolphinscheduler] gabrywu commented on a change in pull request #5814: [Improvement][Api Module] refactor registry client, remove spring annotation

gabrywu commented on a change in pull request #5814:
URL: https://github.com/apache/dolphinscheduler/pull/5814#discussion_r669240897



##########
File path: dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/utils/RegistryCenterUtils.java
##########
@@ -36,21 +36,14 @@
  * fixme Some of the information obtained in the api belongs to the unique information of zk.
  * I am not sure whether there is a good abstraction method. This is related to whether the specific plug-in is provided.
  */
-@Component
-public class RegistryMonitor {
+public class RegistryCenterUtils {
 
-    @Autowired
-    RegistryClient registryClient;
-
-    @PostConstruct
-    public void initRegistry() {
-        registryClient.init();
-    }
+    private static RegistryClient registryClient = RegistryClient.getInstance();
 
     /**
      * @return zookeeper info list
      */
-    public List<ZookeeperRecord> zookeeperInfoList() {
+    public static List<ZookeeperRecord> zookeeperInfoList() {

Review comment:
       remove this method?

##########
File path: dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/utils/RegistryCenterUtils.java
##########
@@ -106,11 +99,23 @@ public void initRegistry() {
         return list;
     }
 
-    public Map<String, String> getServerMaps(NodeType nodeType, boolean hostOnly) {
+    public static Map<String, String> getServerMaps(NodeType nodeType, boolean hostOnly) {
         return registryClient.getServerMaps(nodeType, hostOnly);
     }
 
-    public List<String> getServerNodeList(NodeType nodeType, boolean hostOnly) {
+    public static List<String> getServerNodeList(NodeType nodeType, boolean hostOnly) {
         return registryClient.getServerNodeList(nodeType, hostOnly);
     }
+
+    public static boolean isExisted(String key) {
+        return registryClient.isExisted(key);
+    }
+
+    public static List<String> getChildrenKeys(final String key) {

Review comment:
       getChildrenKeys & isExistted & getValue is meaningless for RegistryCenterUtils, should use a meaningful method name

##########
File path: dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/WorkerGroupServiceImpl.java
##########
@@ -147,7 +137,7 @@ private boolean checkWorkerGroupNameExists(WorkerGroup workerGroup) {
         }
         // check zookeeper
         String workerGroupPath = Constants.REGISTRY_DOLPHINSCHEDULER_WORKERS + Constants.SLASH + workerGroup.getName();
-        return registryClient.isExisted(workerGroupPath);
+        return RegistryCenterUtils.isExisted(workerGroupPath);

Review comment:
       use a meaningful method name




-- 
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: commits-unsubscribe@dolphinscheduler.apache.org

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