@@ -216,6 +222,7 @@
import mProcedure from './tasks/procedure'
import mDependent from './tasks/dependent'
import mHttp from './tasks/http'
+ import mDatax from './tasks/datax'
import mSubProcess from './tasks/sub_process'
import mSelectInput from './_source/selectInput'
import mTimeoutAlarm from './_source/timeoutAlarm'
@@ -565,6 +572,7 @@
mPython,
mDependent,
mHttp,
+ mDatax,
mSelectInput,
mTimeoutAlarm,
mPriority,
diff --git a/dolphinscheduler-ui/src/js/conf/home/pages/dag/_source/formModel/tasks/datax.vue b/dolphinscheduler-ui/src/js/conf/home/pages/dag/_source/formModel/tasks/datax.vue
new file mode 100755
index 0000000000..ce918f49cf
--- /dev/null
+++ b/dolphinscheduler-ui/src/js/conf/home/pages/dag/_source/formModel/tasks/datax.vue
@@ -0,0 +1,292 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements. See the NOTICE file distributed with
+* this work for additional information regarding copyright ownership.
+* The ASF licenses this file to You 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.
+*/
+
+
+
+ {{$t('Datasource')}}
+
+
+
+
+
+
+ {{$t('SQL Statement')}}
+
+
+
+ {{$t('TargetDataBase')}}
+
+
+
+
+
+
+ {{$t('TargetTable')}}
+
+
+
+
+
+
+ {{$t('TargetDataBase')}}{{$t('Pre Statement')}}
+
+
+
+
+
+
+ {{$t('TargetDataBase')}}{{$t('Post Statement')}}
+
+
+
+
+
+
+
+ {{$t('SpeedByte')}}
+
+
+
+
+ ({{$t('0 means unlimited by byte')}})
+
+
+
+
+ {{$t('SpeedRecord')}}
+
+
+
+
+ ({{$t('0 means unlimited by count')}})
+
+
+
+
+
diff --git a/dolphinscheduler-ui/src/js/conf/home/pages/dag/img/toolbar_DATAX.png b/dolphinscheduler-ui/src/js/conf/home/pages/dag/img/toolbar_DATAX.png
new file mode 100644
index 0000000000000000000000000000000000000000..b59c7592081977f8ed36359df9a4467ce9d22f66
GIT binary patch
literal 571
zcmeAS@N?(olHy`uVBq!ia0vp^3LwnF3?v&v(vJfvmUKs7M+SzC{oH>NS%G}U;vjb?
zhIQv;UIIC)C9V-ADTyViR=N2pnQ4^_Mg~R(x&}tN1|}f}7FGu4R)&_^1_o9J1~w}t
z6HzoI7o`IA;nv{$W#L_*2CV>}5LaXO^X>&cW?mP73=r~wk!TF}^OK^dRReYLl?3?(
z|7YO#eSPQW@#1#%sVnC^-mq&T(DlZiE{-7@=aU6km=tddv9WzW-KAj0+;RUD1Djx1
z0HZLQMnM~ghmnfIj~pK1gG}r<60{^L9GE6?*f}3^S
QKZS$uv&Wh8ss2c{p?CY>HVe*%ju&6gy?ZMurTA)f*m*v@Kxm
zz9Fuc9u^atwB%sI6^UaHwj8)ny*1#O)8h+M+t~TIHaD_xMTm)+uo-Od&Ec5D!rh`1
zqLZQHkr8uaL!e~F$0pY^Nxcq?c{2~Rg*vo4YOBngrmr*O#yQ2y7OtBLn4G63Ft<-g
zbexi~bHT%$!evi+!kr`}yds4oP6;21jAe@0E6Ee^_t2RITzu9XY;CCm%f1^jaVT>b
zGDm)3Xgc3)yQm>>Cd0<-lHn=MlbNHfR4f@7Vv@a1Z#T7i1PoXPPgg&ebxsLQ0Dm98
A_y7O^
literal 0
HcmV?d00001
diff --git a/dolphinscheduler-ui/src/js/conf/home/pages/dag/img/toolbar_ETL.png b/dolphinscheduler-ui/src/js/conf/home/pages/dag/img/toolbar_ETL.png
new file mode 100755
index 0000000000000000000000000000000000000000..913af420c6c76ed051ecf44f27b522419fea7ecc
GIT binary patch
literal 3117
zcmZ{mc{J2*8^?c%Axj}4*&_-wW8agVvBZ!qWf{Xv%#a!To{+L+k0N3SHCY;iGK6?!
ziwY&?5pT*e*^T`jo%fu#_c`Z1zjNK!`F+2i>wDjSUdcArrd;eo>;M38nVT8G8D0Fa
z*g%XE7aqRGXv{wPR{8+&nfYto7p6lKVFtGXfbeqw5PKT{wi#0F4*&>)0>GR*0BAh`
z0D*u<&9*uW1LSF8Y6Kh{e#I>nSqz00Z*FDGI(_6A6Ps$>ExlC$I96(Iq;K!kQJ5Q%
zBJwG!ThGUvwiC5U>z!1OzArScq0w+2ZD938F#gmf+YA>W(u_n#88(}{#L1rRJS_eT
zjDV>c&NM=s!_Ckv=a0F=S?-M3bYDLzG4|^E2J+YZFiZfY?LG5fTPH$+_Ji~8frun4>sN9;?U}N5jEP}O|=+Z>%+X&-BR<3ewJozT}H)RfV08q>d8j9eN4FoqY>^C%ntci|FrZXE-h&
z(9Hu23w7{6;x<{AIM+{}EfNQg2
zxH5Z0JjY<3!?Rj$6jqXLWS*SOOW;dH3k^B>L3vXrcfVO2tar(5EI!=Yn(9aq(GCxa
zP2Z5zx&kHaz@QB5-OUWRQ6GpFjS@RG~2*DAydGJkWH_SB76~dImw<-hiVW#
zEwbnA6XK}K&8c{EZYE53IxyDqT(6t%c1ROtpEB6(S-UjHzFt+ck}=%9sjEZnZjpWc
zDWGLlf*_gI9|`3>Cf0cHw}4_N;S~iWo&(G5_XeF@rr+V7y^#9J1{DQfcOg42?t~VF
zBtMS^O|YdHRRzC;
zfLs?@yLF@^VZ@;laC~LTLGE`|nHtrfrrrcy?fnZ`BH`C1`
z&`Sr@M8gxZ%gLgo*@!Y;#d9(;`T2!8`IaWmxj{hyfzRO1$V%X3#CE=qrdlwQv~=7h
zpjS!J>ZpgSEa&r2VG*#(`;_#M0f{M_`+?{Lx7XVibL-(9b$z*Er`rk?#z?*b#U0A^
zI7Ud(V+x(O!uoO@VkdZeWZk`BBw^a_v34TKpr=93mD+)6VpGAr)v>etz<19$v&ZY{
zXFp~zc}gg@h=v6eb#x@tUhh*wi@N(3PUo%|^Db+Awk*J3FqY!&Qc);ds})HKZ!sr1
zl)5~BlHFcs>7tMaZ?ZI1Gra5w#;+7ooht3;<^X@n);XA5&}d=E&FLatVeN}18p2&r
z=7wpga!8`x^huS6TwfhH265vXT(`}nvZU?s?*6Wqn$a1rT
zUK|eyjuxeEhHd3IHto=;XEQ7V7shT1k%W5e6TOto)gEF-@A-*YCZgT*`5UU8Riu4do$nQecve~rgdlcVKC
z+vi#0qd4CeE&LL`f)rvp=z2`4
zfm)V0+n7~F)UBg1-?_A&NOW=a0!H-ZTq>M46UDbr=G+|;qgwb75mI@*6ZP4HSIg11
zU`Hn~UoGaLjjW}-=-DF6%mJ?&WJ*kohme9Q+;C#KlFX+~-mrW2MSiAw7Ob4vP`z`t
zcK`90`HSCcexC5y)*JD5_w-~+bs$eRyUB5VsK*&SQPiOlY~<@|8qIodF1ZT0!LI9x
zNV(M=Bk(hw
z&L%O%wdw9`L`k}jAGff$=j0HJk~h&2mB}!>Zzcu3b@TduP&}`q%TFvwoh$H1(Y44e
zJMFQi%7-OEXzZk>r7?>}aC!1H%p&PY@7z$*@zpNQ6ul;+O!o!PT7`>s`7TW>Sq2
zo7g%L&3AHg_SL7d;Sb8qWrYn2Y@;;=ibWT_W{!63_C8+t-o`cmqu+>)W!z3i^2ob}
z?>;BhtVCkn%X+leD{RsRdt^qjakD$J(zBRxu<#je9=R*Nel0XDZ1c~K?03@d{-q=*
zC--b7uX0NtU!Lw>l^4%yGNze5Lt19KET-EbX
zW>XoQdquz1KAgZL$?Q6%#z*X!nvFJ)FM3dq*{PR%+g_gob7of=LS@@)St;d63a7b0
zIH%pt;pLT6d$&yHl)LYMrxd1UuRvZq(atrCKc!6K^hY{e=gqAcS2Ty$;ydtz{QM~d
znKnB!?*Bpkee1We4UVGufkvXXxVQ)#^D{FQ1IY}j!hzwOg
zm1OTca2Krk_isI!|hD4Q%imOnaO^lAnyaoNk%eSN#6zU5jaYWjqy_G)_5MG^jzgo3J6>n&UbEe%XOz@}nGWkUBWokP8r
z+H+e4+HQi$;A5seffuQ^`NC;!U2=w>IL$JsY92)=oAB^**/dao/mapper/CommandMapperTest.java
**/alert/template/AlertTemplateFactoryTest.java
**/alert/template/impl/DefaultHTMLTemplateTest.java
+ **/server/worker/task/datax/DataxTaskTest.java
+ **/server/utils/DataxUtilsTest.java
From c63cd3e237d7a32b7cad529dd99c4051abd8b86d Mon Sep 17 00:00:00 2001
From: dailidong
Date: Thu, 6 Feb 2020 11:08:06 +0800
Subject: [PATCH 25/35] combine logback config of master/worker/alert/api
server to one (#1898)
* combine logback config of master/worker/alert/api server to one logback.xml
---
.../conf/combined_logback.xml | 6 +-
.../dolphinscheduler/conf/worker_logback.xml | 6 +-
.../src/main/resources/alert_logback.xml | 49 -----
.../src/main/resources/apiserver_logback.xml | 60 ------
.../main/resources/application-api.properties | 2 -
dolphinscheduler-common/pom.xml | 7 +
.../common}/log/MasterLogFilter.java | 2 +-
.../common}/log/SensitiveDataConverter.java | 6 +-
.../common}/log/TaskLogDiscriminator.java | 4 +-
.../common}/log/TaskLogFilter.java | 4 +-
.../common}/log/WorkerLogFilter.java | 6 +-
.../common}/utils/LoggerUtils.java | 9 +-
.../common/utils/SensitiveLogUtils.java | 4 +-
.../src/main/resources/logback.xml | 169 +++++++++++++++++
.../common/log/MasterLogFilterTest.java | 118 ++++++++++++
.../log/SensitiveDataConverterTest.java | 179 ++++++++++++++++++
.../common/log/TaskLogDiscriminatorTest.java | 155 +++++++++++++++
.../common/log/TaskLogFilterTest.java | 120 ++++++++++++
.../common/log/WorkerLogFilterTest.java | 119 ++++++++++++
.../common/utils/LoggerUtilsTest.java | 43 +++++
.../common/utils/SensitiveLogUtilsTest.java | 8 +-
.../server/utils/ProcessUtils.java | 1 +
.../worker/runner/TaskScheduleThread.java | 4 +-
.../worker/task/AbstractCommandExecutor.java | 2 +-
.../src/main/resources/master_logback.xml | 52 -----
.../src/main/resources/worker_logback.xml | 81 --------
.../log/SensitiveDataConverterTest.java | 92 ---------
.../shell/ShellCommandExecutorTest.java | 2 +-
.../server/worker/sql/SqlExecutorTest.java | 2 +-
pom.xml | 1 +
script/dolphinscheduler-daemon.sh | 12 +-
31 files changed, 955 insertions(+), 370 deletions(-)
delete mode 100644 dolphinscheduler-alert/src/main/resources/alert_logback.xml
delete mode 100644 dolphinscheduler-api/src/main/resources/apiserver_logback.xml
rename {dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/master => dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common}/log/MasterLogFilter.java (96%)
rename {dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/worker => dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common}/log/SensitiveDataConverter.java (92%)
rename {dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/worker => dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common}/log/TaskLogDiscriminator.java (94%)
rename {dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/worker => dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common}/log/TaskLogFilter.java (93%)
rename {dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/worker => dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common}/log/WorkerLogFilter.java (91%)
rename {dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server => dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common}/utils/LoggerUtils.java (91%)
rename dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/utils/SensitiveLogUtil.java => dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/SensitiveLogUtils.java (93%)
create mode 100644 dolphinscheduler-common/src/main/resources/logback.xml
create mode 100644 dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/log/MasterLogFilterTest.java
create mode 100644 dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/log/SensitiveDataConverterTest.java
create mode 100644 dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/log/TaskLogDiscriminatorTest.java
create mode 100644 dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/log/TaskLogFilterTest.java
create mode 100644 dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/log/WorkerLogFilterTest.java
create mode 100644 dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/utils/LoggerUtilsTest.java
rename dolphinscheduler-server/src/test/java/org/apache/dolphinscheduler/server/utils/SensitiveLogUtilTest.java => dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/utils/SensitiveLogUtilsTest.java (83%)
delete mode 100644 dolphinscheduler-server/src/main/resources/master_logback.xml
delete mode 100644 dolphinscheduler-server/src/main/resources/worker_logback.xml
delete mode 100644 dolphinscheduler-server/src/test/java/org/apache/dolphinscheduler/server/worker/log/SensitiveDataConverterTest.java
diff --git a/dockerfile/conf/dolphinscheduler/conf/combined_logback.xml b/dockerfile/conf/dolphinscheduler/conf/combined_logback.xml
index 6bdb97cf00..7a9a5b4621 100644
--- a/dockerfile/conf/dolphinscheduler/conf/combined_logback.xml
+++ b/dockerfile/conf/dolphinscheduler/conf/combined_logback.xml
@@ -31,8 +31,8 @@
INFO
-
-
+
+
taskAppId
${log.base}
@@ -52,7 +52,7 @@
${log.base}/dolphinscheduler-combined.log
-
+
INFO
diff --git a/dockerfile/conf/dolphinscheduler/conf/worker_logback.xml b/dockerfile/conf/dolphinscheduler/conf/worker_logback.xml
index 9bbd9615c4..bf4a651e7c 100644
--- a/dockerfile/conf/dolphinscheduler/conf/worker_logback.xml
+++ b/dockerfile/conf/dolphinscheduler/conf/worker_logback.xml
@@ -31,8 +31,8 @@
INFO
-
-
+
+
taskAppId
${log.base}
@@ -52,7 +52,7 @@
${log.base}/dolphinscheduler-worker.log
-
+
INFO
diff --git a/dolphinscheduler-alert/src/main/resources/alert_logback.xml b/dolphinscheduler-alert/src/main/resources/alert_logback.xml
deleted file mode 100644
index 3474df8d2e..0000000000
--- a/dolphinscheduler-alert/src/main/resources/alert_logback.xml
+++ /dev/null
@@ -1,49 +0,0 @@
-
-
-
-
-
-
-
-
-
- [%level] %date{yyyy-MM-dd HH:mm:ss.SSS} %logger{96}:[%line] - %msg%n
-
- UTF-8
-
-
-
-
- ${log.base}/dolphinscheduler-alert.log
-
- ${log.base}/dolphinscheduler-alert.%d{yyyy-MM-dd_HH}.%i.log
- 20
- 64MB
-
-
-
- [%level] %date{yyyy-MM-dd HH:mm:ss.SSS} %logger{96}:[%line] - %msg%n
-
- UTF-8
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/dolphinscheduler-api/src/main/resources/apiserver_logback.xml b/dolphinscheduler-api/src/main/resources/apiserver_logback.xml
deleted file mode 100644
index 4c2ce0d2b3..0000000000
--- a/dolphinscheduler-api/src/main/resources/apiserver_logback.xml
+++ /dev/null
@@ -1,60 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- [%level] %date{yyyy-MM-dd HH:mm:ss.SSS} %logger{96}:[%line] - %msg%n
-
- UTF-8
-
-
-
-
-
-
- INFO
-
- ${log.base}/dolphinscheduler-api-server.log
-
- ${log.base}/dolphinscheduler-api-server.%d{yyyy-MM-dd_HH}.%i.log
- 168
- 64MB
-
-
-
-
- [%level] %date{yyyy-MM-dd HH:mm:ss.SSS} %logger{96}:[%line] - %msg%n
-
- UTF-8
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/dolphinscheduler-api/src/main/resources/application-api.properties b/dolphinscheduler-api/src/main/resources/application-api.properties
index 6ec304a397..21f940baaf 100644
--- a/dolphinscheduler-api/src/main/resources/application-api.properties
+++ b/dolphinscheduler-api/src/main/resources/application-api.properties
@@ -15,8 +15,6 @@
# limitations under the License.
#
-logging.config=classpath:apiserver_logback.xml
-
# server port
server.port=12345
diff --git a/dolphinscheduler-common/pom.xml b/dolphinscheduler-common/pom.xml
index 955e956251..bd2448eee7 100644
--- a/dolphinscheduler-common/pom.xml
+++ b/dolphinscheduler-common/pom.xml
@@ -29,6 +29,7 @@
jar
UTF-8
+ 3.1.0
@@ -604,5 +605,11 @@
org.springframework
spring-context
+
+
+ org.codehaus.janino
+ janino
+ ${codehaus.janino.version}
+
diff --git a/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/master/log/MasterLogFilter.java b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/log/MasterLogFilter.java
similarity index 96%
rename from dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/master/log/MasterLogFilter.java
rename to dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/log/MasterLogFilter.java
index d6de484074..7b5d53a032 100644
--- a/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/master/log/MasterLogFilter.java
+++ b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/log/MasterLogFilter.java
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.dolphinscheduler.server.master.log;
+package org.apache.dolphinscheduler.common.log;
import ch.qos.logback.classic.Level;
import ch.qos.logback.classic.spi.ILoggingEvent;
diff --git a/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/worker/log/SensitiveDataConverter.java b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/log/SensitiveDataConverter.java
similarity index 92%
rename from dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/worker/log/SensitiveDataConverter.java
rename to dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/log/SensitiveDataConverter.java
index 4a98e66c6c..971ce7149c 100644
--- a/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/worker/log/SensitiveDataConverter.java
+++ b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/log/SensitiveDataConverter.java
@@ -14,14 +14,14 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.dolphinscheduler.server.worker.log;
+package org.apache.dolphinscheduler.common.log;
import ch.qos.logback.classic.pattern.MessageConverter;
import ch.qos.logback.classic.spi.ILoggingEvent;
import org.apache.dolphinscheduler.common.Constants;
+import org.apache.dolphinscheduler.common.utils.SensitiveLogUtils;
import org.apache.dolphinscheduler.common.utils.StringUtils;
-import org.apache.dolphinscheduler.server.utils.SensitiveLogUtil;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -77,7 +77,7 @@ public class SensitiveDataConverter extends MessageConverter {
String password = matcher.group();
- String maskPassword = SensitiveLogUtil.maskDataSourcePwd(password);
+ String maskPassword = SensitiveLogUtils.maskDataSourcePwd(password);
matcher.appendReplacement(sb, maskPassword);
}
diff --git a/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/worker/log/TaskLogDiscriminator.java b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/log/TaskLogDiscriminator.java
similarity index 94%
rename from dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/worker/log/TaskLogDiscriminator.java
rename to dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/log/TaskLogDiscriminator.java
index fa00aed772..fd2b0766a8 100644
--- a/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/worker/log/TaskLogDiscriminator.java
+++ b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/log/TaskLogDiscriminator.java
@@ -14,12 +14,12 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.dolphinscheduler.server.worker.log;
+package org.apache.dolphinscheduler.common.log;
import ch.qos.logback.classic.spi.ILoggingEvent;
import ch.qos.logback.core.sift.AbstractDiscriminator;
import org.apache.dolphinscheduler.common.Constants;
-import org.apache.dolphinscheduler.server.utils.LoggerUtils;
+import org.apache.dolphinscheduler.common.utils.LoggerUtils;
/**
* Task Log Discriminator
diff --git a/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/worker/log/TaskLogFilter.java b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/log/TaskLogFilter.java
similarity index 93%
rename from dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/worker/log/TaskLogFilter.java
rename to dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/log/TaskLogFilter.java
index 6398135481..ac258daf20 100644
--- a/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/worker/log/TaskLogFilter.java
+++ b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/log/TaskLogFilter.java
@@ -14,13 +14,13 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.dolphinscheduler.server.worker.log;
+package org.apache.dolphinscheduler.common.log;
import ch.qos.logback.classic.Level;
import ch.qos.logback.classic.spi.ILoggingEvent;
import ch.qos.logback.core.filter.Filter;
import ch.qos.logback.core.spi.FilterReply;
-import org.apache.dolphinscheduler.server.utils.LoggerUtils;
+import org.apache.dolphinscheduler.common.utils.LoggerUtils;
/**
* task log filter
diff --git a/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/worker/log/WorkerLogFilter.java b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/log/WorkerLogFilter.java
similarity index 91%
rename from dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/worker/log/WorkerLogFilter.java
rename to dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/log/WorkerLogFilter.java
index 23758f918a..abcc8bc619 100644
--- a/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/worker/log/WorkerLogFilter.java
+++ b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/log/WorkerLogFilter.java
@@ -14,12 +14,15 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.dolphinscheduler.server.worker.log;
+package org.apache.dolphinscheduler.common.log;
import ch.qos.logback.classic.Level;
import ch.qos.logback.classic.spi.ILoggingEvent;
import ch.qos.logback.core.filter.Filter;
import ch.qos.logback.core.spi.FilterReply;
+import org.apache.dolphinscheduler.common.utils.LoggerUtils;
+
+import java.util.Arrays;
/**
* worker log filter
@@ -40,6 +43,7 @@ public class WorkerLogFilter extends Filter {
if (event.getThreadName().startsWith("Worker-")){
return FilterReply.ACCEPT;
}
+
return FilterReply.DENY;
}
public void setLevel(String level) {
diff --git a/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/utils/LoggerUtils.java b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/LoggerUtils.java
similarity index 91%
rename from dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/utils/LoggerUtils.java
rename to dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/LoggerUtils.java
index 8b40d943c0..fc08eb645b 100644
--- a/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/utils/LoggerUtils.java
+++ b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/LoggerUtils.java
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.dolphinscheduler.server.utils;
+package org.apache.dolphinscheduler.common.utils;
import org.apache.dolphinscheduler.common.Constants;
import org.slf4j.Logger;
@@ -44,6 +44,11 @@ public class LoggerUtils {
*/
public static final String TASK_LOGGER_THREAD_NAME = "TaskLogInfo";
+ /**
+ * Task Logger Thread's name
+ */
+ public static final String TASK_APPID_LOG_FORMAT = "[taskAppId=";
+
/**
* build job id
*
@@ -58,7 +63,7 @@ public class LoggerUtils {
int processInstId,
int taskId){
// - [taskAppId=TASK_79_4084_15210]
- return String.format(" - [taskAppId=%s-%s-%s-%s]",affix,
+ return String.format(" - %s%s-%s-%s-%s]",TASK_APPID_LOG_FORMAT,affix,
processDefId,
processInstId,
taskId);
diff --git a/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/utils/SensitiveLogUtil.java b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/SensitiveLogUtils.java
similarity index 93%
rename from dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/utils/SensitiveLogUtil.java
rename to dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/SensitiveLogUtils.java
index 948e92cb24..eab6c4f124 100644
--- a/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/utils/SensitiveLogUtil.java
+++ b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/SensitiveLogUtils.java
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.dolphinscheduler.server.utils;
+package org.apache.dolphinscheduler.common.utils;
import org.apache.commons.lang.StringUtils;
import org.apache.dolphinscheduler.common.Constants;
@@ -22,7 +22,7 @@ import org.apache.dolphinscheduler.common.Constants;
/**
* sensitive log Util
*/
-public class SensitiveLogUtil {
+public class SensitiveLogUtils {
/**
* @param dataSourcePwd data source password
diff --git a/dolphinscheduler-common/src/main/resources/logback.xml b/dolphinscheduler-common/src/main/resources/logback.xml
new file mode 100644
index 0000000000..7f634da975
--- /dev/null
+++ b/dolphinscheduler-common/src/main/resources/logback.xml
@@ -0,0 +1,169 @@
+
+
+
+
+
+
+
+
+
+
+ [%level] %date{yyyy-MM-dd HH:mm:ss.SSS} %logger{96}:[%line] - %msg%n
+
+ UTF-8
+
+
+
+
+
+
+ ${log.base}/dolphinscheduler-master.log
+
+
+ ${log.base}/dolphinscheduler-master.%d{yyyy-MM-dd_HH}.%i.log
+ 168
+ 200MB
+
+
+
+ [%level] %date{yyyy-MM-dd HH:mm:ss.SSS} %logger{96}:[%line] - %msg%n
+
+ UTF-8
+
+
+
+
+
+
+
+
+
+ INFO
+
+
+
+ taskAppId
+ ${log.base}
+
+
+
+ ${log.base}/${taskAppId}.log
+
+
+ [%level] %date{yyyy-MM-dd HH:mm:ss.SSS} %logger{96}:[%line] - %messsage%n
+
+ UTF-8
+
+ true
+
+
+
+
+ ${log.base}/dolphinscheduler-worker.log
+
+ INFO
+
+
+
+ ${log.base}/dolphinscheduler-worker.%d{yyyy-MM-dd_HH}.%i.log
+ 168
+ 200MB
+
+
+
+ [%level] %date{yyyy-MM-dd HH:mm:ss.SSS} %logger{96}:[%line] - %messsage%n
+
+ UTF-8
+
+
+
+
+
+
+
+ ${log.base}/dolphinscheduler-alert.log
+
+ ${log.base}/dolphinscheduler-alert.%d{yyyy-MM-dd_HH}.%i.log
+ 20
+ 64MB
+
+
+
+ [%level] %date{yyyy-MM-dd HH:mm:ss.SSS} %logger{96}:[%line] - %msg%n
+
+ UTF-8
+
+
+
+
+
+
+
+ ${log.base}/dolphinscheduler-api-server.log
+
+ INFO
+
+
+ ${log.base}/dolphinscheduler-api-server.%d{yyyy-MM-dd_HH}.%i.log
+ 168
+ 64MB
+
+
+
+ [%level] %date{yyyy-MM-dd HH:mm:ss.SSS} %logger{96}:[%line] - %msg%n
+
+ UTF-8
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/log/MasterLogFilterTest.java b/dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/log/MasterLogFilterTest.java
new file mode 100644
index 0000000000..8cf6cfc2df
--- /dev/null
+++ b/dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/log/MasterLogFilterTest.java
@@ -0,0 +1,118 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 org.apache.dolphinscheduler.common.log;
+
+import ch.qos.logback.classic.Level;
+import ch.qos.logback.classic.spi.ILoggingEvent;
+import ch.qos.logback.classic.spi.IThrowableProxy;
+import ch.qos.logback.classic.spi.LoggerContextVO;
+import ch.qos.logback.core.spi.FilterReply;
+import org.apache.dolphinscheduler.common.Constants;
+import org.junit.Assert;
+import org.junit.Test;
+import org.slf4j.Marker;
+import java.util.Map;
+
+public class MasterLogFilterTest {
+
+ @Test
+ public void decide() {
+ MasterLogFilter masterLogFilter = new MasterLogFilter();
+
+
+ FilterReply filterReply = masterLogFilter.decide(new ILoggingEvent() {
+ @Override
+ public String getThreadName() {
+ return Constants.THREAD_NAME_MASTER_SERVER;
+ }
+
+ @Override
+ public Level getLevel() {
+ return Level.INFO;
+ }
+
+ @Override
+ public String getMessage() {
+ return "master insert into queue success, task : shell2";
+// return "consume tasks: [2_177_2_704_-1],there still have 0 tasks need to be executed";
+ }
+
+ @Override
+ public Object[] getArgumentArray() {
+ return new Object[0];
+ }
+
+ @Override
+ public String getFormattedMessage() {
+ return "master insert into queue success, task : shell2";
+ }
+
+ @Override
+ public String getLoggerName() {
+ return null;
+ }
+
+ @Override
+ public LoggerContextVO getLoggerContextVO() {
+ return null;
+ }
+
+ @Override
+ public IThrowableProxy getThrowableProxy() {
+ return null;
+ }
+
+ @Override
+ public StackTraceElement[] getCallerData() {
+ return new StackTraceElement[0];
+ }
+
+ @Override
+ public boolean hasCallerData() {
+ return false;
+ }
+
+ @Override
+ public Marker getMarker() {
+ return null;
+ }
+
+ @Override
+ public Map getMDCPropertyMap() {
+ return null;
+ }
+
+ @Override
+ public Map getMdc() {
+ return null;
+ }
+
+ @Override
+ public long getTimeStamp() {
+ return 0;
+ }
+
+ @Override
+ public void prepareForDeferredProcessing() {
+
+ }
+ });
+
+ Assert.assertEquals(FilterReply.ACCEPT, filterReply);
+
+ }
+}
\ No newline at end of file
diff --git a/dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/log/SensitiveDataConverterTest.java b/dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/log/SensitiveDataConverterTest.java
new file mode 100644
index 0000000000..727ab41002
--- /dev/null
+++ b/dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/log/SensitiveDataConverterTest.java
@@ -0,0 +1,179 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 org.apache.dolphinscheduler.common.log;
+
+
+import ch.qos.logback.classic.Level;
+import ch.qos.logback.classic.spi.ILoggingEvent;
+import ch.qos.logback.classic.spi.IThrowableProxy;
+import ch.qos.logback.classic.spi.LoggerContextVO;
+import org.apache.dolphinscheduler.common.Constants;
+import org.apache.dolphinscheduler.common.utils.SensitiveLogUtils;
+import org.junit.Assert;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.slf4j.Marker;
+
+import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+public class SensitiveDataConverterTest {
+
+ private final Logger logger = LoggerFactory.getLogger(SensitiveDataConverterTest.class);
+
+ /**
+ * password pattern
+ */
+ private final Pattern pwdPattern = Pattern.compile(Constants.DATASOURCE_PASSWORD_REGEX);
+
+ private final String logMsg = "{\"address\":\"jdbc:mysql://192.168.xx.xx:3306\"," +
+ "\"database\":\"carbond\"," +
+ "\"jdbcUrl\":\"jdbc:mysql://192.168.xx.xx:3306/ods\"," +
+ "\"user\":\"view\"," +
+ "\"password\":\"view1\"}";
+
+ private final String maskLogMsg = "{\"address\":\"jdbc:mysql://192.168.xx.xx:3306\"," +
+ "\"database\":\"carbond\"," +
+ "\"jdbcUrl\":\"jdbc:mysql://192.168.xx.xx:3306/ods\"," +
+ "\"user\":\"view\"," +
+ "\"password\":\"******\"}";
+ @Test
+ public void convert() {
+ SensitiveDataConverter sensitiveDataConverter = new SensitiveDataConverter();
+ String result = sensitiveDataConverter.convert(new ILoggingEvent() {
+ @Override
+ public String getThreadName() {
+ return null;
+ }
+
+ @Override
+ public Level getLevel() {
+ return Level.INFO;
+ }
+
+ @Override
+ public String getMessage() {
+ return null;
+ }
+
+ @Override
+ public Object[] getArgumentArray() {
+ return new Object[0];
+ }
+
+ @Override
+ public String getFormattedMessage() {
+ return logMsg;
+ }
+
+ @Override
+ public String getLoggerName() {
+ return null;
+ }
+
+ @Override
+ public LoggerContextVO getLoggerContextVO() {
+ return null;
+ }
+
+ @Override
+ public IThrowableProxy getThrowableProxy() {
+ return null;
+ }
+
+ @Override
+ public StackTraceElement[] getCallerData() {
+ return new StackTraceElement[0];
+ }
+
+ @Override
+ public boolean hasCallerData() {
+ return false;
+ }
+
+ @Override
+ public Marker getMarker() {
+ return null;
+ }
+
+ @Override
+ public Map getMDCPropertyMap() {
+ return null;
+ }
+
+ @Override
+ public Map getMdc() {
+ return null;
+ }
+
+ @Override
+ public long getTimeStamp() {
+ return 0;
+ }
+
+ @Override
+ public void prepareForDeferredProcessing() {
+
+ }
+ });
+
+ Assert.assertEquals(maskLogMsg, passwordHandler(pwdPattern, logMsg));
+
+ }
+
+ /**
+ * mask sensitive logMsg - sql task datasource password
+ */
+ @Test
+ public void testPwdLogMsgConverter() {
+ logger.info("parameter : {}", logMsg);
+ logger.info("parameter : {}", passwordHandler(pwdPattern, logMsg));
+
+ Assert.assertNotEquals(logMsg, passwordHandler(pwdPattern, logMsg));
+ Assert.assertEquals(maskLogMsg, passwordHandler(pwdPattern, logMsg));
+
+ }
+
+ /**
+ * password regex test
+ *
+ * @param logMsg original log
+ */
+ private static String passwordHandler(Pattern pattern, String logMsg) {
+
+ Matcher matcher = pattern.matcher(logMsg);
+
+ StringBuffer sb = new StringBuffer(logMsg.length());
+
+ while (matcher.find()) {
+
+ String password = matcher.group();
+
+ String maskPassword = SensitiveLogUtils.maskDataSourcePwd(password);
+
+ matcher.appendReplacement(sb, maskPassword);
+ }
+ matcher.appendTail(sb);
+
+ return sb.toString();
+ }
+
+
+
+}
diff --git a/dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/log/TaskLogDiscriminatorTest.java b/dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/log/TaskLogDiscriminatorTest.java
new file mode 100644
index 0000000000..8745a4f6b4
--- /dev/null
+++ b/dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/log/TaskLogDiscriminatorTest.java
@@ -0,0 +1,155 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 org.apache.dolphinscheduler.common.log;
+
+import ch.qos.logback.classic.Level;
+import ch.qos.logback.classic.spi.ILoggingEvent;
+import ch.qos.logback.classic.spi.IThrowableProxy;
+import ch.qos.logback.classic.spi.LoggerContextVO;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.slf4j.Marker;
+
+import java.util.Map;
+
+import static org.junit.Assert.*;
+
+public class TaskLogDiscriminatorTest {
+
+ /**
+ * log base
+ */
+ private String logBase = "logs";
+
+ TaskLogDiscriminator taskLogDiscriminator;
+
+ @Before
+ public void before(){
+ taskLogDiscriminator = new TaskLogDiscriminator();
+ taskLogDiscriminator.setLogBase("logs");
+ taskLogDiscriminator.setKey("123");
+ }
+
+ @Test
+ public void getDiscriminatingValue() {
+ String result = taskLogDiscriminator.getDiscriminatingValue(new ILoggingEvent() {
+ @Override
+ public String getThreadName() {
+ return null;
+ }
+
+ @Override
+ public Level getLevel() {
+ return null;
+ }
+
+ @Override
+ public String getMessage() {
+ return null;
+ }
+
+ @Override
+ public Object[] getArgumentArray() {
+ return new Object[0];
+ }
+
+ @Override
+ public String getFormattedMessage() {
+ return null;
+ }
+
+ @Override
+ public String getLoggerName() {
+ return "[taskAppId=TASK-1-1-1";
+ }
+
+ @Override
+ public LoggerContextVO getLoggerContextVO() {
+ return null;
+ }
+
+ @Override
+ public IThrowableProxy getThrowableProxy() {
+ return null;
+ }
+
+ @Override
+ public StackTraceElement[] getCallerData() {
+ return new StackTraceElement[0];
+ }
+
+ @Override
+ public boolean hasCallerData() {
+ return false;
+ }
+
+ @Override
+ public Marker getMarker() {
+ return null;
+ }
+
+ @Override
+ public Map getMDCPropertyMap() {
+ return null;
+ }
+
+ @Override
+ public Map getMdc() {
+ return null;
+ }
+
+ @Override
+ public long getTimeStamp() {
+ return 0;
+ }
+
+ @Override
+ public void prepareForDeferredProcessing() {
+
+ }
+ });
+ Assert.assertEquals("1/1/", result);
+ }
+
+ @Test
+ public void start() {
+ taskLogDiscriminator.start();
+ Assert.assertEquals(true, taskLogDiscriminator.isStarted());
+ }
+
+ @Test
+ public void getKey() {
+ Assert.assertEquals("123", taskLogDiscriminator.getKey());
+ }
+
+ @Test
+ public void setKey() {
+
+ taskLogDiscriminator.setKey("123");
+ }
+
+ @Test
+ public void getLogBase() {
+ Assert.assertEquals("logs", taskLogDiscriminator.getLogBase());
+ }
+
+ @Test
+ public void setLogBase() {
+ taskLogDiscriminator.setLogBase("logs");
+ }
+}
\ No newline at end of file
diff --git a/dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/log/TaskLogFilterTest.java b/dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/log/TaskLogFilterTest.java
new file mode 100644
index 0000000000..52767074da
--- /dev/null
+++ b/dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/log/TaskLogFilterTest.java
@@ -0,0 +1,120 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 org.apache.dolphinscheduler.common.log;
+
+import ch.qos.logback.classic.Level;
+import ch.qos.logback.classic.spi.ILoggingEvent;
+import ch.qos.logback.classic.spi.IThrowableProxy;
+import ch.qos.logback.classic.spi.LoggerContextVO;
+import ch.qos.logback.core.spi.FilterReply;
+import org.apache.dolphinscheduler.common.Constants;
+import org.apache.dolphinscheduler.common.utils.LoggerUtils;
+import org.junit.Assert;
+import org.junit.Test;
+import org.slf4j.Marker;
+
+import java.util.Map;
+
+
+public class TaskLogFilterTest {
+
+ @Test
+ public void decide() {
+ TaskLogFilter taskLogFilter = new TaskLogFilter();
+
+
+ FilterReply filterReply = taskLogFilter.decide(new ILoggingEvent() {
+ @Override
+ public String getThreadName() {
+ return LoggerUtils.TASK_LOGGER_THREAD_NAME;
+ }
+
+ @Override
+ public Level getLevel() {
+ return Level.INFO;
+ }
+
+ @Override
+ public String getMessage() {
+ return "raw script : echo 222";
+ }
+
+ @Override
+ public Object[] getArgumentArray() {
+ return new Object[0];
+ }
+
+ @Override
+ public String getFormattedMessage() {
+ return "raw script : echo 222";
+ }
+
+ @Override
+ public String getLoggerName() {
+ return null;
+ }
+
+ @Override
+ public LoggerContextVO getLoggerContextVO() {
+ return null;
+ }
+
+ @Override
+ public IThrowableProxy getThrowableProxy() {
+ return null;
+ }
+
+ @Override
+ public StackTraceElement[] getCallerData() {
+ return new StackTraceElement[0];
+ }
+
+ @Override
+ public boolean hasCallerData() {
+ return false;
+ }
+
+ @Override
+ public Marker getMarker() {
+ return null;
+ }
+
+ @Override
+ public Map getMDCPropertyMap() {
+ return null;
+ }
+
+ @Override
+ public Map getMdc() {
+ return null;
+ }
+
+ @Override
+ public long getTimeStamp() {
+ return 0;
+ }
+
+ @Override
+ public void prepareForDeferredProcessing() {
+
+ }
+ });
+
+ Assert.assertEquals(FilterReply.ACCEPT, filterReply);
+
+ }
+}
\ No newline at end of file
diff --git a/dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/log/WorkerLogFilterTest.java b/dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/log/WorkerLogFilterTest.java
new file mode 100644
index 0000000000..90b154407f
--- /dev/null
+++ b/dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/log/WorkerLogFilterTest.java
@@ -0,0 +1,119 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 org.apache.dolphinscheduler.common.log;
+
+import ch.qos.logback.classic.Level;
+import ch.qos.logback.classic.spi.ILoggingEvent;
+import ch.qos.logback.classic.spi.IThrowableProxy;
+import ch.qos.logback.classic.spi.LoggerContextVO;
+import ch.qos.logback.core.spi.FilterReply;
+import org.apache.dolphinscheduler.common.Constants;
+import org.junit.Assert;
+import org.junit.Test;
+import org.slf4j.Marker;
+
+import java.util.Map;
+
+
+public class WorkerLogFilterTest {
+
+ @Test
+ public void decide() {
+ WorkerLogFilter workerLogFilter = new WorkerLogFilter();
+
+
+ FilterReply filterReply = workerLogFilter.decide(new ILoggingEvent() {
+ @Override
+ public String getThreadName() {
+ return Constants.THREAD_NAME_WORKER_SERVER;
+ }
+
+ @Override
+ public Level getLevel() {
+ return Level.INFO;
+ }
+
+ @Override
+ public String getMessage() {
+ return "consume tasks: [2_177_2_704_-1],there still have 0 tasks need to be executed";
+ }
+
+ @Override
+ public Object[] getArgumentArray() {
+ return new Object[0];
+ }
+
+ @Override
+ public String getFormattedMessage() {
+ return "consume tasks: [2_177_2_704_-1],there still have 0 tasks need to be executed";
+ }
+
+ @Override
+ public String getLoggerName() {
+ return null;
+ }
+
+ @Override
+ public LoggerContextVO getLoggerContextVO() {
+ return null;
+ }
+
+ @Override
+ public IThrowableProxy getThrowableProxy() {
+ return null;
+ }
+
+ @Override
+ public StackTraceElement[] getCallerData() {
+ return new StackTraceElement[0];
+ }
+
+ @Override
+ public boolean hasCallerData() {
+ return false;
+ }
+
+ @Override
+ public Marker getMarker() {
+ return null;
+ }
+
+ @Override
+ public Map getMDCPropertyMap() {
+ return null;
+ }
+
+ @Override
+ public Map getMdc() {
+ return null;
+ }
+
+ @Override
+ public long getTimeStamp() {
+ return 0;
+ }
+
+ @Override
+ public void prepareForDeferredProcessing() {
+
+ }
+ });
+
+ Assert.assertEquals(FilterReply.ACCEPT, filterReply);
+
+ }
+}
\ No newline at end of file
diff --git a/dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/utils/LoggerUtilsTest.java b/dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/utils/LoggerUtilsTest.java
new file mode 100644
index 0000000000..5a80e388ba
--- /dev/null
+++ b/dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/utils/LoggerUtilsTest.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 org.apache.dolphinscheduler.common.utils;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.List;
+
+public class LoggerUtilsTest {
+ private Logger logger = LoggerFactory.getLogger(LoggerUtilsTest.class);
+
+ @Test
+ public void buildTaskId() {
+
+ String taskId = LoggerUtils.buildTaskId(LoggerUtils.TASK_LOGGER_INFO_PREFIX,79,4084,15210);
+
+ Assert.assertEquals(" - [taskAppId=TASK-79-4084-15210]", taskId);
+ }
+
+ @Test
+ public void getAppIds() {
+ List appIdList = LoggerUtils.getAppIds("Running job: application_1_1",logger);
+ Assert.assertEquals("application_1_1", appIdList.get(0));
+
+ }
+}
\ No newline at end of file
diff --git a/dolphinscheduler-server/src/test/java/org/apache/dolphinscheduler/server/utils/SensitiveLogUtilTest.java b/dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/utils/SensitiveLogUtilsTest.java
similarity index 83%
rename from dolphinscheduler-server/src/test/java/org/apache/dolphinscheduler/server/utils/SensitiveLogUtilTest.java
rename to dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/utils/SensitiveLogUtilsTest.java
index 2e5bfcf3e5..03880b69cc 100644
--- a/dolphinscheduler-server/src/test/java/org/apache/dolphinscheduler/server/utils/SensitiveLogUtilTest.java
+++ b/dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/utils/SensitiveLogUtilsTest.java
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.dolphinscheduler.server.utils;
+package org.apache.dolphinscheduler.common.utils;
import org.apache.dolphinscheduler.common.Constants;
@@ -22,7 +22,7 @@ import org.junit.Assert;
import org.junit.Test;
-public class SensitiveLogUtilTest {
+public class SensitiveLogUtilsTest {
@Test
public void testMaskDataSourcePwd() {
@@ -30,8 +30,8 @@ public class SensitiveLogUtilTest {
String password = "123456";
String emptyPassword = "";
- Assert.assertEquals(Constants.PASSWORD_DEFAULT, SensitiveLogUtil.maskDataSourcePwd(password));
- Assert.assertEquals("", SensitiveLogUtil.maskDataSourcePwd(emptyPassword));
+ Assert.assertEquals(Constants.PASSWORD_DEFAULT, SensitiveLogUtils.maskDataSourcePwd(password));
+ Assert.assertEquals("", SensitiveLogUtils.maskDataSourcePwd(emptyPassword));
}
}
diff --git a/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/utils/ProcessUtils.java b/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/utils/ProcessUtils.java
index 0b621a9bb0..fd0a08cd8e 100644
--- a/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/utils/ProcessUtils.java
+++ b/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/utils/ProcessUtils.java
@@ -18,6 +18,7 @@ package org.apache.dolphinscheduler.server.utils;
import org.apache.dolphinscheduler.common.Constants;
import org.apache.dolphinscheduler.common.utils.CommonUtils;
+import org.apache.dolphinscheduler.common.utils.LoggerUtils;
import org.apache.dolphinscheduler.common.utils.OSUtils;
import org.apache.dolphinscheduler.common.utils.StringUtils;
import org.apache.dolphinscheduler.dao.entity.TaskInstance;
diff --git a/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/worker/runner/TaskScheduleThread.java b/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/worker/runner/TaskScheduleThread.java
index 5f66c3477d..f179d6344a 100644
--- a/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/worker/runner/TaskScheduleThread.java
+++ b/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/worker/runner/TaskScheduleThread.java
@@ -35,8 +35,8 @@ import org.apache.dolphinscheduler.dao.ProcessDao;
import org.apache.dolphinscheduler.dao.entity.ProcessInstance;
import org.apache.dolphinscheduler.dao.entity.TaskInstance;
import org.apache.dolphinscheduler.dao.permission.PermissionCheck;
-import org.apache.dolphinscheduler.server.utils.LoggerUtils;
-import org.apache.dolphinscheduler.server.worker.log.TaskLogDiscriminator;
+import org.apache.dolphinscheduler.common.utils.LoggerUtils;
+import org.apache.dolphinscheduler.common.log.TaskLogDiscriminator;
import org.apache.dolphinscheduler.server.worker.task.AbstractTask;
import org.apache.dolphinscheduler.server.worker.task.TaskManager;
import org.apache.dolphinscheduler.server.worker.task.TaskProps;
diff --git a/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/worker/task/AbstractCommandExecutor.java b/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/worker/task/AbstractCommandExecutor.java
index 8774186bc5..0c62f0648a 100644
--- a/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/worker/task/AbstractCommandExecutor.java
+++ b/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/worker/task/AbstractCommandExecutor.java
@@ -23,7 +23,7 @@ import org.apache.dolphinscheduler.common.utils.HadoopUtils;
import org.apache.dolphinscheduler.common.utils.StringUtils;
import org.apache.dolphinscheduler.dao.ProcessDao;
import org.apache.dolphinscheduler.dao.entity.TaskInstance;
-import org.apache.dolphinscheduler.server.utils.LoggerUtils;
+import org.apache.dolphinscheduler.common.utils.LoggerUtils;
import org.apache.dolphinscheduler.server.utils.ProcessUtils;
import org.slf4j.Logger;
diff --git a/dolphinscheduler-server/src/main/resources/master_logback.xml b/dolphinscheduler-server/src/main/resources/master_logback.xml
deleted file mode 100644
index 54c3cf5781..0000000000
--- a/dolphinscheduler-server/src/main/resources/master_logback.xml
+++ /dev/null
@@ -1,52 +0,0 @@
-
-
-
-
-
-
-
-
-
- [%level] %date{yyyy-MM-dd HH:mm:ss.SSS} %logger{96}:[%line] - %msg%n
-
- UTF-8
-
-
-
-
- ${log.base}/dolphinscheduler-master.log
-
- INFO
-
-
- ${log.base}/dolphinscheduler-master.%d{yyyy-MM-dd_HH}.%i.log
- 168
- 200MB
-
-
-
- [%level] %date{yyyy-MM-dd HH:mm:ss.SSS} %logger{96}:[%line] - %msg%n
-
- UTF-8
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/dolphinscheduler-server/src/main/resources/worker_logback.xml b/dolphinscheduler-server/src/main/resources/worker_logback.xml
deleted file mode 100644
index 7ba0c9b8ab..0000000000
--- a/dolphinscheduler-server/src/main/resources/worker_logback.xml
+++ /dev/null
@@ -1,81 +0,0 @@
-
-
-
-
-
-
-
-
-
-
- [%level] %date{yyyy-MM-dd HH:mm:ss.SSS} %logger{96}:[%line] - %msg%n
-
- UTF-8
-
-
-
-
- INFO
-
-
-
- taskAppId
- ${log.base}
-
-
-
- ${log.base}/${taskAppId}.log
-
-
- [%level] %date{yyyy-MM-dd HH:mm:ss.SSS} %logger{96}:[%line] - %msg%n
-
- UTF-8
-
- true
-
-
-
-
-
- ${log.base}/dolphinscheduler-worker.log
-
- INFO
-
-
-
- ${log.base}/dolphinscheduler-worker.%d{yyyy-MM-dd_HH}.%i.log
- 168
- 200MB
-
-
-
-
- [%level] %date{yyyy-MM-dd HH:mm:ss.SSS} %logger{96}:[%line] - %msg%n
-
- UTF-8
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/dolphinscheduler-server/src/test/java/org/apache/dolphinscheduler/server/worker/log/SensitiveDataConverterTest.java b/dolphinscheduler-server/src/test/java/org/apache/dolphinscheduler/server/worker/log/SensitiveDataConverterTest.java
deleted file mode 100644
index fb564a22fb..0000000000
--- a/dolphinscheduler-server/src/test/java/org/apache/dolphinscheduler/server/worker/log/SensitiveDataConverterTest.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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 org.apache.dolphinscheduler.server.worker.log;
-
-
-import org.apache.dolphinscheduler.common.Constants;
-import org.apache.dolphinscheduler.server.utils.SensitiveLogUtil;
-import org.junit.Assert;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-public class SensitiveDataConverterTest {
-
- private final Logger logger = LoggerFactory.getLogger(SensitiveDataConverterTest.class);
-
- /**
- * password pattern
- */
- private final Pattern pwdPattern = Pattern.compile(Constants.DATASOURCE_PASSWORD_REGEX);
-
-
- /**
- * mask sensitive logMsg - sql task datasource password
- */
- @Test
- public void testPwdLogMsgConverter() {
-
- String logMsg = "{\"address\":\"jdbc:mysql://192.168.xx.xx:3306\"," +
- "\"database\":\"carbond\"," +
- "\"jdbcUrl\":\"jdbc:mysql://192.168.xx.xx:3306/ods\"," +
- "\"user\":\"view\"," +
- "\"password\":\"view1\"}";
-
- String maskLogMsg = "{\"address\":\"jdbc:mysql://192.168.xx.xx:3306\"," +
- "\"database\":\"carbond\"," +
- "\"jdbcUrl\":\"jdbc:mysql://192.168.xx.xx:3306/ods\"," +
- "\"user\":\"view\"," +
- "\"password\":\"******\"}";
-
-
- logger.info("parameter : {}", logMsg);
- logger.info("parameter : {}", passwordHandler(pwdPattern, logMsg));
-
- Assert.assertNotEquals(logMsg, passwordHandler(pwdPattern, logMsg));
- Assert.assertEquals(maskLogMsg, passwordHandler(pwdPattern, logMsg));
-
- }
-
- /**
- * password regex test
- *
- * @param logMsg original log
- */
- private static String passwordHandler(Pattern pattern, String logMsg) {
-
- Matcher matcher = pattern.matcher(logMsg);
-
- StringBuffer sb = new StringBuffer(logMsg.length());
-
- while (matcher.find()) {
-
- String password = matcher.group();
-
- String maskPassword = SensitiveLogUtil.maskDataSourcePwd(password);
-
- matcher.appendReplacement(sb, maskPassword);
- }
- matcher.appendTail(sb);
-
- return sb.toString();
- }
-
-
-}
diff --git a/dolphinscheduler-server/src/test/java/org/apache/dolphinscheduler/server/worker/shell/ShellCommandExecutorTest.java b/dolphinscheduler-server/src/test/java/org/apache/dolphinscheduler/server/worker/shell/ShellCommandExecutorTest.java
index 1117fe0015..04c844827f 100644
--- a/dolphinscheduler-server/src/test/java/org/apache/dolphinscheduler/server/worker/shell/ShellCommandExecutorTest.java
+++ b/dolphinscheduler-server/src/test/java/org/apache/dolphinscheduler/server/worker/shell/ShellCommandExecutorTest.java
@@ -23,7 +23,7 @@ import org.apache.dolphinscheduler.common.model.TaskNode;
import org.apache.dolphinscheduler.common.utils.SpringApplicationContext;
import org.apache.dolphinscheduler.dao.ProcessDao;
import org.apache.dolphinscheduler.dao.entity.TaskInstance;
-import org.apache.dolphinscheduler.server.utils.LoggerUtils;
+import org.apache.dolphinscheduler.common.utils.LoggerUtils;
import org.apache.dolphinscheduler.server.worker.task.AbstractTask;
import org.apache.dolphinscheduler.server.worker.task.TaskManager;
import org.apache.dolphinscheduler.server.worker.task.TaskProps;
diff --git a/dolphinscheduler-server/src/test/java/org/apache/dolphinscheduler/server/worker/sql/SqlExecutorTest.java b/dolphinscheduler-server/src/test/java/org/apache/dolphinscheduler/server/worker/sql/SqlExecutorTest.java
index 7cf4b874d1..7da3f710b6 100644
--- a/dolphinscheduler-server/src/test/java/org/apache/dolphinscheduler/server/worker/sql/SqlExecutorTest.java
+++ b/dolphinscheduler-server/src/test/java/org/apache/dolphinscheduler/server/worker/sql/SqlExecutorTest.java
@@ -24,7 +24,7 @@ import org.apache.dolphinscheduler.common.model.TaskNode;
import org.apache.dolphinscheduler.common.utils.SpringApplicationContext;
import org.apache.dolphinscheduler.dao.ProcessDao;
import org.apache.dolphinscheduler.dao.entity.TaskInstance;
-import org.apache.dolphinscheduler.server.utils.LoggerUtils;
+import org.apache.dolphinscheduler.common.utils.LoggerUtils;
import org.apache.dolphinscheduler.server.worker.task.AbstractTask;
import org.apache.dolphinscheduler.server.worker.task.TaskManager;
import org.apache.dolphinscheduler.server.worker.task.TaskProps;
diff --git a/pom.xml b/pom.xml
index 0ff2f65f60..59278f73cd 100644
--- a/pom.xml
+++ b/pom.xml
@@ -675,6 +675,7 @@
**/common/utils/*.java
+ **/common/log/*.java
**/common/threadutils/*.java
**/common/graph/*.java
**/common/queue/*.java
diff --git a/script/dolphinscheduler-daemon.sh b/script/dolphinscheduler-daemon.sh
index b3310c384f..d4db103fe1 100644
--- a/script/dolphinscheduler-daemon.sh
+++ b/script/dolphinscheduler-daemon.sh
@@ -57,16 +57,16 @@ pid=$DOLPHINSCHEDULER_LOG_DIR/dolphinscheduler-$command.pid
cd $DOLPHINSCHEDULER_HOME
if [ "$command" = "api-server" ]; then
- LOG_FILE="-Dlogging.config=classpath:apiserver_logback.xml -Dspring.profiles.active=api"
+ LOG_FILE="-Dserver=api-server -Dspring.profiles.active=api"
CLASS=org.apache.dolphinscheduler.api.ApiApplicationServer
elif [ "$command" = "master-server" ]; then
- LOG_FILE="-Dlogging.config=classpath:master_logback.xml -Ddruid.mysql.usePingMethod=false"
+ LOG_FILE="-Dserver=master-server -Ddruid.mysql.usePingMethod=false"
CLASS=org.apache.dolphinscheduler.server.master.MasterServer
elif [ "$command" = "worker-server" ]; then
- LOG_FILE="-Dlogging.config=classpath:worker_logback.xml -Ddruid.mysql.usePingMethod=false"
+ LOG_FILE="-Dserver=worker-server -Ddruid.mysql.usePingMethod=false"
CLASS=org.apache.dolphinscheduler.server.worker.WorkerServer
elif [ "$command" = "alert-server" ]; then
- LOG_FILE="-Dlogback.configurationFile=conf/alert_logback.xml"
+ LOG_FILE="-Dserver=alert-server"
CLASS=org.apache.dolphinscheduler.alert.AlertServer
elif [ "$command" = "logger-server" ]; then
CLASS=org.apache.dolphinscheduler.server.rpc.LoggerServer
@@ -93,8 +93,8 @@ case $startStop in
exec_command="$LOG_FILE $DOLPHINSCHEDULER_OPTS -classpath $DOLPHINSCHEDULER_CONF_DIR:$DOLPHINSCHEDULER_LIB_JARS $CLASS"
- echo "nohup $JAVA_HOME/bin/java $exec_command > $log 2>&1 < /dev/null &"
- nohup $JAVA_HOME/bin/java $exec_command > $log 2>&1 < /dev/null &
+ echo "nohup $JAVA_HOME/bin/java $exec_command > $log 2>&1 > /dev/null &"
+ nohup $JAVA_HOME/bin/java $exec_command > $log 2>&1 > /dev/null &
echo $! > $pid
;;
From 18750dfc0881180a068edb92a5fbde6d66ac6ef6 Mon Sep 17 00:00:00 2001
From: dailidong
Date: Thu, 6 Feb 2020 18:52:44 +0800
Subject: [PATCH 26/35] remove jasper-runtime jar, not need anymore (#1900)
* update README about DolphinScheduler
* Update issue templates
* update
* regularize api pom xml
update rpc maven compile to 1.8
* regularize api pom xml
* change commons.lang3.StringUtils to common.utils.StringUtils
* update pom.xml
* update
* correct equals method
* jasper-runtime is needed when api server start
* jasper-runtime jar is needed when api server start
* combine logback config of master/worker/alert/api server to one logback.xml
* remove tomcat runtime jar
* add UT
* add license
* remove jasper-runtime jar, not need anymore
Co-authored-by: DS
---
dolphinscheduler-api/pom.xml | 10 ----------
1 file changed, 10 deletions(-)
diff --git a/dolphinscheduler-api/pom.xml b/dolphinscheduler-api/pom.xml
index fd56fb8d9f..bac74da0b0 100644
--- a/dolphinscheduler-api/pom.xml
+++ b/dolphinscheduler-api/pom.xml
@@ -27,10 +27,6 @@
${project.artifactId}
jar
-
- 5.5.23
-
-
org.apache.dolphinscheduler
@@ -182,12 +178,6 @@
hadoop-aws
-
- tomcat
- jasper-runtime
- ${jasper-runtime.version}
-
-
javax.servlet
servlet-api
From b3b075d9157fc865cc8a090a8f31142bdfa8223f Mon Sep 17 00:00:00 2001
From: Jave-Chen
Date: Thu, 6 Feb 2020 19:32:31 +0800
Subject: [PATCH 27/35] Fix bug: Use try-with-resources or close this
"Statement" in a "finally" clause. (#1702)
* #1701 Fix bug: Use try-with-resources or close this "Statement" in a "finally" clause.
* fix some indent
* refix code smell
---
.../common/utils/ScriptRunner.java | 152 ++++++++----------
1 file changed, 65 insertions(+), 87 deletions(-)
diff --git a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/ScriptRunner.java b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/ScriptRunner.java
index 529052c7cf..bbc937c89f 100644
--- a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/ScriptRunner.java
+++ b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/ScriptRunner.java
@@ -16,13 +16,17 @@
*/
package org.apache.dolphinscheduler.common.utils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
import java.io.IOException;
import java.io.LineNumberReader;
import java.io.Reader;
-import java.sql.*;
+import java.sql.Connection;
+import java.sql.ResultSet;
+import java.sql.ResultSetMetaData;
+import java.sql.SQLException;
+import java.sql.Statement;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/*
* Slightly modified version of the com.ibatis.common.jdbc.ScriptRunner class
@@ -94,9 +98,7 @@ public class ScriptRunner {
} finally {
connection.setAutoCommit(originalAutoCommit);
}
- } catch (IOException e) {
- throw e;
- } catch (SQLException e) {
+ } catch (IOException | SQLException e) {
throw e;
} catch (Exception e) {
throw new RuntimeException("Error running script. Cause: " + e, e);
@@ -114,9 +116,7 @@ public class ScriptRunner {
} finally {
connection.setAutoCommit(originalAutoCommit);
}
- } catch (IOException e) {
- throw e;
- } catch (SQLException e) {
+ } catch (IOException | SQLException e) {
throw e;
} catch (Exception e) {
throw new RuntimeException("Error running script. Cause: " + e, e);
@@ -161,44 +161,34 @@ public class ScriptRunner {
|| fullLineDelimiter && trimmedLine.equals(getDelimiter())) {
command.append(line.substring(0, line.lastIndexOf(getDelimiter())));
command.append(" ");
- Statement statement = conn.createStatement();
- boolean hasResults = false;
- logger.info("sql:"+command.toString());
- if (stopOnError) {
- hasResults = statement.execute(command.toString());
- } else {
- try {
- statement.execute(command.toString());
- } catch (SQLException e) {
- logger.error(e.getMessage(),e);
- throw e;
- }
- }
-
- ResultSet rs = statement.getResultSet();
- if (hasResults && rs != null) {
- ResultSetMetaData md = rs.getMetaData();
- int cols = md.getColumnCount();
- for (int i = 0; i < cols; i++) {
- String name = md.getColumnLabel(i);
- logger.info(name + "\t");
- }
- logger.info("");
- while (rs.next()) {
- for (int i = 0; i < cols; i++) {
- String value = rs.getString(i);
- logger.info(value + "\t");
- }
- logger.info("");
- }
- }
+ logger.info("sql: {}", command);
+ try (Statement statement = conn.createStatement()) {
+ statement.execute(command.toString());
+ try (ResultSet rs = statement.getResultSet()) {
+ if (stopOnError && rs != null) {
+ ResultSetMetaData md = rs.getMetaData();
+ int cols = md.getColumnCount();
+ for (int i = 0; i < cols; i++) {
+ String name = md.getColumnLabel(i);
+ logger.info("{} \t", name);
+ }
+ logger.info("");
+ while (rs.next()) {
+ for (int i = 0; i < cols; i++) {
+ String value = rs.getString(i);
+ logger.info("{} \t", value);
+ }
+ logger.info("");
+ }
+ }
+ }
+ } catch (SQLException e) {
+ logger.error("SQLException", e);
+ throw e;
+ }
+
command = null;
- try {
- statement.close();
- } catch (Exception e) {
- // Ignore to workaround a bug in Jakarta DBCP
- }
Thread.yield();
} else {
command.append(line);
@@ -207,11 +197,11 @@ public class ScriptRunner {
}
} catch (SQLException e) {
- logger.error("Error executing: " + command.toString());
+ logger.error("Error executing: {}", command);
throw e;
} catch (IOException e) {
e.fillInStackTrace();
- logger.error("Error executing: " + command.toString());
+ logger.error("Error executing: {}", command);
throw e;
}
}
@@ -243,46 +233,35 @@ public class ScriptRunner {
|| fullLineDelimiter && trimmedLine.equals(getDelimiter())) {
command.append(line.substring(0, line.lastIndexOf(getDelimiter())));
command.append(" ");
- Statement statement = conn.createStatement();
-
sql = command.toString().replaceAll("\\{\\{APPDB\\}\\}", dbName);
- boolean hasResults = false;
- logger.info("sql : " + sql);
- if (stopOnError) {
- hasResults = statement.execute(sql);
- } else {
- try {
- statement.execute(sql);
- } catch (SQLException e) {
- logger.error(e.getMessage(),e);
- throw e;
- }
- }
-
- ResultSet rs = statement.getResultSet();
- if (hasResults && rs != null) {
- ResultSetMetaData md = rs.getMetaData();
- int cols = md.getColumnCount();
- for (int i = 0; i < cols; i++) {
- String name = md.getColumnLabel(i);
- logger.info(name + "\t");
- }
- logger.info("");
- while (rs.next()) {
- for (int i = 0; i < cols; i++) {
- String value = rs.getString(i);
- logger.info(value + "\t");
- }
- logger.info("");
- }
- }
+ logger.info("sql : {}", sql);
+
+ try (Statement statement = conn.createStatement()) {
+ statement.execute(sql);
+ try (ResultSet rs = statement.getResultSet()) {
+ if (stopOnError && rs != null) {
+ ResultSetMetaData md = rs.getMetaData();
+ int cols = md.getColumnCount();
+ for (int i = 0; i < cols; i++) {
+ String name = md.getColumnLabel(i);
+ logger.info("{} \t", name);
+ }
+ logger.info("");
+ while (rs.next()) {
+ for (int i = 0; i < cols; i++) {
+ String value = rs.getString(i);
+ logger.info("{} \t", value);
+ }
+ logger.info("");
+ }
+ }
+ }
+ } catch (SQLException e) {
+ logger.error("SQLException", e);
+ throw e;
+ }
command = null;
- try {
- statement.close();
- } catch (Exception e) {
- // Ignore to workaround a bug in Jakarta DBCP
- }
Thread.yield();
} else {
command.append(line);
@@ -291,11 +270,10 @@ public class ScriptRunner {
}
} catch (SQLException e) {
- logger.error("Error executing: " + sql);
throw e;
} catch (IOException e) {
e.fillInStackTrace();
- logger.error("Error executing: " + sql);
+ logger.error("Error executing: {}", sql);
throw e;
}
}
From 662233e0dd5b09d6099bddeeb8d5812dac05ab19 Mon Sep 17 00:00:00 2001
From: zhangzy
Date: Fri, 7 Feb 2020 10:15:42 +0800
Subject: [PATCH 28/35] =?UTF-8?q?Remove=20ScheduleUtil=EF=BC=8Cuse=20the?=
=?UTF-8?q?=20existing=20CronUtils?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
CronUtils is a public quartz tools, then the project dolphinscheduler-api can remove dolphinscheduler-server
---
dolphinscheduler-api/pom.xml | 4 -
.../api/service/ExecutorService.java | 14 +++-
.../master/runner/MasterExecThread.java | 15 +++-
.../server/utils/ScheduleUtils.java | 79 -------------------
.../server/utils/ScheduleUtilsTest.java | 44 -----------
pom.xml | 1 -
6 files changed, 23 insertions(+), 134 deletions(-)
delete mode 100644 dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/utils/ScheduleUtils.java
delete mode 100644 dolphinscheduler-server/src/test/java/org/apache/dolphinscheduler/server/utils/ScheduleUtilsTest.java
diff --git a/dolphinscheduler-api/pom.xml b/dolphinscheduler-api/pom.xml
index bac74da0b0..c10f443384 100644
--- a/dolphinscheduler-api/pom.xml
+++ b/dolphinscheduler-api/pom.xml
@@ -43,10 +43,6 @@
org.apache.dolphinscheduler
dolphinscheduler-dao
-
- org.apache.dolphinscheduler
- dolphinscheduler-server
-
diff --git a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/ExecutorService.java b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/ExecutorService.java
index c1689c5bec..7c0a8637ad 100644
--- a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/ExecutorService.java
+++ b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/ExecutorService.java
@@ -30,7 +30,8 @@ import org.apache.dolphinscheduler.dao.entity.*;
import org.apache.dolphinscheduler.dao.mapper.ProcessDefinitionMapper;
import org.apache.dolphinscheduler.dao.mapper.ProcessInstanceMapper;
import org.apache.dolphinscheduler.dao.mapper.ProjectMapper;
-import org.apache.dolphinscheduler.server.utils.ScheduleUtils;
+import org.apache.dolphinscheduler.dao.utils.cron.CronUtils;
+import org.quartz.CronExpression;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@@ -512,8 +513,15 @@ public class ExecutorService extends BaseService{
List listDate = new LinkedList<>();
if(!CollectionUtils.isEmpty(schedules)){
for (Schedule item : schedules) {
- List list = ScheduleUtils.getRecentTriggerTime(item.getCrontab(), start, end);
- listDate.addAll(list);
+ CronExpression cronExpression = null;
+ try {
+ cronExpression = CronUtils.parse2CronExpression(item.getCrontab());
+ List list = CronUtils.getSelfFireDateList(start, end, cronExpression);
+ listDate.addAll(list);
+ } catch (ParseException e) {
+ logger.error(e.getMessage(), e);
+ continue;
+ }
}
}
if(!CollectionUtils.isEmpty(listDate)){
diff --git a/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/master/runner/MasterExecThread.java b/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/master/runner/MasterExecThread.java
index 2d0e99a867..1e876239de 100644
--- a/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/master/runner/MasterExecThread.java
+++ b/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/master/runner/MasterExecThread.java
@@ -33,14 +33,16 @@ import org.apache.dolphinscheduler.dao.entity.ProcessInstance;
import org.apache.dolphinscheduler.dao.entity.Schedule;
import org.apache.dolphinscheduler.dao.entity.TaskInstance;
import org.apache.dolphinscheduler.dao.utils.DagHelper;
+import org.apache.dolphinscheduler.dao.utils.cron.CronUtils;
import org.apache.dolphinscheduler.server.master.config.MasterConfig;
import org.apache.dolphinscheduler.server.utils.AlertManager;
-import org.apache.dolphinscheduler.server.utils.ScheduleUtils;
+import org.quartz.CronExpression;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File;
import java.io.IOException;
+import java.text.ParseException;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ExecutorService;
@@ -213,8 +215,15 @@ public class MasterExecThread implements Runnable {
List listDate = Lists.newLinkedList();
if(!CollectionUtils.isEmpty(schedules)){
for (Schedule schedule : schedules) {
- List list = ScheduleUtils.getRecentTriggerTime(schedule.getCrontab(), startDate, endDate);
- listDate.addAll(list);
+ CronExpression cronExpression = null;
+ try {
+ cronExpression = CronUtils.parse2CronExpression(schedule.getCrontab());
+ List list = CronUtils.getSelfFireDateList(startDate, endDate, cronExpression);
+ listDate.addAll(list);
+ } catch (ParseException e) {
+ logger.error(e.getMessage(), e);
+ continue;
+ }
}
}
// get first fire date
diff --git a/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/utils/ScheduleUtils.java b/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/utils/ScheduleUtils.java
deleted file mode 100644
index 11730b9545..0000000000
--- a/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/utils/ScheduleUtils.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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 org.apache.dolphinscheduler.server.utils;
-
-import org.quartz.impl.triggers.CronTriggerImpl;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.text.ParseException;
-import java.util.Date;
-import java.util.LinkedList;
-import java.util.List;
-
-/**
- * ScheduleUtils
- */
-public class ScheduleUtils {
-
- private static final Logger logger = LoggerFactory.getLogger(ScheduleUtils.class);
-
- /**
- * Get the execution time of the time interval
- * @param cron
- * @param from
- * @param to
- * @return
- */
- public static List getRecentTriggerTime(String cron, Date from, Date to) {
- return getRecentTriggerTime(cron, Integer.MAX_VALUE, from, to);
- }
-
- /**
- * Get the execution time of the time interval
- * @param cron
- * @param size
- * @param from
- * @param to
- * @return
- */
- public static List getRecentTriggerTime(String cron, int size, Date from, Date to) {
- List list = new LinkedList();
- if(to.before(from)){
- logger.error("schedule date from:{} must before date to:{}!", from, to);
- return list;
- }
- try {
- CronTriggerImpl trigger = new CronTriggerImpl();
- trigger.setCronExpression(cron);
- trigger.setStartTime(from);
- trigger.setEndTime(to);
- trigger.computeFirstFireTime(null);
- for (int i = 0; i < size; i++) {
- Date schedule = trigger.getNextFireTime();
- if(null == schedule){
- break;
- }
- list.add(schedule);
- trigger.triggered(null);
- }
- } catch (ParseException e) {
- logger.error("cron:{} error:{}", cron, e.getMessage());
- }
- return java.util.Collections.unmodifiableList(list);
- }
-}
\ No newline at end of file
diff --git a/dolphinscheduler-server/src/test/java/org/apache/dolphinscheduler/server/utils/ScheduleUtilsTest.java b/dolphinscheduler-server/src/test/java/org/apache/dolphinscheduler/server/utils/ScheduleUtilsTest.java
deleted file mode 100644
index 4fbbdab70f..0000000000
--- a/dolphinscheduler-server/src/test/java/org/apache/dolphinscheduler/server/utils/ScheduleUtilsTest.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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 org.apache.dolphinscheduler.server.utils;
-
-import org.apache.dolphinscheduler.common.utils.DateUtils;
-import org.junit.Test;
-import java.util.Date;
-import static org.junit.Assert.assertEquals;
-
-/**
- * Test ScheduleUtils
- */
-public class ScheduleUtilsTest {
-
- /**
- * Test the getRecentTriggerTime method
- */
- @Test
- public void testGetRecentTriggerTime() {
- Date from = DateUtils.stringToDate("2020-01-01 00:00:00");
- Date to = DateUtils.stringToDate("2020-01-31 01:00:00");
- // test date
- assertEquals(0, ScheduleUtils.getRecentTriggerTime("0 0 0 * * ? ", to, from).size());
- // test error cron
- assertEquals(0, ScheduleUtils.getRecentTriggerTime("0 0 0 * *", from, to).size());
- // test cron
- assertEquals(31, ScheduleUtils.getRecentTriggerTime("0 0 0 * * ? ", from, to).size());
- }
-}
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index 59278f73cd..d1141eed96 100644
--- a/pom.xml
+++ b/pom.xml
@@ -706,7 +706,6 @@
**/server/utils/SparkArgsUtilsTest.java
**/server/utils/FlinkArgsUtilsTest.java
**/server/utils/ParamUtilsTest.java
- **/server/utils/ScheduleUtilsTest.java
**/server/master/MasterExecThreadTest.java
**/dao/mapper/AccessTokenMapperTest.java
**/dao/mapper/AlertGroupMapperTest.java
From 9d944d3f76dafb421f352e0afaa88312f9321ec8 Mon Sep 17 00:00:00 2001
From: zhangzy
Date: Fri, 7 Feb 2020 15:47:07 +0800
Subject: [PATCH 29/35] Optimize duplicate code
Use public methods to simplify duplicate code
---
.../api/service/ExecutorService.java | 11 +----------
.../dao/utils/cron/CronUtils.java | 17 +++++++++++++++++
.../server/master/runner/MasterExecThread.java | 12 +-----------
3 files changed, 19 insertions(+), 21 deletions(-)
diff --git a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/ExecutorService.java b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/ExecutorService.java
index 7c0a8637ad..257f15d580 100644
--- a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/ExecutorService.java
+++ b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/ExecutorService.java
@@ -31,7 +31,6 @@ import org.apache.dolphinscheduler.dao.mapper.ProcessDefinitionMapper;
import org.apache.dolphinscheduler.dao.mapper.ProcessInstanceMapper;
import org.apache.dolphinscheduler.dao.mapper.ProjectMapper;
import org.apache.dolphinscheduler.dao.utils.cron.CronUtils;
-import org.quartz.CronExpression;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@@ -513,15 +512,7 @@ public class ExecutorService extends BaseService{
List listDate = new LinkedList<>();
if(!CollectionUtils.isEmpty(schedules)){
for (Schedule item : schedules) {
- CronExpression cronExpression = null;
- try {
- cronExpression = CronUtils.parse2CronExpression(item.getCrontab());
- List list = CronUtils.getSelfFireDateList(start, end, cronExpression);
- listDate.addAll(list);
- } catch (ParseException e) {
- logger.error(e.getMessage(), e);
- continue;
- }
+ listDate.addAll(CronUtils.getSelfFireDateList(start, end, item.getCrontab()));
}
}
if(!CollectionUtils.isEmpty(listDate)){
diff --git a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/utils/cron/CronUtils.java b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/utils/cron/CronUtils.java
index 8649462110..fc5681356d 100644
--- a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/utils/cron/CronUtils.java
+++ b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/utils/cron/CronUtils.java
@@ -156,6 +156,23 @@ public class CronUtils {
return dateList;
}
+ /**
+ * gets all scheduled times for a period of time based on self dependency
+ * @param startTime startTime
+ * @param endTime endTime
+ * @param cron cron
+ * @return date list
+ */
+ public static List getSelfFireDateList(Date startTime, Date endTime, String cron) {
+ CronExpression cronExpression = null;
+ try {
+ cronExpression = CronUtils.parse2CronExpression(cron);
+ }catch (ParseException e){
+ logger.error(e.getMessage(), e);
+ return Collections.EMPTY_LIST;
+ }
+ return getSelfFireDateList(startTime, endTime, cronExpression);
+ }
/**
* get expiration time
diff --git a/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/master/runner/MasterExecThread.java b/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/master/runner/MasterExecThread.java
index 1e876239de..2b1ff4d23f 100644
--- a/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/master/runner/MasterExecThread.java
+++ b/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/master/runner/MasterExecThread.java
@@ -36,13 +36,11 @@ import org.apache.dolphinscheduler.dao.utils.DagHelper;
import org.apache.dolphinscheduler.dao.utils.cron.CronUtils;
import org.apache.dolphinscheduler.server.master.config.MasterConfig;
import org.apache.dolphinscheduler.server.utils.AlertManager;
-import org.quartz.CronExpression;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File;
import java.io.IOException;
-import java.text.ParseException;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ExecutorService;
@@ -215,15 +213,7 @@ public class MasterExecThread implements Runnable {
List listDate = Lists.newLinkedList();
if(!CollectionUtils.isEmpty(schedules)){
for (Schedule schedule : schedules) {
- CronExpression cronExpression = null;
- try {
- cronExpression = CronUtils.parse2CronExpression(schedule.getCrontab());
- List list = CronUtils.getSelfFireDateList(startDate, endDate, cronExpression);
- listDate.addAll(list);
- } catch (ParseException e) {
- logger.error(e.getMessage(), e);
- continue;
- }
+ listDate.addAll(CronUtils.getSelfFireDateList(startDate, endDate, schedule.getCrontab()));
}
}
// get first fire date
From fccbcc8d7df592cc591568f6e7b328abdbce7602 Mon Sep 17 00:00:00 2001
From: Rubik <39549317+wenhemin@users.noreply.github.com>
Date: Fri, 7 Feb 2020 16:13:50 +0800
Subject: [PATCH 30/35] fix: The constructor has passed in an taskAppId, no
need to get from taskAppId. (#1906)
---
.../server/worker/task/AbstractCommandExecutor.java | 3 ---
1 file changed, 3 deletions(-)
diff --git a/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/worker/task/AbstractCommandExecutor.java b/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/worker/task/AbstractCommandExecutor.java
index 0c62f0648a..04098215dd 100644
--- a/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/worker/task/AbstractCommandExecutor.java
+++ b/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/worker/task/AbstractCommandExecutor.java
@@ -147,9 +147,6 @@ public abstract class AbstractCommandExecutor {
// get process id
int pid = getProcessId(process);
- // task instance id
- int taskInstId = Integer.parseInt(taskAppId.split("_")[2]);
-
processDao.updatePidByTaskInstId(taskInstId, pid, "");
logger.info("process start, process id is: {}", pid);
From a09d2d9d0a49127f0c7ba7eb86cef54ca5928d81 Mon Sep 17 00:00:00 2001
From: zhangzy
Date: Fri, 7 Feb 2020 16:43:24 +0800
Subject: [PATCH 31/35] add CronUtils ut
---
.../dao/utils/cron/CronUtils.java | 2 +-
.../dolphinscheduler/dao/cron/CronUtilsTest.java | 15 +++++++++++++++
2 files changed, 16 insertions(+), 1 deletion(-)
diff --git a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/utils/cron/CronUtils.java b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/utils/cron/CronUtils.java
index fc5681356d..8a9087a33c 100644
--- a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/utils/cron/CronUtils.java
+++ b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/utils/cron/CronUtils.java
@@ -166,7 +166,7 @@ public class CronUtils {
public static List getSelfFireDateList(Date startTime, Date endTime, String cron) {
CronExpression cronExpression = null;
try {
- cronExpression = CronUtils.parse2CronExpression(cron);
+ cronExpression = parse2CronExpression(cron);
}catch (ParseException e){
logger.error(e.getMessage(), e);
return Collections.EMPTY_LIST;
diff --git a/dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/cron/CronUtilsTest.java b/dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/cron/CronUtilsTest.java
index c375143d7b..05ebde9c0f 100644
--- a/dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/cron/CronUtilsTest.java
+++ b/dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/cron/CronUtilsTest.java
@@ -17,6 +17,7 @@
package org.apache.dolphinscheduler.dao.cron;
import org.apache.dolphinscheduler.common.enums.CycleEnum;
+import org.apache.dolphinscheduler.common.utils.DateUtils;
import org.apache.dolphinscheduler.dao.utils.cron.CronUtils;
import com.cronutils.builder.CronBuilder;
import com.cronutils.model.Cron;
@@ -31,6 +32,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.text.ParseException;
+import java.util.Date;
import static com.cronutils.model.field.expression.FieldExpressionFactory.*;
@@ -180,4 +182,17 @@ public class CronUtilsTest {
}
}
}
+
+
+ @Test
+ public void test3(){
+ Date from = DateUtils.stringToDate("2020-01-01 00:00:00");
+ Date to = DateUtils.stringToDate("2020-01-31 01:00:00");
+ // test date
+ Assert.assertEquals(0, CronUtils.getSelfFireDateList(to, from, "0 0 0 * * ? ").size());
+ // test error cron
+ Assert.assertEquals(0, CronUtils.getSelfFireDateList(from, to, "0 0 0 * *").size());
+ // test cron
+ Assert.assertEquals(30, CronUtils.getSelfFireDateList(from, to, "0 0 0 * * ? ").size());
+ }
}
From 515255b9199eecb944b498a1506b0c1b5ff65563 Mon Sep 17 00:00:00 2001
From: zhangzy
Date: Fri, 7 Feb 2020 17:18:27 +0800
Subject: [PATCH 32/35] ut
---
.../dolphinscheduler/server/master/MasterExecThreadTest.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/dolphinscheduler-server/src/test/java/org/apache/dolphinscheduler/server/master/MasterExecThreadTest.java b/dolphinscheduler-server/src/test/java/org/apache/dolphinscheduler/server/master/MasterExecThreadTest.java
index 6f31e66213..d7c3de13a5 100644
--- a/dolphinscheduler-server/src/test/java/org/apache/dolphinscheduler/server/master/MasterExecThreadTest.java
+++ b/dolphinscheduler-server/src/test/java/org/apache/dolphinscheduler/server/master/MasterExecThreadTest.java
@@ -134,7 +134,7 @@ public class MasterExecThreadTest {
method.setAccessible(true);
method.invoke(masterExecThread);
// one create save, and 15(1 to 31 step 2) for next save, and last day 31 no save
- verify(processDao, times(16)).saveProcessInstance(processInstance);
+ verify(processDao, times(15)).saveProcessInstance(processInstance);
}catch (Exception e){
Assert.assertTrue(false);
}
From 61593cfe6b2a36a287b9e6a60ec3aba516e953e4 Mon Sep 17 00:00:00 2001
From: zhangzy
Date: Fri, 7 Feb 2020 17:35:12 +0800
Subject: [PATCH 33/35] ut change
---
.../dolphinscheduler/api/service/ExecutorService2Test.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ExecutorService2Test.java b/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ExecutorService2Test.java
index b4f3e7e31f..66c7a3ebab 100644
--- a/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ExecutorService2Test.java
+++ b/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ExecutorService2Test.java
@@ -203,7 +203,7 @@ public class ExecutorService2Test {
"", "", RunMode.RUN_MODE_PARALLEL,
Priority.LOW, 0, 110);
Assert.assertEquals(Status.SUCCESS, result.get(Constants.STATUS));
- verify(processDao, times(16)).createCommand(any(Command.class));
+ verify(processDao, times(15)).createCommand(any(Command.class));
}catch (Exception e){
Assert.assertTrue(false);
}
From 6b586f31fc0416f72363db31039c7d41c4500cbd Mon Sep 17 00:00:00 2001
From: zhangzy
Date: Fri, 7 Feb 2020 18:34:38 +0800
Subject: [PATCH 34/35] =?UTF-8?q?pom=20add=20ut=EF=BC=8C=20add=20cronutils?=
=?UTF-8?q?=20ut?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../dao/cron/CronUtilsTest.java | 36 ++++++++++++++++---
pom.xml | 1 +
2 files changed, 32 insertions(+), 5 deletions(-)
diff --git a/dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/cron/CronUtilsTest.java b/dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/cron/CronUtilsTest.java
index 05ebde9c0f..8cf1b6eaf3 100644
--- a/dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/cron/CronUtilsTest.java
+++ b/dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/cron/CronUtilsTest.java
@@ -70,9 +70,9 @@ public class CronUtilsTest {
@Test
public void testCronParse() throws ParseException {
String strCrontab = "0 1 2 3 * ? *";
- strCrontab = "0/50 0/59 * * * ? *";
- strCrontab = "3/5 * 0/5 * * ? *";
- strCrontab = "1/5 3/5 1/5 3/30 * ? *";
+// strCrontab = "0/50 0/59 * * * ? *";
+// strCrontab = "3/5 * 0/5 * * ? *";
+// strCrontab = "1/5 3/5 1/5 3/30 * ? *";
Cron depCron = CronUtils.parse2Cron(strCrontab);
Assert.assertEquals(depCron.retrieve(CronFieldName.SECOND).getExpression().asString(), "0");
@@ -90,11 +90,14 @@ public class CronUtilsTest {
@Test
public void testScheduleType() throws ParseException {
- CycleEnum cycleEnum = CronUtils.getMaxCycle("0 */1 * * * ? *");
+ CycleEnum cycleEnum = CronUtils.getMaxCycle(CronUtils.parse2Cron("0 */1 * * * ? *"));
Assert.assertEquals(cycleEnum.name(), "MINUTE");
CycleEnum cycleEnum2 = CronUtils.getMaxCycle("0 * * * * ? *");
Assert.assertEquals(cycleEnum2.name(), "MINUTE");
+
+ CycleEnum cycleEnum3 = CronUtils.getMiniCycle(CronUtils.parse2Cron("0 * * * * ? *"));
+ Assert.assertEquals(cycleEnum3.name(), "MINUTE");
}
/**
@@ -185,7 +188,12 @@ public class CronUtilsTest {
@Test
- public void test3(){
+ public void parse2Cron(){
+
+ }
+
+ @Test
+ public void getSelfFireDateList() throws ParseException{
Date from = DateUtils.stringToDate("2020-01-01 00:00:00");
Date to = DateUtils.stringToDate("2020-01-31 01:00:00");
// test date
@@ -194,5 +202,23 @@ public class CronUtilsTest {
Assert.assertEquals(0, CronUtils.getSelfFireDateList(from, to, "0 0 0 * *").size());
// test cron
Assert.assertEquals(30, CronUtils.getSelfFireDateList(from, to, "0 0 0 * * ? ").size());
+ // test other
+ Assert.assertEquals(30, CronUtils.getFireDateList(from, to, CronUtils.parse2CronExpression("0 0 0 * * ? ")).size());
+ Assert.assertEquals(5, CronUtils.getSelfFireDateList(from, to, CronUtils.parse2CronExpression("0 0 0 * * ? "), 5).size());
+ }
+
+ @Test
+ public void getExpirationTime(){
+ Date startTime = DateUtils.stringToDate("2020-02-07 18:30:00");
+ Date expirationTime = CronUtils.getExpirationTime(startTime, CycleEnum.HOUR);
+ Assert.assertEquals("2020-02-07 19:30:00", DateUtils.dateToString(expirationTime));
+ expirationTime = CronUtils.getExpirationTime(startTime, CycleEnum.DAY);
+ Assert.assertEquals("2020-02-07 23:59:59", DateUtils.dateToString(expirationTime));
+ expirationTime = CronUtils.getExpirationTime(startTime, CycleEnum.WEEK);
+ Assert.assertEquals("2020-02-07 23:59:59", DateUtils.dateToString(expirationTime));
+ expirationTime = CronUtils.getExpirationTime(startTime, CycleEnum.MONTH);
+ Assert.assertEquals("2020-02-07 23:59:59", DateUtils.dateToString(expirationTime));
+ expirationTime = CronUtils.getExpirationTime(startTime, CycleEnum.YEAR);
+ Assert.assertEquals("2020-02-07 18:30:00", DateUtils.dateToString(expirationTime));
}
}
diff --git a/pom.xml b/pom.xml
index d1141eed96..875577c672 100644
--- a/pom.xml
+++ b/pom.xml
@@ -711,6 +711,7 @@
**/dao/mapper/AlertGroupMapperTest.java
**/dao/mapper/AlertMapperTest.java
**/dao/mapper/CommandMapperTest.java
+ **/dao/cron/CronUtilsTest.java
**/alert/template/AlertTemplateFactoryTest.java
**/alert/template/impl/DefaultHTMLTemplateTest.java
**/server/worker/task/datax/DataxTaskTest.java
From 0eec3b8661adc6153409b8cf2c8674b855c8aa65 Mon Sep 17 00:00:00 2001
From: zhangzy
Date: Fri, 7 Feb 2020 19:17:47 +0800
Subject: [PATCH 35/35] Remove useless code
---
.../dao/cron/CronUtilsTest.java | 38 +++----------------
1 file changed, 6 insertions(+), 32 deletions(-)
diff --git a/dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/cron/CronUtilsTest.java b/dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/cron/CronUtilsTest.java
index 8cf1b6eaf3..1135cf20f5 100644
--- a/dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/cron/CronUtilsTest.java
+++ b/dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/cron/CronUtilsTest.java
@@ -37,6 +37,7 @@ import java.util.Date;
import static com.cronutils.model.field.expression.FieldExpressionFactory.*;
/**
+ * CronUtilsTest
*/
public class CronUtilsTest {
@@ -57,8 +58,9 @@ public class CronUtilsTest {
.withSecond(on(0))
.instance();
// Obtain the string expression
- String cronAsString = cron.asString(); // 0 */5 * * * ? * Every five minutes(once every 5 minutes)
+ String cronAsString = cron.asString();
+ // 0 */5 * * * ? * Every five minutes(once every 5 minutes)
Assert.assertEquals(cronAsString, "0 */5 * * * ? *");
}
@@ -70,9 +72,6 @@ public class CronUtilsTest {
@Test
public void testCronParse() throws ParseException {
String strCrontab = "0 1 2 3 * ? *";
-// strCrontab = "0/50 0/59 * * * ? *";
-// strCrontab = "3/5 * 0/5 * * ? *";
-// strCrontab = "1/5 3/5 1/5 3/30 * ? *";
Cron depCron = CronUtils.parse2Cron(strCrontab);
Assert.assertEquals(depCron.retrieve(CronFieldName.SECOND).getExpression().asString(), "0");
@@ -89,7 +88,6 @@ public class CronUtilsTest {
*/
@Test
public void testScheduleType() throws ParseException {
-
CycleEnum cycleEnum = CronUtils.getMaxCycle(CronUtils.parse2Cron("0 */1 * * * ? *"));
Assert.assertEquals(cycleEnum.name(), "MINUTE");
@@ -114,26 +112,9 @@ public class CronUtilsTest {
.withMinute(every(5))
.withSecond(on(0))
.instance();
-
- String cronAsString = cron1.asString(); // 0 */5 * * * ? * once every 5 minutes
- //logger.info(cronAsString);
- // Obtain the string expression
- //String minCrontab = "0 0 * * * ? *";
- //String minCrontab = "0 0 10,14,16 * * ?";
- //String minCrontab = "0 0-5 14 * * ? *";
- //String minCrontab = "0 0 2 ? * SUN *";
- //String minCrontab = "* 0,3 2 SUN * 1#1 *";
- //String minCrontab = "* 0,3 * 1W * ? *";
- //cron = CronUtils.parse2Cron("0 * * * * ? *");
- // month cycle
- /*String[] cronArayy = new String[]{"* 0,3 * 1W * ? *","* 0 0 1W * ? *",
- "0 0 0 L 3/5 ? *","0 0 0 ? 3/5 2/2 *"};*/
// minute cycle
String[] cronArayy = new String[]{"* * * * * ? *","* 0 * * * ? *",
"* 5 * * 3/5 ? *","0 0 * * * ? *"};
- // week cycle
- /*String[] cronArayy = new String[]{"* * * ? * 2/1 *","0 *//*5 * ? * 2/1 *",
- "* * *//*5 ? * 2/1 *"};*/
for(String minCrontab:cronArayy){
if (!org.quartz.CronExpression.isValidExpression(minCrontab)) {
throw new RuntimeException(minCrontab+" verify failure, cron expression not valid");
@@ -176,7 +157,6 @@ public class CronUtilsTest {
logger.info("dayOfWeekField instanceof And:"+(dayOfWeekField.getExpression() instanceof And));
logger.info("dayOfWeekField instanceof QuestionMark:"+(dayOfWeekField.getExpression() instanceof QuestionMark));
-
CycleEnum cycleEnum = CronUtils.getMaxCycle(minCrontab);
if(cycleEnum !=null){
logger.info(cycleEnum.name());
@@ -186,22 +166,16 @@ public class CronUtilsTest {
}
}
-
- @Test
- public void parse2Cron(){
-
- }
-
@Test
public void getSelfFireDateList() throws ParseException{
Date from = DateUtils.stringToDate("2020-01-01 00:00:00");
- Date to = DateUtils.stringToDate("2020-01-31 01:00:00");
+ Date to = DateUtils.stringToDate("2020-01-31 00:00:00");
// test date
Assert.assertEquals(0, CronUtils.getSelfFireDateList(to, from, "0 0 0 * * ? ").size());
// test error cron
Assert.assertEquals(0, CronUtils.getSelfFireDateList(from, to, "0 0 0 * *").size());
// test cron
- Assert.assertEquals(30, CronUtils.getSelfFireDateList(from, to, "0 0 0 * * ? ").size());
+ Assert.assertEquals(29, CronUtils.getSelfFireDateList(from, to, "0 0 0 * * ? ").size());
// test other
Assert.assertEquals(30, CronUtils.getFireDateList(from, to, CronUtils.parse2CronExpression("0 0 0 * * ? ")).size());
Assert.assertEquals(5, CronUtils.getSelfFireDateList(from, to, CronUtils.parse2CronExpression("0 0 0 * * ? "), 5).size());
@@ -221,4 +195,4 @@ public class CronUtilsTest {
expirationTime = CronUtils.getExpirationTime(startTime, CycleEnum.YEAR);
Assert.assertEquals("2020-02-07 18:30:00", DateUtils.dateToString(expirationTime));
}
-}
+}
\ No newline at end of file