ruanwenjun commented on code in PR #10406: URL: https://github.com/apache/dolphinscheduler/pull/10406#discussion_r894989316
########## 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: Yes, this is a bad practice, I updated as you suggest. ########## dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-mysql/README.md: ########## @@ -0,0 +1,33 @@ +# Introduction + +This module is the mysql registry plugin module, this plugin will use mysql as the registry center. + +# How to use + +If you want to set the registry center as mysql, you need to do the below two steps: + +1. Initialize the mysql table + +You can directly execute the sql script `src/main/resources/mysql_registry_init.sql`. + +2. Open the config + +You need to set the registry properties in master/worker/api's appplication.yml + +```yaml +registry: + type: mysql + term-refresh-interval: 2000 Review Comment: Done -- 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]
