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.ExternalDataSourceProperties

private 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.DataSourceConstant

public 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 {

    @Override
    public 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);
    }

    @Override
    public 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 {

    @Override
    public 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);
    }

    @Override
    public 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";

    @Override
    public MapperResult findConfigInfoByAppFetchRows(MapperContext context) {
        final String appName = (String) context.getWhereParameter(FieldConstant.APP_NAME);
        final String tenantId = (String) context.getWhereParameter(FieldConstant.TENANT_ID);
        String sql =

相关推荐

  1. 数据库相关设置

    2024-07-16 08:14:04       28 阅读
  2. 数据库初级考试认证

    2024-07-16 08:14:04       14 阅读
  3. 应用数据库还是数据库应用

    2024-07-16 08:14:04       54 阅读
  4. flutter 屏幕宽工具

    2024-07-16 08:14:04       30 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-07-16 08:14:04       67 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-07-16 08:14:04       72 阅读
  3. 在Django里面运行非项目文件

    2024-07-16 08:14:04       58 阅读
  4. Python语言-面向对象

    2024-07-16 08:14:04       69 阅读

热门阅读

  1. Redis是什么

    2024-07-16 08:14:04       27 阅读
  2. 机器学习——机器学习概述

    2024-07-16 08:14:04       21 阅读
  3. 深入理解 Vue.js 的生命周期:从创建到销毁

    2024-07-16 08:14:04       26 阅读
  4. 2024.7.10 day 3 比赛总结

    2024-07-16 08:14:04       19 阅读
  5. 大模型 GPT 到 GPT-3.5 知识点总结

    2024-07-16 08:14:04       21 阅读
  6. Python 和 R两者的主要区别和优缺点对比

    2024-07-16 08:14:04       25 阅读
  7. k8s怎么配置secret呢?

    2024-07-16 08:14:04       22 阅读
  8. vue $refs

    2024-07-16 08:14:04       23 阅读
  9. 【php开发系统遇到CPU飙升的思考记录】

    2024-07-16 08:14:04       24 阅读
  10. AppML 案例:Products

    2024-07-16 08:14:04       22 阅读
  11. 深度学习--基础语法

    2024-07-16 08:14:04       18 阅读