适配2.4.1达梦

This commit is contained in:
zhuyijun 2024-08-21 16:37:53 +08:00
parent 106a1d57dd
commit 528c33a9fb
30 changed files with 1426 additions and 18 deletions

View File

@ -37,7 +37,11 @@
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
<dependency>
<groupId>dm.jdbc</groupId>
<artifactId>DmJdbcDriver</artifactId>
<version>${dm-jdbc.version}</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>

View File

@ -32,6 +32,11 @@
<url>https://nacos.io</url>
<dependencies>
<dependency>
<groupId>dm.jdbc</groupId>
<artifactId>DmJdbcDriver</artifactId>
<version>${dm-jdbc.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>

View File

@ -40,10 +40,14 @@ server.port=8848
# db.num=1
### Connect URL of DB:
# db.url.0=jdbc:mysql://127.0.0.1:3306/nacos?characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true&useUnicode=true&useSSL=false&serverTimezone=UTC
#db.jdbc-driver-name.0=dm.jdbc.driver.DmDriver
# db.url.0=db.url.0=jdbc:dm://IP:5236/DB
# db.user.0=nacos
# db.password.0=nacos
#db.jdbc-driver-name.0?db.pool.config.driverClassName??
#db.pool.config.driverClassName=dm.jdbc.driver.DmDriver
### Connection pool configuration: hikariCP
db.pool.config.connectionTimeout=30000
db.pool.config.validationTimeout=10000
@ -127,7 +131,7 @@ server.tomcat.accesslog.rotate=true
server.tomcat.accesslog.file-date-format=.yyyy-MM-dd-HH
### The access log pattern:
server.tomcat.accesslog.pattern=%h %l %u %t "%r" %s %b %D %{User-Agent}i %{Request-Source}i
server.tomcat.accesslog.max-days=30
### The directory of access log:
server.tomcat.basedir=file:.
@ -142,7 +146,7 @@ nacos.security.ignore.urls=/,/error,/**/*.css,/**/*.js,/**/*.html,/**/*.map,/**/
nacos.core.auth.system.type=nacos
### If turn on auth system:
nacos.core.auth.enabled=false
nacos.core.auth.enabled=true
### Turn on/off caching of auth information. By turning on this switch, the update of auth information would have a 15 seconds delay.
nacos.core.auth.caching.enabled=true
@ -152,15 +156,15 @@ nacos.core.auth.enable.userAgentAuthWhite=false
### Since 1.4.1, worked when nacos.core.auth.enabled=true and nacos.core.auth.enable.userAgentAuthWhite=false.
### The two properties is the white list for auth and used by identity the request from other server.
nacos.core.auth.server.identity.key=
nacos.core.auth.server.identity.value=
nacos.core.auth.server.identity.key=${NACOS_AUTH_IDENTITY_KEY:NACOS_KEY}
nacos.core.auth.server.identity.value=${NACOS_AUTH_IDENTITY_KEY:NACOS_VALUE}
### worked when nacos.core.auth.system.type=nacos
### The token expiration in seconds:
nacos.core.auth.plugin.nacos.token.cache.enable=false
nacos.core.auth.plugin.nacos.token.expire.seconds=18000
### The default token (Base64 String):
nacos.core.auth.plugin.nacos.token.secret.key=
nacos.core.auth.plugin.nacos.token.secret.key=${NACOS_AUTH_TOKEN:TmFjb3NEbXp5ajk5ODEhQCMhUUFaWFNXMWRxaXVkdDhxaWN0ODczMmRhZGhhaXVkZzg2M2tqdg==}
### worked when nacos.core.auth.system.type=ldap{0} is Placeholder,replace login username
#nacos.core.auth.ldap.url=ldap://localhost:389

View File

@ -0,0 +1,553 @@
CREATE TABLE "USERS"
(
"USERNAME" VARCHAR(50) NOT NULL,
"PASSWORD" VARCHAR(500) NOT NULL,
"ENABLED" TINYINT NOT NULL
);
CREATE TABLE "TENANT_INFO"
(
"ID" BIGINT IDENTITY(1,1) NOT NULL,
"KP" VARCHAR(128) NOT NULL,
"TENANT_ID" VARCHAR(128) DEFAULT ''
NULL,
"TENANT_NAME" VARCHAR(128) DEFAULT ''
NULL,
"TENANT_DESC" VARCHAR(256) NULL,
"CREATE_SOURCE" VARCHAR(32) NULL,
"GMT_CREATE" BIGINT NOT NULL,
"GMT_MODIFIED" BIGINT NOT NULL
);
CREATE TABLE "TENANT_CAPACITY"
(
"ID" BIGINT IDENTITY(1,1) NOT NULL,
"TENANT_ID" VARCHAR(128) DEFAULT ''
NOT NULL,
"QUOTA" BIGINT DEFAULT 0
NOT NULL,
"USAGE" BIGINT DEFAULT 0
NOT NULL,
"MAX_SIZE" BIGINT DEFAULT 0
NOT NULL,
"MAX_AGGR_COUNT" BIGINT DEFAULT 0
NOT NULL,
"MAX_AGGR_SIZE" BIGINT DEFAULT 0
NOT NULL,
"MAX_HISTORY_COUNT" BIGINT DEFAULT 0
NOT NULL,
"GMT_CREATE" TIMESTAMP(0) DEFAULT CURRENT_TIMESTAMP()
NOT NULL,
"GMT_MODIFIED" TIMESTAMP(0) DEFAULT CURRENT_TIMESTAMP()
NOT NULL
);
CREATE TABLE "ROLES"
(
"USERNAME" VARCHAR(50) NOT NULL,
"ROLE" VARCHAR(50) NOT NULL
);
CREATE TABLE "PERMISSIONS"
(
"ROLE" VARCHAR(50) NOT NULL,
"RESOURCE" VARCHAR(255) NOT NULL,
"ACTION" VARCHAR(8) NOT NULL
);
CREATE TABLE "HIS_CONFIG_INFO"
(
"ID" DECIMAL(20,0) NOT NULL,
"NID" BIGINT IDENTITY(1,1) NOT NULL,
"DATA_ID" VARCHAR(255) NOT NULL,
"GROUP_ID" VARCHAR(128) NOT NULL,
"APP_NAME" VARCHAR(128) NULL,
"CONTENT" CLOB NOT NULL,
"MD5" VARCHAR(32) NULL,
"GMT_CREATE" TIMESTAMP(0) DEFAULT CURRENT_TIMESTAMP()
NOT NULL,
"GMT_MODIFIED" TIMESTAMP(0) DEFAULT CURRENT_TIMESTAMP()
NOT NULL,
"SRC_USER" TEXT NULL,
"SRC_IP" VARCHAR(50) NULL,
"OP_TYPE" CHAR(10) NULL,
"TENANT_ID" VARCHAR(128) DEFAULT ''
NULL,
"ENCRYPTED_DATA_KEY" TEXT NOT NULL
);
CREATE TABLE "GROUP_CAPACITY"
(
"ID" BIGINT IDENTITY(1,1) NOT NULL,
"GROUP_ID" VARCHAR(128) DEFAULT ''
NOT NULL,
"QUOTA" BIGINT DEFAULT 0
NOT NULL,
"USAGE" BIGINT DEFAULT 0
NOT NULL,
"MAX_SIZE" BIGINT DEFAULT 0
NOT NULL,
"MAX_AGGR_COUNT" BIGINT DEFAULT 0
NOT NULL,
"MAX_AGGR_SIZE" BIGINT DEFAULT 0
NOT NULL,
"MAX_HISTORY_COUNT" BIGINT DEFAULT 0
NOT NULL,
"GMT_CREATE" TIMESTAMP(0) DEFAULT CURRENT_TIMESTAMP()
NOT NULL,
"GMT_MODIFIED" TIMESTAMP(0) DEFAULT CURRENT_TIMESTAMP()
NOT NULL
);
CREATE TABLE "CONFIG_TAGS_RELATION"
(
"ID" BIGINT NOT NULL,
"TAG_NAME" VARCHAR(128) NOT NULL,
"TAG_TYPE" VARCHAR(64) NULL,
"DATA_ID" VARCHAR(255) NOT NULL,
"GROUP_ID" VARCHAR(128) NOT NULL,
"TENANT_ID" VARCHAR(128) DEFAULT ''
NULL,
"NID" BIGINT IDENTITY(1,1) NOT NULL
);
CREATE TABLE "CONFIG_INFO_TAG"
(
"ID" BIGINT IDENTITY(1,1) NOT NULL,
"DATA_ID" VARCHAR(255) NOT NULL,
"GROUP_ID" VARCHAR(128) NOT NULL,
"TENANT_ID" VARCHAR(128) DEFAULT ''
NULL,
"TAG_ID" VARCHAR(128) NOT NULL,
"APP_NAME" VARCHAR(128) NULL,
"CONTENT" CLOB NOT NULL,
"MD5" VARCHAR(32) NULL,
"GMT_CREATE" TIMESTAMP(0) DEFAULT CURRENT_TIMESTAMP()
NOT NULL,
"GMT_MODIFIED" TIMESTAMP(0) DEFAULT CURRENT_TIMESTAMP()
NOT NULL,
"SRC_USER" TEXT NULL,
"SRC_IP" VARCHAR(50) NULL
);
CREATE TABLE "CONFIG_INFO_BETA"
(
"ID" BIGINT IDENTITY(1,1) NOT NULL,
"DATA_ID" VARCHAR(255) NOT NULL,
"GROUP_ID" VARCHAR(128) NOT NULL,
"APP_NAME" VARCHAR(128) NULL,
"CONTENT" CLOB NOT NULL,
"BETA_IPS" VARCHAR(1024) NULL,
"MD5" VARCHAR(32) NULL,
"GMT_CREATE" TIMESTAMP(0) DEFAULT CURRENT_TIMESTAMP()
NOT NULL,
"GMT_MODIFIED" TIMESTAMP(0) DEFAULT CURRENT_TIMESTAMP()
NOT NULL,
"SRC_USER" TEXT NULL,
"SRC_IP" VARCHAR(50) NULL,
"TENANT_ID" VARCHAR(128) DEFAULT ''
NULL,
"ENCRYPTED_DATA_KEY" TEXT NOT NULL
);
CREATE TABLE "CONFIG_INFO_AGGR"
(
"ID" BIGINT IDENTITY(1,1) NOT NULL,
"DATA_ID" VARCHAR(255) NOT NULL,
"GROUP_ID" VARCHAR(128) NOT NULL,
"DATUM_ID" VARCHAR(255) NOT NULL,
"CONTENT" CLOB NOT NULL,
"GMT_MODIFIED" TIMESTAMP(0) NOT NULL,
"APP_NAME" VARCHAR(128) NULL,
"TENANT_ID" VARCHAR(128) DEFAULT ''
NULL
);
CREATE TABLE "CONFIG_INFO"
(
"ID" BIGINT IDENTITY(1,1) NOT NULL,
"DATA_ID" VARCHAR(255) NOT NULL,
"GROUP_ID" VARCHAR(128) NULL,
"CONTENT" CLOB NOT NULL,
"MD5" VARCHAR(32) NULL,
"GMT_CREATE" TIMESTAMP(0) DEFAULT CURRENT_TIMESTAMP()
NOT NULL,
"GMT_MODIFIED" TIMESTAMP(0) DEFAULT CURRENT_TIMESTAMP()
NOT NULL,
"SRC_USER" TEXT NULL,
"SRC_IP" VARCHAR(50) NULL,
"APP_NAME" VARCHAR(128) NULL,
"TENANT_ID" VARCHAR(128) DEFAULT ''
NULL,
"C_DESC" VARCHAR(256) NULL,
"C_USE" VARCHAR(64) NULL,
"EFFECT" VARCHAR(64) NULL,
"TYPE" VARCHAR(64) NULL,
"C_SCHEMA" TEXT NULL,
"ENCRYPTED_DATA_KEY" TEXT NOT NULL
);
SET IDENTITY_INSERT "CONFIG_INFO" ON;
SET IDENTITY_INSERT "CONFIG_INFO" OFF;
SET IDENTITY_INSERT "CONFIG_INFO_AGGR" ON;
SET IDENTITY_INSERT "CONFIG_INFO_AGGR" OFF;
SET IDENTITY_INSERT "CONFIG_INFO_BETA" ON;
SET IDENTITY_INSERT "CONFIG_INFO_BETA" OFF;
SET IDENTITY_INSERT "CONFIG_INFO_TAG" ON;
SET IDENTITY_INSERT "CONFIG_INFO_TAG" OFF;
SET IDENTITY_INSERT "CONFIG_TAGS_RELATION" ON;
SET IDENTITY_INSERT "CONFIG_TAGS_RELATION" OFF;
SET IDENTITY_INSERT "GROUP_CAPACITY" ON;
SET IDENTITY_INSERT "GROUP_CAPACITY" OFF;
SET IDENTITY_INSERT "HIS_CONFIG_INFO" ON;
SET IDENTITY_INSERT "HIS_CONFIG_INFO" OFF;
INSERT INTO "ROLES"("USERNAME","ROLE") VALUES('nacos','ROLE_ADMIN');
SET IDENTITY_INSERT "TENANT_CAPACITY" ON;
SET IDENTITY_INSERT "TENANT_CAPACITY" OFF;
SET IDENTITY_INSERT "TENANT_INFO" ON;
SET IDENTITY_INSERT "TENANT_INFO" OFF;
INSERT INTO "USERS"("USERNAME","PASSWORD","ENABLED") VALUES('nacos','$2a$10$EuWPZHzz32dJN7jexM34MOeYirDdFAZm2kuWj7VEOJhhZkDrxfvUu',1);
ALTER TABLE "USERS" ADD CONSTRAINT PRIMARY KEY("USERNAME") ;
ALTER TABLE "TENANT_INFO" ADD CONSTRAINT PRIMARY KEY("ID") ;
ALTER TABLE "TENANT_INFO" ADD CONSTRAINT "UK_TENANT_INFO_KPTENANTID" UNIQUE("KP","TENANT_ID") ;
ALTER TABLE "TENANT_CAPACITY" ADD CONSTRAINT PRIMARY KEY("ID") ;
ALTER TABLE "TENANT_CAPACITY" ADD CONSTRAINT "UK_TENANT_ID" UNIQUE("TENANT_ID") ;
ALTER TABLE "ROLES" ADD CONSTRAINT "IDX_USER_ROLE" UNIQUE("USERNAME","ROLE") ;
ALTER TABLE "PERMISSIONS" ADD CONSTRAINT "UK_ROLE_PERMISSION" UNIQUE("ROLE","RESOURCE","ACTION") ;
ALTER TABLE "HIS_CONFIG_INFO" ADD CONSTRAINT PRIMARY KEY("NID") ;
ALTER TABLE "GROUP_CAPACITY" ADD CONSTRAINT PRIMARY KEY("ID") ;
ALTER TABLE "GROUP_CAPACITY" ADD CONSTRAINT "UK_GROUP_ID" UNIQUE("GROUP_ID") ;
ALTER TABLE "CONFIG_TAGS_RELATION" ADD CONSTRAINT PRIMARY KEY("NID") ;
ALTER TABLE "CONFIG_TAGS_RELATION" ADD CONSTRAINT "UK_CONFIGTAGRELATION_CONFIGIDTAG" UNIQUE("ID","TAG_NAME","TAG_TYPE") ;
ALTER TABLE "CONFIG_INFO_TAG" ADD CONSTRAINT PRIMARY KEY("ID") ;
ALTER TABLE "CONFIG_INFO_TAG" ADD CONSTRAINT "UK_CONFIGINFOTAG_DATAGROUPTENANTTAG" UNIQUE("DATA_ID","GROUP_ID","TENANT_ID","TAG_ID") ;
ALTER TABLE "CONFIG_INFO_BETA" ADD CONSTRAINT PRIMARY KEY("ID") ;
ALTER TABLE "CONFIG_INFO_BETA" ADD CONSTRAINT "UK_CONFIGINFOBETA_DATAGROUPTENANT" UNIQUE("DATA_ID","GROUP_ID","TENANT_ID") ;
ALTER TABLE "CONFIG_INFO_AGGR" ADD CONSTRAINT PRIMARY KEY("ID") ;
ALTER TABLE "CONFIG_INFO_AGGR" ADD CONSTRAINT "UK_CONFIGINFOAGGR_DATAGROUPTENANTDATUM" UNIQUE("DATA_ID","GROUP_ID","TENANT_ID","DATUM_ID") ;
ALTER TABLE "CONFIG_INFO" ADD CONSTRAINT PRIMARY KEY("ID") ;
ALTER TABLE "CONFIG_INFO" ADD CONSTRAINT "UK_CONFIGINFO_DATAGROUPTENANT" UNIQUE("DATA_ID","GROUP_ID","TENANT_ID") ;
CREATE UNIQUE INDEX "PRIMARY"
ON "USERS"("USERNAME");
COMMENT ON COLUMN "USERS"."USERNAME" IS 'username';
COMMENT ON COLUMN "USERS"."PASSWORD" IS 'password';
COMMENT ON COLUMN "USERS"."ENABLED" IS 'enabled';
CREATE INDEX "IDX_TENANT_ID"
ON "TENANT_INFO"("TENANT_ID");
CREATE UNIQUE INDEX "INDEX134402165964299"
ON "TENANT_INFO"("ID");
COMMENT ON TABLE "TENANT_INFO" IS 'tenant_info';
COMMENT ON COLUMN "TENANT_INFO"."ID" IS 'id';
COMMENT ON COLUMN "TENANT_INFO"."KP" IS 'kp';
COMMENT ON COLUMN "TENANT_INFO"."TENANT_ID" IS 'tenant_id';
COMMENT ON COLUMN "TENANT_INFO"."TENANT_NAME" IS 'tenant_name';
COMMENT ON COLUMN "TENANT_INFO"."TENANT_DESC" IS 'tenant_desc';
COMMENT ON COLUMN "TENANT_INFO"."CREATE_SOURCE" IS 'create_source';
COMMENT ON COLUMN "TENANT_INFO"."GMT_CREATE" IS '创建时间';
COMMENT ON COLUMN "TENANT_INFO"."GMT_MODIFIED" IS '修改时间';
ALTER TABLE "TENANT_CAPACITY" ADD CHECK ("QUOTA" >= 0) ENABLE ;
ALTER TABLE "TENANT_CAPACITY" ADD CHECK ("MAX_HISTORY_COUNT" >= 0) ENABLE ;
ALTER TABLE "TENANT_CAPACITY" ADD CHECK ("MAX_AGGR_SIZE" >= 0) ENABLE ;
ALTER TABLE "TENANT_CAPACITY" ADD CHECK ("MAX_AGGR_COUNT" >= 0) ENABLE ;
ALTER TABLE "TENANT_CAPACITY" ADD CHECK ("MAX_SIZE" >= 0) ENABLE ;
ALTER TABLE "TENANT_CAPACITY" ADD CHECK ("USAGE" >= 0) ENABLE ;
CREATE UNIQUE INDEX "INDEX134403016796300"
ON "TENANT_CAPACITY"("ID");
COMMENT ON TABLE "TENANT_CAPACITY" IS '租户容量信息表';
COMMENT ON COLUMN "TENANT_CAPACITY"."ID" IS '主键ID';
COMMENT ON COLUMN "TENANT_CAPACITY"."TENANT_ID" IS 'Tenant ID';
COMMENT ON COLUMN "TENANT_CAPACITY"."QUOTA" IS '配额0表示使用默认值';
COMMENT ON COLUMN "TENANT_CAPACITY"."USAGE" IS '使用量';
COMMENT ON COLUMN "TENANT_CAPACITY"."MAX_SIZE" IS '单个配置大小上限单位为字节0表示使用默认值';
COMMENT ON COLUMN "TENANT_CAPACITY"."MAX_AGGR_COUNT" IS '聚合子配置最大个数';
COMMENT ON COLUMN "TENANT_CAPACITY"."MAX_AGGR_SIZE" IS '单个聚合数据的子配置大小上限单位为字节0表示使用默认值';
COMMENT ON COLUMN "TENANT_CAPACITY"."MAX_HISTORY_COUNT" IS '最大变更历史数量';
COMMENT ON COLUMN "TENANT_CAPACITY"."GMT_CREATE" IS '创建时间';
COMMENT ON COLUMN "TENANT_CAPACITY"."GMT_MODIFIED" IS '修改时间';
COMMENT ON COLUMN "ROLES"."USERNAME" IS 'username';
COMMENT ON COLUMN "ROLES"."ROLE" IS 'role';
COMMENT ON COLUMN "PERMISSIONS"."ROLE" IS 'role';
COMMENT ON COLUMN "PERMISSIONS"."RESOURCE" IS 'resource';
COMMENT ON COLUMN "PERMISSIONS"."ACTION" IS 'action';
ALTER TABLE "HIS_CONFIG_INFO" ADD CHECK ("ID" >= 0) ENABLE ;
CREATE INDEX "IDX_DID"
ON "HIS_CONFIG_INFO"("DATA_ID");
CREATE INDEX "IDX_GMT_MODIFIED"
ON "HIS_CONFIG_INFO"("GMT_MODIFIED");
CREATE INDEX "IDX_GMT_CREATE"
ON "HIS_CONFIG_INFO"("GMT_CREATE");
CREATE UNIQUE INDEX "INDEX134404266256800"
ON "HIS_CONFIG_INFO"("NID");
COMMENT ON TABLE "HIS_CONFIG_INFO" IS '多租户改造';
COMMENT ON COLUMN "HIS_CONFIG_INFO"."ID" IS 'id';
COMMENT ON COLUMN "HIS_CONFIG_INFO"."NID" IS 'nid, 自增标识';
COMMENT ON COLUMN "HIS_CONFIG_INFO"."DATA_ID" IS 'data_id';
COMMENT ON COLUMN "HIS_CONFIG_INFO"."GROUP_ID" IS 'group_id';
COMMENT ON COLUMN "HIS_CONFIG_INFO"."APP_NAME" IS 'app_name';
COMMENT ON COLUMN "HIS_CONFIG_INFO"."CONTENT" IS 'content';
COMMENT ON COLUMN "HIS_CONFIG_INFO"."MD5" IS 'md5';
COMMENT ON COLUMN "HIS_CONFIG_INFO"."GMT_CREATE" IS '创建时间';
COMMENT ON COLUMN "HIS_CONFIG_INFO"."GMT_MODIFIED" IS '修改时间';
COMMENT ON COLUMN "HIS_CONFIG_INFO"."SRC_USER" IS 'source user';
COMMENT ON COLUMN "HIS_CONFIG_INFO"."SRC_IP" IS 'source ip';
COMMENT ON COLUMN "HIS_CONFIG_INFO"."OP_TYPE" IS 'operation type';
COMMENT ON COLUMN "HIS_CONFIG_INFO"."TENANT_ID" IS '租户字段';
COMMENT ON COLUMN "HIS_CONFIG_INFO"."ENCRYPTED_DATA_KEY" IS '密钥';
ALTER TABLE "GROUP_CAPACITY" ADD CHECK ("QUOTA" >= 0) ENABLE ;
ALTER TABLE "GROUP_CAPACITY" ADD CHECK ("MAX_HISTORY_COUNT" >= 0) ENABLE ;
ALTER TABLE "GROUP_CAPACITY" ADD CHECK ("MAX_AGGR_SIZE" >= 0) ENABLE ;
ALTER TABLE "GROUP_CAPACITY" ADD CHECK ("MAX_AGGR_COUNT" >= 0) ENABLE ;
ALTER TABLE "GROUP_CAPACITY" ADD CHECK ("MAX_SIZE" >= 0) ENABLE ;
ALTER TABLE "GROUP_CAPACITY" ADD CHECK ("USAGE" >= 0) ENABLE ;
CREATE UNIQUE INDEX "INDEX134405629453900"
ON "GROUP_CAPACITY"("ID");
COMMENT ON TABLE "GROUP_CAPACITY" IS '集群、各Group容量信息表';
COMMENT ON COLUMN "GROUP_CAPACITY"."ID" IS '主键ID';
COMMENT ON COLUMN "GROUP_CAPACITY"."GROUP_ID" IS 'Group ID空字符表示整个集群';
COMMENT ON COLUMN "GROUP_CAPACITY"."QUOTA" IS '配额0表示使用默认值';
COMMENT ON COLUMN "GROUP_CAPACITY"."USAGE" IS '使用量';
COMMENT ON COLUMN "GROUP_CAPACITY"."MAX_SIZE" IS '单个配置大小上限单位为字节0表示使用默认值';
COMMENT ON COLUMN "GROUP_CAPACITY"."MAX_AGGR_COUNT" IS '聚合子配置最大个数0表示使用默认值';
COMMENT ON COLUMN "GROUP_CAPACITY"."MAX_AGGR_SIZE" IS '单个聚合数据的子配置大小上限单位为字节0表示使用默认值';
COMMENT ON COLUMN "GROUP_CAPACITY"."MAX_HISTORY_COUNT" IS '最大变更历史数量';
COMMENT ON COLUMN "GROUP_CAPACITY"."GMT_CREATE" IS '创建时间';
COMMENT ON COLUMN "GROUP_CAPACITY"."GMT_MODIFIED" IS '修改时间';
CREATE INDEX "INDEX134406418558100"
ON "CONFIG_TAGS_RELATION"("TENANT_ID");
CREATE UNIQUE INDEX "INDEX134406537578900"
ON "CONFIG_TAGS_RELATION"("NID");
COMMENT ON TABLE "CONFIG_TAGS_RELATION" IS 'config_tag_relation';
COMMENT ON COLUMN "CONFIG_TAGS_RELATION"."ID" IS 'id';
COMMENT ON COLUMN "CONFIG_TAGS_RELATION"."TAG_NAME" IS 'tag_name';
COMMENT ON COLUMN "CONFIG_TAGS_RELATION"."TAG_TYPE" IS 'tag_type';
COMMENT ON COLUMN "CONFIG_TAGS_RELATION"."DATA_ID" IS 'data_id';
COMMENT ON COLUMN "CONFIG_TAGS_RELATION"."GROUP_ID" IS 'group_id';
COMMENT ON COLUMN "CONFIG_TAGS_RELATION"."TENANT_ID" IS 'tenant_id';
COMMENT ON COLUMN "CONFIG_TAGS_RELATION"."NID" IS 'nid, 自增长标识';
CREATE UNIQUE INDEX "INDEX134407033963000"
ON "CONFIG_INFO_TAG"("ID");
COMMENT ON TABLE "CONFIG_INFO_TAG" IS 'config_info_tag';
COMMENT ON COLUMN "CONFIG_INFO_TAG"."ID" IS 'id';
COMMENT ON COLUMN "CONFIG_INFO_TAG"."DATA_ID" IS 'data_id';
COMMENT ON COLUMN "CONFIG_INFO_TAG"."GROUP_ID" IS 'group_id';
COMMENT ON COLUMN "CONFIG_INFO_TAG"."TENANT_ID" IS 'tenant_id';
COMMENT ON COLUMN "CONFIG_INFO_TAG"."TAG_ID" IS 'tag_id';
COMMENT ON COLUMN "CONFIG_INFO_TAG"."APP_NAME" IS 'app_name';
COMMENT ON COLUMN "CONFIG_INFO_TAG"."CONTENT" IS 'content';
COMMENT ON COLUMN "CONFIG_INFO_TAG"."MD5" IS 'md5';
COMMENT ON COLUMN "CONFIG_INFO_TAG"."GMT_CREATE" IS '创建时间';
COMMENT ON COLUMN "CONFIG_INFO_TAG"."GMT_MODIFIED" IS '修改时间';
COMMENT ON COLUMN "CONFIG_INFO_TAG"."SRC_USER" IS 'source user';
COMMENT ON COLUMN "CONFIG_INFO_TAG"."SRC_IP" IS 'source ip';
CREATE UNIQUE INDEX "INDEX134407798104699"
ON "CONFIG_INFO_BETA"("ID");
COMMENT ON TABLE "CONFIG_INFO_BETA" IS 'config_info_beta';
COMMENT ON COLUMN "CONFIG_INFO_BETA"."ID" IS 'id';
COMMENT ON COLUMN "CONFIG_INFO_BETA"."DATA_ID" IS 'data_id';
COMMENT ON COLUMN "CONFIG_INFO_BETA"."GROUP_ID" IS 'group_id';
COMMENT ON COLUMN "CONFIG_INFO_BETA"."APP_NAME" IS 'app_name';
COMMENT ON COLUMN "CONFIG_INFO_BETA"."CONTENT" IS 'content';
COMMENT ON COLUMN "CONFIG_INFO_BETA"."BETA_IPS" IS 'betaIps';
COMMENT ON COLUMN "CONFIG_INFO_BETA"."MD5" IS 'md5';
COMMENT ON COLUMN "CONFIG_INFO_BETA"."GMT_CREATE" IS '创建时间';
COMMENT ON COLUMN "CONFIG_INFO_BETA"."GMT_MODIFIED" IS '修改时间';
COMMENT ON COLUMN "CONFIG_INFO_BETA"."SRC_USER" IS 'source user';
COMMENT ON COLUMN "CONFIG_INFO_BETA"."SRC_IP" IS 'source ip';
COMMENT ON COLUMN "CONFIG_INFO_BETA"."TENANT_ID" IS '租户字段';
COMMENT ON COLUMN "CONFIG_INFO_BETA"."ENCRYPTED_DATA_KEY" IS '密钥';
CREATE UNIQUE INDEX "INDEX134408619300900"
ON "CONFIG_INFO_AGGR"("ID");
COMMENT ON TABLE "CONFIG_INFO_AGGR" IS '增加租户字段';
COMMENT ON COLUMN "CONFIG_INFO_AGGR"."ID" IS 'id';
COMMENT ON COLUMN "CONFIG_INFO_AGGR"."DATA_ID" IS 'data_id';
COMMENT ON COLUMN "CONFIG_INFO_AGGR"."GROUP_ID" IS 'group_id';
COMMENT ON COLUMN "CONFIG_INFO_AGGR"."DATUM_ID" IS 'datum_id';
COMMENT ON COLUMN "CONFIG_INFO_AGGR"."CONTENT" IS '内容';
COMMENT ON COLUMN "CONFIG_INFO_AGGR"."GMT_MODIFIED" IS '修改时间';
COMMENT ON COLUMN "CONFIG_INFO_AGGR"."APP_NAME" IS 'app_name';
COMMENT ON COLUMN "CONFIG_INFO_AGGR"."TENANT_ID" IS '租户字段';
CREATE UNIQUE INDEX "INDEX134409166029299"
ON "CONFIG_INFO"("ID");
COMMENT ON TABLE "CONFIG_INFO" IS 'config_info';
COMMENT ON COLUMN "CONFIG_INFO"."ID" IS 'id';
COMMENT ON COLUMN "CONFIG_INFO"."DATA_ID" IS 'data_id';
COMMENT ON COLUMN "CONFIG_INFO"."GROUP_ID" IS 'group_id';
COMMENT ON COLUMN "CONFIG_INFO"."CONTENT" IS 'content';
COMMENT ON COLUMN "CONFIG_INFO"."MD5" IS 'md5';
COMMENT ON COLUMN "CONFIG_INFO"."GMT_CREATE" IS '创建时间';
COMMENT ON COLUMN "CONFIG_INFO"."GMT_MODIFIED" IS '修改时间';
COMMENT ON COLUMN "CONFIG_INFO"."SRC_USER" IS 'source user';
COMMENT ON COLUMN "CONFIG_INFO"."SRC_IP" IS 'source ip';
COMMENT ON COLUMN "CONFIG_INFO"."APP_NAME" IS 'app_name';
COMMENT ON COLUMN "CONFIG_INFO"."TENANT_ID" IS '租户字段';
COMMENT ON COLUMN "CONFIG_INFO"."C_DESC" IS 'configuration description';
COMMENT ON COLUMN "CONFIG_INFO"."C_USE" IS 'configuration usage';
COMMENT ON COLUMN "CONFIG_INFO"."EFFECT" IS '配置生效的描述';
COMMENT ON COLUMN "CONFIG_INFO"."TYPE" IS '配置的类型';
COMMENT ON COLUMN "CONFIG_INFO"."C_SCHEMA" IS '配置的模式';
COMMENT ON COLUMN "CONFIG_INFO"."ENCRYPTED_DATA_KEY" IS '密钥';

View File

@ -34,6 +34,11 @@
<url>https://nacos.io</url>
<dependencies>
<dependency>
<groupId>dm.jdbc</groupId>
<artifactId>DmJdbcDriver</artifactId>
<version>${dm-jdbc.version}</version>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>nacos-core</artifactId>

View File

@ -31,7 +31,7 @@ public class PersistenceConstant {
public static final String DATASOURCE_PLATFORM_PROPERTY_OLD = "spring.datasource.platform";
public static final String DATASOURCE_PLATFORM_PROPERTY = "spring.sql.init.platform";
public static final String DM = "dm";
public static final String MYSQL = "mysql";
public static final String DERBY = "derby";

View File

@ -48,7 +48,15 @@ public class ExternalDataSourceProperties {
private List<String> user = new ArrayList<>();
private List<String> password = new ArrayList<>();
private List<String> jdbcDriverName = new ArrayList<>();
public List<String> getJdbcDriverName() {
return jdbcDriverName;
}
public void setJdbcDriverName(List<String> jdbcDriverName) {
this.jdbcDriverName = jdbcDriverName;
}
public void setNum(Integer num) {
this.num = num;
}
@ -83,7 +91,7 @@ public class ExternalDataSourceProperties {
Preconditions.checkArgument(url.size() >= currentSize, "db.url.%s is null", index);
DataSourcePoolProperties poolProperties = DataSourcePoolProperties.build(environment);
if (StringUtils.isEmpty(poolProperties.getDataSource().getDriverClassName())) {
poolProperties.setDriverClassName(JDBC_DRIVER_NAME);
poolProperties.setDriverClassName(getOrDefault(jdbcDriverName,index,jdbcDriverName.get(index)).trim());
}
poolProperties.setJdbcUrl(url.get(index).trim());
poolProperties.setUsername(getOrDefault(user, index, user.get(0)).trim());

View File

@ -18,6 +18,7 @@ package com.alibaba.nacos.plugin.auth.impl.persistence.handler;
import com.alibaba.nacos.plugin.auth.impl.persistence.handler.support.DefaultPageHandlerAdapter;
import com.alibaba.nacos.plugin.auth.impl.persistence.handler.support.DerbyPageHandlerAdapter;
import com.alibaba.nacos.plugin.auth.impl.persistence.handler.support.DmPageHandlerAdapter;
import com.alibaba.nacos.plugin.auth.impl.persistence.handler.support.MysqlPageHandlerAdapter;
import java.util.ArrayList;
@ -53,6 +54,8 @@ public class PageHandlerAdapterFactory {
handlerAdapters.add(handlerAdapter);
handlerAdapterMap.put(handlerAdapter.getClass().getName(), handlerAdapter);
};
// DmPageHandlerAdapter
addHandlerAdapter.accept(new DmPageHandlerAdapter());
// MysqlPageHandlerAdapter
addHandlerAdapter.accept(new MysqlPageHandlerAdapter());
// DerbyPageHandlerAdapter

View File

@ -0,0 +1,34 @@
package com.alibaba.nacos.plugin.auth.impl.persistence.handler.support;
import com.alibaba.nacos.persistence.constants.PersistenceConstant;
import com.alibaba.nacos.plugin.auth.impl.constant.AuthPageConstant;
import com.alibaba.nacos.plugin.auth.impl.model.OffsetFetchResult;
import com.alibaba.nacos.plugin.auth.impl.persistence.handler.PageHandlerAdapter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public class DmPageHandlerAdapter implements PageHandlerAdapter {
@Override
public boolean supports(String dataSourceType) {
return PersistenceConstant.DM.equals(dataSourceType);
}
@Override
public OffsetFetchResult addOffsetAndFetchNext(String fetchSql, Object[] arg, int pageNo, int pageSize) {
if (!fetchSql.contains(AuthPageConstant.LIMIT)) {
fetchSql += " " + AuthPageConstant.LIMIT_SIZE;
List<Object> newArgsList = new ArrayList<>(Arrays.asList(arg));
newArgsList.add((pageNo - 1) * pageSize);
newArgsList.add(pageSize);
Object[] newArgs = newArgsList.toArray(new Object[0]);
return new OffsetFetchResult(fetchSql, newArgs);
}
return new OffsetFetchResult(fetchSql, arg);
}
}

View File

@ -26,4 +26,6 @@ public class DataSourceConstant {
public static final String MYSQL = "mysql";
public static final String DERBY = "derby";
public static final String DM = "dm";
}

View File

@ -0,0 +1,33 @@
/*
* 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.dm;
import com.alibaba.nacos.plugin.datasource.enums.mysql.TrustedMysqlFunctionEnum;
import com.alibaba.nacos.plugin.datasource.mapper.AbstractMapper;
/**
* The abstract mysql mapper contains CRUD methods.
*
* @author blake.qiu
**/
public abstract class AbstractMapperByDm extends AbstractMapper {
@Override
public String getFunction(String functionName) {
return TrustedMysqlFunctionEnum.getFunctionByName(functionName);
}
}

View File

@ -0,0 +1,54 @@
/*
* 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.dm;
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.ConfigInfoAggrMapper;
import com.alibaba.nacos.plugin.datasource.model.MapperContext;
import com.alibaba.nacos.plugin.datasource.model.MapperResult;
import java.util.List;
/**
* The mysql implementation of ConfigInfoAggrMapper.
*
* @author hyx
**/
public class ConfigInfoAggrMapperByDm extends AbstractMapperByDm 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 LIMIT " + startRow + "," + pageSize;
List<Object> paramList = CollectionUtils.list(dataId, groupId, tenantId);
return new MapperResult(sql, paramList);
}
@Override
public String getDataSource() {
return DataSourceConstant.DM;
}
}

View File

@ -0,0 +1,53 @@
/*
* 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.dm;
import com.alibaba.nacos.plugin.datasource.constants.DataSourceConstant;
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 mysql implementation of ConfigInfoBetaMapper.
*
* @author hyx
**/
public class ConfigInfoBetaMapperByDm extends AbstractMapperByDm 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 LIMIT " + startRow + "," + 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.DM;
}
}

