This is an automated email from the ASF dual-hosted git repository.
wenjun pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/dolphinscheduler.git
The following commit(s) were added to refs/heads/dev by this push:
new 0a02522420 Fix registry table field (#14043)
0a02522420 is described below
commit 0a025224206916bb2fb80dfabe97f0e419cb886e
Author: Wenjun Ruan <[email protected]>
AuthorDate: Thu May 4 22:51:23 2023 +0800
Fix registry table field (#14043)
---
.../plugin/registry/jdbc/JdbcOperator.java | 16 ++++++++--------
.../registry/jdbc/mapper/JdbcRegistryDataMapper.java | 10 +++++-----
.../plugin/registry/jdbc/model/JdbcRegistryData.java | 13 +++----------
.../plugin/registry/jdbc/model/JdbcRegistryLock.java | 8 +-------
.../plugin/registry/jdbc/task/SubscribeDataManager.java | 8 ++++----
.../src/main/resources/mysql_registry_init.sql | 12 ++++++------
.../src/main/resources/postgresql_registry_init.sql | 12 ++++++------
7 files changed, 33 insertions(+), 46 deletions(-)
diff --git
a/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-jdbc/src/main/java/org/apache/dolphinscheduler/plugin/registry/jdbc/JdbcOperator.java
b/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-jdbc/src/main/java/org/apache/dolphinscheduler/plugin/registry/jdbc/JdbcOperator.java
index dfb297a6a6..5129a89232 100644
---
a/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-jdbc/src/main/java/org/apache/dolphinscheduler/plugin/registry/jdbc/JdbcOperator.java
+++
b/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-jdbc/src/main/java/org/apache/dolphinscheduler/plugin/registry/jdbc/JdbcOperator.java
@@ -70,9 +70,9 @@ public class JdbcOperator {
return id;
}
jdbcRegistryData = JdbcRegistryData.builder()
- .key(key)
- .data(value)
- .type(DataType.EPHEMERAL.getTypeValue())
+ .dataKey(key)
+ .dataValue(value)
+ .dataType(DataType.EPHEMERAL.getTypeValue())
.lastTerm(System.currentTimeMillis())
.build();
jdbcRegistryDataMapper.insert(jdbcRegistryData);
@@ -89,9 +89,9 @@ public class JdbcOperator {
return id;
}
jdbcRegistryData = JdbcRegistryData.builder()
- .key(key)
- .data(value)
- .type(DataType.PERSISTENT.getTypeValue())
+ .dataKey(key)
+ .dataValue(value)
+ .dataType(DataType.PERSISTENT.getTypeValue())
.lastTerm(System.currentTimeMillis())
.build();
jdbcRegistryDataMapper.insert(jdbcRegistryData);
@@ -122,7 +122,7 @@ public class JdbcOperator {
public List<String> getChildren(String key) throws SQLException {
return jdbcRegistryDataMapper.fuzzyQueryByKey(key)
.stream()
- .map(JdbcRegistryData::getKey)
+ .map(JdbcRegistryData::getDataKey)
.filter(fullPath -> fullPath.length() > key.length())
.map(fullPath ->
StringUtils.substringBefore(fullPath.substring(key.length() + 1), "/"))
.collect(Collectors.toList());
@@ -139,7 +139,7 @@ public class JdbcOperator {
@SuppressWarnings("checkstyle:IllegalCatch")
public JdbcRegistryLock tryToAcquireLock(String key) throws SQLException {
JdbcRegistryLock jdbcRegistryLock = JdbcRegistryLock.builder()
- .key(key)
+ .lockKey(key)
.lockOwner(JdbcRegistryConstant.LOCK_OWNER)
.lastTerm(System.currentTimeMillis())
.build();
diff --git
a/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-jdbc/src/main/java/org/apache/dolphinscheduler/plugin/registry/jdbc/mapper/JdbcRegistryDataMapper.java
b/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-jdbc/src/main/java/org/apache/dolphinscheduler/plugin/registry/jdbc/mapper/JdbcRegistryDataMapper.java
index 83eb0aab43..701f2e7310 100644
---
a/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-jdbc/src/main/java/org/apache/dolphinscheduler/plugin/registry/jdbc/mapper/JdbcRegistryDataMapper.java
+++
b/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-jdbc/src/main/java/org/apache/dolphinscheduler/plugin/registry/jdbc/mapper/JdbcRegistryDataMapper.java
@@ -34,19 +34,19 @@ public interface JdbcRegistryDataMapper extends
BaseMapper<JdbcRegistryData> {
@Select("select * from t_ds_jdbc_registry_data")
List<JdbcRegistryData> selectAll();
- @Select("select * from t_ds_jdbc_registry_data where key = #{key}")
+ @Select("select * from t_ds_jdbc_registry_data where data_key = #{key}")
JdbcRegistryData selectByKey(@Param("key") String key);
- @Select("select * from t_ds_jdbc_registry_data where key like CONCAT
(#{key}, '%')")
+ @Select("select * from t_ds_jdbc_registry_data where data_key like CONCAT
(#{key}, '%')")
List<JdbcRegistryData> fuzzyQueryByKey(@Param("key") String key);
- @Update("update t_ds_jdbc_registry_data set data = #{data}, last_term =
#{term} where id = #{id}")
+ @Update("update t_ds_jdbc_registry_data set data_value = #{data},
last_term = #{term} where id = #{id}")
int updateDataAndTermById(@Param("id") long id, @Param("data") String
data, @Param("term") long term);
- @Delete("delete from t_ds_jdbc_registry_data where key = #{key}")
+ @Delete("delete from t_ds_jdbc_registry_data where data_key = #{key}")
void deleteByKey(@Param("key") String key);
- @Delete("delete from t_ds_jdbc_registry_data where last_term < #{term} and
type = #{type}")
+ @Delete("delete from t_ds_jdbc_registry_data where last_term < #{term} and
data_type = #{type}")
void clearExpireEphemeralDate(@Param("term") long term, @Param("type") int
type);
@Update({"<script>",
diff --git
a/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-jdbc/src/main/java/org/apache/dolphinscheduler/plugin/registry/jdbc/model/JdbcRegistryData.java
b/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-jdbc/src/main/java/org/apache/dolphinscheduler/plugin/registry/jdbc/model/JdbcRegistryData.java
index 5df1557d21..565e613151 100644
---
a/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-jdbc/src/main/java/org/apache/dolphinscheduler/plugin/registry/jdbc/model/JdbcRegistryData.java
+++
b/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-jdbc/src/main/java/org/apache/dolphinscheduler/plugin/registry/jdbc/model/JdbcRegistryData.java
@@ -25,7 +25,6 @@ import lombok.Data;
import lombok.NoArgsConstructor;
import com.baomidou.mybatisplus.annotation.IdType;
-import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
@@ -38,17 +37,11 @@ public class JdbcRegistryData {
@TableId(value = "id", type = IdType.AUTO)
private Long id;
- @TableField(value = "key")
- private String key;
- @TableField(value = "data")
- private String data;
- @TableField(value = "type")
- private int type;
- @TableField(value = "last_term")
+ private String dataKey;
+ private String dataValue;
+ private int dataType;
private long lastTerm;
- @TableField(value = "create_time")
private Date createTime;
- @TableField(value = "last_time")
private Date lastUpdateTime;
}
diff --git
a/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-jdbc/src/main/java/org/apache/dolphinscheduler/plugin/registry/jdbc/model/JdbcRegistryLock.java
b/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-jdbc/src/main/java/org/apache/dolphinscheduler/plugin/registry/jdbc/model/JdbcRegistryLock.java
index d937e33ef6..17f840c37f 100644
---
a/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-jdbc/src/main/java/org/apache/dolphinscheduler/plugin/registry/jdbc/model/JdbcRegistryLock.java
+++
b/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-jdbc/src/main/java/org/apache/dolphinscheduler/plugin/registry/jdbc/model/JdbcRegistryLock.java
@@ -25,7 +25,6 @@ import lombok.Data;
import lombok.NoArgsConstructor;
import com.baomidou.mybatisplus.annotation.IdType;
-import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
@@ -41,26 +40,21 @@ public class JdbcRegistryLock {
/**
* The lock key.
*/
- @TableField(value = "key")
- private String key;
+ private String lockKey;
/**
* acquire lock host.
*/
- @TableField(value = "lock_owner")
private String lockOwner;
/**
* The last term, if the (currentTime - lastTerm) > termExpire time, the
lock will be expired.
*/
- @TableField(value = "last_term")
private Long lastTerm;
/**
* The lock last update time.
*/
- @TableField(value = "last_update_time")
private Date lastUpdateTime;
/**
* The lock create time.
*/
- @TableField(value = "create_time")
private Date createTime;
}
diff --git
a/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-jdbc/src/main/java/org/apache/dolphinscheduler/plugin/registry/jdbc/task/SubscribeDataManager.java
b/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-jdbc/src/main/java/org/apache/dolphinscheduler/plugin/registry/jdbc/task/SubscribeDataManager.java
index 03c7c00641..4718b053f4 100644
---
a/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-jdbc/src/main/java/org/apache/dolphinscheduler/plugin/registry/jdbc/task/SubscribeDataManager.java
+++
b/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-jdbc/src/main/java/org/apache/dolphinscheduler/plugin/registry/jdbc/task/SubscribeDataManager.java
@@ -80,7 +80,7 @@ public class SubscribeDataManager implements AutoCloseable {
if (jdbcRegistryData == null) {
return null;
}
- return jdbcRegistryData.getData();
+ return jdbcRegistryData.getDataValue();
}
@Override
@@ -102,7 +102,7 @@ public class SubscribeDataManager implements AutoCloseable {
try {
Map<String, JdbcRegistryData> currentJdbcDataMap =
jdbcOperator.queryAllJdbcRegistryData()
.stream()
- .collect(Collectors.toMap(JdbcRegistryData::getKey,
Function.identity()));
+
.collect(Collectors.toMap(JdbcRegistryData::getDataKey, Function.identity()));
// find the different
List<JdbcRegistryData> addedData = new ArrayList<>();
List<JdbcRegistryData> deletedData = new ArrayList<>();
@@ -143,9 +143,9 @@ public class SubscribeDataManager implements AutoCloseable {
List<SubscribeListener>
subscribeListeners,
Event.Type type) {
for (JdbcRegistryData data : dataList) {
- if (data.getKey().startsWith(subscribeKey)) {
+ if (data.getDataKey().startsWith(subscribeKey)) {
subscribeListeners.forEach(subscribeListener ->
subscribeListener
- .notify(new Event(data.getKey(), data.getKey(),
data.getData(), type)));
+ .notify(new Event(data.getDataKey(),
data.getDataKey(), data.getDataValue(), type)));
}
}
}
diff --git
a/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-jdbc/src/main/resources/mysql_registry_init.sql
b/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-jdbc/src/main/resources/mysql_registry_init.sql
index 87acb5af3b..30af3066ff 100644
---
a/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-jdbc/src/main/resources/mysql_registry_init.sql
+++
b/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-jdbc/src/main/resources/mysql_registry_init.sql
@@ -21,14 +21,14 @@ DROP TABLE IF EXISTS `t_ds_jdbc_registry_data`;
CREATE TABLE `t_ds_jdbc_registry_data`
(
`id` bigint(11) NOT NULL AUTO_INCREMENT COMMENT 'primary
key',
- `key` varchar(256) NOT NULL COMMENT 'key, like zookeeper node
path',
- `data` text NOT NULL COMMENT 'data, like zookeeper
node value',
- `type` tinyint(4) NOT NULL COMMENT '1: ephemeral node, 2:
persistent node',
+ `data_key` varchar(256) NOT NULL COMMENT 'key, like zookeeper node
path',
+ `data_value` text NOT NULL COMMENT 'data, like zookeeper
node value',
+ `data_type` tinyint(4) NOT NULL COMMENT '1: ephemeral node, 2:
persistent node',
`last_term` bigint NOT NULL COMMENT 'last term time',
`last_update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON
UPDATE CURRENT_TIMESTAMP COMMENT 'last update time',
`create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT
'create time',
PRIMARY KEY (`id`),
- unique (`key`)
+ unique (`data_key`)
) ENGINE = InnoDB
DEFAULT CHARSET = utf8;
@@ -37,12 +37,12 @@ DROP TABLE IF EXISTS `t_ds_jdbc_registry_lock`;
CREATE TABLE `t_ds_jdbc_registry_lock`
(
`id` bigint(11) NOT NULL AUTO_INCREMENT COMMENT 'primary
key',
- `key` varchar(256) NOT NULL COMMENT 'lock path',
+ `lock_key` varchar(256) NOT NULL COMMENT 'lock path',
`lock_owner` varchar(256) NOT NULL COMMENT 'the lock owner,
ip_processId',
`last_term` bigint NOT NULL COMMENT 'last term time',
`last_update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON
UPDATE CURRENT_TIMESTAMP COMMENT 'last update time',
`create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT
'create time',
PRIMARY KEY (`id`),
- unique (`key`)
+ unique (`lock_key`)
) ENGINE = InnoDB
DEFAULT CHARSET = utf8;
diff --git
a/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-jdbc/src/main/resources/postgresql_registry_init.sql
b/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-jdbc/src/main/resources/postgresql_registry_init.sql
index bdf6283060..795bc9b3eb 100644
---
a/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-jdbc/src/main/resources/postgresql_registry_init.sql
+++
b/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-jdbc/src/main/resources/postgresql_registry_init.sql
@@ -20,15 +20,15 @@ create table t_ds_jdbc_registry_data
(
id serial
constraint t_ds_jdbc_registry_data_pk primary key,
- key varchar not null,
- data text not null,
- type int4 not null,
+ data_key varchar not null,
+ data_value text not null,
+ data_type int4 not null,
last_term bigint not null,
last_update_time timestamp default current_timestamp not null,
create_time timestamp default current_timestamp not null
);
-create unique index t_ds_jdbc_registry_data_key_uindex on
t_ds_jdbc_registry_data (key);
+create unique index t_ds_jdbc_registry_data_key_uindex on
t_ds_jdbc_registry_data (data_key);
DROP TABLE IF EXISTS t_ds_jdbc_registry_lock;
@@ -36,10 +36,10 @@ create table t_ds_jdbc_registry_lock
(
id serial
constraint t_ds_jdbc_registry_lock_pk primary key,
- key varchar not null,
+ lock_key varchar not null,
lock_owner varchar not null,
last_term bigint not null,
last_update_time timestamp default current_timestamp not null,
create_time timestamp default current_timestamp not null
);
-create unique index t_ds_jdbc_registry_lock_key_uindex on
t_ds_jdbc_registry_lock (key);
+create unique index t_ds_jdbc_registry_lock_key_uindex on
t_ds_jdbc_registry_lock (lock_key);