nacos 适配瀚高数据库、ARM 架构

下载nacos源码: https://github.com/alibaba/nacos/tree/2.3.1

瀚高技术文档

1、修改pom.xml

根目录nacos-all => pom.xml<dependencyManagement><dependency><groupId>com.highgo</groupId><artifactId>HgdbJdbc</artifactId><version>6.2.3</version></dependency></dependencyManagement>.nacos-config模块 => pom.xml
<dependency><groupId>com.highgo</groupId><artifactId>HgdbJdbc</artifactId>            
</dependency>

2、修改nacos-config模块 连接驱动    ExternalDataSourceProperties

com.alibaba.nacos.persistence.datasource.ExternalDataSourcePropertiesprivate static final String JDBC_DRIVER_NAME = "com.mysql.cj.jdbc.Driver";
修改为:
private static final String JDBC_DRIVER_NAME = "com.highgo.jdbc.Driver";

3、nacos-datasource-plugin模块增加支持的数据库类型

com.alibaba.nacos.plugin.datasource.constants.DataSourceConstantpublic class DataSourceConstant {public static final String MYSQL = "mysql";public static final String DERBY = "derby";public static final String HIGHGO = "highgo";
}

4、 根据SPI机制进行代码扩展

ConfigInfoAggrMapperByHighgo
ConfigInfoBetaMapperByHighgo
ConfigInfoMapperByHighgo
ConfigInfoTagMapperByHighgo
ConfigTagsRelationMapperByHighgo
GroupCapacityMapperByHighgo
HistoryConfigInfoMapperByHighgo
TenantCapacityMapperByHighgo
TenantInfoMapperByHighgo