View File

@ -0,0 +1,275 @@
/*
* 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.dm;
import com.alibaba.nacos.common.utils.CollectionUtils;
import com.alibaba.nacos.common.utils.NamespaceUtil;
import com.alibaba.nacos.common.utils.StringUtils;
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.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 mysql implementation of ConfigInfoMapper.
*
* @author hyx
**/
public class ConfigInfoMapperByDm extends AbstractMapperByDm 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 = "SELECT id,data_id,group_id,tenant_id,app_name,content FROM config_info"
+ " WHERE tenant_id LIKE ? AND app_name= ?" + " LIMIT " + context.getStartRow() + ","
+ context.getPageSize();
return new MapperResult(sql, CollectionUtils.list(tenantId, appName));
}
@Override
public MapperResult getTenantIdList(MapperContext context) {
String sql = "SELECT tenant_id FROM config_info WHERE tenant_id != '" + NamespaceUtil.getNamespaceDefaultId()
+ "' GROUP BY tenant_id LIMIT " + context.getStartRow() + "," + context.getPageSize();
return new MapperResult(sql, Collections.emptyList());
}
@Override
public MapperResult getGroupIdList(MapperContext context) {
String sql = "SELECT group_id FROM config_info WHERE tenant_id ='" + NamespaceUtil.getNamespaceDefaultId()
+ "' GROUP BY group_id LIMIT " + context.getStartRow() + "," + context.getPageSize();
return new MapperResult(sql, Collections.emptyList());
}
@Override
public 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 LIMIT " + context.getStartRow() + ","
+ context.getPageSize() + " )" + " g, config_info t WHERE g.id = t.id ";
return new MapperResult(sql, CollectionUtils.list(context.getWhereParameter(FieldConstant.TENANT_ID)));
}
@Override
public MapperResult findAllConfigInfoBaseFetchRows(MapperContext context) {
String sql = "SELECT t.id,data_id,group_id,content,md5"
+ " FROM ( SELECT id FROM config_info ORDER BY id LIMIT " + context.getStartRow() + ","
+ context.getPageSize() + " )" + " g, config_info t WHERE g.id = t.id ";
return new MapperResult(sql, Collections.emptyList());
}
@Override
public 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 LIMIT "
+ context.getStartRow() + "," + context.getPageSize();
return new MapperResult(sql, CollectionUtils.list(context.getWhereParameter(FieldConstant.ID)));
}
@Override
public 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 = StringUtils.isBlank(tenant) ? 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 (!StringUtils.isBlank(dataId)) {
where += " AND data_id LIKE ? ";
paramList.add(dataId);
}
if (!StringUtils.isBlank(group)) {
where += " AND group_id LIKE ? ";
paramList.add(group);
}
if (!StringUtils.isBlank(tenantTmp)) {
where += " AND tenant_id = ? ";
paramList.add(tenantTmp);
}
if (!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" + " LIMIT " + 0 + "," + context.getPageSize(), paramList);
}
@Override
public 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 LIMIT " + context.getStartRow() + ","
+ context.getPageSize() + " ) g, config_info t WHERE g.id = t.id";
return new MapperResult(sql, Collections.emptyList());
}
@Override
public 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 (!StringUtils.isBlank(dataId)) {
where += " AND data_id LIKE ? ";
paramList.add(dataId);
}
if (!StringUtils.isBlank(group)) {
where += " AND group_id LIKE ";
paramList.add(group);
}
if (!StringUtils.isBlank(content)) {
where += " AND content LIKE ? ";
paramList.add(content);
}
return new MapperResult(sqlFetchRows + where + " LIMIT " + context.getStartRow() + "," + context.getPageSize(),
paramList);
}
@Override
public 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 (StringUtils.isNotBlank(dataId)) {
where.append(" AND data_id=? ");
paramList.add(dataId);
}
if (StringUtils.isNotBlank(group)) {
where.append(" AND group_id=? ");
paramList.add(group);
}
if (StringUtils.isNotBlank(appName)) {
where.append(" AND app_name=? ");
paramList.add(appName);
}
if (!StringUtils.isBlank(content)) {
where.append(" AND content LIKE ? ");
paramList.add(content);
}
return new MapperResult(sql + where + " LIMIT " + context.getStartRow() + "," + context.getPageSize(),
paramList);
}
@Override
public MapperResult findConfigInfoBaseByGroupFetchRows(MapperContext context) {
String sql = "SELECT id,data_id,group_id,content FROM config_info WHERE group_id=? AND tenant_id=?" + " LIMIT "
+ context.getStartRow() + "," + context.getPageSize();
return new MapperResult(sql, CollectionUtils.list(context.getWhereParameter(FieldConstant.GROUP_ID),
context.getWhereParameter(FieldConstant.TENANT_ID)));
}
@Override
public 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 (!StringUtils.isBlank(dataId)) {
where.append(" AND data_id LIKE ? ");
paramList.add(dataId);
}
if (!StringUtils.isBlank(group)) {
where.append(" AND group_id LIKE ? ");
paramList.add(group);
}
if (!StringUtils.isBlank(appName)) {
where.append(" AND app_name = ? ");
paramList.add(appName);
}
if (!StringUtils.isBlank(content)) {
where.append(" AND content LIKE ? ");
paramList.add(content);
}
return new MapperResult(sqlFetchRows + where + " LIMIT " + context.getStartRow() + "," + context.getPageSize(),
paramList);
}
@Override
public 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 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()));
}
@Override
public String getDataSource() {
return DataSourceConstant.DM;
}
}

