RexXiong commented on code in PR #2100: URL: https://github.com/apache/incubator-celeborn/pull/2100#discussion_r1396587653
########## service/src/main/scala/org/apache/celeborn/server/common/service/config/ConfigService.java: ########## @@ -0,0 +1,37 @@ +/* + * 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.celeborn.server.common.service.config; + +public interface ConfigService { + + SystemConfig getSystemConfig(); + + TenantConfig getRawTenantConfig(String tenantId); + + default DynamicConfig getTenantConfig(String tenantId) { + TenantConfig tenantConfig = getRawTenantConfig(tenantId); + if (tenantConfig == null || tenantConfig.getConfigs().isEmpty()) { + return getSystemConfig(); + } else { + return tenantConfig; + } + } + + void refreshAllCache(); + Review Comment: yeah, add shutdown method ########## service/src/main/scala/org/apache/celeborn/server/common/service/config/FsConfigServiceImpl.java: ########## @@ -0,0 +1,120 @@ +/* + * 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.celeborn.server.common.service.config; + +import org.apache.celeborn.common.util.ThreadUtils; + +import java.io.File; +import java.io.FileInputStream; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicReference; +import java.util.stream.Collectors; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.yaml.snakeyaml.Yaml; + +import org.apache.celeborn.common.CelebornConf; + +public class FsConfigServiceImpl implements ConfigService { + private static final Logger LOG = LoggerFactory.getLogger(FsConfigServiceImpl.class); + private CelebornConf celebornConf; + private final AtomicReference<SystemConfig> systemConfigAtomicReference = new AtomicReference<>(); + private final AtomicReference<Map<String, TenantConfig>> tenantConfigAtomicReference = new AtomicReference<>(new HashMap<>()); + private static final String CONF_TENANT_ID = "tenantId"; + private static final String CONF_LEVEL = "level"; + private static final String CONF_CONFIG = "config"; + + private final ScheduledExecutorService configRefreshService = Review Comment: ditto -- 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]