/** 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.highgo;import com.alibaba.nacos.common.utils.CollectionUtils;
import com.alibaba.nacos.plugin.datasource.constants.DataSourceConstant;
import com.alibaba.nacos.plugin.datasource.constants.FieldConstant;
import com.alibaba.nacos.plugin.datasource.mapper.AbstractMapper;
import com.alibaba.nacos.plugin.datasource.mapper.ConfigInfoAggrMapper;
import com.alibaba.nacos.plugin.datasource.model.MapperContext;
import com.alibaba.nacos.plugin.datasource.model.MapperResult;import java.util.List;/*** The highgo implementation of ConfigInfoAggrMapper.** @Date: 2023/05/11*/
public class ConfigInfoAggrMapperByHighgo extends AbstractMapper implements ConfigInfoAggrMapper {@Overridepublic MapperResult findConfigInfoAggrByPageFetchRows(MapperContext context) {int startRow = context.getStartRow();int pageSize = context.getPageSize();String dataId = (String) context.getWhereParameter(FieldConstant.DATA_ID);String groupId = (String) context.getWhereParameter(FieldConstant.GROUP_ID);String tenantId = (String) context.getWhereParameter(FieldConstant.TENANT_ID);String sql ="SELECT data_id,group_id,tenant_id,datum_id,app_name,content FROM config_info_aggr WHERE data_id= ? AND "+ " group_id= ? AND tenant_id= ? ORDER BY datum_id " + " OFFSET " + startRow + " LIMIT " + pageSize;List<Object> paramList = CollectionUtils.list(dataId, groupId, tenantId);return new MapperResult(sql, paramList);}@Overridepublic String getDataSource() {return DataSourceConstant.HIGHGO;}
}
/** 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.highgo;import com.alibaba.nacos.plugin.datasource.constants.DataSourceConstant;
import com.alibaba.nacos.plugin.datasource.mapper.AbstractMapper;
import com.alibaba.nacos.plugin.datasource.mapper.ConfigInfoBetaMapper;
import com.alibaba.nacos.plugin.datasource.model.MapperContext;
import com.alibaba.nacos.plugin.datasource.model.MapperResult;import java.util.ArrayList;
import java.util.List;/*** The highgo implementation of ConfigInfoBetaMapper.** @Date: 2023/05/11*/
public class ConfigInfoBetaMapperByHighgo extends AbstractMapper implements ConfigInfoBetaMapper {@Overridepublic MapperResult findAllConfigInfoBetaForDumpAllFetchRows(MapperContext context) {int startRow = context.getStartRow();int pageSize = context.getPageSize();String sql = " SELECT t.id,data_id,group_id,tenant_id,app_name,content,md5,gmt_modified,beta_ips,encrypted_data_key "+ " FROM ( SELECT id FROM config_info_beta  ORDER BY id OFFSET " + startRow + " LIMIT " + pageSize + ")"+ "  g, config_info_beta t WHERE g.id = t.id ";List<Object> paramList = new ArrayList<>();paramList.add(startRow);paramList.add(pageSize);return new MapperResult(sql, paramList);}@Overridepublic String getDataSource() {return DataSourceConstant.HIGHGO;}
}
/** 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.highgo;import com.alibaba.nacos.common.utils.CollectionUtils;
import com.alibaba.nacos.common.utils.NamespaceUtil;
import com.alibaba.nacos.plugin.datasource.constants.ContextConstant;
import com.alibaba.nacos.plugin.datasource.constants.DataSourceConstant;
import com.alibaba.nacos.plugin.datasource.constants.FieldConstant;
import com.alibaba.nacos.plugin.datasource.mapper.AbstractMapper;
import com.alibaba.nacos.plugin.datasource.mapper.ConfigInfoMapper;
import com.alibaba.nacos.plugin.datasource.model.MapperContext;
import com.alibaba.nacos.plugin.datasource.model.MapperResult;import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;/*** The highgo implementation of ConfigInfoMapper.** @Date: 2023/05/11*/
public class ConfigInfoMapperByHighgo extends AbstractMapper implements ConfigInfoMapper {private static final String DATA_ID = "dataId";private static final String GROUP = "group";private static final String APP_NAME = "appName";private static final String CONTENT = "content";private static final String TENANT = "tenant";@Overridepublic MapperResult findConfigInfoByAppFetchRows(MapperContext context) {final String appName = (String) context.getWhereParameter(FieldConstant.APP_NAME);final String tenantId = (String) context.getWhereParameter(FieldConstant.TENANT_ID);String sql = "SELECT id,data_id,group_id,tenant_id,app_name,content FROM config_info"+ " WHERE tenant_id LIKE ? AND app_name= ?" + " OFFSET " + context.getStartRow() + " LIMIT " + context.getPageSize();return new MapperResult(sql, CollectionUtils.list(tenantId, appName));}@Overridepublic MapperResult getTenantIdList(MapperContext context) {String sql = "SELECT tenant_id FROM config_info WHERE tenant_id != '" + NamespaceUtil.getNamespaceDefaultId()+ "' GROUP BY tenant_id OFFSET " + context.getStartRow() + " LIMIT " + context.getPageSize();return new MapperResult(sql, Collections.emptyList());}@Overridepublic MapperResult getGroupIdList(MapperContext context) {String sql = "SELECT group_id FROM config_info WHERE tenant_id ='" + NamespaceUtil.getNamespaceDefaultId()+ "' GROUP BY group_id OFFSET " + context.getStartRow() + " LIMIT " + context.getPageSize();return new MapperResult(sql, Collections.emptyList());}@Overridepublic MapperResult findAllConfigKey(MapperContext context) {String sql = " SELECT data_id,group_id,app_name  FROM ( "+ " SELECT id FROM config_info WHERE tenant_id LIKE ? ORDER BY id OFFSET " + context.getStartRow() + " LIMIT "+ context.getPageSize() + " )" + " g, config_info t WHERE g.id = t.id  ";return new MapperResult(sql, CollectionUtils.list(context.getWhereParameter(FieldConstant.TENANT_ID)));}@Overridepublic MapperResult findAllConfigInfoBaseFetchRows(MapperContext context) {String sql = "SELECT t.id,data_id,group_id,content,md5"+ " FROM ( SELECT id FROM config_info ORDER BY id OFFSET ? LIMIT ? ) "+ " g, config_info t  WHERE g.id = t.id ";return new MapperResult(sql, Collections.emptyList());}@Overridepublic MapperResult findAllConfigInfoFragment(MapperContext context) {String contextParameter = context.getContextParameter(ContextConstant.NEED_CONTENT);boolean needContent = contextParameter != null && Boolean.parseBoolean(contextParameter);String sql = "SELECT id,data_id,group_id,tenant_id,app_name," + (needContent ? "content," : "")+ "md5,gmt_modified,type,encrypted_data_key FROM config_info WHERE id > ? ORDER BY id ASC OFFSET "+ context.getStartRow() + " LIMIT " + context.getPageSize();return new MapperResult(sql, CollectionUtils.list(context.getWhereParameter(FieldConstant.ID)));}@Overridepublic MapperResult findChangeConfigFetchRows(MapperContext context) {final String tenant = (String) context.getWhereParameter(FieldConstant.TENANT_ID);final String dataId = (String) context.getWhereParameter(FieldConstant.DATA_ID);final String group = (String) context.getWhereParameter(FieldConstant.GROUP_ID);final String appName = (String) context.getWhereParameter(FieldConstant.APP_NAME);final String tenantTmp = com.alibaba.nacos.common.utils.StringUtils.isBlank(tenant)? com.alibaba.nacos.common.utils.StringUtils.EMPTY : tenant;final Timestamp startTime = (Timestamp) context.getWhereParameter(FieldConstant.START_TIME);final Timestamp endTime = (Timestamp) context.getWhereParameter(FieldConstant.END_TIME);List<Object> paramList = new ArrayList<>();final String sqlFetchRows = "SELECT id,data_id,group_id,tenant_id,app_name,type,md5,gmt_modified FROM config_info WHERE ";String where = " 1=1 ";if (!com.alibaba.nacos.common.utils.StringUtils.isBlank(dataId)) {where += " AND data_id LIKE ? ";paramList.add(dataId);}if (!com.alibaba.nacos.common.utils.StringUtils.isBlank(group)) {where += " AND group_id LIKE ? ";paramList.add(group);}if (!com.alibaba.nacos.common.utils.StringUtils.isBlank(tenantTmp)) {where += " AND tenant_id = ? ";paramList.add(tenantTmp);}if (!com.alibaba.nacos.common.utils.StringUtils.isBlank(appName)) {where += " AND app_name = ? ";paramList.add(appName);}if (startTime != null) {where += " AND gmt_modified >=? ";paramList.add(startTime);}if (endTime != null) {where += " AND gmt_modified <=? ";paramList.add(endTime);}return new MapperResult(sqlFetchRows + where + " AND id > " + context.getWhereParameter(FieldConstant.LAST_MAX_ID)+ " ORDER BY id ASC" + " OFFSET " + 0 + " LIMIT " + context.getPageSize(), paramList);}@Overridepublic MapperResult listGroupKeyMd5ByPageFetchRows(MapperContext context) {String sql = "SELECT t.id,data_id,group_id,tenant_id,app_name,md5,type,gmt_modified,encrypted_data_key FROM "+ "( SELECT id FROM config_info ORDER BY id OFFSET " + context.getStartRow() + " LIMIT "+ context.getPageSize() + " ) g, config_info t WHERE g.id = t.id";return new MapperResult(sql, Collections.emptyList());}@Overridepublic MapperResult findConfigInfoBaseLikeFetchRows(MapperContext context) {final String dataId = (String) context.getWhereParameter(FieldConstant.DATA_ID);final String group = (String) context.getWhereParameter(FieldConstant.GROUP_ID);final String content = (String) context.getWhereParameter(FieldConstant.CONTENT);final String sqlFetchRows = "SELECT id,data_id,group_id,tenant_id,content FROM config_info WHERE ";String where = " 1=1 AND tenant_id='" + NamespaceUtil.getNamespaceDefaultId() + "' ";List<Object> paramList = new ArrayList<>();if (!com.alibaba.nacos.common.utils.StringUtils.isBlank(dataId)) {where += " AND data_id LIKE ? ";paramList.add(dataId);}if (!com.alibaba.nacos.common.utils.StringUtils.isBlank(group)) {where += " AND group_id LIKE ";paramList.add(group);}if (!com.alibaba.nacos.common.utils.StringUtils.isBlank(content)) {where += " AND content LIKE ? ";paramList.add(content);}return new MapperResult(sqlFetchRows + where + " OFFSET " + context.getStartRow() + " LIMIT " + context.getPageSize(),paramList);}@Overridepublic MapperResult findConfigInfo4PageFetchRows(MapperContext context) {final String tenant = (String) context.getWhereParameter(FieldConstant.TENANT_ID);final String dataId = (String) context.getWhereParameter(FieldConstant.DATA_ID);final String group = (String) context.getWhereParameter(FieldConstant.GROUP_ID);final String appName = (String) context.getWhereParameter(FieldConstant.APP_NAME);final String content = (String) context.getWhereParameter(FieldConstant.CONTENT);List<Object> paramList = new ArrayList<>();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=? ");paramList.add(tenant);if (com.alibaba.nacos.common.utils.StringUtils.isNotBlank(dataId)) {where.append(" AND data_id=? ");paramList.add(dataId);}if (com.alibaba.nacos.common.utils.StringUtils.isNotBlank(group)) {where.append(" AND group_id=? ");paramList.add(group);}if (com.alibaba.nacos.common.utils.StringUtils.isNotBlank(appName)) {where.append(" AND app_name=? ");paramList.add(appName);}if (!com.alibaba.nacos.common.utils.StringUtils.isBlank(content)) {where.append(" AND content LIKE ? ");paramList.add(content);}return new MapperResult(sql + where + " OFFSET " + context.getStartRow() + " LIMIT " + context.getPageSize(),paramList);}@Overridepublic MapperResult findConfigInfoBaseByGroupFetchRows(MapperContext context) {String sql = "SELECT id,data_id,group_id,content FROM config_info WHERE group_id=? AND tenant_id=?" + " OFFSET "+ context.getStartRow() + " LIMIT " + context.getPageSize();return new MapperResult(sql, CollectionUtils.list(context.getWhereParameter(FieldConstant.GROUP_ID),context.getWhereParameter(FieldConstant.TENANT_ID)));}@Overridepublic MapperResult findConfigInfoLike4PageFetchRows(MapperContext context) {final String tenant = (String) context.getWhereParameter(FieldConstant.TENANT_ID);final String dataId = (String) context.getWhereParameter(FieldConstant.DATA_ID);final String group = (String) context.getWhereParameter(FieldConstant.GROUP_ID);final String appName = (String) context.getWhereParameter(FieldConstant.APP_NAME);final String content = (String) context.getWhereParameter(FieldConstant.CONTENT);List<Object> paramList = new ArrayList<>();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 ? ");paramList.add(tenant);if (!com.alibaba.nacos.common.utils.StringUtils.isBlank(dataId)) {where.append(" AND data_id LIKE ? ");paramList.add(dataId);}if (!com.alibaba.nacos.common.utils.StringUtils.isBlank(group)) {where.append(" AND group_id LIKE ? ");paramList.add(group);}if (!com.alibaba.nacos.common.utils.StringUtils.isBlank(appName)) {where.append(" AND app_name = ? ");paramList.add(appName);}if (!com.alibaba.nacos.common.utils.StringUtils.isBlank(content)) {where.append(" AND content LIKE ? ");paramList.add(content);}return new MapperResult(sqlFetchRows + where + " OFFSET " + context.getStartRow() + " LIMIT " + context.getPageSize(),paramList);}@Overridepublic MapperResult findAllConfigInfoFetchRows(MapperContext context) {String sql = "SELECT t.id,data_id,group_id,tenant_id,app_name,content,md5 "+ " FROM (  SELECT id FROM config_info WHERE tenant_id LIKE ? ORDER BY id OFFSET ? LIMIT ? )"+ " g, config_info t  WHERE g.id = t.id ";return new MapperResult(sql,CollectionUtils.list(context.getWhereParameter(FieldConstant.TENANT_ID), context.getStartRow(),context.getPageSize()));}@Overridepublic String getDataSource() {return DataSourceConstant.HIGHGO;}}
/** 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.highgo;import com.alibaba.nacos.plugin.datasource.constants.DataSourceConstant;
import com.alibaba.nacos.plugin.datasource.mapper.AbstractMapper;
import com.alibaba.nacos.plugin.datasource.mapper.ConfigInfoTagMapper;
import com.alibaba.nacos.plugin.datasource.model.MapperContext;
import com.alibaba.nacos.plugin.datasource.model.MapperResult;import java.util.Collections;/*** The highgo implementation of ConfigInfoTagMapper.** @Date: 2023/05/11*/
public class ConfigInfoTagMapperByHighgo extends AbstractMapper implements ConfigInfoTagMapper {@Overridepublic MapperResult findAllConfigInfoTagForDumpAllFetchRows(MapperContext context) {String sql = " SELECT t.id,data_id,group_id,tenant_id,tag_id,app_name,content,md5,gmt_modified "+ " FROM (  SELECT id FROM config_info_tag  ORDER BY id OFFSET " + context.getStartRow() + " LIMIT "+ context.getPageSize() + " ) " + "g, config_info_tag t  WHERE g.id = t.id  ";return new MapperResult(sql, Collections.emptyList());}@Overridepublic String getDataSource() {return DataSourceConstant.HIGHGO;}
}
/** 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.highgo;import com.alibaba.nacos.common.utils.StringUtils;
import com.alibaba.nacos.plugin.datasource.constants.DataSourceConstant;
import com.alibaba.nacos.plugin.datasource.constants.FieldConstant;
import com.alibaba.nacos.plugin.datasource.mapper.AbstractMapper;
import com.alibaba.nacos.plugin.datasource.mapper.ConfigTagsRelationMapper;
import com.alibaba.nacos.plugin.datasource.model.MapperContext;
import com.alibaba.nacos.plugin.datasource.model.MapperResult;import java.util.ArrayList;
import java.util.List;/*** The highgo implementation of ConfigTagsRelationMapper.** @Date: 2023/05/11*/
public class ConfigTagsRelationMapperByHighgo extends AbstractMapper implements ConfigTagsRelationMapper {@Overridepublic MapperResult findConfigInfo4PageFetchRows(MapperContext context) {final String tenant = (String) context.getWhereParameter(FieldConstant.TENANT_ID);final String dataId = (String) context.getWhereParameter(FieldConstant.DATA_ID);final String group = (String) context.getWhereParameter(FieldConstant.GROUP_ID);final String appName = (String) context.getWhereParameter(FieldConstant.APP_NAME);final String content = (String) context.getWhereParameter(FieldConstant.CONTENT);final String[] tagArr = (String[]) context.getWhereParameter(FieldConstant.TAG_ARR);List<Object> paramList = new ArrayList<>();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=? ");paramList.add(tenant);if (StringUtils.isNotBlank(dataId)) {where.append(" AND a.data_id=? ");paramList.add(dataId);}if (StringUtils.isNotBlank(group)) {where.append(" AND a.group_id=? ");paramList.add(group);}if (StringUtils.isNotBlank(appName)) {where.append(" AND a.app_name=? ");paramList.add(appName);}if (!StringUtils.isBlank(content)) {where.append(" AND a.content LIKE ? ");paramList.add(content);}where.append(" AND b.tag_name IN (");for (int i = 0; i < tagArr.length; i++) {if (i != 0) {where.append(", ");}where.append('?');paramList.add(tagArr[i]);}where.append(") ");return new MapperResult(sql + where + " OFFSET " + context.getStartRow() + " LIMIT " + context.getPageSize(),paramList);}@Overridepublic MapperResult findConfigInfoLike4PageFetchRows(MapperContext context) {final String tenant = (String) context.getWhereParameter(FieldConstant.TENANT_ID);final String dataId = (String) context.getWhereParameter(FieldConstant.DATA_ID);final String group = (String) context.getWhereParameter(FieldConstant.GROUP_ID);final String appName = (String) context.getWhereParameter(FieldConstant.APP_NAME);final String content = (String) context.getWhereParameter(FieldConstant.CONTENT);final String[] tagArr = (String[]) context.getWhereParameter(FieldConstant.TAG_ARR);List<Object> paramList = new ArrayList<>();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 ? ");paramList.add(tenant);if (!StringUtils.isBlank(dataId)) {where.append(" AND a.data_id LIKE ? ");paramList.add(dataId);}if (!StringUtils.isBlank(group)) {where.append(" AND a.group_id LIKE ? ");paramList.add(group);}if (!StringUtils.isBlank(appName)) {where.append(" AND a.app_name = ? ");paramList.add(appName);}if (!StringUtils.isBlank(content)) {where.append(" AND a.content LIKE ? ");paramList.add(content);}where.append(" AND b.tag_name IN (");for (int i = 0; i < tagArr.length; i++) {if (i != 0) {where.append(", ");}where.append('?');paramList.add(tagArr[i]);}where.append(") ");return new MapperResult(sqlFetchRows + where + " OFFSET " + context.getStartRow() + " LIMIT " + context.getPageSize(),paramList);}@Overridepublic String getDataSource() {return DataSourceConstant.HIGHGO;}
}
/** 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.highgo;import com.alibaba.nacos.common.utils.CollectionUtils;
import com.alibaba.nacos.plugin.datasource.constants.DataSourceConstant;
import com.alibaba.nacos.plugin.datasource.constants.FieldConstant;
import com.alibaba.nacos.plugin.datasource.mapper.AbstractMapper;
import com.alibaba.nacos.plugin.datasource.mapper.GroupCapacityMapper;
import com.alibaba.nacos.plugin.datasource.model.MapperContext;
import com.alibaba.nacos.plugin.datasource.model.MapperResult;/*** The highgo implementation of GroupCapacityMapper.** @Date: 2023/05/11*/
public class GroupCapacityMapperByHighgo extends AbstractMapper implements GroupCapacityMapper {@Overridepublic MapperResult selectGroupInfoBySize(MapperContext context) {String sql = "SELECT id, group_id FROM group_capacity WHERE id > ? LIMIT ?";return new MapperResult(sql, CollectionUtils.list(context.getWhereParameter(FieldConstant.ID), context.getPageSize()));}@Overridepublic String getDataSource() {return DataSourceConstant.HIGHGO;}
}
/** 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.highgo;import com.alibaba.nacos.common.utils.CollectionUtils;
import com.alibaba.nacos.plugin.datasource.constants.DataSourceConstant;
import com.alibaba.nacos.plugin.datasource.constants.FieldConstant;
import com.alibaba.nacos.plugin.datasource.mapper.AbstractMapper;
import com.alibaba.nacos.plugin.datasource.mapper.HistoryConfigInfoMapper;
import com.alibaba.nacos.plugin.datasource.model.MapperContext;
import com.alibaba.nacos.plugin.datasource.model.MapperResult;/*** The highgo implementation of HistoryConfigInfoMapper.** @Date: 2023/05/11*/
public class HistoryConfigInfoMapperByHighgo extends AbstractMapper implements HistoryConfigInfoMapper {@Overridepublic MapperResult removeConfigHistory(MapperContext context) {String sql = "DELETE FROM his_config_info WHERE gmt_modified < ? LIMIT ?";return new MapperResult(sql, CollectionUtils.list(context.getWhereParameter(FieldConstant.START_TIME),context.getWhereParameter(FieldConstant.LIMIT_SIZE)));}@Overridepublic MapperResult pageFindConfigHistoryFetchRows(MapperContext context) {String sql ="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 = ? ORDER BY nid DESC  OFFSET "+ context.getStartRow() + " LIMIT " + context.getPageSize();return new MapperResult(sql, CollectionUtils.list(context.getWhereParameter(FieldConstant.DATA_ID),context.getWhereParameter(FieldConstant.GROUP_ID), context.getWhereParameter(FieldConstant.TENANT_ID)));}@Overridepublic String getDataSource() {return DataSourceConstant.HIGHGO;}
}
/** 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.highgo;import com.alibaba.nacos.common.utils.CollectionUtils;
import com.alibaba.nacos.plugin.datasource.constants.DataSourceConstant;
import com.alibaba.nacos.plugin.datasource.constants.FieldConstant;
import com.alibaba.nacos.plugin.datasource.mapper.AbstractMapper;
import com.alibaba.nacos.plugin.datasource.mapper.TenantCapacityMapper;
import com.alibaba.nacos.plugin.datasource.model.MapperContext;
import com.alibaba.nacos.plugin.datasource.model.MapperResult;/*** The highgo implementation of TenantCapacityMapper.** @Date: 2023/05/11*/
public class TenantCapacityMapperByHighgo extends AbstractMapper implements TenantCapacityMapper {@Overridepublic MapperResult getCapacityList4CorrectUsage(MapperContext context) {String sql = "SELECT id, tenant_id FROM tenant_capacity WHERE id>? LIMIT ?";return new MapperResult(sql, CollectionUtils.list(context.getWhereParameter(FieldConstant.ID),context.getWhereParameter(FieldConstant.LIMIT_SIZE)));}@Overridepublic String getDataSource() {return DataSourceConstant.HIGHGO;}
}
/** 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.highgo;import com.alibaba.nacos.plugin.datasource.constants.DataSourceConstant;
import com.alibaba.nacos.plugin.datasource.mapper.AbstractMapper;
import com.alibaba.nacos.plugin.datasource.mapper.TenantInfoMapper;/*** The highgo implementation of TenantInfoMapper.** @Date: 2023/05/11*/
public class TenantInfoMapperByHighgo extends AbstractMapper implements TenantInfoMapper {@Overridepublic String getDataSource() {return DataSourceConstant.HIGHGO;}
}
com.alibaba.nacos.plugin.datasource.mapper.Mapper文件
plugin/datasource/src/main/resources/META-INF/servicescom.alibaba.nacos.plugin.datasource.impl.mysql.ConfigInfoAggrMapperByMySql
com.alibaba.nacos.plugin.datasource.impl.mysql.ConfigInfoBetaMapperByMySql
com.alibaba.nacos.plugin.datasource.impl.mysql.ConfigInfoMapperByMySql
com.alibaba.nacos.plugin.datasource.impl.mysql.ConfigInfoTagMapperByMySql
com.alibaba.nacos.plugin.datasource.impl.mysql.ConfigTagsRelationMapperByMySql
com.alibaba.nacos.plugin.datasource.impl.mysql.HistoryConfigInfoMapperByMySql
com.alibaba.nacos.plugin.datasource.impl.mysql.TenantInfoMapperByMySql
com.alibaba.nacos.plugin.datasource.impl.mysql.TenantCapacityMapperByMySql
com.alibaba.nacos.plugin.datasource.impl.mysql.GroupCapacityMapperByMysqlcom.alibaba.nacos.plugin.datasource.impl.derby.ConfigInfoAggrMapperByDerby
com.alibaba.nacos.plugin.datasource.impl.derby.ConfigInfoBetaMapperByDerby
com.alibaba.nacos.plugin.datasource.impl.derby.ConfigInfoMapperByDerby
com.alibaba.nacos.plugin.datasource.impl.derby.ConfigInfoTagMapperByDerby
com.alibaba.nacos.plugin.datasource.impl.derby.ConfigInfoTagsRelationMapperByDerby
com.alibaba.nacos.plugin.datasource.impl.derby.HistoryConfigInfoMapperByDerby
com.alibaba.nacos.plugin.datasource.impl.derby.TenantInfoMapperByDerby
com.alibaba.nacos.plugin.datasource.impl.derby.TenantCapacityMapperByDerby
com.alibaba.nacos.plugin.datasource.impl.derby.GroupCapacityMapperByDerby-- 新增highgo
com.alibaba.nacos.plugin.datasource.impl.highgo.ConfigInfoAggrMapperByHighgo
com.alibaba.nacos.plugin.datasource.impl.highgo.ConfigInfoBetaMapperByHighgo
com.alibaba.nacos.plugin.datasource.impl.highgo.ConfigInfoMapperByHighgo
com.alibaba.nacos.plugin.datasource.impl.highgo.ConfigInfoTagMapperByHighgo
com.alibaba.nacos.plugin.datasource.impl.highgo.ConfigTagsRelationMapperByHighgo
com.alibaba.nacos.plugin.datasource.impl.highgo.HistoryConfigInfoMapperByHighgo
com.alibaba.nacos.plugin.datasource.impl.highgo.TenantInfoMapperByHighgo
com.alibaba.nacos.plugin.datasource.impl.highgo.TenantCapacityMapperByHighgo
com.alibaba.nacos.plugin.datasource.impl.highgo.GroupCapacityMapperByHighgo