View File

@ -0,0 +1,46 @@
/*
* 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.dm;
import com.alibaba.nacos.plugin.datasource.constants.DataSourceConstant;
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 mysql implementation of ConfigInfoTagMapper.
*
* @author hyx
**/
public class ConfigInfoTagMapperByDm extends AbstractMapperByDm implements ConfigInfoTagMapper {
@Override
public 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 LIMIT " + context.getStartRow() + ","
+ context.getPageSize() + " ) " + "g, config_info_tag t WHERE g.id = t.id ";
return new MapperResult(sql, Collections.emptyList());
}
@Override
public String getDataSource() {
return DataSourceConstant.DM;
}
}

View File

@ -0,0 +1,135 @@
/*
* 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.dm;
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.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 mysql implementation of ConfigTagsRelationMapper.
*
* @author hyx
**/
public class ConfigTagsRelationMapperByDm extends AbstractMapperByDm implements ConfigTagsRelationMapper {
@Override
public 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 + " LIMIT " + context.getStartRow() + "," + context.getPageSize(),
paramList);
}
@Override
public 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 + " LIMIT " + context.getStartRow() + "," + context.getPageSize(),
paramList);
}
@Override
public String getDataSource() {
return DataSourceConstant.DM;
}
}

View File

@ -0,0 +1,44 @@
/*
* 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.dm;
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.GroupCapacityMapper;
import com.alibaba.nacos.plugin.datasource.model.MapperContext;
import com.alibaba.nacos.plugin.datasource.model.MapperResult;
/**
* The derby implementation of {@link GroupCapacityMapper}.
*
* @author lixiaoshuang
*/
public class GroupCapacityMapperByDm extends AbstractMapperByDm implements GroupCapacityMapper {
@Override
public String getDataSource() {
return DataSourceConstant.DM;
}
@Override
public 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()));
}
}

