kezhenxu94 commented on code in PR #10406:
URL: https://github.com/apache/dolphinscheduler/pull/10406#discussion_r894986537


##########
dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-mysql/src/main/java/org/apache/dolphinscheduler/plugin/registry/mysql/MysqlRegistry.java:
##########
@@ -0,0 +1,179 @@
+/*
+ * 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.dolphinscheduler.plugin.registry.mysql;
+
+import 
org.apache.dolphinscheduler.plugin.registry.mysql.task.EphemeralDateManager;
+import 
org.apache.dolphinscheduler.plugin.registry.mysql.task.RegistryLockManager;
+import 
org.apache.dolphinscheduler.plugin.registry.mysql.task.SubscribeDataManager;
+import org.apache.dolphinscheduler.registry.api.ConnectionListener;
+import org.apache.dolphinscheduler.registry.api.Registry;
+import org.apache.dolphinscheduler.registry.api.RegistryException;
+import org.apache.dolphinscheduler.registry.api.SubscribeListener;
+
+import java.sql.SQLException;
+import java.time.Duration;
+import java.util.Collection;
+
+import javax.annotation.PostConstruct;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
+import org.springframework.stereotype.Component;
+
+
+/**
+ * This is one of the implementation of {@link Registry}, with this 
implementation, you need to rely on mysql database to
+ * store the DolphinScheduler master/worker's metadata and do the server 
registry/unRegistry.
+ */
+@Component
+@ConditionalOnProperty(prefix = "registry", name = "type", havingValue = 
"mysql")
+public class MysqlRegistry implements Registry {
+
+    private static Logger LOGGER = 
LoggerFactory.getLogger(MysqlRegistry.class);
+
+    private final EphemeralDateManager ephemeralDateManager;
+    private final SubscribeDataManager subscribeDataManager;
+    private final RegistryLockManager registryLockManager;
+    private final MysqlOperator mysqlOperator;
+
+    public MysqlRegistry(MysqlRegistryProperties mysqlRegistryProperties) {
+        MysqlRegistryConstant.TERM_REFRESH_INTERVAL = 
mysqlRegistryProperties.getTermRefreshInterval();
+        MysqlRegistryConstant.TERM_EXPIRE_TIMES = 
mysqlRegistryProperties.getTermExpireTimes();

Review Comment:
   Hi, why do you choose to save the properties to a static class instead of 
injecting this `mysqlRegistryProperties` to where it's needed (as 
`mysqlRegistryProperties` is Spring-managed)? This is a bad practice to me as 
you are hard to keep `mysqlRegistryProperties` and 
`MysqlRegistryConstant.TERM_REFRESH_INTERVAL` in sync.
   
   Also, as a default value of `MysqlRegistryProperties.termRefreshInterval` I 
don't think it necessary to add another constant if you can simply write
   
   ```java
   public class MysqlRegistryProperties {
   
       /**
        * Used to schedule refresh the ephemeral data/ lock.
        */
       private Duration termRefreshInterval = Duration.ofSeconds(2);
   ```



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