5、修改nacos-console模块

瀚高数据库 需要添加  currentSchema=nacos_config   否则连不上数据库

console/src/main/resources/application.propertiesspring.sql.init.platform=highgo
db.num=1
db.url.0=jdbc:highgo://xxxx:5866/nacos_config?currentSchema=nacos_config&characterEncoding=utf8&connectTimeout=10000&socketTimeout=30000&autoReconnect=true&useUnicode=true&useSSL=false&serverTimezone=UTC
db.user.0=nacos
db.password.0=nacos
db.pool.config.driverClassName=com.highgo.jdbc.Driver

 6、单机启动  

启动的时候添加 -Dnacos.standalone=true 参数来表明我们是单机启动的

7、打包 


mvn -Prelease-nacos -Dmaven.test.skip=true -Dpmd.skip=true -Dcheckstyle.skip=true clean install -U在nacos-2.2.0\distribution\target下生成压缩文件,可直接使用

8、适配ARM架构

8.1下载源码以及build/Dockerfile.Slim 对应的镜像
找到对应版本的nacos-dockerhttps://github.com/nacos-group/nacos-docker/tree/v2.3.1

下载对应的镜像  
https://hub.docker.com/_/buildpack-deps/tags?page=&page_size=&ordering=&name=buster-curlhttps://hub.docker.com/r/adoptopenjdk/openjdk8/tags?page=2&page_size=&name=jre8u372-b07&ordering=

 

 8.2 在naocs源码的根目录增加二个文件 方便修改后打包直接上次镜像