View File

@ -0,0 +1,55 @@
/*
* 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.dm;
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.HistoryConfigInfoMapper;
import com.alibaba.nacos.plugin.datasource.model.MapperContext;
import com.alibaba.nacos.plugin.datasource.model.MapperResult;
/**
* The mysql implementation of HistoryConfigInfoMapper.
*
* @author hyx
**/
public class HistoryConfigInfoMapperByDm extends AbstractMapperByDm implements HistoryConfigInfoMapper {
@Override
public 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)));
}
@Override
public 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 LIMIT "
+ context.getStartRow() + "," + context.getPageSize();
return new MapperResult(sql, CollectionUtils.list(context.getWhereParameter(FieldConstant.DATA_ID),
context.getWhereParameter(FieldConstant.GROUP_ID), context.getWhereParameter(FieldConstant.TENANT_ID)));
}
@Override
public String getDataSource() {
return DataSourceConstant.DM;
}
}

View File

@ -0,0 +1,46 @@
/*
* 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.dm;
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.TenantCapacityMapper;
import com.alibaba.nacos.plugin.datasource.model.MapperContext;
import com.alibaba.nacos.plugin.datasource.model.MapperResult;
/**
* The mysql implementation of TenantCapacityMapper.
*
* @author hyx
**/
public class TenantCapacityMapperByDm extends AbstractMapperByDm implements TenantCapacityMapper {
@Override
public String getDataSource() {
return DataSourceConstant.DM;
}
@Override
public 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)));
}
}

