Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
apache
DolphinScheduler
提交
49b23460
DolphinScheduler
项目概览
apache
/
DolphinScheduler
上一次同步 1 年多
通知
704
Star
9572
Fork
3514
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
DolphinScheduler
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
未验证
提交
49b23460
编写于
4月 19, 2021
作者:
J
JinyLeeChina
提交者:
GitHub
4月 19, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update SnowFlake (#5321)
Co-authored-by:
N
JinyLeeChina
<
297062848@qq.com
>
上级
2a81b29b
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
15 addition
and
29 deletion
+15
-29
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessDefinitionServiceImpl.java
...eduler/api/service/impl/ProcessDefinitionServiceImpl.java
+1
-1
dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/model/TaskNode.java
...va/org/apache/dolphinscheduler/common/model/TaskNode.java
+3
-3
dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/SnowFlakeUtils.java
.../apache/dolphinscheduler/common/utils/SnowFlakeUtils.java
+5
-17
dolphinscheduler-common/src/main/resources/common.properties
dolphinscheduler-common/src/main/resources/common.properties
+0
-2
dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/utils/DagHelper.java
...java/org/apache/dolphinscheduler/dao/utils/DagHelper.java
+1
-1
dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/master/runner/MasterExecThread.java
...lphinscheduler/server/master/runner/MasterExecThread.java
+1
-1
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessService.java
...ache/dolphinscheduler/service/process/ProcessService.java
+4
-4
未找到文件。
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessDefinitionServiceImpl.java
浏览文件 @
49b23460
...
...
@@ -1414,7 +1414,7 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
((
ObjectNode
)
locationsJN
.
get
(
id
)).
put
(
"name"
,
newName
);
taskNode
.
setName
(
taskNode
.
getName
()
+
suffix
);
taskNode
.
setCode
(
"0"
);
taskNode
.
setCode
(
0L
);
});
processData
.
setTasks
(
taskNodeList
);
String
processDefinitionJson
=
JSONUtils
.
toJsonString
(
processData
);
...
...
dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/model/TaskNode.java
浏览文件 @
49b23460
...
...
@@ -42,7 +42,7 @@ public class TaskNode {
/**
* task node code
*/
private
Stri
ng
code
;
private
Lo
ng
code
;
/**
* task node version
...
...
@@ -329,11 +329,11 @@ public class TaskNode {
this
.
delayTime
=
delayTime
;
}
public
Stri
ng
getCode
()
{
public
Lo
ng
getCode
()
{
return
code
;
}
public
void
setCode
(
Stri
ng
code
)
{
public
void
setCode
(
Lo
ng
code
)
{
this
.
code
=
code
;
}
...
...
dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/SnowFlakeUtils.java
浏览文件 @
49b23460
...
...
@@ -17,36 +17,25 @@
package
org.apache.dolphinscheduler.common.utils
;
import
org.apache.dolphinscheduler.common.Constants
;
import
java.net.InetAddress
;
import
java.net.UnknownHostException
;
import
java.util.Objects
;
public
class
SnowFlakeUtils
{
// start timestamp
private
static
final
long
START_TIMESTAMP
=
1609430400
000
L
;
//2021-01-01
private
static
final
long
START_TIMESTAMP
=
1609430400L
;
//2021-01-01
// Number of digits
private
static
final
long
SEQUENCE_BIT
=
12
;
private
static
final
long
MACHINE_BIT
=
5
;
private
static
final
long
DATA_CENTER_BIT
=
5
;
// Maximum value
private
static
final
long
MAX_DATA_CENTER_NUM
=
~(-
1L
<<
DATA_CENTER_BIT
);
private
static
final
long
SEQUENCE_BIT
=
13
;
private
static
final
long
MACHINE_BIT
=
2
;
private
static
final
long
MAX_SEQUENCE
=
~(-
1L
<<
SEQUENCE_BIT
);
// The displacement to the left
private
static
final
long
MACHINE_LEFT
=
SEQUENCE_BIT
;
private
static
final
long
DATA_CENTER_LEFT
=
SEQUENCE_BIT
+
MACHINE_BIT
;
private
static
final
long
TIMESTAMP_LEFT
=
DATA_CENTER_LEFT
+
DATA_CENTER_BIT
;
private
final
int
dataCenterId
;
private
static
final
long
TIMESTAMP_LEFT
=
SEQUENCE_BIT
+
MACHINE_BIT
;
private
final
int
machineId
;
private
long
sequence
=
0L
;
private
long
lastTimestamp
=
-
1L
;
private
SnowFlakeUtils
()
throws
SnowFlakeException
{
this
.
dataCenterId
=
PropertyUtils
.
getInt
(
Constants
.
SNOW_FLAKE_DATA_CENTER_ID
,
1
);
if
(
dataCenterId
>
MAX_DATA_CENTER_NUM
||
dataCenterId
<
0
)
{
throw
new
IllegalArgumentException
(
String
.
format
(
"dataCenterId can't be greater than %d or less than 0"
,
MAX_DATA_CENTER_NUM
));
}
try
{
this
.
machineId
=
Math
.
abs
(
Objects
.
hash
(
InetAddress
.
getLocalHost
().
getHostName
()))
%
32
;
}
catch
(
UnknownHostException
e
)
{
...
...
@@ -78,7 +67,6 @@ public class SnowFlakeUtils {
}
lastTimestamp
=
currStmp
;
return
(
currStmp
-
START_TIMESTAMP
)
<<
TIMESTAMP_LEFT
|
dataCenterId
<<
DATA_CENTER_LEFT
|
machineId
<<
MACHINE_LEFT
|
sequence
;
}
...
...
@@ -92,7 +80,7 @@ public class SnowFlakeUtils {
}
private
long
nowTimestamp
()
{
return
System
.
currentTimeMillis
();
return
System
.
currentTimeMillis
()
/
1000
;
}
public
static
class
SnowFlakeException
extends
Exception
{
...
...
dolphinscheduler-common/src/main/resources/common.properties
浏览文件 @
49b23460
...
...
@@ -79,8 +79,6 @@ datasource.encryption.salt=!@#$%^&*
# Network IP gets priority, default inner outer
#dolphin.scheduler.network.priority.strategy=default
# 0<dataCenterId<32
#data.center.id=1
# use sudo or not, if set true ,executing user is tenant user and deploy user need sudo permissions ; if set false, executing user is the deploy user, don't need sudo permissions.
sudo.enable
=
true
dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/utils/DagHelper.java
浏览文件 @
49b23460
...
...
@@ -440,7 +440,7 @@ public class DagHelper {
Map
<
Long
,
TaskNode
>
taskNodeMap
=
new
HashMap
<>();
taskNodeList
.
forEach
(
taskNode
->
{
taskNodeMap
.
putIfAbsent
(
Long
.
parseLong
(
taskNode
.
getCode
()
),
taskNode
);
taskNodeMap
.
putIfAbsent
(
taskNode
.
getCode
(
),
taskNode
);
});
List
<
TaskNodeRelation
>
taskNodeRelations
=
new
ArrayList
<>();
...
...
dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/master/runner/MasterExecThread.java
浏览文件 @
49b23460
...
...
@@ -475,7 +475,7 @@ public class MasterExecThread implements Runnable {
TaskInstance
taskInstance
=
findTaskIfExists
(
nodeName
);
if
(
taskInstance
==
null
)
{
taskInstance
=
new
TaskInstance
();
taskInstance
.
setTaskCode
(
Long
.
parseLong
(
taskNode
.
getCode
()
));
taskInstance
.
setTaskCode
(
taskNode
.
getCode
(
));
taskInstance
.
setTaskDefinitionVersion
(
taskNode
.
getVersion
());
// task name
taskInstance
.
setName
(
nodeName
);
...
...
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessService.java
浏览文件 @
49b23460
...
...
@@ -2325,7 +2325,7 @@ public class ProcessService {
}
Map
<
String
,
TaskDefinition
>
taskDefinitionMap
=
new
HashMap
<>();
for
(
TaskNode
taskNode
:
taskNodes
)
{
TaskDefinition
taskDefinition
=
taskDefinitionMapper
.
queryByDefinitionCode
(
StringUtils
.
strDigitToLong
(
taskNode
.
getCode
(),
-
1L
));
TaskDefinition
taskDefinition
=
taskDefinitionMapper
.
queryByDefinitionCode
(
taskNode
.
getCode
(
));
if
(
taskDefinition
==
null
)
{
try
{
long
code
=
SnowFlakeUtils
.
getInstance
().
nextId
();
...
...
@@ -2484,7 +2484,7 @@ public class ProcessService {
taskNodeMap
.
compute
(
processTaskRelation
.
getPostTaskCode
(),
(
k
,
v
)
->
{
if
(
v
==
null
)
{
v
=
new
TaskNode
();
v
.
setCode
(
processTaskRelation
.
getPostTaskCode
()
+
""
);
v
.
setCode
(
processTaskRelation
.
getPostTaskCode
());
v
.
setVersion
(
processTaskRelation
.
getPostTaskVersion
());
v
.
setConditionResult
(
processTaskRelation
.
getConditionParams
());
List
<
PreviousTaskNode
>
preTaskNodeList
=
new
ArrayList
<>();
...
...
@@ -2504,7 +2504,7 @@ public class ProcessService {
taskNodeMap
.
forEach
((
k
,
v
)
->
{
TaskDefinitionLog
taskDefinitionLog
=
taskDefinitionLogMap
.
get
(
k
);
v
.
setId
(
locationMap
.
get
(
taskDefinitionLog
.
getName
()));
v
.
setCode
(
taskDefinitionLog
.
getCode
()
+
""
);
v
.
setCode
(
taskDefinitionLog
.
getCode
());
v
.
setName
(
taskDefinitionLog
.
getName
());
v
.
setDesc
(
taskDefinitionLog
.
getDescription
());
v
.
setType
(
taskDefinitionLog
.
getTaskType
().
toUpperCase
());
...
...
@@ -2547,7 +2547,7 @@ public class ProcessService {
taskRelationList
.
forEach
(
relation
->
taskCodeMap
.
putIfAbsent
(
relation
.
getPostTaskCode
(),
relation
.
getPostTaskVersion
()));
taskNode
.
setCode
(
String
.
valueOf
(
taskDefinition
.
getCode
()
));
taskNode
.
setCode
(
taskDefinition
.
getCode
(
));
taskNode
.
setVersion
(
taskDefinition
.
getVersion
());
taskNode
.
setName
(
taskDefinition
.
getName
());
taskNode
.
setName
(
taskDefinition
.
getName
());
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录