"""
/** Copyright 1999-2021 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.*/
"""
pipeline {agent {docker {image 'reg.xxx.com/library/arm64/maven-arm64:3.5.3'args '-v /root/.m2:/root/.m2 -v /usr/bin/docker:/usr/bin/docker -v /var/run/docker.sock:/var/run/docker.sock -v /usr/bin/kubectl:/usr/bin/kubectl'label 'arm64'}}stages {stage('build') {steps {sh 'mvn -Prelease-nacos -Dmaven.test.skip=true -Dpmd.skip=true -Dcheckstyle.skip=true clean install -U'}}stage('deploy') {steps {withCredentials([usernamePassword(credentialsId: 'harbor-xxx', passwordVariable: 'HPASSWD', usernameVariable: 'HUSER')]) {sh '''docker build -f Dockerfile_arm -t reg.xxx.com/dev/arm64/nacos-arm64-linux:2.3.1 .docker login reg.sdses.com -u $HUSER -p $HPASSWDdocker push reg.xxx.com/dev/arm64/nacos-arm64-linux:2.3.1'''}}}}
}

dockerFile

#
# Copyright 1999-2021 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.
#FROM reg.xxx.com/library/arm64/buildpack-deps:buster-curl as installerARG NACOS_VERSION=2.3.1
ARG HOT_FIX_FLAG=""COPY distribution/target/nacos-server-2.3.1.tar.gz /var/tmp/RUN tar -xzvf /var/tmp/nacos-server-2.3.1.tar.gz -C /home/FROM reg.xxx.com/library/arm64/nacos/openjdk8:jre8u372-b07# set environment
ENV MODE="cluster" \PREFER_HOST_MODE="ip"\BASE_DIR="/home/nacos" \CLASSPATH=".:/home/nacos/conf:$CLASSPATH" \CLUSTER_CONF="/home/nacos/conf/cluster.conf" \FUNCTION_MODE="all" \NACOS_USER="nacos" \JAVA="/opt/java/openjdk/bin/java" \JVM_XMS="1g" \JVM_XMX="1g" \JVM_XMN="512m" \JVM_MS="128m" \JVM_MMS="320m" \NACOS_DEBUG="n" \TOMCAT_ACCESSLOG_ENABLED="false" \TZ="Asia/Shanghai"WORKDIR $BASE_DIR# copy nacos bin
COPY --from=installer ["/home/nacos", "/home/nacos"]ADD build/bin/docker-startup.sh bin/docker-startup.sh
#ADD conf/application.properties conf/application.properties# set startup log dir
RUN mkdir -p logs \&& cd logs \&& touch start.out \&& ln -sf /dev/stdout start.out \&& ln -sf /dev/stderr start.out
RUN chmod +x bin/docker-startup.shEXPOSE 8848
ENTRYPOINT ["bin/docker-startup.sh"]

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/872660.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

