This is an automated email from the ASF dual-hosted git repository.
ethanfeng 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 99a34f36b [CELEBORN-1618][CIP-11] Supporting tags via DB Config Service
99a34f36b is described below
commit 99a34f36b5894e1672667d8dd8b437c98ffa5bc2
Author: Sanskar Modi <[email protected]>
AuthorDate: Fri Nov 22 14:29:30 2024 +0800
[CELEBORN-1618][CIP-11] Supporting tags via DB Config Service
### What changes were proposed in this pull request?
Adding support for worker tags in DBConfigService.
### Why are the changes needed?
https://cwiki.apache.org/confluence/display/CELEBORN/CIP-11+Supporting+Tags+in+Celeborn
### Does this PR introduce _any_ user-facing change?
For the users using DBConfigService they can upgrade their DB using by
following the README present in PR.
```
% mysql --verbose
mysql> use <configstore_db_name>;
Database changed
mysql> source upgrade-0.5.0-to-0.6.0-mysql.sql
```
### How was this patch tested?
- UTs
- Verified the DB scripts on local
Closes #2925 from s0nskar/db_config.
Authored-by: Sanskar Modi <[email protected]>
Signed-off-by: mingji <[email protected]>
---
.../common/service/config/DbConfigServiceImpl.java | 4 +-
.../common/service/config/DynamicConfig.java | 2 +-
.../server/common/service/config/SystemConfig.java | 32 ++++----
.../server/common/service/model/ClusterTag.java | 77 +++++++++++++++++++
.../common/service/store/IServiceManager.java | 7 +-
.../common/service/store/db/DBSessionFactory.java | 2 +
.../service/store/db/DbServiceManagerImpl.java | 15 +++-
.../mapper/ClusterTagsMapper.java} | 22 ++----
.../sql/mysql/001-CELEBORN-1618-mysql.sql} | 31 +++-----
service/src/main/resources/sql/mysql/README.md | 88 ++++++++++++++++++++++
.../resources/sql/mysql/celeborn-0.5.0-mysql.sql | 1 +
...rn-0.5.0-mysql.sql => celeborn-0.6.0-mysql.sql} | 13 ++++
.../sql/mysql/upgrade-0.5.0-to-0.6.0-mysql.sql} | 23 +-----
.../common/service/config/ConfigServiceSuiteJ.java | 52 ++++++-------
...2-ut-data.sql => celeborn-0.6.0-h2-ut-data.sql} | 6 ++
...celeborn-0.5.0-h2.sql => celeborn-0.6.0-h2.sql} | 13 ++++
service/src/test/resources/dynamicConfig.yaml | 7 ++
service/src/test/resources/dynamicConfig_2.yaml | 7 ++
service/src/test/resources/dynamicConfig_tags.yaml | 45 -----------
.../src/test/resources/dynamicConfig_tags2.yaml | 33 --------
20 files changed, 295 insertions(+), 185 deletions(-)
diff --git
a/service/src/main/java/org/apache/celeborn/server/common/service/config/DbConfigServiceImpl.java
b/service/src/main/java/org/apache/celeborn/server/common/service/config/DbConfigServiceImpl.java
index 7ef0fcd5f..851fd6a86 100644
---
a/service/src/main/java/org/apache/celeborn/server/common/service/config/DbConfigServiceImpl.java
+++
b/service/src/main/java/org/apache/celeborn/server/common/service/config/DbConfigServiceImpl.java
@@ -45,7 +45,9 @@ public class DbConfigServiceImpl extends
BaseConfigServiceImpl implements Config
}
}
- systemConfigAtomicReference.set(iServiceManager.getSystemConfig());
+
systemConfigAtomicReference.get().setConfigs(iServiceManager.getSystemConfig());
+
systemConfigAtomicReference.get().setTags(iServiceManager.getClusterTags());
+
tenantConfigAtomicReference.set(
iServiceManager.getAllTenantConfigs().stream()
.collect(Collectors.toMap(TenantConfig::getTenantId,
Function.identity())));
diff --git
a/service/src/main/java/org/apache/celeborn/server/common/service/config/DynamicConfig.java
b/service/src/main/java/org/apache/celeborn/server/common/service/config/DynamicConfig.java
index 14aa73382..29c317e7e 100644
---
a/service/src/main/java/org/apache/celeborn/server/common/service/config/DynamicConfig.java
+++
b/service/src/main/java/org/apache/celeborn/server/common/service/config/DynamicConfig.java
@@ -42,7 +42,7 @@ import org.apache.celeborn.common.util.Utils;
*/
public abstract class DynamicConfig {
private static final Logger LOG =
LoggerFactory.getLogger(DynamicConfig.class);
- protected Map<String, String> configs = new HashMap<>();
+ protected volatile Map<String, String> configs = new HashMap<>();
protected volatile Quota quota = null;
protected volatile Map<String, Set<String>> tags = null;
diff --git
a/service/src/main/java/org/apache/celeborn/server/common/service/config/SystemConfig.java
b/service/src/main/java/org/apache/celeborn/server/common/service/config/SystemConfig.java
index be420275e..23c28d47f 100644
---
a/service/src/main/java/org/apache/celeborn/server/common/service/config/SystemConfig.java
+++
b/service/src/main/java/org/apache/celeborn/server/common/service/config/SystemConfig.java
@@ -17,33 +17,21 @@
package org.apache.celeborn.server.common.service.config;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
+import java.util.*;
import org.apache.celeborn.common.CelebornConf;
import org.apache.celeborn.common.internal.config.ConfigEntry;
import org.apache.celeborn.server.common.service.model.ClusterSystemConfig;
+import org.apache.celeborn.server.common.service.model.ClusterTag;
public class SystemConfig extends DynamicConfig {
private final CelebornConf celebornConf;
- public SystemConfig(CelebornConf celebornConf, Map<String, String> configs) {
- this.celebornConf = celebornConf;
- this.configs.putAll(configs);
- }
-
public SystemConfig(CelebornConf celebornConf) {
this.celebornConf = celebornConf;
this.configs = new HashMap<>();
}
- public SystemConfig(CelebornConf celebornConf, List<ClusterSystemConfig>
systemConfigs) {
- this.celebornConf = celebornConf;
- systemConfigs.forEach(t -> configs.put(t.getConfigKey(),
t.getConfigValue()));
- }
-
@Override
public DynamicConfig getParentLevelConfig() {
return null;
@@ -69,10 +57,26 @@ public class SystemConfig extends DynamicConfig {
this.configs = configs;
}
+ public void setConfigs(List<ClusterSystemConfig> configs) {
+ Map<String, String> newConfigs = new HashMap<>();
+ for (ClusterSystemConfig c : configs) {
+ newConfigs.put(c.getConfigKey(), c.getConfigValue());
+ }
+ this.configs = newConfigs;
+ }
+
public void setTags(Map<String, Set<String>> tags) {
this.tags = tags;
}
+ public void setTags(List<ClusterTag> tags) {
+ Map<String, Set<String>> newTags = new HashMap<>();
+ for (ClusterTag t : tags) {
+ newTags.computeIfAbsent(t.getTag(), k -> new
HashSet<>()).add(t.getWorkerId());
+ }
+ this.tags = newTags;
+ }
+
@Override
protected Map<String, Set<String>> currentTags() {
return this.tags;
diff --git
a/service/src/main/java/org/apache/celeborn/server/common/service/model/ClusterTag.java
b/service/src/main/java/org/apache/celeborn/server/common/service/model/ClusterTag.java
new file mode 100644
index 000000000..e6539403c
--- /dev/null
+++
b/service/src/main/java/org/apache/celeborn/server/common/service/model/ClusterTag.java
@@ -0,0 +1,77 @@
+/*
+ * 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.model;
+
+import java.time.Instant;
+
+public class ClusterTag {
+ private Integer id;
+ private Integer clusterId;
+ private String tag;
+ private String workerId;
+ private Instant gmtCreate;
+ private Instant gmtModify;
+
+ public Integer getId() {
+ return id;
+ }
+
+ public void setId(Integer id) {
+ this.id = id;
+ }
+
+ public Integer getClusterId() {
+ return clusterId;
+ }
+
+ public void setClusterId(Integer clusterId) {
+ this.clusterId = clusterId;
+ }
+
+ public String getTag() {
+ return tag;
+ }
+
+ public void setTag(String tag) {
+ this.tag = tag;
+ }
+
+ public String getWorkerId() {
+ return workerId;
+ }
+
+ public void setWorkerId(String workerId) {
+ this.workerId = workerId;
+ }
+
+ public Instant getGmtCreate() {
+ return gmtCreate;
+ }
+
+ public void setGmtCreate(Instant gmtCreate) {
+ this.gmtCreate = gmtCreate;
+ }
+
+ public Instant getGmtModify() {
+ return gmtModify;
+ }
+
+ public void setGmtModify(Instant gmtModify) {
+ this.gmtModify = gmtModify;
+ }
+}
diff --git
a/service/src/main/java/org/apache/celeborn/server/common/service/store/IServiceManager.java
b/service/src/main/java/org/apache/celeborn/server/common/service/store/IServiceManager.java
index 7889297d9..6438050fe 100644
---
a/service/src/main/java/org/apache/celeborn/server/common/service/store/IServiceManager.java
+++
b/service/src/main/java/org/apache/celeborn/server/common/service/store/IServiceManager.java
@@ -19,9 +19,10 @@ package org.apache.celeborn.server.common.service.store;
import java.util.List;
-import org.apache.celeborn.server.common.service.config.SystemConfig;
import org.apache.celeborn.server.common.service.config.TenantConfig;
import org.apache.celeborn.server.common.service.model.ClusterInfo;
+import org.apache.celeborn.server.common.service.model.ClusterSystemConfig;
+import org.apache.celeborn.server.common.service.model.ClusterTag;
public interface IServiceManager {
@@ -33,5 +34,7 @@ public interface IServiceManager {
List<TenantConfig> getAllTenantUserConfigs();
- SystemConfig getSystemConfig();
+ List<ClusterSystemConfig> getSystemConfig();
+
+ List<ClusterTag> getClusterTags();
}
diff --git
a/service/src/main/java/org/apache/celeborn/server/common/service/store/db/DBSessionFactory.java
b/service/src/main/java/org/apache/celeborn/server/common/service/store/db/DBSessionFactory.java
index 1c3457661..bc035a071 100644
---
a/service/src/main/java/org/apache/celeborn/server/common/service/store/db/DBSessionFactory.java
+++
b/service/src/main/java/org/apache/celeborn/server/common/service/store/db/DBSessionFactory.java
@@ -37,6 +37,7 @@ import org.slf4j.LoggerFactory;
import org.apache.celeborn.common.CelebornConf;
import
org.apache.celeborn.server.common.service.store.db.mapper.ClusterInfoMapper;
import
org.apache.celeborn.server.common.service.store.db.mapper.ClusterSystemConfigMapper;
+import
org.apache.celeborn.server.common.service.store.db.mapper.ClusterTagsMapper;
import
org.apache.celeborn.server.common.service.store.db.mapper.ClusterTenantConfigMapper;
public class DBSessionFactory {
@@ -82,6 +83,7 @@ public class DBSessionFactory {
configuration.addMapper(ClusterInfoMapper.class);
configuration.addMapper(ClusterSystemConfigMapper.class);
configuration.addMapper(ClusterTenantConfigMapper.class);
+ configuration.addMapper(ClusterTagsMapper.class);
SqlSessionFactoryBuilder builder = new SqlSessionFactoryBuilder();
_instance = builder.build(configuration);
diff --git
a/service/src/main/java/org/apache/celeborn/server/common/service/store/db/DbServiceManagerImpl.java
b/service/src/main/java/org/apache/celeborn/server/common/service/store/db/DbServiceManagerImpl.java
index 5378742d3..86bf03be2 100644
---
a/service/src/main/java/org/apache/celeborn/server/common/service/store/db/DbServiceManagerImpl.java
+++
b/service/src/main/java/org/apache/celeborn/server/common/service/store/db/DbServiceManagerImpl.java
@@ -33,14 +33,15 @@ import org.slf4j.LoggerFactory;
import org.apache.celeborn.common.CelebornConf;
import org.apache.celeborn.server.common.service.config.ConfigLevel;
import org.apache.celeborn.server.common.service.config.ConfigService;
-import org.apache.celeborn.server.common.service.config.SystemConfig;
import org.apache.celeborn.server.common.service.config.TenantConfig;
import org.apache.celeborn.server.common.service.model.ClusterInfo;
import org.apache.celeborn.server.common.service.model.ClusterSystemConfig;
+import org.apache.celeborn.server.common.service.model.ClusterTag;
import org.apache.celeborn.server.common.service.model.ClusterTenantConfig;
import org.apache.celeborn.server.common.service.store.IServiceManager;
import
org.apache.celeborn.server.common.service.store.db.mapper.ClusterInfoMapper;
import
org.apache.celeborn.server.common.service.store.db.mapper.ClusterSystemConfigMapper;
+import
org.apache.celeborn.server.common.service.store.db.mapper.ClusterTagsMapper;
import
org.apache.celeborn.server.common.service.store.db.mapper.ClusterTenantConfigMapper;
import org.apache.celeborn.server.common.service.utils.JsonUtils;
@@ -143,11 +144,10 @@ public class DbServiceManagerImpl implements
IServiceManager {
}
@Override
- public SystemConfig getSystemConfig() {
+ public List<ClusterSystemConfig> getSystemConfig() {
try (SqlSession sqlSession = sqlSessionFactory.openSession()) {
ClusterSystemConfigMapper mapper =
sqlSession.getMapper(ClusterSystemConfigMapper.class);
- List<ClusterSystemConfig> clusterSystemConfig =
mapper.getClusterSystemConfig(clusterId);
- return new SystemConfig(celebornConf, clusterSystemConfig);
+ return mapper.getClusterSystemConfig(clusterId);
}
}
@@ -164,4 +164,11 @@ public class DbServiceManagerImpl implements
IServiceManager {
return clusterInfo;
}
+
+ public List<ClusterTag> getClusterTags() {
+ try (SqlSession sqlSession = sqlSessionFactory.openSession()) {
+ ClusterTagsMapper mapper = sqlSession.getMapper(ClusterTagsMapper.class);
+ return mapper.getClusterTags(clusterId);
+ }
+ }
}
diff --git
a/service/src/main/java/org/apache/celeborn/server/common/service/store/IServiceManager.java
b/service/src/main/java/org/apache/celeborn/server/common/service/store/db/mapper/ClusterTagsMapper.java
similarity index 61%
copy from
service/src/main/java/org/apache/celeborn/server/common/service/store/IServiceManager.java
copy to
service/src/main/java/org/apache/celeborn/server/common/service/store/db/mapper/ClusterTagsMapper.java
index 7889297d9..25dd0f341 100644
---
a/service/src/main/java/org/apache/celeborn/server/common/service/store/IServiceManager.java
+++
b/service/src/main/java/org/apache/celeborn/server/common/service/store/db/mapper/ClusterTagsMapper.java
@@ -15,23 +15,17 @@
* limitations under the License.
*/
-package org.apache.celeborn.server.common.service.store;
+package org.apache.celeborn.server.common.service.store.db.mapper;
import java.util.List;
-import org.apache.celeborn.server.common.service.config.SystemConfig;
-import org.apache.celeborn.server.common.service.config.TenantConfig;
-import org.apache.celeborn.server.common.service.model.ClusterInfo;
+import org.apache.ibatis.annotations.Select;
-public interface IServiceManager {
+import org.apache.celeborn.server.common.service.model.ClusterTag;
- int createCluster(ClusterInfo clusterInfo);
-
- ClusterInfo getClusterInfo(String clusterName);
-
- List<TenantConfig> getAllTenantConfigs();
-
- List<TenantConfig> getAllTenantUserConfigs();
-
- SystemConfig getSystemConfig();
+public interface ClusterTagsMapper {
+ @Select(
+ "SELECT id, cluster_id, tag, worker_id, gmt_create, gmt_modify "
+ + "FROM celeborn_cluster_tags WHERE cluster_id = #{clusterId}")
+ List<ClusterTag> getClusterTags(int clusterId);
}
diff --git
a/service/src/main/java/org/apache/celeborn/server/common/service/store/IServiceManager.java
b/service/src/main/resources/sql/mysql/001-CELEBORN-1618-mysql.sql
similarity index 59%
copy from
service/src/main/java/org/apache/celeborn/server/common/service/store/IServiceManager.java
copy to service/src/main/resources/sql/mysql/001-CELEBORN-1618-mysql.sql
index 7889297d9..962556df5 100644
---
a/service/src/main/java/org/apache/celeborn/server/common/service/store/IServiceManager.java
+++ b/service/src/main/resources/sql/mysql/001-CELEBORN-1618-mysql.sql
@@ -15,23 +15,14 @@
* limitations under the License.
*/
-package org.apache.celeborn.server.common.service.store;
-
-import java.util.List;
-
-import org.apache.celeborn.server.common.service.config.SystemConfig;
-import org.apache.celeborn.server.common.service.config.TenantConfig;
-import org.apache.celeborn.server.common.service.model.ClusterInfo;
-
-public interface IServiceManager {
-
- int createCluster(ClusterInfo clusterInfo);
-
- ClusterInfo getClusterInfo(String clusterName);
-
- List<TenantConfig> getAllTenantConfigs();
-
- List<TenantConfig> getAllTenantUserConfigs();
-
- SystemConfig getSystemConfig();
-}
+CREATE TABLE IF NOT EXISTS celeborn_cluster_tags
+(
+ id int NOT NULL AUTO_INCREMENT,
+ cluster_id int NOT NULL,
+ tag varchar(255) NOT NULL,
+ worker_id varchar(255) NOT NULL,
+ gmt_create timestamp NOT NULL,
+ gmt_modify timestamp NOT NULL,
+ PRIMARY KEY (id),
+ UNIQUE KEY `index_unique_cluster_tag_key` (`cluster_id`, `tag`,
`worker_id`)
+);
diff --git a/service/src/main/resources/sql/mysql/README.md
b/service/src/main/resources/sql/mysql/README.md
new file mode 100644
index 000000000..34141d105
--- /dev/null
+++ b/service/src/main/resources/sql/mysql/README.md
@@ -0,0 +1,88 @@
+---
+license: |
+ 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
+
+ https://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.
+---
+
+Celeborn DB ConfigStore Upgrade HowTo
+============================
+
+This document describes how to upgrade the schema of a MySQL backed
+DB ConfigStore instance from one release version of Celeborn to another
+release version of Celeborn. For example, by following the steps listed
+below it is possible to upgrade Celeborn 0.5.0 DBConfigStore schema to
+Celeborn 0.6.0 DB ConfigStore schema. Before attempting this project we
+strongly recommend that you read through all the steps in this document
+and familiarize yourself with the required tools.
+
+ConfigStore Upgrade Steps
+=======================
+
+1) Shutdown your ConfigStore instance and restrict access to the
+ ConfigStore's MySQL database. It is very important that no one else
+ accesses or modifies the contents of database while you are
+ performing the schema upgrade.
+
+2) Create a backup of your MySQL ConfigStore database. This will allow
+ you to revert any changes made during the upgrade process if
+ something goes wrong. The mysqldump utility is the easiest way to
+ create a backup of a MySQL database:
+
+ % mysqldump --opt <configstore_db_name> > configstore_backup.sql
+
+ Note that you may need also need to specify a hostname and username
+ using the --host and --user command line switches.
+
+3) Dump your configstore database schema to a file. We use the mysqldump
+ utility again, but this time with a command line option that
+ specifies we are only interested in dumping the DDL statements
+ required to create the schema:
+
+ % mysqldump --skip-add-drop-table --no-data <configstore_db_name> >
celeborn-x.y.z-mysql.sql
+
+4) The schema upgrade scripts assume that the schema you are upgrading
+ closely matches the official schema for your particular version of
+ Celeborn. The files in this directory with names like
+ "celeborn-x.y.z-mysql.sql" contain dumps of the official schemas
+ corresponding to each of the released versions of Celeborn. You can
+ determine differences between your schema and the official schema
+ by diffing the contents of the official dump with the schema dump
+ you created in the previous step. Some differences are acceptable
+ and will not interfere with the upgrade process, but others need to
+ be resolved manually or the upgrade scripts will fail to complete.
+
+5) You are now ready to run the schema upgrade scripts. If you are
+ upgrading from Celeborn 0.5.0 to Celeborn 0.6.0 you need to run the
+ upgrade-0.5.0-to-0.6.0-mysql.sql script, but if you are upgrading from
+ 0.6.0 to a future version like 0.7.0, you will need to run the 1.6.0 to
+ 0.7.0 upgrade script followed by the 0.6.0 to 0.7.0 upgrade script.
+
+ % mysql --verbose
+ mysql> use <configstore_db_name>;
+ Database changed
+ mysql> source upgrade-0.5.0-to-0.6.0-mysql.sql
+ mysql> source upgrade-0.6.0-to-0.7.0-mysql.sql
+
+ These scripts should run to completion without any errors. If you
+ do encounter errors you need to analyze the cause and attempt to
+ trace it back to one of the preceding steps.
+
+6) The final step of the upgrade process is validating your freshly
+ upgraded schema against the official schema for your particular
+ version of Celeborn. This is accomplished by repeating steps (3) and
+ (4), but this time comparing against the official version of the
+ upgraded schema, e.g. if you upgraded the schema to Celeborn 0.6.0 then
+ you will want to compare your schema dump against the contents of
+ celeborn-0.6.0-mysql.sql
diff --git a/service/src/main/resources/sql/mysql/celeborn-0.5.0-mysql.sql
b/service/src/main/resources/sql/mysql/celeborn-0.5.0-mysql.sql
index fe275a11b..b16b8f78f 100644
--- a/service/src/main/resources/sql/mysql/celeborn-0.5.0-mysql.sql
+++ b/service/src/main/resources/sql/mysql/celeborn-0.5.0-mysql.sql
@@ -14,6 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
CREATE TABLE IF NOT EXISTS celeborn_cluster_info
(
id int NOT NULL AUTO_INCREMENT,
diff --git a/service/src/main/resources/sql/mysql/celeborn-0.5.0-mysql.sql
b/service/src/main/resources/sql/mysql/celeborn-0.6.0-mysql.sql
similarity index 86%
copy from service/src/main/resources/sql/mysql/celeborn-0.5.0-mysql.sql
copy to service/src/main/resources/sql/mysql/celeborn-0.6.0-mysql.sql
index fe275a11b..a425b2e93 100644
--- a/service/src/main/resources/sql/mysql/celeborn-0.5.0-mysql.sql
+++ b/service/src/main/resources/sql/mysql/celeborn-0.6.0-mysql.sql
@@ -14,6 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
CREATE TABLE IF NOT EXISTS celeborn_cluster_info
(
id int NOT NULL AUTO_INCREMENT,
@@ -54,3 +55,15 @@ CREATE TABLE IF NOT EXISTS celeborn_cluster_tenant_config
PRIMARY KEY (id),
UNIQUE KEY `index_unique_tenant_config_key` (`cluster_id`, `tenant_id`,
`name`, `config_key`)
);
+
+CREATE TABLE IF NOT EXISTS celeborn_cluster_tags
+(
+ id int NOT NULL AUTO_INCREMENT,
+ cluster_id int NOT NULL,
+ tag varchar(255) NOT NULL,
+ worker_id varchar(255) NOT NULL,
+ gmt_create timestamp NOT NULL,
+ gmt_modify timestamp NOT NULL,
+ PRIMARY KEY (id),
+ UNIQUE KEY `index_unique_cluster_tag_key` (`cluster_id`, `tag`,
`worker_id`)
+);
diff --git
a/service/src/main/java/org/apache/celeborn/server/common/service/store/IServiceManager.java
b/service/src/main/resources/sql/mysql/upgrade-0.5.0-to-0.6.0-mysql.sql
similarity index 59%
copy from
service/src/main/java/org/apache/celeborn/server/common/service/store/IServiceManager.java
copy to service/src/main/resources/sql/mysql/upgrade-0.5.0-to-0.6.0-mysql.sql
index 7889297d9..f287a1c9f 100644
---
a/service/src/main/java/org/apache/celeborn/server/common/service/store/IServiceManager.java
+++ b/service/src/main/resources/sql/mysql/upgrade-0.5.0-to-0.6.0-mysql.sql
@@ -15,23 +15,6 @@
* limitations under the License.
*/
-package org.apache.celeborn.server.common.service.store;
-
-import java.util.List;
-
-import org.apache.celeborn.server.common.service.config.SystemConfig;
-import org.apache.celeborn.server.common.service.config.TenantConfig;
-import org.apache.celeborn.server.common.service.model.ClusterInfo;
-
-public interface IServiceManager {
-
- int createCluster(ClusterInfo clusterInfo);
-
- ClusterInfo getClusterInfo(String clusterName);
-
- List<TenantConfig> getAllTenantConfigs();
-
- List<TenantConfig> getAllTenantUserConfigs();
-
- SystemConfig getSystemConfig();
-}
+SELECT '< Upgrading config store schema from 0.5.0 to 0.6.0 >' AS ' ';
+SOURCE 001-CELEBORN-1618-mysql.sql;
+SELECT '< Finished upgrading config store schema from 0.5.0 to 0.6.0 >' AS ' ';
diff --git
a/service/src/test/java/org/apache/celeborn/server/common/service/config/ConfigServiceSuiteJ.java
b/service/src/test/java/org/apache/celeborn/server/common/service/config/ConfigServiceSuiteJ.java
index 95d0fc6c8..c856d66b8 100644
---
a/service/src/test/java/org/apache/celeborn/server/common/service/config/ConfigServiceSuiteJ.java
+++
b/service/src/test/java/org/apache/celeborn/server/common/service/config/ConfigServiceSuiteJ.java
@@ -19,6 +19,7 @@ package org.apache.celeborn.server.common.service.config;
import java.io.IOException;
import java.sql.SQLException;
+import java.sql.Statement;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
@@ -49,8 +50,8 @@ public class ConfigServiceSuiteJ {
CelebornConf celebornConf = new CelebornConf();
celebornConf.set(
CelebornConf.DYNAMIC_CONFIG_STORE_DB_HIKARI_JDBC_URL(),
- "jdbc:h2:mem:test;MODE=MYSQL;INIT=RUNSCRIPT FROM
'classpath:celeborn-0.5.0-h2.sql'\\;"
- + "RUNSCRIPT FROM
'classpath:celeborn-0.5.0-h2-ut-data.sql';DB_CLOSE_DELAY=-1;");
+ "jdbc:h2:mem:test;MODE=MYSQL;INIT=RUNSCRIPT FROM
'classpath:celeborn-0.6.0-h2.sql'\\;"
+ + "RUNSCRIPT FROM
'classpath:celeborn-0.6.0-h2-ut-data.sql';DB_CLOSE_DELAY=-1;");
celebornConf.set(
CelebornConf.DYNAMIC_CONFIG_STORE_DB_HIKARI_DRIVER_CLASS_NAME(),
"org.h2.Driver");
celebornConf.set(CelebornConf.DYNAMIC_CONFIG_STORE_DB_HIKARI_MAXIMUM_POOL_SIZE(),
"1");
@@ -58,20 +59,22 @@ public class ConfigServiceSuiteJ {
verifySystemConfig(configService);
verifyTenantConfig(configService);
verifyTenantUserConfig(configService);
+ verifyTags(configService);
SqlSessionFactory sqlSessionFactory = DBSessionFactory.get(celebornConf);
try (SqlSession sqlSession = sqlSessionFactory.openSession(true)) {
- sqlSession
- .getConnection()
- .createStatement()
- .execute(
- "UPDATE celeborn_cluster_system_config SET config_value = 100
WHERE config_key='celeborn.test.int.only'");
+ Statement statement = sqlSession.getConnection().createStatement();
+
+ statement.execute(
+ "UPDATE celeborn_cluster_system_config SET config_value = 100 WHERE
config_key='celeborn.test.int.only'");
+ statement.execute("UPDATE celeborn_cluster_tags SET tag = 'tag3' WHERE
tag='tag2'");
} catch (SQLException e) {
throw new RuntimeException(e);
}
configService.refreshCache();
verifyConfigChanged(configService);
+ verifyTagsChanged(configService);
verifyServiceManager(
((DbConfigServiceImpl) configService).getServiceManager(),
celebornConf,
@@ -88,12 +91,15 @@ public class ConfigServiceSuiteJ {
verifySystemConfig(configService);
verifyTenantConfig(configService);
verifyTenantUserConfig(configService);
+ verifyTags(configService);
+
// change -> refresh config
file = getClass().getResource("/dynamicConfig_2.yaml").getFile();
celebornConf.set(CelebornConf.DYNAMIC_CONFIG_STORE_FS_PATH(), file);
configService.refreshCache();
verifyConfigChanged(configService);
+ verifyTagsChanged(configService);
}
@After
@@ -311,25 +317,7 @@ public class ConfigServiceSuiteJ {
Assert.assertEquals(gmtTime, clusterInfo.getGmtModify());
}
- @Test
- public void testTags() throws IOException {
- CelebornConf celebornConf = new CelebornConf();
- String file = getClass().getResource("/dynamicConfig_tags.yaml").getFile();
- celebornConf.set(CelebornConf.DYNAMIC_CONFIG_STORE_FS_PATH(), file);
- celebornConf.set(CelebornConf.DYNAMIC_CONFIG_REFRESH_INTERVAL(), 5L);
- configService = new FsConfigServiceImpl(celebornConf);
-
- verifyTags(configService);
-
- // change -> refresh config
- file = getClass().getResource("/dynamicConfig_tags2.yaml").getFile();
- celebornConf.set(CelebornConf.DYNAMIC_CONFIG_STORE_FS_PATH(), file);
- configService.refreshCache();
-
- verifyModifiedTags(configService);
- }
-
- public void verifyTags(ConfigService configService) {
+ private void verifyTags(ConfigService configService) {
SystemConfig systemConfig = configService.getSystemConfigFromCache();
Map<String, Set<String>> tags = systemConfig.getTags();
@@ -349,25 +337,27 @@ public class ConfigServiceSuiteJ {
verifyTenantAndUserTagsAsNull(configService);
}
- public void verifyModifiedTags(ConfigService configService) {
+ private void verifyTagsChanged(ConfigService configService) {
System.out.println("Tags changed");
SystemConfig systemConfig = configService.getSystemConfigFromCache();
Map<String, Set<String>> tags = systemConfig.getTags();
Set<String> tag1 = tags.getOrDefault("tag1", new HashSet<>());
- Assert.assertEquals(tag1.size(), 1);
+ Assert.assertEquals(tag1.size(), 2);
Assert.assertTrue(tag1.contains("host1:1111"));
+ Assert.assertTrue(tag1.contains("host2:2222"));
Set<String> tag2 = tags.getOrDefault("tag2", new HashSet<>());
Assert.assertEquals(tag2.size(), 0);
Set<String> tag3 = tags.getOrDefault("tag3", new HashSet<>());
- Assert.assertEquals(tag3.size(), 1);
- Assert.assertTrue(tag3.contains("host5:5555"));
+ Assert.assertEquals(tag3.size(), 2);
+ Assert.assertTrue(tag3.contains("host3:3333"));
+ Assert.assertTrue(tag3.contains("host4:4444"));
}
- public void verifyTenantAndUserTagsAsNull(ConfigService configService) {
+ private void verifyTenantAndUserTagsAsNull(ConfigService configService) {
TenantConfig tenantConfig =
configService.getRawTenantConfigFromCache("tenant_id1");
Assert.assertNull(tenantConfig.getTags());
diff --git a/service/src/test/resources/celeborn-0.5.0-h2-ut-data.sql
b/service/src/test/resources/celeborn-0.6.0-h2-ut-data.sql
similarity index 91%
rename from service/src/test/resources/celeborn-0.5.0-h2-ut-data.sql
rename to service/src/test/resources/celeborn-0.6.0-h2-ut-data.sql
index d6dc77f87..b9a6a0bb9 100644
--- a/service/src/test/resources/celeborn-0.5.0-h2-ut-data.sql
+++ b/service/src/test/resources/celeborn-0.6.0-h2-ut-data.sql
@@ -45,3 +45,9 @@ VALUES
( 14, 1, 'tenant_id1', 'TENANT', '',
'celeborn.client.push.queue.capacity', '1024', 'QUOTA', '2023-08-26 22:08:30',
'2023-08-26 22:08:30' ),
( 15, 1, 'tenant_id1', 'TENANT_USER', 'Jerry',
'celeborn.client.push.buffer.initial.size', '1k', 'QUOTA', '2023-08-26
22:08:30', '2023-08-26 22:08:30' ),
( 16, 1, 'tenant_id1', 'TENANT_USER', 'Jerry',
'celeborn.client.push.buffer.initial.size.user.only', '512k', 'QUOTA',
'2023-08-26 22:08:30', '2023-08-26 22:08:30' );
+INSERT INTO `celeborn_cluster_tags` ( `id`, `cluster_id`, `tag`, `worker_id`,
`gmt_create`, `gmt_modify` )
+VALUES
+ ( 1, 1, 'tag1', 'host1:1111', '2023-08-26 22:08:30', '2023-08-26 22:08:30'
),
+ ( 2, 1, 'tag1', 'host2:2222', '2023-08-26 22:08:30', '2023-08-26 22:08:30'
),
+ ( 3, 1, 'tag2', 'host3:3333', '2023-08-26 22:08:30', '2023-08-26 22:08:30'
),
+ ( 4, 1, 'tag2', 'host4:4444', '2023-08-26 22:08:30', '2023-08-26 22:08:30'
);
diff --git a/service/src/test/resources/celeborn-0.5.0-h2.sql
b/service/src/test/resources/celeborn-0.6.0-h2.sql
similarity index 85%
rename from service/src/test/resources/celeborn-0.5.0-h2.sql
rename to service/src/test/resources/celeborn-0.6.0-h2.sql
index 0a912eae7..07fb3ed27 100644
--- a/service/src/test/resources/celeborn-0.5.0-h2.sql
+++ b/service/src/test/resources/celeborn-0.6.0-h2.sql
@@ -21,6 +21,7 @@ SET SCHEMA TEST;
DROP TABLE IF exists celeborn_cluster_info;
DROP TABLE IF exists celeborn_cluster_system_config;
DROP TABLE IF exists celeborn_cluster_tenant_config;
+DROP TABLE IF exists celeborn_cluster_tags;
CREATE TABLE IF NOT EXISTS celeborn_cluster_info
(
@@ -62,3 +63,15 @@ CREATE TABLE IF NOT EXISTS celeborn_cluster_tenant_config
PRIMARY KEY (id),
UNIQUE KEY `index_unique_tenant_config_key` (`cluster_id`, `tenant_id`,
`name`, `config_key`)
);
+
+CREATE TABLE IF NOT EXISTS celeborn_cluster_tags
+(
+ id int NOT NULL AUTO_INCREMENT,
+ cluster_id int NOT NULL,
+ tag varchar(255) NOT NULL,
+ worker_id varchar(255) NOT NULL,
+ gmt_create timestamp NOT NULL,
+ gmt_modify timestamp NOT NULL,
+ PRIMARY KEY (id),
+ UNIQUE KEY `index_unique_cluster_tag_key` (`cluster_id`, `tag`,
`worker_id`)
+);
diff --git a/service/src/test/resources/dynamicConfig.yaml
b/service/src/test/resources/dynamicConfig.yaml
index a916f46d1..bf28222d0 100644
--- a/service/src/test/resources/dynamicConfig.yaml
+++ b/service/src/test/resources/dynamicConfig.yaml
@@ -23,6 +23,13 @@
celeborn.test.timeoutMs.only: 100s
celeborn.test.enabled.only: false
celeborn.test.int.only: 10
+ tags:
+ tag1:
+ - 'host1:1111'
+ - 'host2:2222'
+ tag2:
+ - 'host3:3333'
+ - 'host4:4444'
- tenantId: tenant_id
level: TENANT
diff --git a/service/src/test/resources/dynamicConfig_2.yaml
b/service/src/test/resources/dynamicConfig_2.yaml
index 57645e0b8..43490caec 100644
--- a/service/src/test/resources/dynamicConfig_2.yaml
+++ b/service/src/test/resources/dynamicConfig_2.yaml
@@ -17,4 +17,11 @@
- level: SYSTEM
config:
celeborn.test.int.only: 100
+ tags:
+ tag1:
+ - 'host1:1111'
+ - 'host2:2222'
+ tag3:
+ - 'host3:3333'
+ - 'host4:4444'
diff --git a/service/src/test/resources/dynamicConfig_tags.yaml
b/service/src/test/resources/dynamicConfig_tags.yaml
deleted file mode 100644
index d764463ee..000000000
--- a/service/src/test/resources/dynamicConfig_tags.yaml
+++ /dev/null
@@ -1,45 +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.
-#
-- level: SYSTEM
- config:
- celeborn.test.int.only: 100
- tags:
- tag1:
- - 'host1:1111'
- - 'host2:2222'
- tag2:
- - 'host3:3333'
- - 'host4:4444'
-
-- tenantId: tenant_id1
- level: TENANT
- config:
- celeborn.test.int.only: 50
- # Tags should be null for tenant/user config
- tags:
- tag1:
- - 'host1:1111'
- - 'host2:2222'
- users:
- - name: Jerry
- config:
- celeborn.test.int.only: 10
- # Tags should be null for tenant/user config
- tags:
- tag1:
- - 'host1:1111'
- - 'host2:2222'
\ No newline at end of file
diff --git a/service/src/test/resources/dynamicConfig_tags2.yaml
b/service/src/test/resources/dynamicConfig_tags2.yaml
deleted file mode 100644
index 385425b01..000000000
--- a/service/src/test/resources/dynamicConfig_tags2.yaml
+++ /dev/null
@@ -1,33 +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.
-#
-- level: SYSTEM
- config:
- celeborn.test.int.only: 100
- tags:
- tag1:
- - 'host1:1111'
- tag3:
- - 'host5:5555'
-
-- tenantId: tenant_id
- level: TENANT
- config:
- celeborn.test.int.only: 50
- users:
- - name: tenant1
- config:
- celeborn.test.int.only: 10
\ No newline at end of file