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.rhkb.cn/news/379623.html

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

相关文章

免费的数字孪生平台助力产业创新,让新质生产力概念有据可依

关于新质生产力的概念&#xff0c;在如今传统企业现代化发展中被反复提及。 那到底什么是新质生产力&#xff1f;它与哪些行业存在联系&#xff0c;我们又该使用什么工具来加快新质生产力的发展呢&#xff1f;今天我将介绍一款为发展新质生产力而量身定做的数字孪生工具。 新…

0718,TCP协议,三次握手,四次挥手

目录 上课喵&#xff1a; TCP&#xff08;Transmission Control Protocol&#xff0c;传输控制协议&#xff09;的状态迁移图 TCP连接的状态迁移图 状态迁移说明&#xff1a; 注意&#xff1a; big_htonl.c 字节序转换 addr.c IP地址的转换 作业喵&#xff1a; …

人工智能与算力:推动各行业变革的关键力量

随着人工智能&#xff08;AI&#xff09;技术的飞速发展&#xff0c;算力需求也在不断增加。算力&#xff0c;即计算能力&#xff0c;已经成为数字经济时代的核心资源之一。从科学研究到制造业&#xff0c;从医疗健康到教育&#xff0c;各行各业都在通过提升算力来推动自身的数…

基于springboot新生宿舍管理系统

系统背景 在当今高等教育日益普及的时代背景下&#xff0c;高校作为知识传播与创新的重要基地&#xff0c;其基础设施的智能化管理显得尤为重要。新生宿舍作为大学生活的起点&#xff0c;不仅是学生日常生活与学习的重要场所&#xff0c;也是培养学生独立生活能力和团队合作精神…

专题四:设计模式总览

前面三篇我们通过从一些零散的例子&#xff0c;和简单应用来模糊的感受了下设计模式在编程中的智慧&#xff0c;从现在开始正式进入设计模式介绍&#xff0c;本篇将从设计模式的7大原则、设计模式的三大类型、与23种设计模式的进行总结&#xff0c;和描述具体意义。 设计模式体…

Stateflow中的状态转换表

状态转换表是表达顺序模态逻辑的另一种方式。不要在Stateflow图表中以图形方式绘制状态和转换&#xff0c;而是使用状态转换表以表格格式表示模态逻辑。 使用状态转换表的好处包括&#xff1a; 易于对类列车状态机进行建模&#xff0c;其中模态逻辑涉及从一个状态到其邻居的转换…

【46 Pandas+Pyecharts | 当当网畅销图书榜单数据分析可视化】

文章目录 &#x1f3f3;️‍&#x1f308; 1. 导入模块&#x1f3f3;️‍&#x1f308; 2. Pandas数据处理2.1 读取数据2.2 查看数据信息2.3 去除重复数据2.4 书名处理2.5 提取年份 &#x1f3f3;️‍&#x1f308; 3. Pyecharts数据可视化3.1 作者图书数量分布3.2 图书出版年份…

易飞未生成发票单据查询

易飞本身带有未开票查询作业&#xff0c;财务开票收票一般都不是立即开票&#xff0c;月结90&#xff0c;60&#xff0c;30天常常有&#xff0c;且当公司财务状况好时候是这样&#xff0c;如果购销双方出点状况都会推迟&#xff0c;应收应付会计一般暂估会次月完成&#xff0c;…

Qt 制作安装包

记录使用Qt工具制作一个安装包的过程 目录 1.准备工作 1.1检查Qt Installer Frameworks是否安装 1.2.安装Qt Installer Frameworks 1.3准备release出来的exe dll等文件 2.创建打包工程所需要的文件及目录 2.1创建子目录 2.2 创建工程文件 2.3 创建config/config.xml …

剧本杀小程序搭建,为商家带来新的收益方向

近几年&#xff0c;剧本杀游戏成为了游戏市场的一匹黑马&#xff0c;受到了不少年轻玩家的欢迎。随着信息技术的快速发展&#xff0c;传统的剧本杀门店已经无法满足游戏玩家日益增长的需求&#xff0c;因此&#xff0c;剧本杀市场开始向线上模式发展&#xff0c;实现行业数字化…

linux centos limits.conf 修改错误,无法登陆问题修复 centos7.9

