Nacos适配人大金仓数据库
感谢各位老师分享,在原基础上做调整。
一、版本适配说明
(一)、nacos版本
nacos版本为:2.2.0。下载地址:https://github.com/alibaba/nacos/archive/refs/tags/2.2.0.zip。
(二)数据库版本
数据版本为:8.6.0。具体版本为:KingbaseES V008R006C008B0014 。下载地址:https://www.kingbase.com.cn/xzzx/index.htm。
} if (!StringUtils.isBlank(params.get(CONTENT))) { where += " AND content LIKE ? "; } String sql = sqlFetchRows + where; return buildPaginationSql(sql, startRow, pageSize); } @Override public String findConfigInfo4PageCountRows(Map<String, String> params) { final String appName = params.get(APP_NAME); final String dataId = params.get(DATA_ID); final String group = params.get(GROUP); final String sqlCount = "SELECT count(*) FROM config_info"; StringBuilder where = new StringBuilder(" WHERE "); where.append(" ( tenant_id= ? or tenant_id is NULL )"); if (StringUtils.isNotBlank(dataId)) { where.append(" AND data_id=? "); } if (StringUtils.isNotBlank(group)) { where.append(" AND group_id=? "); } if (StringUtils.isNotBlank(appName)) { where.append(" AND app_name=? "); } return sqlCount + where; } @Override public String findConfigInfo4PageFetchRows(Map<String, String> params, int startRow, int pageSize) { final String appName = params.get(APP_NAME); final String dataId = params.get(DATA_ID); final String group = params.get(GROUP); final String sql = "SELECT id,data_id,group_id,tenant_id,app_name,content,type,encrypted_data_key FROM config_info"; StringBuilder where = new StringBuilder(" WHERE "); where.append(" ( tenant_id= ? or tenant_id is NULL ) "); if (StringUtils.isNotBlank(dataId)) { where.append(" AND data_id=? "); } if (StringUtils.isNotBlank(group)) { where.append(" AND group_id=? "); } if (StringUtils.isNotBlank(appName)) { where.append(" AND app_name=? "); } return buildPaginationSql(sql + where, startRow, pageSize); } @Override public String findConfigInfoBaseByGroupFetchRows(int startRow, int pageSize) { String sql = "SELECT id,data_id,group_id,content FROM config_info WHERE group_id=? AND ( tenant_id= ? or tenant_id is NULL )"; return buildPaginationSql(sql, startRow, pageSize); } @Override public String findConfigInfoLike4PageCountRows(Map<String, String> params) { String dataId = params.get(DATA_ID); String group = params.get(GROUP); final String appName = params.get(APP_NAME); final String content = params.get(CONTENT); final String sqlCountRows = "SELECT count(*) FROM config_info"; StringBuilder where = new StringBuilder(" WHERE "); where.append(" (tenant_id LIKE ? OR tenant_id IS NULL) "); if (!StringUtils.isBlank(dataId)) { where.append(" AND data_id LIKE ? "); } if (!StringUtils.isBlank(group)) { where.append(" AND group_id LIKE ? "); } if (!StringUtils.isBlank(appName)) { where.append(" AND app_name = ? "); } if (!StringUtils.isBlank(content)) { where.append(" AND content LIKE ? "); } return sqlCountRows + where; } @Override public String findConfigInfoLike4PageFetchRows(Map<String, String> params, int startRow, int pageSize) { String dataId = params.get(DATA_ID); String group = params.get(GROUP); final String appName = params.get(APP_NAME); final String content = params.get(CONTENT); final String sqlFetchRows = "SELECT id,data_id,group_id,tenant_id,app_name,content,encrypted_data_key FROM config_info"; StringBuilder where = new StringBuilder(" WHERE "); where.append(" (tenant_id LIKE ? OR tenant_id IS NULL) "); if (!StringUtils.isBlank(dataId)) { where.append(" AND data_id LIKE ? "); } if (!StringUtils.isBlank(group)) { where.append(" AND group_id LIKE ? "); } if (!StringUtils.isBlank(appName)) { where.append(" AND app_name = ? "); } if (!StringUtils.isBlank(content)) { where.append(" AND content LIKE ? "); } return buildPaginationSql(sqlFetchRows + where, startRow, pageSize); } @Override public String findAllConfigInfoFetchRows(int startRow, int pageSize) { String sql = "SELECT id,data_id,group_id,tenant_id,app_name,content,md5 " + " FROM config_info WHERE (tenant_id LIKE ? OR tenant_id IS NULL) ORDER BY id "; return buildPaginationSql(sql, startRow, pageSize); } @Override public String findConfigInfosByIds(int idSize) { StringBuilder sql = new StringBuilder( "SELECT ID,data_id,group_id,tenant_id,app_name,content,md5 FROM config_info WHERE "); sql.append("id IN ("); for (int i = 0; i < idSize; i++) { if (i != 0) { sql.append(", "); } sql.append('?'); } sql.append(") "); return sql.toString(); } @Override public String removeConfigInfoByIdsAtomic(int size) { StringBuilder sql = new StringBuilder("DELETE FROM config_info WHERE "); sql.append("id IN ("); for (int i = 0; i < size; i++) { if (i != 0) { sql.append(", "); } sql.append('?'); } sql.append(") "); return sql.toString(); } @Override public String updateConfigInfoAtomicCas() { return "UPDATE config_info SET " + "content=?, md5 = ?, src_ip=?,src_user=?,gmt_modified=?, app_name=?,c_desc=?,c_use=?,effect=?,type=?,c_schema=? " + "WHERE data_id=? AND group_id=? AND (tenant_id=? OR tenant_id IS NULL) AND (md5=? OR md5 IS NULL OR md5='')"; } @Override public String getTableName() { return TableConstant.CONFIG_INFO; } @Override public String getDataSource() { return DataSourceConstant.KINGBASE; } }
(4)、ConfigInfoTagMapperByKingbase
/* * Copyright 1999-2022 Alibaba Group Holding Ltd. * * Licensed 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 com.alibaba.nacos.plugin.datasource.impl.kingbase; import com.alibaba.nacos.plugin.datasource.constants.TableConstant; import com.alibaba.nacos.plugin.datasource.mapper.ConfigInfoTagMapper; import com.alibaba.nacos.plugin.datasource.constants.DataSourceConstant; import com.alibaba.nacos.plugin.datasource.mapper.KingbaseAbstractMapper; /* * TODO * * @author xuanSam * @version 1.0 * @date 2023/10/18 20:53 * @Desc */ public class ConfigInfoTagMapperByKingbase extends KingbaseAbstractMapper implements ConfigInfoTagMapper { @Override public String updateConfigInfo4TagCas() { return "UPDATE config_info_tag SET content = ?, md5 = ?, src_ip = ?,src_user = ?,gmt_modified = ?,app_name = ? " + "WHERE data_id = ? AND group_id = ? AND (tenant_id = ? OR tenant_id IS NULL) AND tag_id = ? AND (md5 = " + "? OR md5 IS NULL OR md5 = '') "; } @Override public String findAllConfigInfoTagForDumpAllFetchRows(int startRow, int pageSize) { return " SELECT t.id,data_id,group_id,tenant_id,tag_id,app_name,content,md5,gmt_modified " + " FROM ( SELECT id FROM config_info_tag WHERE ROWNUM > " + startRow + " AND ROWNUM <=" + (startRow + pageSize) + "ORDER BY id " + " ) " + "g, config_info_tag t WHERE g.id = t.id "; } @Override public String getTableName() { return TableConstant.CONFIG_INFO_TAG; } @Override public String getDataSource() { return DataSourceConstant.KINGBASE; } }
(5)、ConfigTagsRelationMapperByKingbase
/* * Copyright 1999-2022 Alibaba Group Holding Ltd. * * Licensed 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 com.alibaba.nacos.plugin.datasource.impl.kingbase; import com.alibaba.nacos.common.utils.StringUtils; import com.alibaba.nacos.plugin.datasource.constants.TableConstant; import com.alibaba.nacos.plugin.datasource.mapper.ConfigTagsRelationMapper; import com.alibaba.nacos.plugin.datasource.constants.DataSourceConstant; import com.alibaba.nacos.plugin.datasource.mapper.KingbaseAbstractMapper; import java.util.Map; /* * TODO * * @author xuanSam * @version 1.0 * @date 2023/10/18 20:54 * @Desc */ public class ConfigTagsRelationMapperByKingbase extends KingbaseAbstractMapper implements ConfigTagsRelationMapper { @Override public String findConfigInfo4PageCountRows(final Map<String, String> params, final int tagSize) { final String appName = params.get("appName"); final String dataId = params.get("dataId"); final String group = params.get("group"); StringBuilder where = new StringBuilder(" WHERE "); final String sqlCount = "SELECT count(*) FROM config_info a LEFT JOIN config_tags_relation b ON a.id=b.id"; where.append(" (a.tenant_id=? OR a.tenant_id IS NULL)"); if (StringUtils.isNotBlank(dataId)) { where.append(" AND a.data_id=? "); } if (StringUtils.isNotBlank(group)) { where.append(" AND a.group_id=? "); } if (StringUtils.isNotBlank(appName)) { where.append(" AND a.app_name=? "); } where.append(" AND b.tag_name IN ("); for (int i = 0; i < tagSize; i++) { if (i != 0) { where.append(", "); } where.append('?'); } where.append(") "); return sqlCount + where; } @Override public String findConfigInfo4PageFetchRows(Map<String, String> params, int tagSize, int startRow, int pageSize) { final String appName = params.get("appName"); final String dataId = params.get("dataId"); final String group = params.get("group"); StringBuilder where = new StringBuilder(" WHERE "); final String sql = "SELECT a.id,a.data_id,a.group_id,a.tenant_id,a.app_name,a.content FROM config_info a LEFT JOIN " + "config_tags_relation b ON a.id=b.id"; where.append("( a.tenant_id=? OR tenant_id IS NULL)"); if (StringUtils.isNotBlank(dataId)) { where.append(" AND a.data_id=? "); } if (StringUtils.isNotBlank(group)) { where.append(" AND a.group_id=? "); } if (StringUtils.isNotBlank(appName)) { where.append(" AND a.app_name=? "); } where.append(" AND b.tag_name IN ("); for (int i = 0; i < tagSize; i++) { if (i != 0) { where.append(", "); } where.append('?'); } where.append(") "); return sql + where + " AND ROWNUM > " + sql + " AND ROWNUM <= " + (startRow + pageSize); } @Override public String findConfigInfoLike4PageCountRows(final Map<String, String> params, int tagSize) { final String appName = params.get("appName"); final String content = params.get("content"); final String dataId = params.get("dataId"); final String group = params.get("group"); StringBuilder where = new StringBuilder(" WHERE "); final String sqlCountRows = "SELECT count(*) FROM config_info a LEFT JOIN config_tags_relation b ON a.id=b.id "; where.append(" a.(tenant_id LIKE ? OR tenant_id IS NULL) "); if (!StringUtils.isBlank(dataId)) { where.append(" AND a.data_id LIKE ? "); } if (!StringUtils.isBlank(group)) { where.append(" AND a.group_id LIKE ? "); } if (!StringUtils.isBlank(appName)) { where.append(" AND a.app_name = ? "); } if (!StringUtils.isBlank(content)) { where.append(" AND a.content LIKE ? "); } where.append(" AND b.tag_name IN ("); for (int i = 0; i < tagSize; i++) { if (i != 0) { where.append(", "); } where.append('?'); } where.append(") "); return sqlCountRows + where; } @Override public String findConfigInfoLike4PageFetchRows(final Map<String, String> params, int tagSize, int startRow, int pageSize) { final String appName = params.get("appName"); final String content = params.get("content"); final String dataId = params.get("dataId"); final String group = params.get("group"); StringBuilder where = new StringBuilder(" WHERE "); final String sqlFetchRows = "SELECT a.id,a.data_id,a.group_id,a.tenant_id,a.app_name,a.content " + "FROM config_info a LEFT JOIN config_tags_relation b ON a.id=b.id "; where.append(" a.(tenant_id LIKE ? OR tenant_id IS NULL) "); if (!StringUtils.isBlank(dataId)) { where.append(" AND a.data_id LIKE ? "); } if (!StringUtils.isBlank(group)) { where.append(" AND a.group_id LIKE ? "); } if (!StringUtils.isBlank(appName)) { where.append(" AND a.app_name = ? "); } if (!StringUtils.isBlank(content)) { where.append(" AND a.content LIKE ? "); } where.append(" AND b.tag_name IN ("); for (int i = 0; i < tagSize; i++) { if (i != 0) { where.append(", "); } where.append('?'); } where.append(") "); return sqlFetchRows + where + " AND ROWNUM > " + startRow + " AND ROWNUM <= " + (startRow + pageSize); } @Override public String getTableName() { return TableConstant.CONFIG_TAGS_RELATION; } @Override public String getDataSource() { return DataSourceConstant.KINGBASE; } }
(6)、GroupCapacityMapperByKingbase
/* * Copyright 1999-2022 Alibaba Group Holding Ltd. * * Licensed 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 com.alibaba.nacos.plugin.datasource.impl.kingbase; import com.alibaba.nacos.plugin.datasource.constants.TableConstant; import com.alibaba.nacos.plugin.datasource.mapper.GroupCapacityMapper; import com.alibaba.nacos.plugin.datasource.constants.DataSourceConstant; import com.alibaba.nacos.plugin.datasource.mapper.KingbaseAbstractMapper; /* * TODO * * @author xuanSam * @version 1.0 * @date 2023/10/18 20:55 * @Desc */ public class GroupCapacityMapperByKingbase extends KingbaseAbstractMapper implements GroupCapacityMapper { @Override public String insertIntoSelect() { return "INSERT INTO group_capacity (group_id, quota, `usage`, `max_size`, max_aggr_count, max_aggr_size,gmt_create," + " gmt_modified) SELECT ?, ?, count(*), ?, ?, ?, ?, ? FROM config_info"; } @Override public String insertIntoSelectByWhere() { return "INSERT INTO group_capacity (group_id, quota,`usage`, `max_size`, max_aggr_count, max_aggr_size, gmt_create," + " gmt_modified) SELECT ?, ?, count(*), ?, ?, ?, ?, ? FROM config_info WHERE group_id=? AND tenant_id = ''"; } @Override public String incrementUsageByWhereQuotaEqualZero() { return "UPDATE group_capacity SET `usage` = `usage` + 1, gmt_modified = ? WHERE group_id = ? AND `usage` < ? AND quota = 0"; } @Override public String incrementUsageByWhereQuotaNotEqualZero() { return "UPDATE group_capacity SET `usage` = `usage` + 1, gmt_modified = ? WHERE group_id = ? AND `usage` < quota AND quota != 0"; } @Override public String incrementUsageByWhere() { return "UPDATE group_capacity SET `usage` = `usage` + 1, gmt_modified = ? WHERE group_id = ?"; } @Override public String decrementUsageByWhere() { return "UPDATE group_capacity SET `usage` = `usage` - 1, gmt_modified = ? WHERE group_id = ? AND `usage` > 0"; } @Override public String updateUsage() { return "UPDATE group_capacity SET `usage` = (SELECT count(*) FROM config_info), gmt_modified = ? WHERE group_id = ?"; } @Override public String updateUsageByWhere() { return "UPDATE group_capacity SET `usage` = (SELECT count(*) FROM config_info WHERE group_id=? AND tenant_id = '')," + " gmt_modified = ? WHERE group_id= ?"; } @Override public String selectGroupInfoBySize() { return "SELECT id, group_id FROM group_capacity WHERE id > ? ROWNUM > ?"; } @Override public String getTableName() { return TableConstant.GROUP_CAPACITY; } @Override public String getDataSource() { return DataSourceConstant.KINGBASE; } }
(7)、HistoryConfigInfoMapperByKingbase
/* * Copyright 1999-2022 Alibaba Group Holding Ltd. * * Licensed 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 com.alibaba.nacos.plugin.datasource.impl.kingbase; import com.alibaba.nacos.plugin.datasource.constants.TableConstant; import com.alibaba.nacos.plugin.datasource.mapper.HistoryConfigInfoMapper; import com.alibaba.nacos.plugin.datasource.constants.DataSourceConstant; import com.alibaba.nacos.plugin.datasource.mapper.KingbaseAbstractMapper; /* * TODO * * @author xuanSam * @version 1.0 * @date 2023/10/18 20:56 * @Desc */ public class HistoryConfigInfoMapperByKingbase extends KingbaseAbstractMapper implements HistoryConfigInfoMapper { @Override public String removeConfigHistory() { return "DELETE FROM his_config_info WHERE gmt_modified < ? AND ROWNUM > ?"; } @Override public String findConfigHistoryCountByTime() { return "SELECT count(*) FROM his_config_info WHERE gmt_modified < ?"; } @Override public String findDeletedConfig() { return "SELECT DISTINCT data_id, group_id, tenant_id FROM his_config_info WHERE op_type = 'D' AND gmt_modified >= ? AND gmt_modified <= ?"; } @Override public String findConfigHistoryFetchRows() { return "SELECT nid,data_id,group_id,tenant_id,app_name,src_ip,src_user,op_type,gmt_create,gmt_modified FROM his_config_info " + "WHERE data_id = ? AND group_id = ? AND (tenant_id = ? OR tenant_id IS NULL) ORDER BY nid DESC"; } @Override public String detailPreviousConfigHistory() { return "SELECT nid,data_id,group_id,tenant_id,app_name,content,md5,src_user,src_ip,op_type,gmt_create,gmt_modified " + "FROM his_config_info WHERE nid = (SELECT max(nid) FROM his_config_info WHERE id = ?) "; } @Override public String getTableName() { return TableConstant.HIS_CONFIG_INFO; } @Override public String getDataSource() { return DataSourceConstant.KINGBASE; } }
(8)、TenantCapacityMapperByKingbase
/* * Copyright 1999-2022 Alibaba Group Holding Ltd. * * Licensed 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 com.alibaba.nacos.plugin.datasource.impl.kingbase; import com.alibaba.nacos.plugin.datasource.constants.TableConstant; import com.alibaba.nacos.plugin.datasource.mapper.KingbaseAbstractMapper; import com.alibaba.nacos.plugin.datasource.mapper.TenantCapacityMapper; import com.alibaba.nacos.plugin.datasource.constants.DataSourceConstant; /* * TODO * * @author xuanSam * @version 1.0 * @date 2023/10/18 20:57 * @Desc */ public class TenantCapacityMapperByKingbase extends KingbaseAbstractMapper implements TenantCapacityMapper { @Override public String incrementUsageWithDefaultQuotaLimit() { return "UPDATE tenant_capacity SET `usage` = `usage` + 1, gmt_modified = ? WHERE " + "((tenant_id = ? OR tenant_id IS NULL) OR tenant_id IS NULL) AND `usage` <" + " ? AND quota = 0"; } @Override public String incrementUsageWithQuotaLimit() { return "UPDATE tenant_capacity SET `usage` = `usage` + 1, gmt_modified = ? WHERE " + "(tenant_id = ? OR tenant_id IS NULL) AND `usage` < " + "quota AND quota != 0"; } @Override public String incrementUsage() { return "UPDATE tenant_capacity SET `usage` = `usage` + 1, gmt_modified = ? WHERE (tenant_id = ? OR tenant_id IS NULL)"; } @Override public String decrementUsage() { return "UPDATE tenant_capacity SET `usage` = `usage` - 1, gmt_modified = ? WHERE (tenant_id = ? OR tenant_id IS NULL) AND `usage` > 0"; } @Override public String correctUsage() { return "UPDATE tenant_capacity SET `usage` = (SELECT count(*) FROM config_info WHERE (tenant_id = ? OR tenant_id IS NULL)), " + "gmt_modified = ? WHERE (tenant_id = ? OR tenant_id IS NULL)"; } @Override public String getCapacityList4CorrectUsage() { return "SELECT id, tenant_id FROM tenant_capacity WHERE id> AND ROWNUM > ?"; } @Override public String insertTenantCapacity() { return "INSERT INTO tenant_capacity (tenant_id, quota, `usage`, `max_size`, max_aggr_count, max_aggr_size, " + "gmt_create, gmt_modified) SELECT ?, ?, count(*), ?, ?, ?, ?, ? FROM config_info WHERE tenant_id=? OR tenant_id IS NULL;"; } @Override public String getTableName() { return TableConstant.TENANT_CAPACITY; } @Override public String getDataSource() { return DataSourceConstant.KINGBASE; } }
(9)、TenantInfoMapperByKingbase
/* * Copyright 1999-2022 Alibaba Group Holding Ltd. * * Licensed 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 com.alibaba.nacos.plugin.datasource.impl.kingbase; import com.alibaba.nacos.plugin.datasource.constants.TableConstant; import com.alibaba.nacos.plugin.datasource.mapper.KingbaseAbstractMapper; import com.alibaba.nacos.plugin.datasource.mapper.TenantInfoMapper; import com.alibaba.nacos.plugin.datasource.constants.DataSourceConstant; /* * TODO * * @author xuanSam * @version 1.0 * @date 2023/10/18 20:57 * @Desc */ public class TenantInfoMapperByKingbase extends KingbaseAbstractMapper implements TenantInfoMapper { @Override public String getTableName() { return TableConstant.TENANT_INFO; } @Override public String getDataSource() { return DataSourceConstant.KINGBASE; } }
(10)、plugin/datasource/src/main/resources/META-INF/services 下增加以下数据
com.alibaba.nacos.plugin.datasource.impl.kingbase.ConfigInfoAggrMapperByKingbase
com.alibaba.nacos.plugin.datasource.impl.kingbase.ConfigInfoBetaMapperByKingbase
com.alibaba.nacos.plugin.datasource.impl.kingbase.ConfigInfoMapperByKingbase
com.alibaba.nacos.plugin.datasource.impl.kingbase.ConfigInfoTagMapperByKingbase
com.alibaba.nacos.plugin.datasource.impl.kingbase.ConfigTagsRelationMapperByKingbase
com.alibaba.nacos.plugin.datasource.impl.kingbase.GroupCapacityMapperByKingbase
com.alibaba.nacos.plugin.datasource.impl.kingbase.HistoryConfigInfoMapperByKingbase
com.alibaba.nacos.plugin.datasource.impl.kingbase.TenantCapacityMapperByKingbase
com.alibaba.nacos.plugin.datasource.impl.kingbase.TenantInfoMapperByKingbase
(四)nacos-config包源码修改
1.在ExternalDataSourceServiceImpl类中找到方法public void init() 追加如下代码。
if(Objects.isNull(jt.getDataSource())){ jt.setDataSource(dataSourceList.get(0)); }
防止启动项目报错:
Invocation of init method failed; nested exception is ErrCode:500, ErrMsg:Nacos Server did not start because dumpservice bean construction failure :
No DataSource set
2.在ExternalConfigInfoPersistServiceImpl类中找到方法void insertOrUpdate方法,修改代码。
因为ora_input_emptystr_isnull 参数设置的原因,如果设置为“on”,表"config_info" 的三个字段(data_id, group_id, tenant_id)设置的唯一索引,出现问题,用户使用配置信息
将会报错。如果设置为“off”,重启数据库,则无需修改如下代码。
(1)修改前
(2)修改后
源码:
@Override public void insertOrUpdate(String srcIp, String srcUser, ConfigInfo configInfo, Timestamp time, Map<String, Object> configAdvanceInfo, boolean notify) { try { ConfigAllInfo configAllInfo = findConfigAllInfo(configInfo.getDataId(), configInfo.getGroup(),configInfo.getTenant()); if(configAllInfo !=null){ updateConfigInfo(configInfo, srcIp, srcUser, time, configAdvanceInfo, notify); }else{ addConfigInfo(srcIp, srcUser, configInfo, time, configAdvanceInfo, notify); } } catch (DataIntegrityViolationException ive) { // Unique constraint conflict updateConfigInfo(configInfo, srcIp, srcUser, time, configAdvanceInfo, notify); } }
四、构建打包
mvn -Prelease-nacos -Dmaven.test.skip=true -Dpmd.skip=true -Dcheckstyle.skip=true -Drat.skip=true clean install
或者
mvn -Prelease-nacos -Dmaven.test.skip=true -Dpmd.skip=true -Dcheckstyle.skip=true clean install
或者
mvn -Prelease-nacos clean package install -Dmaven.test.skip=true
打包成功后,在distribution的target下生成两个包,如下图。nacos-server-2.2.0.tar.gz 是linux环境的部署包,nacos-server-2.2.0.zip 是windows环境的部署包。
五、源码
源码仓库:https://gitee.com/liuqq_1015/kingbase_nacos