硅纪元视角 | 微软开发全新AI模型,革新电子表格处理效率!

在数字化浪潮的推动下&#xff0c;人工智能&#xff08;AI&#xff09;正成为塑造未来的关键力量。硅纪元视角栏目紧跟AI科技的最新发展&#xff0c;捕捉行业动态&#xff1b;提供深入的新闻解读&#xff0c;助您洞悉技术背后的逻辑&#xff1b;汇聚行业专家的见解&#xff0c;…

使用llama-cpp-python制作api接口

文章目录 概要整体操作流程技术细节小结 概要 使用llama-cpp-python制作api接口&#xff0c;可以接入gradio当中&#xff0c;参考上一节。 llama-cpp-python的github网址 整体操作流程 下载llama-cpp-python。首先判断自己是在CPU的环境下还是GPU的环境下。以下操作均在魔搭…

java占位符替换的五种方式

简介 在Java开发中&#xff0c;如何通过使用占位符来输出文本串&#xff0c;以提高代码的可维护性和扩展性。 背景 在业务开发中&#xff0c;文本串的输出常见&#xff0c;但直接拼接字段不利于后续修改。 解决方案 使用字符串模板和占位符&#xff0c;便于后续内容的修改…

springboot+js实现SSE消息推送

一、后端 1、新建工具类SseServiceTool package com.example.system_manage.utils;import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Component; import org.springframework.web.servlet.mvc.method.annotation.SseEmitter;import java.util.Map; i…

