ruanwenjun commented on code in PR #15826: URL: https://github.com/apache/dolphinscheduler/pull/15826#discussion_r1565229257
########## dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/config/ImmutableYamlDelegate.java: ########## @@ -0,0 +1,82 @@ +/* + * 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.common.config; + +import java.io.IOException; +import java.io.InputStream; +import java.util.Map; +import java.util.Set; +import java.util.concurrent.ConcurrentHashMap; + +import lombok.extern.slf4j.Slf4j; + +import org.yaml.snakeyaml.Yaml; + +@Slf4j +public class ImmutableYamlDelegate implements IYamlDelegate { Review Comment: Should directly implements IPropertyDelegate is enough. ########## dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/log/remote/RemoteLogConfiguration.java: ########## @@ -0,0 +1,55 @@ +/* + * 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.common.log.remote; + +import static org.apache.dolphinscheduler.common.constants.Constants.REMOTE_LOGGING_YAML_PATH; + +import org.apache.dolphinscheduler.common.config.IYamlDelegate; +import org.apache.dolphinscheduler.common.config.ImmutableYamlDelegate; +import org.apache.dolphinscheduler.common.constants.Constants; + +import lombok.experimental.UtilityClass; +import lombok.extern.slf4j.Slf4j; + +@UtilityClass +@Slf4j +public class RemoteLogConfiguration { + + private static final IYamlDelegate yamlDelegate = + new ImmutableYamlDelegate(REMOTE_LOGGING_YAML_PATH); + + public static Boolean isEnable() { + return yamlDelegate.getBoolean(Constants.REMOTE_LOGGING_ENABLE, Boolean.FALSE); + } + + public static String getTarget() { + return yamlDelegate.getString(Constants.REMOTE_LOGGING_TARGET).toUpperCase(); + } + + public static String getLogBaseDir() { + return yamlDelegate.getString(Constants.REMOTE_LOGGING_BASE_DIR); + } + + public static Integer getThreadPoolSize() { + return yamlDelegate.getInt(Constants.REMOTE_LOGGING_THREAD_POOL_SIZE, 10); + } + + public static IYamlDelegate getYamlDelegate(String key) { + return yamlDelegate.getYamlDelegate(key); + } Review Comment: The delegate shouldn't exposed. ########## dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/config/IYamlDelegate.java: ########## @@ -0,0 +1,104 @@ +/* + * 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.common.config; + +import java.util.Map; +import java.util.Optional; +import java.util.Set; +import java.util.function.Function; + +public interface IYamlDelegate { Review Comment: You don't need to create this interface, we already have a `IPropertyDelegate` interface, the yaml implementation can directly implement this. -- 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]