View File

@ -0,0 +1,34 @@
/*
* 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.dm;
import com.alibaba.nacos.plugin.datasource.constants.DataSourceConstant;
import com.alibaba.nacos.plugin.datasource.mapper.TenantInfoMapper;
/**
* The mysql implementation of TenantInfoMapper.
*
* @author hyx
**/
public class TenantInfoMapperByDm extends AbstractMapperByDm implements TenantInfoMapper {
@Override
public String getDataSource() {
return DataSourceConstant.DM;
}
}

View File

@ -13,6 +13,15 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
com.alibaba.nacos.plugin.datasource.impl.dm.ConfigInfoAggrMapperByDm
com.alibaba.nacos.plugin.datasource.impl.dm.ConfigInfoBetaMapperByDm
com.alibaba.nacos.plugin.datasource.impl.dm.ConfigInfoMapperByDm
com.alibaba.nacos.plugin.datasource.impl.dm.ConfigInfoTagMapperByDm
com.alibaba.nacos.plugin.datasource.impl.dm.ConfigTagsRelationMapperByDm
com.alibaba.nacos.plugin.datasource.impl.dm.HistoryConfigInfoMapperByDm
com.alibaba.nacos.plugin.datasource.impl.dm.TenantInfoMapperByDm
com.alibaba.nacos.plugin.datasource.impl.dm.TenantCapacityMapperByDm
com.alibaba.nacos.plugin.datasource.impl.dm.GroupCapacityMapperByDm
com.alibaba.nacos.plugin.datasource.impl.mysql.ConfigInfoAggrMapperByMySql
com.alibaba.nacos.plugin.datasource.impl.mysql.ConfigInfoBetaMapperByMySql