【Linux杂货铺】期末总结篇4:shell编程

&#x1f308;个人主页&#xff1a;聆风吟_ &#x1f525;系列专栏&#xff1a;Linux实践室、网络奇遇记 &#x1f516;少年有梦不应止于心动&#xff0c;更要付诸行动。 文章目录 一. ⛳️什么是Shell脚本&#xff1f;二. ⛳️Shell 入门三. ⛳️Shell 变量3.1 &#x1f514;变…

Kotlin中Unit、Any和Nothing

Unit Unit是一个特殊的类型&#xff0c;它表示“没有意义的值”的单元类型。在Kotlin中&#xff0c;当你不需要函数返回任何具体值时&#xff0c;可以使用Unit类型。 和Java 中 void一样。 Any 所有非空类的父类 Any?所有类的父类 类似Java中Object Nothing 表示一个函数或…

# 如何解决 App Store 审核中的 4.3(a) 问题:Guideline 4.3(a) - Design - Spam

如何解决 App Store 审核中的 4.3(a) 问题&#xff1a;Guideline 4.3(a) - Design - Spam 4.3(a) 审核问题是指&#xff1a;你的应用与其他开发者提交的应用在二进制文件、元数据和/或概念上存在相似之处&#xff0c;仅有微小差别。这通常会导致你的应用被视为垃圾应用而被拒绝…