一、问题描述 由于修改/etc/security/limits.conf这个文件中的值不当&#xff0c;重启后会导致其账户无法远程登录&#xff0c;本机登录。 如改成这样《错误示范》&#xff1a; 会出现&#xff1a; 二、解决 现在知道是由于修改limits.conf文件不当造成的&#xff0c;那么就…

Docker搭建Harbor

1.什么是Harbor Harbor 是 vMware 公司开源的企业级 Docker 〖egistry 项日&#xff0c;其日标是帮助用户迅速搭建一个企业级的 Docker Registry 服务。Harbor以 Docker 公司开源的 Registry 为基础&#xff0c;提供了图形管理UI 、基于角色的访问控制(Role Based Accesscontr…

virtuoso:Schematic Editor创建global net

我正在「拾陆楼」和朋友们讨论有趣的话题&#xff0c;你⼀起来吧&#xff1f; 拾陆楼知识星球入口 模块的电源地在top层写网表的时候没写出来&#xff0c;重新导入一遍网表转schematic太耗时间&#xff0c;可以在schematic的模块层出pg pin的位置创建global的pg net。 方法如…

C语言 ——— 输入两个正整数,求出最小公倍数

目录 何为最小公倍数 题目要求 代码实现 方法一&#xff1a;暴力求解法&#xff08;不推荐&#xff09; 方法二&#xff1a;递乘试摸法&#xff08;推荐&#xff09; 何为最小公倍数 最小公倍数是指两个或者多个正整数&#xff08;除了0以外&#xff09;的最小的公共倍数…

Day16_集合与迭代器

Day16-集合 Day16 集合与迭代器1.1 集合的概念 集合继承图1.2 Collection接口1、添加元素2、删除元素3、查询与获取元素不过当我们实际使用都是使用的他的子类Arraylist&#xff01;&#xff01;&#xff01; 1.3 API演示1、演示添加2、演示删除3、演示查询与获取元素 2 Iterat…

C语言 底层逻辑详细阐述指针(一)万字讲解 #指针是什么? #指针和指针类型 #指针的解引用 #野指针 #指针的运算 #指针和数组 #二级指针 #指针数组

文章目录 前言 序1&#xff1a;什么是内存&#xff1f; 序2&#xff1a;地址是怎么产生的&#xff1f; 一、指针是什么 1、指针变量的创建及其意义&#xff1a; 2、指针变量的大小 二、指针的解引用 三、指针类型存在的意义 四、野指针 1、什么是野指针 2、野指针的成因 a、指…

js vue axios post 数组请求参数获取转换, 后端go参数解析(gin框架)全流程示例

今天介绍的是前后端分离系统中的请求参数 数组参数的生成&#xff0c;api请求发送&#xff0c;到后端请求参数接收的全过程示例。 为何会有这个文章&#xff1a;后端同一个API接口同时处理单条或者多条数据&#xff0c;这样就要求我们在前端发送请求参数的时候需要统一将请…

纯前端小游戏,4096小游戏,有音效,Html5,可学习使用

// 游戏开始运行create: function(){this.fieldArray [];this.fieldGroup this.add.group();this.score 0;//4096 增加得分this.bestScore localStorage.getItem(gameOptions.localStorageName) null ? 0 : localStorage.getItem(gameOptions.localStorageName);for(var …

昇思25天学习打卡营第9天|生成式

昇思25天学习打卡营第9天 文章目录 昇思25天学习打卡营第9天CycleGAN图像风格迁移互换模型介绍模型简介模型结构 数据集数据集下载数据集加载可视化 构建生成器构建判别器优化器和损失函数前向计算计算梯度和反向传播模型训练模型推理参考打卡记录 CycleGAN图像风格迁移互换 本…

【PostgreSQL】PostgreSQL 教程

博主介绍&#xff1a;✌全网粉丝20W&#xff0c;CSDN博客专家、Java领域优质创作者&#xff0c;掘金/华为云/阿里云/InfoQ等平台优质作者、专注于Java技术领域✌ 技术范围&#xff1a;SpringBoot、SpringCloud、Vue、SSM、HTML、Nodejs、Python、MySQL、PostgreSQL、大数据、物…