View File

@ -30,7 +30,7 @@ import java.util.List;
import static org.junit.jupiter.api.Assertions.assertEquals;
class ConfigInfoAggrMapperByMySqlTest {
class ConfigInfoAggrMapperByDmTest {
private ConfigInfoAggrMapperByMySql configInfoAggrMapperByMySql;

View File

@ -32,7 +32,7 @@ import java.util.List;
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
class ConfigInfoBetaMapperByMySqlTest {
class ConfigInfoBetaMapperByDmTest {
int startRow = 0;

View File

@ -33,7 +33,7 @@ import java.util.List;
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
class ConfigInfoMapperByMySqlTest {
class ConfigInfoMapperByDmTest {
private final Object[] emptyObjs = new Object[] {};

View File

@ -31,7 +31,7 @@ import java.util.List;
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
class ConfigInfoTagMapperByMySqlTest {
class ConfigInfoTagMapperByDmTest {
private final Object[] emptyObjs = new Object[] {};

View File

@ -31,7 +31,7 @@ import java.util.List;
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
class ConfigTagsRelationMapperByMySqlTest {
class ConfigTagsRelationMapperByDmTest {
int startRow = 0;

View File

@ -29,7 +29,7 @@ import java.sql.Timestamp;
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
class HistoryConfigInfoMapperByMySqlTest {
class HistoryConfigInfoMapperByDmTest {
int startRow = 0;

View File

@ -29,7 +29,7 @@ import java.sql.Timestamp;
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
class TenantCapacityMapperByMySqlTest {
class TenantCapacityMapperByDmTest {
String tenantId = "tenantId";

View File

@ -23,7 +23,7 @@ import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
class TenantInfoMapperByMySqlTest {
class TenantInfoMapperByDmTest {
private TenantInfoMapperByMySql tenantInfoMapperByMySql;

View File

@ -152,6 +152,7 @@
<spring.version>5.3.34</spring.version>
<spring-security.version>5.7.12</spring-security.version>
<junit5.version>5.10.2</junit5.version>
<dm-jdbc.version>1.8</dm-jdbc.version>
</properties>
<!-- == -->
<!-- =========================================================Build plugins================================================ -->
@ -622,6 +623,11 @@
<!-- Default dependencies in all subprojects -->
<dependencies>
<dependency>
<groupId>dm.jdbc</groupId>
<artifactId>DmJdbcDriver</artifactId>
<version>${dm-jdbc.version}</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>