This is an automated email from the ASF dual-hosted git repository.

rexxiong pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/celeborn.git


The following commit(s) were added to refs/heads/main by this push:
     new d335c644a [CELEBORN-1594] Refine dynamicConfig template and prevent NPE
d335c644a is described below

commit d335c644aa37a23a2f4ee20eb60ec4423e940a01
Author: Wang, Fei <[email protected]>
AuthorDate: Sun Sep 15 22:11:23 2024 +0800

    [CELEBORN-1594] Refine dynamicConfig template and prevent NPE
    
    ### What changes were proposed in this pull request?
    
    1. seems the quota.yaml is outdated, remove it
    2. the config item set in dynamicConfig.yaml.template is not dynamic 
config, remove the one
    3. prevent  NPE when loading dynamicConfig.yaml
    
    ### Why are the changes needed?
    As title.
    
    ### Does this PR introduce _any_ user-facing change?
    
    No.
    
    ### How was this patch tested?
    
    Existing UT.
    
    Closes #2737 from turboFei/dynamic_config.
    
    Authored-by: Wang, Fei <[email protected]>
    Signed-off-by: Shuang <[email protected]>
---
 conf/dynamicConfig.yaml.template                   |  7 +++--
 conf/quota.yaml.template                           | 32 ----------------------
 .../common/service/config/FsConfigServiceImpl.java |  9 ++++--
 service/src/test/resources/dynamicConfig.yaml      |  7 +++++
 4 files changed, 18 insertions(+), 37 deletions(-)

diff --git a/conf/dynamicConfig.yaml.template b/conf/dynamicConfig.yaml.template
index 87789754b..4dafbfb75 100644
--- a/conf/dynamicConfig.yaml.template
+++ b/conf/dynamicConfig.yaml.template
@@ -16,12 +16,15 @@
 #
 -  level: SYSTEM
    config:
-     celeborn.worker.directMemoryRatioToPauseReceive: 0.75
-
 
 -  tenantId: tenant_id
    level: TENANT
    config:
+   users:
+     - name: user_name
+       config:
+         celeborn.quota.tenant.diskBytesWritten: 100G
+         celeborn.quota.tenant.diskFileCount: 10000
 
 
 
diff --git a/conf/quota.yaml.template b/conf/quota.yaml.template
deleted file mode 100644
index 8cd129eff..000000000
--- a/conf/quota.yaml.template
+++ /dev/null
@@ -1,32 +0,0 @@
-#
-# 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.
-#
-
--  tenantId: AAA
-   name: Tom
-   quota:
-     diskBytesWritten: 100m
-     diskFileCount: 200
-     hdfsBytesWritten: 200m
-     hdfsFileCount: 100
-
--  tenantId: BBB
-   name: Jerry
-   quota:
-     diskBytesWritten: 1G
-     diskFileCount: 1000
-     hdfsBytesWritten: 3G
-     hdfsFileCount: 200
diff --git 
a/service/src/main/java/org/apache/celeborn/server/common/service/config/FsConfigServiceImpl.java
 
b/service/src/main/java/org/apache/celeborn/server/common/service/config/FsConfigServiceImpl.java
index 3085d34bf..125e81d73 100644
--- 
a/service/src/main/java/org/apache/celeborn/server/common/service/config/FsConfigServiceImpl.java
+++ 
b/service/src/main/java/org/apache/celeborn/server/common/service/config/FsConfigServiceImpl.java
@@ -20,6 +20,7 @@ package org.apache.celeborn.server.common.service.config;
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.IOException;
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -80,9 +81,11 @@ public class FsConfigServiceImpl extends 
BaseConfigServiceImpl implements Config
   }
 
   private Map<String, String> getConfigs(Map<String, Object> configMap) {
-    return ((Map<String, Object>) configMap.get(CONF_CONFIG))
-        .entrySet().stream()
-            .collect(Collectors.toMap(Map.Entry::getKey, config -> 
config.getValue().toString()));
+    Map<String, Object> configs = (Map<String, Object>) 
configMap.get(CONF_CONFIG);
+    if (configs == null) return Collections.emptyMap();
+    return configs.entrySet().stream()
+        .filter(config -> config.getValue() != null)
+        .collect(Collectors.toMap(Map.Entry::getKey, config -> 
config.getValue().toString()));
   }
 
   private File getConfigFile(Map<String, String> env) throws IOException {
diff --git a/service/src/test/resources/dynamicConfig.yaml 
b/service/src/test/resources/dynamicConfig.yaml
index ea759a4f3..a916f46d1 100644
--- a/service/src/test/resources/dynamicConfig.yaml
+++ b/service/src/test/resources/dynamicConfig.yaml
@@ -50,4 +50,11 @@
          celeborn.client.push.buffer.initial.size: 1k
          celeborn.client.push.buffer.initial.size.user.only: 512k
 
+-  tenantId: tenant_id2
+   level: TENANT
+   config:
+   users:
+     - name: Jerry
+       config:
+         celeborn.client.push.buffer.initial.size:
 

Reply via email to