java启动springboot项目前根据环境变量动态改编yaml文件的变量值

需求&#xff1a;在学习FC时&#xff0c;启动一个springboot项目时需要由用户填写自己的某些特殊变量&#xff0c;解决方案是在FC中由用户自己添加环境变量&#xff0c;通过java代码获取到环境中的环境变量&#xff0c;在springboot启动前注入到yaml文件中。 1.java获取环境变…

volatile相关知识

volatile的两大作用 保持线程的可见性 可见性&#xff1a;当一个线程修改一个共享变量时&#xff0c;其他的线程可以都可以直到到这个值被修改了。 在每次访问 volatile 变量时&#xff0c;都会直接从主内存中读取最新值&#xff0c;而不会使用线程本地的缓存&#xff0c;从…

旗晟巡检机器人的应用场景有哪些?

巡检机器人作为现代科技的杰出成果&#xff0c;已广泛应用于各个关键场景。从危险的工业现场到至关重要的基础设施&#xff0c;它们的身影无处不在。它们以精准、高效、不知疲倦的特性&#xff0c;担当起保障生产、守护安全的重任&#xff0c;为行业发展注入新的活力。那么&…

如何使用简鹿水印助手或 Photoshop 给照片添加文字

在社交媒体中&#xff0c;为照片添加个性化的文字已经成为了一种流行趋势。无论是添加注释、引用名言还是表达情感&#xff0c;文字都能够为图片增添额外的意义和风格。本篇文章将使用“简鹿水印助手”和“Adobe Photoshop”这两种工具给照片添加文字的详细步骤。 使用简鹿水印…

