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的环境下。以下操作均在魔搭…

【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 表示一个函数或…

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

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

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

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

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)

初识Docker及管理Docker

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

计算机网络技术期末复习

一. 填空 在采用电信号表达数据的系统中&#xff0c;数据有 数字数据 和 模拟数据 两种。域名系统DNS是一个 分布式数据库 系统。TCP/IP的网络层最重要的协议是 IP互连网协议&#xff0c;它可将多个网络连成一个互连网。 4. 在TCP/IP层次模型的网络层中包括的协议主要有ARP 、…

科技出海|百分点科技智慧政务解决方案亮相非洲展会

近日&#xff0c;华为非洲全联接大会在南非约翰内斯堡举办&#xff0c;吸引政府官员行业专家、思想领袖、生态伙伴等2,000多人参会&#xff0c;百分点科技作为华为云生态合作伙伴&#xff0c;重点展示了智慧政务解决方案&#xff0c;发表《Enable a Smarter Government with Da…

Web开发:卡片翻转效果(HTML、CSS)

目录 一、实现效果 二、完整代码 三、实现过程 1、页面结构 2、初始样式 3、翻转效果 4、图片大小问题 一、实现效果 如下图所示&#xff0c;当鼠标移入某个盒子&#xff0c;就反转这个盒子&#xff0c;并显示其背面的内容——卡片翻转效果&#xff1b; 卡片翻转效果 二…

Linux网络编程-socket套接字使用详解

1.概念 在Linux中&#xff0c;套接字&#xff08;socket&#xff09;是一种通信机制&#xff0c;用于实现不同进程之间或同一主机上的不同线程之间的数据交换。它是网络编程的基础&#xff0c;允许应用程序通过网络进行通信&#xff0c;也可以在同一台机器上的不同进程间进行通…

集群服务器如何解决跨服务器通信?大量并发通信问题?

Nginx tcp负载均衡模块&#xff1a; 1.将client的请求按照 负载均衡算法 分发到服务器 2.负载均衡器与服务器保持心跳机制&#xff0c;监测故障、保障服务可靠性 3.可以发现添加新的服务器&#xff0c;方便扩展服务器集群的数量 Nginx反向代理用途&#xff1a; 2.4 用途 …

在golang中Sprintf和Printf 的区别

最近一直在学习golang这个编程语言&#xff0c;我们这里做一个笔记就是 Sprintf和Printf 的区别 fmt.Sprintf 根据格式化参数生成格式化的字符串并返回该字符串。 fmt.Printf 根据格式化参数生成格式化的字符串并写入标准输出。由上面就可以知道&#xff0c;fmt.Sprintf返回的…

php随机海量高清壁纸系统源码,数据采集于网络,使用很方便

2022 多个分类随机海量高清壁纸系统源码&#xff0c;核心文件就两个&#xff0c;php文件负责采集&#xff0c;html负责显示&#xff0c;很简单。做流量工具还是不错的。 非第三方接口&#xff0c;图片数据采集壁纸多多官方所有数据&#xff01; 大家拿去自行研究哈&#xff0…

在 Windows 上开发.NET MAUI 应用_2.生成你的第一个应用

先决条件 Visual Studio 2022 17.8 或更高版本&#xff0c;并安装了 .NET Multi-platform App UI 工作负载。 可参考上一篇文章&#xff1a;http://t.csdnimg.cn/n38Yy 创建应用 1.启动 Visual Studio 2022。 在开始窗口中&#xff0c;单击“创建新项目”以创建新项目&#…

【B树、B-树、B+、B*树】

目录 一、B-树&#xff08;即B树&#xff09;的定义及操作1.1、定义1.2、操作1.2.1、查找1.2.2、插入1.2.3、删除 二、B树的定义及操作2.1、定义2.2、操作2.2.1、查找2.2.2、插入2.2.3、删除 三、B*树 一、B-树&#xff08;即B树&#xff09;的定义及操作 1.1、定义 B-tree即…