SpringBoot 解决 getSession().getAttribute() 在负载均衡环境下无法获取session的问题

在Spring Boot中&#xff0c;使用getSession().getAttribute()方法时遇到在负载均衡环境下无法正确获取session属性的问题&#xff0c;通常是由于session属性存储在单个服务器的内存中&#xff0c;而负载均衡会导致用户的请求被分配到不同的服务器上&#xff0c;因此无法找到在…

IDEA实现NPM项目的自打包自发布自部署

目录 前言 正文 操作背景 NPM自发布 Package自发布 NPM部署 尾声 &#x1f52d; Hi,I’m Pleasure1234&#x1f331; I’m currently learning Vue.js,SpringBoot,Computer Security and so on.&#x1f46f; I’m studying in University of Nottingham Ningbo China&#x1f…

射线和平面求交

射线和平面求交 1、平面方程 如果已知平面的高度&#xff08;即沿法向量方向的距离&#xff09;为 height&#xff0c;平面方程可以表示为&#xff1a; n ^ ⋅ p h e i g h t \bold{\hat{n}} \cdot p height n^⋅pheight p p p 是平面上的任意一点 height 的正负取决于法向量…

W外链创建抖音私信卡片教程,私信卡片跳转微信工具

W外链地址wai.cn 在数字化时代的浪潮中&#xff0c;私域流量的价值愈发凸显&#xff0c;成为企业获取用户、建立品牌忠诚度、提升转化率的关键手段。抖音&#xff0c;作为当下最热门的短视频社交平台之一&#xff0c;其用户基数庞大、互动性强&#xff0c;为企业私域引流提供了…

一些颜色的RGB整理

(214,219,233) (215,220,230) (189,189,189) (193,210,240) (190,210,240) (0,60,119) (0,60,120) (230,230,250)

百度地图基于范围的搜索

系列文章目录 提示&#xff1a;这里可以添加系列文章的所有文章的目录&#xff0c;目录需要自己手动添加 例如&#xff1a;第一章 Python 机器学习入门之pandas的使用 文章目录 系列文章目录前言一、空间范围中点位数量的快速统计算法1.引入库2.百度地图基于范围的搜索 Java 前…

文件访问:C/C++/MFC

文章目录 1. C语言1.1 打开并读取文件1.2 写入文件1.3 读取二进制文件1.4 写入二进制文件1.5 文件指针的移动 2. C2.1 包含头文件2.2 打开文件2.3 检查文件是否成功打开2.4 读取文件2.5 写入文件2.6 关闭文件2.7 文件指针的移动和获取位置2.8 实例 3. C语言和C文件打开模式4. M…

分类题解清单

目录 简介MySQL题一、聚合函数二、排序和分组三、高级查询和连接四、子查询五、高级字符串函数 / 正则表达式 / 子句 算法题一、双指针二、滑动窗口三、模拟四、贪心五、矩阵六、排序七、链表八、设计九、前缀和十、哈希表十一、字符串十二、二叉树十三、二分查找十四、回溯十五…

初识Docker及管理Docker

Docker部署 初识DockerDocker是什么Docker的核心概念镜像容器仓库 容器优点容器在内核中支持2种重要技术&#xff1a;Docker容器与虚拟机的区别 安装Docker源码安装yum安装检查Docker Docker 镜像操作配置镜像加速器&#xff08;阿里系&#xff09;搜索镜像获取镜像查看镜像信息…