未验证 提交 73b0eaa9 编写于 作者: K Kirs 提交者: GitHub

merge dev to alert_plugin_design (#4530)

* merge from 1.3.3-release

* refactor code style

* refactor code style

* refactor code style

* merge from 1.3.3-release

* merge from 1.3.3-release

* merge from 1.3.3-release

* merge from 1.3.3-release

* merge from 1.3.3-release

* refactor ut test

* refactor ut test

* merge from 1.3.3-release

* merge from 1.3.3-release

* merge from 1.3.3-release

* fix #3900 kill multi yarn app in one job

* refactor ut

* merge from 1.3.3-release

* refactor ut

* refactor ut

* refactor

* refactor

* refactor code style

* refactor code style

* refactor code style

* refactor code style

* merge from 1.3.3-release

* merge from 1.3.3-release

* merge from 1.3.3-release

* merge from 1.3.3-release

* merge from 1.3.3-release

* add ProcessUtils UT

* refactor code style

* refactor code style

* refactor code style

* refactor code style

* [Draft][Merge][133-dev]133 merge dev (#4031)

* [Feture-3327][ui]Add the function of re-uploading files in the resource center

* [Feture-3327][ui]Add the function of re-uploading files in the resource center (#3394)

* Before creating a workflow, clear the canvas

* [Fix-3256][ui] herry pick commit from dev for Fix admin user info update error (#3306)

* [Feture-3327][ui]Add the function of re-uploading files in the resource center
Co-authored-by: Nwuchunfu <319355703@qq.com>

* [Improvement-3327][api]support re-upload the resource file (#3395)

* [Fix-3390][server]Running hive sql task need find the hdfs path correctly (#3396)

* [Fix-3390][api]Running hive sql task need find the hdfs path correctly

* [Fix-3390][api]Running hive sql task need find the hdfs path correctly

* update soft version

* hive UDF function to modify the background color

* fix

* fix bug: Fix master task dependency check bug

* cancel spark task version check (#3406)
Co-authored-by: NEights-Li <yelli.hl@gmail.com>

* [Bug][ui]Fix front-end bug #3413

* [Feature][ambari_plugin]support one worker can belongs different worker groups when execute install script (#3410)

* Optimize dag

* Update actions.js (#3401)

* [Fix-3256][ui] Fix admin user info update error (#3425) (#3428)

* [PROPOSAL-3139] Datasource selection changes from radio to select

* [PROPOSAL-3139] Datasource selection changes from radio to select

* [BUG FIX] issues #3256

* [BUG FIX] issues #3256

* [BUG FIX] issues #3256

* [Fix-3256][ui] Fix admin user info update error

* [Fix-3256][ui] Fix admin user info update error

* [Fix-3256][ui] Fix admin user info update error

* [Fix-3256][ui] Fix admin user info update error

* reset createUser.vue

* [Fix-3256][ui] Fix admin user info update error
Co-authored-by: Ndailidong <dailidong66@gmail.com>
Co-authored-by: Nwuchunfu <319355703@qq.com>
Co-authored-by: Ndailidong <dailidong66@gmail.com>

* [Fix-3433][api]Fixed that release the imported process definition which version is below 1.3.0 will be failure

* dag connection add check

* fix

* [Fix-3423][dao][sql]Fixed that the resource file of the task node can't be found when upgrade from 1.2.0 to 1.3.x (#3454)

* Remove node deep monitoring

* If worker group id is null,don't need to set the value of the worker group (#3460)

* [Fix-3423][dao][sql]Fixed that the resource file of the task node can't be found when upgrade from 1.2.0 to 1.3.x

* [Fix-3423][dao]If worker group id is null,don't need to set the value of the worker group

* [ui]Code optimization

* fix

* fix

* [fix-3058][ui]Move rtTargetArr to jsPlumbHandle.js

* [optimization][ui]Prevent the shell script input box from being empty

* [Fix-3462][api]If login user is admin,need list all udfs (#3465)

* [Fix-3462][api]If login user is admin,need list all udfs

* [Fix-3462][api]add the test on the method of QueryUdfFuncList

* [Fix-3462][api]fix the code smell

* [Fix-3462][api]fix the code smell

* [Fix-3462][api]fix the code smell

* [Fix-3463][api]Fixed that run the sql task will be failure after rename the udf resource (#3482)

* [fixBug-3058][ui]Fix connection abnormalities in historical workflow instance data

* [Feture-3327][ui]Add the function of re-uploading files in the udf subdirectory

* fix bug: Fix master task dependency check bug (#3473)
Co-authored-by: Nlenboo <baoliang@analysys.com.cn>

* [maven-release-plugin] prepare release 1.3.2

* [maven-release-plugin] prepare for next development iteration

* fix ci_e2e fail (#3497)

* [Fix-3469][api]Should filter the resource by the different program type (#3498)

* [Fix-3463][api]Fixed that run the sql task will be failure after rename the udf resource

* [Fix-3469][api]Should list python file and jar file

* [Fix-3469][api]Should filter the resource by the different program type

* [Fix-3469][api]fix the code smell

* test release 1.3.2 version rollback

* test release 1.3.2 version rollback

* test release 1.3.2 version rollback (#3499)

* [Feature] JVM parameter optimization , related issue #3370

* [Feature] JVM parameter optimization , related issue #3370

* test release 1.3.2 version rollback

* test release 1.3.2 version rollback
Co-authored-by: Nqiaozhanwei <qiaozhanwei@analysys.com.cn>

* [maven-release-plugin] prepare release 1.3.2

* [maven-release-plugin] prepare for next development iteration

* [Fix-3469][ui]The value of maintenance resources and the filtering of resources according to different program types

* fix

* Revert "fix ci_e2e fail (#3497)"

This reverts commit e367f90b.

* test

* test release 1.3.2 version rollback

* test release 1.3.2 version rollback (#3503)

* [Feature] JVM parameter optimization , related issue #3370

* [Feature] JVM parameter optimization , related issue #3370

* test release 1.3.2 version rollback

* test release 1.3.2 version rollback

* test

* test release 1.3.2 version rollback
Co-authored-by: Nqiaozhanwei <qiaozhanwei@analysys.com.cn>

* [maven-release-plugin] prepare release 1.3.2

* [maven-release-plugin] prepare for next development iteration

* test release 1.3.2 version rollback (#3504)

* [Feature] JVM parameter optimization , related issue #3370

* [Feature] JVM parameter optimization , related issue #3370

* test release 1.3.2 version rollback

* test release 1.3.2 version rollback

* test

* test release 1.3.2 version rollback
Co-authored-by: Nqiaozhanwei <qiaozhanwei@analysys.com.cn>

* [maven-release-plugin] prepare release 1.3.2

* [maven-release-plugin] prepare for next development iteration

* fix ds muti-level directory in zk, which lead to fail to assign work

* add login user check some actions in api

* [Hotfix][ci] Fix e2e ci docker image build error

* modify tag 1.3.0 to HEAD

* modify tag 1.3.0 to HEAD (#3525)

* [Feature] JVM parameter optimization , related issue #3370

* [Feature] JVM parameter optimization , related issue #3370

* test release 1.3.2 version rollback

* test release 1.3.2 version rollback

* test

* test release 1.3.2 version rollback

* modify tag 1.3.0 to HEAD
Co-authored-by: Nqiaozhanwei <qiaozhanwei@analysys.com.cn>

* remove OGNL part of the mybaits notice (#3526)

* [maven-release-plugin] prepare release 1.3.2

* [maven-release-plugin] prepare for next development iteration

* release 1.3.2 version rollback (#3527)

* [Feature] JVM parameter optimization , related issue #3370

* [Feature] JVM parameter optimization , related issue #3370

* test release 1.3.2 version rollback

* test release 1.3.2 version rollback

* test

* test release 1.3.2 version rollback

* modify tag 1.3.0 to HEAD
Co-authored-by: Nqiaozhanwei <qiaozhanwei@analysys.com.cn>

* [ui]Script input box to modify the delay loading time

* fix

* fix

* fix

* fix

* modify general user can't create token

* [ui]It is forbidden to select non-existent resources and modify the tree display data format

* modify general user can't create token (#3533)

* [Feature] JVM parameter optimization , related issue #3370

* [Feature] JVM parameter optimization , related issue #3370

* test release 1.3.2 version rollback

* test release 1.3.2 version rollback

* test

* test release 1.3.2 version rollback

* modify tag 1.3.0 to HEAD

* modify general user can't create token
Co-authored-by: Nqiaozhanwei <qiaozhanwei@analysys.com.cn>

* if task is null , set task type is null instead of "null"

* [Fix-3536][api]If user didn't have tenant,create resource directory will NPE (#3537)

* [Fix-3536][api]If user didn't have tenant,create resource will NPE

* [Fix-3536][api]If user didn't have tenant,create resource directory will NPE

* modify general user can't create,delete,update token (#3538)
Co-authored-by: Nqiaozhanwei <qiaozhanwei@analysys.com.cn>

* [ui]Resource delete OK button to increase loading, change the number of homepage display cursor

* fix

* [Fix-3616][Server] when worker akc/response master exception , async retry (#3748)

* [fixbug][ui]Repair the master and worker management instrument display

* [Fix-3238][docker]Fix that can not create folder in docker with standalone mode (#3741)

* [fixbug][ui]Remove non-existent or deleted resources disabled

* [fixBug-3621][ui]If the workflow instance status is executing status, it is forbidden to select

* [fix-3553][ui]Repair click workflow connection, select the entire path

* fix

* fix

* [Fix-3238][docker]Fix that can not create folder in docker with standalone mode

* [Fix-3616][Server] when worker akc/response master exception , async retry (#3776)

* [Fix-3616][Server] when worker akc/response master exception , async retry

* [Fix-3616][Server] when worker akc/response master exception , async retry

* [Fix-3616][Server] when worker akc/response master exception , async retry

* [Fix-3616][Server] when worker akc/response master exception , async retry

* [Fix-3616][Server] when worker akc/response master exception , async retry

* [Fix-3616][Server] when worker akc/response master exception , async retry

* [Fix-3616][Server] when worker akc/response master exception , async retry

* [Fix-3616][Server] when worker akc/response master exception , async retry

* [Fix-3616][Server] when worker akc/response master exception , async retry

* [Fix-3616][Server] when worker akc/response master exception , async retry

* [Fix-3616][Server] when worker akc/response master exception , async retry
Co-authored-by: Nqiaozhanwei <qiaozhanwei@analysys.com.cn>

* The batch delete function in the workflow definition and workflow instance pages cannot be canceled if selected.

* [Improvement-3720][ui] js mailbox verification fix

* [Fix-3549] [Server][sqlTask]The alias column in the query SQL does not take effect (#3784)

* [Fix-3616][Server] when worker akc/response master exception , async retry

* [Fix-3616][Server] when worker akc/response master exception , async retry

* [Fix-3616][Server] when worker akc/response master exception , async retry

* [Fix-3616][Server] when worker akc/response master exception , async retry

* [Fix-3616][Server] when worker akc/response master exception , async retry

* [Fix-3616][Server] when worker akc/response master exception , async retry

* [Fix-3616][Server] when worker akc/response master exception , async retry

* [Fix-3616][Server] when worker akc/response master exception , async retry

* [Fix-3616][Server] when worker akc/response master exception , async retry

* [Fix-3616][Server] when worker akc/response master exception , async retry

* [Fix-3616][Server] when worker akc/response master exception , async retry

* The batch delete function in the workflow definition and workflow instance pages cannot be canceled if selected.

* [Fix-3549] [Server][sqlTask]The alias column in the query SQL does not take effect

* [Fix-3549] [Server][sqlTask]The alias column in the query SQL does not take effect
Co-authored-by: Nqiaozhanwei <qiaozhanwei@analysys.com.cn>
Co-authored-by: Nzhuangchong <zhuangchong8@163.com>
Co-authored-by: NJinyLeeChina <42576980+JinyLeeChina@users.noreply.github.com>

* [Fix-3124][docker]Fix that can not build a docker image on windows (#3765)

* [Fix-3549] [Server][sqlTask]The alias column in the query SQL does not take effect (#3786)

* [Fix-3616][Server] when worker akc/response master exception , async retry

* [Fix-3616][Server] when worker akc/response master exception , async retry

* [Fix-3616][Server] when worker akc/response master exception , async retry

* [Fix-3616][Server] when worker akc/response master exception , async retry

* [Fix-3616][Server] when worker akc/response master exception , async retry

* [Fix-3616][Server] when worker akc/response master exception , async retry

* [Fix-3616][Server] when worker akc/response master exception , async retry

* [Fix-3616][Server] when worker akc/response master exception , async retry

* [Fix-3616][Server] when worker akc/response master exception , async retry

* [Fix-3616][Server] when worker akc/response master exception , async retry

* [Fix-3616][Server] when worker akc/response master exception , async retry

* The batch delete function in the workflow definition and workflow instance pages cannot be canceled if selected.

* [Fix-3549] [Server][sqlTask]The alias column in the query SQL does not take effect

* [Fix-3549] [Server][sqlTask]The alias column in the query SQL does not take effect

* [Fix-3549] [Server][sqlTask]The alias column in the query SQL does not take effect
Co-authored-by: Nqiaozhanwei <qiaozhanwei@analysys.com.cn>
Co-authored-by: Nzhuangchong <zhuangchong8@163.com>
Co-authored-by: NJinyLeeChina <42576980+JinyLeeChina@users.noreply.github.com>

* [Fix-3258][Security][Worker group manage] Connot get create time and update time,report DateTimeParseException (#3787)

* [Fix-3616][Server] when worker akc/response master exception , async retry

* [Fix-3616][Server] when worker akc/response master exception , async retry

* [Fix-3616][Server] when worker akc/response master exception , async retry

* [Fix-3616][Server] when worker akc/response master exception , async retry

* [Fix-3616][Server] when worker akc/response master exception , async retry

* [Fix-3616][Server] when worker akc/response master exception , async retry

* [Fix-3616][Server] when worker akc/response master exception , async retry

* [Fix-3616][Server] when worker akc/response master exception , async retry

* [Fix-3616][Server] when worker akc/response master exception , async retry

* [Fix-3616][Server] when worker akc/response master exception , async retry

* [Fix-3616][Server] when worker akc/response master exception , async retry

* The batch delete function in the workflow definition and workflow instance pages cannot be canceled if selected.

* [Fix-3549] [Server][sqlTask]The alias column in the query SQL does not take effect

* [Fix-3549] [Server][sqlTask]The alias column in the query SQL does not take effect

* [Fix-3549] [Server][sqlTask]The alias column in the query SQL does not take effect

* [BugFixed] issue #3258 (#3265)

* 'ExecutionStatus'

* '3258'

* Update WorkerGroupServiceTest.java

* Delete UserState.java

* Delete ResourceSyncService.java

* Delete core-site.xml

* Delete hdfs-site.xml
Co-authored-by: Ndailidong <dailidong66@gmail.com>
Co-authored-by: Nqiaozhanwei <qiaozhanwei@outlook.com>
Co-authored-by: Nqiaozhanwei <qiaozhanwei@analysys.com.cn>
Co-authored-by: Nzhuangchong <zhuangchong8@163.com>
Co-authored-by: NJinyLeeChina <42576980+JinyLeeChina@users.noreply.github.com>
Co-authored-by: Ndailidong <dailidong66@gmail.com>

* [fixBug-3792][ui]Click on the sidebar to adapt the width of the pie chart on the project homepage

* [Bug-3713][HadoopUtils] catfile method Stream not closed  (#3715)

* fix bug

Delete invalid field: executorcores

Modify verification prompt

* fix bug

Delete invalid field: executorcores

Modify verification prompt

* fix bug

Delete invalid field: executorcores

Modify verification prompt

* dag  add close button

* reset last version

* reset last version

* dag add close buttion

dag add close buttion

* update  CLICK_SAVE_WORKFLOW_BUTTON  xpath

* updae CLICK_SAVE_WORKFLOW_BUTTON xpath

* updae CLICK_SAVE_WORKFLOW_BUTTON xpath

* updae CLICK_SAVE_WORKFLOW_BUTTON xpath

* Update CreateWorkflowLocator.java

modify submit workflow button

* Update CreateWorkflowLocator.java

* Update CreateWorkflowLocator.java

modify CLICK_ADD_BUTTON

* Update CreateWorkflowLocator.java

delete print

* Update CreateWorkflowLocator.java

1

* Update CreateWorkflowLocator.java

1

* Setting '-XX:+DisableExplicitGC ' causes netty memory leaks

in addition

update '- XX: largepagesizeinbytes = 128M' to '- XX: largepagesizeinbytes = 10M'

* Update dag.vue

* Update dag.vue

* Update dag.vue

* Update CreateWorkflowLocator.java

* Revert "Setting '-XX:+DisableExplicitGC ' causes netty memory leaks"

This reverts commit 3a2cba7a

* Setting '-XX:+DisableExplicitGC ' causes netty memory leaks

in addition

update '- XX: largepagesizeinbytes = 128M' to '- XX: largepagesizeinbytes = 10M'

* Update dolphinscheduler-daemon.sh

* catfile method Stream not closed

* catfile method Stream not closed
Co-authored-by: Ndailidong <dailidong66@gmail.com>
Co-authored-by: Nxingchun-chen <55787491+xingchun-chen@users.noreply.github.com>

* [Fix-#3713][common]Fix that catfile method Stream not closed

* [Fix-#3713][common]Fix that catfile method Stream not closed (#3810)

* [Bug-3713][HadoopUtils] catfile method Stream not closed  (#3715)

* fix bug

Delete invalid field: executorcores

Modify verification prompt

* fix bug

Delete invalid field: executorcores

Modify verification prompt

* fix bug

Delete invalid field: executorcores

Modify verification prompt

* dag  add close button

* reset last version

* reset last version

* dag add close buttion

dag add close buttion

* update  CLICK_SAVE_WORKFLOW_BUTTON  xpath

* updae CLICK_SAVE_WORKFLOW_BUTTON xpath

* updae CLICK_SAVE_WORKFLOW_BUTTON xpath

* updae CLICK_SAVE_WORKFLOW_BUTTON xpath

* Update CreateWorkflowLocator.java

modify submit workflow button

* Update CreateWorkflowLocator.java

* Update CreateWorkflowLocator.java

modify CLICK_ADD_BUTTON

* Update CreateWorkflowLocator.java

delete print

* Update CreateWorkflowLocator.java

1

* Update CreateWorkflowLocator.java

1

* Setting '-XX:+DisableExplicitGC ' causes netty memory leaks

in addition

update '- XX: largepagesizeinbytes = 128M' to '- XX: largepagesizeinbytes = 10M'

* Update dag.vue

* Update dag.vue

* Update dag.vue

* Update CreateWorkflowLocator.java

* Revert "Setting '-XX:+DisableExplicitGC ' causes netty memory leaks"

This reverts commit 3a2cba7a

* Setting '-XX:+DisableExplicitGC ' causes netty memory leaks

in addition

update '- XX: largepagesizeinbytes = 128M' to '- XX: largepagesizeinbytes = 10M'

* Update dolphinscheduler-daemon.sh

* catfile method Stream not closed

* catfile method Stream not closed
Co-authored-by: Ndailidong <dailidong66@gmail.com>
Co-authored-by: Nxingchun-chen <55787491+xingchun-chen@users.noreply.github.com>

* [Fix-#3713][common]Fix that catfile method Stream not closed
Co-authored-by: NBoYiZhang <39816903+BoYiZhang@users.noreply.github.com>
Co-authored-by: Ndailidong <dailidong66@gmail.com>
Co-authored-by: Nxingchun-chen <55787491+xingchun-chen@users.noreply.github.com>

* [Fix-#3487][api、dao] cherry pick from dev to fix that create folder duplicate name under multithreading

* [Hotfix-3131][api] Fix the new tenant already exists prompt (#3132)

* Bugfix: Fix the new tenant already exists prompt

* Feature: Add test cases

* Update TenantServiceTest.java
Co-authored-by: Ndailidong <dailidong66@gmail.com>
Co-authored-by: Nqiaozhanwei <qiaozhanwei@outlook.com>

* Set up JDK 11 for SonarCloud in github action. (#3052)

* Set up JDK 11 for SonarCloud in github action.

* Fix javadoc error with JDK 11.

* Prevent Javadoc from stopping if it finds any html errors.

* [fixBug-3621][ui]Select the batch checkbox to unfilter the instances in the executing state

* add verify tenant name cannot contain special characters.

* [fixBug-3840][ui]The tenant code only allows letters or a combination of letters and numbers

* fix

* fix

* fix

* [Fix-#3702][api] When re-upload the resource file but don't change the name or desc,it need replace the origin resource file. (#3862)

* [Fix-#3702][api] When re-upload the resource file but don't change the name or desc,it will not replace the origin resource file.

* [Fix-#3702][api] When re-upload the resource file but don't change the name or desc,it will not replace the origin resource file.

* [fixbug-3621][ui]Workflow instance ready to stop and ready to suspend state prohibits checking

* [fixbug-3887][ui]Fix missing English translation of re-upload files

* add process define name verify. (#3879)

* Revert "[1.3.3-release][fix-3835][ui] When the tenantName contains "<", the tenant drop-down list is blankadd verify tenant name cannot contain special characters."

* revert pr 3872

* [FIX-3617][Service]after subtask fault tolerance, 2 task instances are generated (#3830)

* fix bug(#3617): after subtask fault tolerance, 2 task instances are generated.

* delete unused code

* update code smell

* refactor sub work command process

* add process service ut

* add license header

* fix some code smell

* chang ut java8 to java11

* update sonar to java11

* copy ut config from dev

* remove checkstyle

* revert to 1.3.3

* change proess service test to executor service

* add process service test

* add process service test

* revert

* revert

* add comments

* change dev to 1.3.3-release

* revert
Co-authored-by: Nbaoliang <baoliang@analysys.com.cn>

* [Fix-#3487][sql] add dolphinscheduler_dml.sql under 1.3.3_schema (#3907)

* [FIX-3836][1.3.3-release-API] process definition validation name interface prompt information error  (#3899)

* fix bug : error message

* fix code smell

* fix code smell

* [FIX_#3789][remote]cherry pick from dev to support netty heart beat

* [FIX_#3789][remote]cherry pick from dev to support netty heart beat

* [FIX_#3789][remote]cherry pick from dev to support netty heart beat (#3913)

* [FIX_#3789][remote]cherry pick from dev to support netty heart beat

* [FIX_#3789][remote]cherry pick from dev to support netty heart beat
Co-authored-by: NKirs <acm_master@163.com>

* Repair check box cannot be canceled

* [fix-3843][api] When update workflow definition,if name already exists, the prompt is not friendly

* [fix-3843][api] When update workflow definition,if name already exists, the prompt is not friendly

* [fix-#3843][api]When update workflow definition,if name already exists, the prompt is not friendly (#3918)

* [FIX_#3789][remote]cherry pick from dev to support netty heart beat

* [FIX_#3789][remote]cherry pick from dev to support netty heart beat

* [fix-3843][api] When update workflow definition,if name already exists, the prompt is not friendly

* [fix-3843][api] When update workflow definition,if name already exists, the prompt is not friendly
Co-authored-by: NKirs <acm_master@163.com>

* [Fix-#3487][sql] update uc_dolphin_T_t_ds_resources_un

* Workflow definition name re-modified and added check

* [fix-#3843][api]When update workflow definition,if name already exists, the prompt is not friendly.

* update code.

* [#3931][ui]Field name optimization for spark, flink, and mr

* change version from 1.3.2-SNAPSHOT to 1.3.3-SNAPSHOT (#3934)

* [maven-release-plugin] prepare release 1.3.3

* [maven-release-plugin] prepare for next development iteration

* [ambari-plugin]change version 1.3.2 to 1.3.3 (#3935)

* fix bug:3615 After the task is executed successfully, but the next task has not been submitted, stop the master

* [fixBug-3964][ui]Switch back and forth over timeout alarm, the selected value is empty

* solve too many files, close logClientService (#3971)

* fix #3966 sub process doesnot send alert mail after process instance ending. (#3972)
Co-authored-by: Nbaoliang <baoliang@analysys.com.cn>

* [Fix-#3618][server] resolve task executed finished but not release the file handle (#3975)

* [Fix-#3618][server] resolve task executed finished but not release the file handle

* [Fix-#3618][server] resolve task executed finished but not release the file handle

* [Fix-#3958][api] files should not be created successfully in the directory of the authorized file

* [FIX-3966] The timeout warning does not take effect in sub_process (#3982)

* fix #3966 sub process doesnot send alert mail after process instance ending.

* fix bug 3964: sub_process The timeout warning does not take effect
add timeout warning for sub_process/dependent task.

* fix code smell

* fix code smell

* fix code smell

* update worker group inherit from parent
Co-authored-by: Nbaoliang <baoliang@analysys.com.cn>

* fix import dolphinscheduler_mysql.sql insert admin user data

* [FIX-3929] condition task would post wrong tasks when failover. (#3999)

* fix #3966 sub process doesnot send alert mail after process instance ending.

* fix bug 3964: sub_process The timeout warning does not take effect
add timeout warning for sub_process/dependent task.

* fix code smell

* fix code smell

* fix code smell

* update worker group inherit from parent

* remove stdout in logback configuration

* fix bug #3929 condition task would post error when failover.

* remove unused test

* add comments

* add skip node judge
Co-authored-by: Nbaoliang <baoliang@analysys.com.cn>

* [FIX-3929]  because of no lock, start up failover would dispatch two same tasks. (#4004)

* fix #3966 sub process doesnot send alert mail after process instance ending.

* fix bug 3964: sub_process The timeout warning does not take effect
add timeout warning for sub_process/dependent task.

* fix code smell

* fix code smell

* fix code smell

* update worker group inherit from parent

* remove stdout in logback configuration

* fix bug #3929 condition task would post error when failover.

* remove unused test

* add comments

* add skip node judge

* fix bug 3929: because of no lock, start up failover would dispatch two same tasks.
Co-authored-by: Nbaoliang <baoliang@analysys.com.cn>

* revert pom version to 1.3.3-release

* [maven-release-plugin] prepare release 1.3.3

* [maven-release-plugin] prepare for next development iteration

* [release]revert pom version to 1.3.3-release

* fix bug 4010: remove failed condition tasks from error-task-list. (#4011)
Co-authored-by: Nbaoliang <baoliang@analysys.com.cn>

* [maven-release-plugin] prepare release 1.3.3

* [maven-release-plugin] prepare for next development iteration

* merge from 1.3.3-release

* merge from 1.3.3-release

* merge from 1.3.3-release

* merge from 1.3.3-release

* merge from 1.3.3-release

* merge from 1.3.3-release

* merge from 1.3.3-release

* merge from 1.3.3-release

* merge from 1.3.3-release

* refactor code style

* refactor code style

* refactor code style

* merge from 1.3.3-release

* merge from 1.3.3-release

* merge from 1.3.3-release

* merge from 1.3.3-release

* merge from 1.3.3-release

* refactor ut test

* refactor ut test

* merge from 1.3.3-release

* merge from 1.3.3-release

* merge from 1.3.3-release

* refactor ut

* merge from 1.3.3-release

* refactor ut

* refactor ut

* refactor

* refactor

* refactor code style

* refactor code style

* refactor code style

* refactor code style

* merge from 1.3.3-release

* merge from 1.3.3-release

* merge from 1.3.3-release

* merge from 1.3.3-release

* merge from 1.3.3-release

* refactor code style
Co-authored-by: Nbreak60 <790061044@qq.com>
Co-authored-by: Nwuchunfu <319355703@qq.com>
Co-authored-by: Nlgcareer <18610854716@163.com>
Co-authored-by: Nxingchun-chen <55787491+xingchun-chen@users.noreply.github.com>
Co-authored-by: Nlenboo <baoliang@analysys.com.cn>
Co-authored-by: Nqiaozhanwei <qiaozhanwei@analysys.com.cn>
Co-authored-by: NYelli <amarantine@my.com>
Co-authored-by: NEights-Li <yelli.hl@gmail.com>
Co-authored-by: NJinyLeeChina <42576980+JinyLeeChina@users.noreply.github.com>
Co-authored-by: Ndailidong <dailidong66@gmail.com>
Co-authored-by: Nqiaozhanwei <qiaozhanwei@outlook.com>
Co-authored-by: NXiaotaoYi <v-xiayi@hotmail.com>
Co-authored-by: NYichao Yang <1048262223@qq.com>
Co-authored-by: Nzhuangchong <zhuangchong8@163.com>
Co-authored-by: NBoYiZhang <39816903+BoYiZhang@users.noreply.github.com>
Co-authored-by: Nmuzhongjiang <mu_zhongjiang@163.com>
Co-authored-by: NJave-Chen <baicai.chen@gmail.com>
Co-authored-by: Nzhuangchong <zhuangchong6@163.com>
Co-authored-by: Nzhuangchong <37063904+zhuangchong@users.noreply.github.com>
Co-authored-by: NKirs <acm_master@163.com>
Co-authored-by: Nlgcareer <lgcareer@apache.org>
Co-authored-by: Nwulingqi <wulingqi@baijiahulian.com>

* Revert "[Draft][Merge][133-dev]133 merge dev (#4031)" (#4057)

This reverts commit ad2d9f99.

* [Fix][API] Condition task null pointer exception (#4056)

* add ProcessUtils UT

* modify ProcessUtils & ProcessUtilsTest

* Enhance user experience, add close button, return to the previous page (#4006)
Co-authored-by: Nzhanglong <zhanglong@ysstech.com>

* [FIX_BUG][server-test] dismiss of server warm-up time in RoundRobinSelectorTest (#4067)

* [Fix][api] Fix build parameter error of sqlserver when create. (#4015)

* [fix-#3962][api] Avoid ClassCastException for LoggerService.queryLog().

* [Fix][api] Fix build parameter error of sqlserver when create.

* [Feature-3985][Datax] Datax supports setting up running memory (#3986)

* Datax supports setting up running memory

* Datax supports setting up running memory

* Datax supports setting up running memory

* When running a task, the resource file is lost, which results in an error

* add unit test

* add unit test

* add unit test

* add test unit

* add test unit

* add test unit

* fix code smell

* add test unit

* add test unit

* [Improvement-3767][api] Task instance supports query by process instance name (#3825)

* Task instance supports query by process instance name.

* add test code checkstyle.

* add test param.

* resolve the sonar duplication check.

* solve logger single-line string exceeds 200 characters.

* resolve the sonar check.

* Resolve code conflicts.
Co-authored-by: Nzhuangchong <zhuangchong8@163.com>

* deal with magic value

* [Feature-4050][server] Spark task support udv inject (#4061)

* #4050 spark task support udv inject

* modify spark task UT

* modify sparkTaskExecutionCtx

* add exp for spark task get main jar method

* deal with magic value

* [Improvement-3471][common] JSONUtils.toMap It is not necessary to check whether the JSON method is empty again. #3471 (#3481)

* JSONUtils.toMap call improvement.

* [Fix-4054][Api] Fix The last week of the month for adding/editing timing, preview and save timing will report an error

* 解决单独执行子节点空指针的问题

* using OSUtils.execCmd when kill yarn app

* 解决单独执行子节点空指针的问题(增加checkstyle)

* 解决单独执行子节点空指针的问题(增加checkstyle)

* [FIX-#4083][server]fix taskInstance state change error
Concurrent processing of ack message and result message causes the execution sequence to be wrong

# this close # 4083

* code style

* fix replaceNRTtoUnderline NullPointerException #4098 (#4100)

* fix replaceNRTtoUnderline NullPointerException

* add  unit Test

* add taskResponseTest

* add taskResponseTest

* code smell

* Time is too small and the task is not finished

* Time is too small and the task is not finished

* [FIX-4034][server] fix sqoop import fail (#4036)

* fix #4043, sqoop import query fail

* fix #4043, sqoop task hard code & code style

* add license for SqoopConstants

* add private constructor for SqoopConstants

* fixed sqoop mysql pwd have special character

* fix checkstyle

* fix sqoop task log

* remove unused constants

* Time is too small and the task is not finished

* Time is too small and the task is not finished

* test

* remove assert

* test

* test

* fix task instance status judgment error

* fix: security page disappear delay problem when force refresh under GENERAL_USER

* improvement: resovle download url with resolveURL to prevent change of apiPrefix

* fix sqoop task jdbc string contains special char (#4105)

* [Bug][Common] read file garbled (#3479)

* fix bug : Random code problem
Co-authored-by: Nzhanglong <zhanglong@ysstech.com>

* [Improvement-3933][db operation] Improve the performance of sql query (#3940)

* optimize select * case

* emove redundancy

* bug fixed

* Update en_US.js

* Update startup.sh

* optimize

* optimize code

* optimize

* bug fixed

* add ut

* bug fixed

* bug fixed

* bug fixed

* bug fixed

* Delete WorkFlowLineageMapper.xml

* Delete createTenement.vue

* recove wrongly deleted file

* Update WorkFlowLineageMapper.xml

* Update createTenement.vue

* [Feature][API]enable response resources gzip compression (#4121)

* enable response compression

* add server.compression.mime-types with default value explicitly

* [Improvement][API] ignore noNodeException when get worker groups (#4120)

* ignore noNodeException when get worker groups

* add ut

* [Improvement][Code style] FIX SPELL WAITTING TO WAITING , etc. (#4118)

* FIX SPELL

* FIX SPELL AND  Optimizing code conventions

* add ut  cannot construct process instance, return null;

* add ut testExportProcessMetaData

* add ut testExportProcessMetaData

* add ut testImportProcessSchedule

* add ut MasterExecThreadTest

* add ut MasterExecThreadTest

* add ut testSubProcessViewTree

* add ut testComplementWithStartNodeList

* add ut testRecurseFindSubProcessId

* add ut testRecurseFindSubProcessId

* add ut testRecurseFindSubProcessId

* [FIX#4033] $[] conflicts with mysql keywords (#4111)

* [FIX#4033] $[] conflicts with mysql keywords
We currently only use this symbol for dates, so I filtered out the number type.
this close #4033

* test

* fix error

* split sqoop import hive database and table (#4141)

* upgrade quartz version to 2.3.0

* add HikariCP-java6,c3p0,mchange-commons-java license

* upgrade jackson version to 2.9.10

* start from force success

* correct param name

* correct names

* remove c3p0,mchange-commons-java license

* update Check code style

* update  code style

* Update pom.xml

* Update pom.xml

* Update LICENSE

not need to add HikariCP-java6

* Delete LICENSE-HikariCP-java6.txt

* Update known-dependencies.txt

* Update TaskInstanceMapper.xml

optimize page of [TaskInstance] load data slow

* [FIX-PR-4097][server-master]task ack miss (#4189)

When the message of successful execution arrives earlier than
the message of ack,
the message of ack will be discarded,
resulting in some information missing

* fix bug #4125 (#4127)

* fix bug #4125

* code style!

* code style.
Co-authored-by: Nchengp <chengp@chengp.net>

* [FIX-4190][DAO] When the amount of json data is large, the process list page display slowly. (#4201)

* fix 4190: When the amount of json data is large, process list page display slowly

* fix 4190: When the amount of json data is large, process list page display slowly

* fix 4190: When the amount of json data is large, process list page display slowly
Co-authored-by: Nbaoliang <baoliang@analysys.com.cn>

* [Fix-3457][flink] fix flink args build problem (#4166)

* [Fix][Flink] fix flink args build problem

* [Fix][Flink] fix FlinkArgsUtilsTest

* [Improvement][UI] hide version and cluster input when deployMode is local

* [common]del windows file( not support windows ) (#4204)

* del support win

* del support win

* [Feature-4138][Master] dispatch workgroup error add sleep time (#4139)

* When there are tasks with assignment failure and the number of tasks in the current task queue is less than 10, sleep for 1 second

* When there are tasks with assignment failure and the number of tasks in the current task queue is less than 10, sleep for 1 second

* fix code smell & code style

* fix code smell & code style
Co-authored-by: Nzhanglong <zhanglong@ysstech.com>

* [FIX-#4172][server-worker] kill task NPE (#4182)

* [FIX-#4172][server-worker] kill task NPE

The cache task will be sent when the Process is generated. Before that, if a kill task appears, then NPE will appear
Modification method: write into the cache when the task is received, and mark it as preData
If the task is killed before the Process is generated, delete the cache directly at this time
It will be judged before the process is generated. If the task has been killed, it will not be executed.
After the new process is created, write it into the cache, and judge again, if kill, then kill the process.

this closes #4172

* Delete the commented out code
Add spring beans

* code smell

* add test

* add test

* fix error

* test

* test

* revert

* fix error

* [Feature-3878]Replace the page with element-ui (#4065)

* [Feature-3878]Introduce elment-ui and replace the security center module page with elment-ui

* Change node version

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* Replace the page with element-ui

* Replace user management with elment-ui

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* Repair the last Sunday of each month

* support auto eslint for .js, .vue file on save

* update .eslintrc.yml and license check exclude .eslintignore

* fix eslint: fix syntax by npm run lint automatically

* fix eslint: fatal syntax errors

* fix eslint: expected '!==' but instead saw '!=', expected '===' but instead saw '=='

* fix eslint: Unexpected side effect in 'cacheParams' computed property

* fix eslint: assigned a value but never used

* fix eslint: component has been registered but not used

* fix eslint: unexpected mutation of prop

* fix bug: start from the setting nodes with NODE_PRE would be NPE. (#4219)

* deleted invalid code as assigned in issue 4215 (#4221)

deleted the code at following two places:
org.apache.dolphinscheduler.service.process.ProcessService#checkTaskExistsInTaskQueue
org.apache.dolphinscheduler.service.process.ProcessService#taskZkInfo

* [FIX-#3177]Task time parameter parsing error (#4224)

* [FIX-#3177]Task time parameter parsing error

rerun schedule time error

this closes #3177

* [FIX-#3177]Task time parameter parsing error

rerun schedule time error

this closes #3177

* fix sql error (#4227)

* [FIX-3177]Task time parameter parsing error (#4228)

* [FIX-3177]Task time parameter parsing error
when system.datetime !=null $[datetime] = system.datetime
else $[datetime] = current time

* remove unused import

* fix date_convert null

* fix time cover

* fix time cover

* reformat

* add ut

* [Fix][UI]: fix re-login problem in new tab and state synchronization problem in multiple tabs (#4162)

* fix(ui): re-login problem in new tab

* refresh page in new tab automatically

* support to reload router view in lightweight

* optimize visibility code

* [Improvement][UI] Add no-var rule for eslint and add 'npm run lint:fix' command (#4225)

Add no-var rule for eslint, and fix related files
Add npm run lint:fix command, which distinguished from the default command npm run lint
The behavior of command npm run lint and command npm run lint:fix should be distinguished
The first command is used to lint only, and the second one is used to lint and fix problems automatically

* [FIX][UI ]  security user state  tenantCode User Type Display abnormal (#4255)

* fix user state error

* fix userType  error

* fix tenantCode  error

* [Fix-4222][Master]Add the priority queue to ensure that tasks are submitted according to priority. (#4250)

* [Fix-4222][Master]Add the priority queue to ensure that tasks are submitted according to priority.

* [Fix-4222][Master]Add the priority queue to ensure that tasks are submitted according to priority.

* [Fix-4222][Master]Remove useless import

* [Fix-4222][Master]Reformat code style

* [Fix-4222][Master]Reformat code style

* [Fix-4222][Master]Reformat code style

* [Fix-4222][Master]add PeerTaskInstancePriorityQueueTest

* [Fix-4222][Master]Fix code smell

* [Fix-4222][Master]Reformat code style

* [Fix-4222][Master]Fix code smell
Co-authored-by: Nxingchun-chen <55787491+xingchun-chen@users.noreply.github.com>

* update bug template (#4260)

* add pasue icon button and adjust operation button style

* Align each item one by one in locale

* match frontend and backend for force success

* [Improvement-4069][server] When the tenant does not exist, the task execution should throw an exception (#4108)

* when  the tenant does not exist, the task execution should throw an exception

* remote method createWorkDirAndUserIfAbsent

* set the task status failed when the tenant code does not exist.

* add taskLog.

* update check os user exists

* update TaskExecuteThreadTest test method.

* solving sonar fail.

* remove AbstractTask.getCurTaskParamsClass()and replace with TaskParametersUtils.getParameters() (#4262)

* remove getCurTaskParamsClass() in AbstractTask.java and replace it with TaskParametersUtils.getParameters()

* remove unused imports in AbstractTask.java

* reformat

* fix code style and test

* [Fix-4271][server] Fix IOException or NoSuchFileException in logger server (#4272)

* fix version funcation delete. (#4265)

* [improvement][config] Update datasource.properties,add mysql meta data template (#4266)

* Update datasource.properties

[新增]元数据mysql连接模版

* Update datasource.properties
Co-authored-by: Ndailidong <dailidong66@gmail.com>

* fix taskInstance submitTime is empty. (#4274)

* [Improvement-3878]Tenant list delete user name (#4278)

* [Fix-4268] Fix NumberFormatException when visiting a doc.html or swagger-ui.html (#4269)

* [Fix-4268] Fix NumberFormatException when visiting a doc.html or swagger-ui.html

* Fix checkstyle error

* Update swagger-models in known-dependencies.txt

* [Improvement-3878][ui]Fix the list style (#4280)

* [Improvement-3878]Tenant list delete user name

* [Improvement-3878][ui]Fix the list style

* [FIX] [UI] fix create project cancel button invalid (#4282)

* fix create project cancel button invalid

* [Improvement] Refactor code to support distributed tracing (#4270)

* Refactor code to support tracing

* Extension network protocol, support context and version
* Extension master asynchronous queue support context
* Extract scan task method from MasterSchedulerService for tracing

* fix

* fix

* add test case

* fix

* fix
Co-authored-by: Nhailin0 <hailin0@yeah.net>

* [Improvement] Add Flink job name (#4285)

* [Improvement] Add Flink job name

* fix typo

* [Improvement][ui]List vacancy optimization and icon icon repair (#4286)

* [Improvement][ui] List vacancy optimization and icon icon repair

* adjust locale for new pr

* [FEATURE-736] integrate ldap authentication (#3743)

* [FEATURE-736] integrate ldap authentication

* add ldap authentication type
* refactor authentication with ldap and password
* add  createUser for ldap in user service
* remove duplicate password authenticator

* [Fix-4289][*] Flink name with disappeared and unescaped problem (#4290)

* fix flink name not display in process definition editor

* fix flink name not escape problem

* simplify escape method

* fix database is the mysql DB keyword. (#4295)

* fix the token management list does not display the user name. (#4302)

* Dev imp server process utils (#4263)


* Adds the comment on the WINDOWSATTERN
Co-authored-by: NKirs <acm_master@163.com>
Co-authored-by: N0002939 <licongyang@mininglamp.com>

* fix version close function does not take effect. (#4307)

* fix user management authorization operation exceptions do not prompt exception information. (#4292)

* [Fix][UI] Fix ui style problem and refactor form style (#4329)

* rename from-model to form-model

* [UI] remove duplicated css style code

* [UI] refactor css style of form model

* fix form model overflow problem in ie

* Align each item one by one in locale

* fix el-dialog width is too wide

* fix locale

* [Improvement][UI] Improve script box and dialog css style (#4331)

* [Fix-4335][UI] Fix IE 9-11 not supported

* [FIx-4338][UI] Fix invalid date problem in IE

* [Improvement] Use environment variable $DOLPHINSCHEDULE_OPTS as daemon startup arguments (#4341)
Co-authored-by: Nhailin0 <hailin0@yeah.net>

* [Fix][common] only two yarns can be selected(#4314) (#4344)

* modify_Status (#4352)
Co-authored-by: Nzt-1997 <“18841012545@163.com”>

* fix the page does not refresh after clicking the delete function.. (#4360)

* [FIX-4326][UI] Add description field to data source list (#4362)

* [Feature-4318][API] Rename tenant code (#4320)

Rename tenant code
Rename tenant code (English version)
Rname tenant name in ui label
Rname TENANT_CODE_EXIST to OS_TENANT_CODE_EXIST
Rname enum  TENANT_CODE_* to OS_TENANT_CODE_*

* [Fix-3233][api-server] Fix the bug when compile the code in Java9 env (#4312)

* [Fix-3233][api-server] Fix the bug when compile the code in Java9 env
 delete release-docs/licenses/LICENSE-jsp-api-2.1-6.1.14.txt
 delete ant-1.6.5.jar core-3.1.1.jar jsp-api-2.1-6.1.14.jar
 delete LICENSE-ant-1.6.5.txt,LICENSE-core-3.1.1.txt
 delete maven repository address of ant-1.6.5.jar ,core-3.1.1.jar ,jsp-api-2-1-6.1.14.jar
Co-authored-by: N李长福 <changfu.li@dmall.com>

* [Improvement][ui] Introduce remixicon, delete ans-ui license and font-awesome (#4313)

* [Improvement-3878]Tenant list delete user name

* [Improvement-3878][ui]Fix the list style

* [Improvement][ui] List vacancy optimization and icon icon repair

* Add font-awesome license and delete ans-ui license

* Introduce remixicon

* [Improvement-4257][api]  Increase "queryProcessDefinitionByName" API (#4390)

* 1. Increase "queryProcessDefinitionByName" API.
2. Will queryProcessDefinitionById api "PROCESS_INSTANCE_EXIST" state is modified to "PROCESS_DEFINE_NOT_EXIST".

* Correct spelling mistakes in words

* Logging should not be vulnerable to injection attacks
Co-authored-by: Nyinyong <yinyong@netposa.com>

* remove the operation resume_from_forced_success

* refactor code styles

* readme file fixed (#4374)

* readme fix

* readme fix

* readme fix

* readme fix

* readme fix
Co-authored-by: NTinaPang <pangtianyang@analysys.com.cn>

* [Fix-4293][UI] Fix data loss in switched tab (#4415)

* [Fix-4293][UI] Fix data loss in switched tab

* The disclaimer should be same with the website

* [Improvement][UI] Rename disabled to enabled in menu (#4414)

* [Feature-#130] pass global param values when starting new process instance (#4372)

* [DS-130][feat] pass global param values when starting new process instance
    add optional param for start-process-instance api
    reuse command_param in command table for persistence
    overload curingGlobalParams function in ParameterUtils
    not adapt the UI code yet

* change import order

* support datetime expression

* print start params

* (fix) avoid npe when cmdParam is null

Change-Id: I3b4c4b5fa1df316ff221e27146e45d7d4d3a404e

* fix alert-spi error
todo sql script

* [DS-4396][feat] Add project information to email alert message (#4413)

* [DS-4396][feat] Add project information to email alert message
- build find project and user sql to ProjectMapper
- add project information to alert db.

* [DS-4396][style] change style

* add page query plugin instance
add plugin instance check name

* add page query plugin instance
add plugin instance check name

* add props field

* ding talk some filed is not required

* fix bug

* [Improvement][UI] Correct spelling mistakes (#4440)

* fix error

* revert

* [FEATURE-4451][API]After the workflow editing page is submitted, the user chooses whether to go online or not. 0 means not to go online, 1 means online. (#4437)

* vvvv

* vvvvv

* vvvvv

* testReleaseProcessDefinition
Co-authored-by: Nzt-1997 <“18841012545@163.com”>

* [Feature-4428][dao、UI] It is recommended to add an owner in the data source center and the Resource Center to make it easier to manage (#4442)

* add owner to datasource list and resource list

* add owner to datasource list and resource list
Co-authored-by: Nbobqiu <xiaoqiu369@gmail.com>

* [Fix-4455][common] fix parse shell output (#4456)

* add name field provide to ui

* [FIX][UT]testVerifyTenantCode assert error (#4460)

* [FIX][UT]testVerifyTenantCode assert error

* [FIX][UT]testVerifyTenantCode assert error

* code smell

* fix the exception of update null point of workflow instance due to no… (#4459)

* fix the exception of update null point of workflow instance due to not add global parameter when create workflow definition

* optimization of the leading package
Co-authored-by: Nyaoshui <huangqitao@accesscorporate.com.cn>

* chore: set up license-eye to check license headers (#4453)

* [Improvement][alert] Refactor alert module to fix code smell (#4434)

* chore: Refactore dolphinscheduler-alert to fix code smell

* chore: Refactor code to fix codestyle error

* fix: use shellformat(shfmt) and shellcheck fix mvnw (#3692)

use shellformat(shfmt) and shellcheck fix mvnw

* [Feature-4451][UI]: add an option to the UI page for saving the workflow definition: whether to go online? online by default (#4474)
Co-authored-by: Nlinyanbin <linyanbin@lizhi.fm>

* [FIX-4247][Api]Fixed the problem that the global parameters are not updated after the workflow instance click rerun
Co-authored-by: Nzt-1997 <“18841012545@163.com”>

* [Improvement-4435][datasource] the datasource tests the connection and returns details when the connection is wrong (#4436)

* add datasource test connection return result message.

* add code checkstyle.

* spark/hive datasoure test connection add loadKerberosConf.

* solve sonarcloud coverage.

* [Improvement-4480][API] change method checkAdmin to isNotAdmin (#4483)

* change method 'checkAdmin' to 'isNotAdmin', for better understand.
Co-authored-by: N蒙强 <mengqiang@zhongan.com>

* fix send error

* add ui

* delete useless constant definitions
code style

* code style

* fix license head error

* [Improvement-#4481][API] ProcessDefinitionController save API optimization 
Co-authored-by: Nlei.zou <lei.zou@rootcloud.com>

* fix ut error

* fix ut error

* del unused jar

* [Feature-4423][UI] When the process definition is running, the pop-up box can manually set the global parameters. (#4433)

* [DS-130][feat] pass global param values when starting new process instance
    add optional param for start-process-instance api
    reuse command_param in command table for persistence
    overload curingGlobalParams function in ParameterUtils
    not adapt the UI code yet

* change import order

* support datetime expression

* print start params

* (fix) avoid npe when cmdParam is null

Change-Id: I3b4c4b5fa1df316ff221e27146e45d7d4d3a404e

* [Feature-4423][UI] When the process definition is running, the pop-up box can manually set the global parameters
(frontend) adapt the UI code
(backend-fix) add empty string check for param

Change-Id: I710db55f5059f8bd324c79f4494f2798d58e7b19

* add Startup parameters label

Change-Id: I5ac82031ea1b64abec330ee8cf2991477a28fcaa

* reuse i18n label

Change-Id: I5f322cb1dd8e2cade0c679bd025fc984e31bf3ae

* import alert-plugin

* upgrade jboss-logging

* upgrade jboss-logging

* fix ut error

* fix Vulnerabilities

* fix Vulnerabilities

* fix Vulnerabilities

* code smell

* [fix-4472][DataSource] Hive JDBC partial permission parameter concatenation JDBC URL error (#4473)

* Solve the problem of parameter splicing of permission part in Hive JDBC URL.

* update code style.

* add test check in pom.xml.

* [FIX-#4468] [UI] Workflow relationships Name filtering invalidated #4508
Co-authored-by: N花花 <huahua@thinkingdata.cn>

* fix Vulnerabilities

* add  public constructors

* fix  Vulnerabilities

* [NOTICE Update]Update year to 2021 (#4521)

* [feat-4496][server]  Add to! {} is used to mark the custom parameters to be output as-is in sql (#4497)

* feat([server]): Add to! {} is used to mark the custom parameters to be output as-is in sql

Before pre-compiling sql, replace the custom parameters marked with !{}
to prevent the parameters in the hive plus partition path from being
replaced with single quotes

Closes This closes #4496

* feat([server]): Add to! {} is used to mark the custom parameters to be output as-is in sql

Before pre-compiling sql, replace the custom parameters marked with !{}
to prevent the parameters in the hive plus partition path from being
replaced with single quotes

Closes This closes #4496

* feat([server]): Add to! {} is used to mark the custom parameters to be output as-is in sql

Before pre-compiling sql, replace the custom parameters marked with !{}
to prevent the parameters in the hive plus partition path from being
replaced with single quotes

Closes This closes #4496

* resolve conflicts

* add eg

* add eg

* code style

* revert mysql config
Co-authored-by: Nbaoliang <baoliang@analysys.com.cn>
Co-authored-by: NEights-LI <yelli.eights@gmail.com>
Co-authored-by: Nbao liang <29528966+lenboo@users.noreply.github.com>
Co-authored-by: Nbreak60 <790061044@qq.com>
Co-authored-by: Nwuchunfu <319355703@qq.com>
Co-authored-by: Nlgcareer <18610854716@163.com>
Co-authored-by: Nxingchun-chen <55787491+xingchun-chen@users.noreply.github.com>
Co-authored-by: Nqiaozhanwei <qiaozhanwei@analysys.com.cn>
Co-authored-by: NYelli <amarantine@my.com>
Co-authored-by: NEights-Li <yelli.hl@gmail.com>
Co-authored-by: NJinyLeeChina <42576980+JinyLeeChina@users.noreply.github.com>
Co-authored-by: Ndailidong <dailidong66@gmail.com>
Co-authored-by: Nqiaozhanwei <qiaozhanwei@outlook.com>
Co-authored-by: NXiaotaoYi <v-xiayi@hotmail.com>
Co-authored-by: NYichao Yang <1048262223@qq.com>
Co-authored-by: Nzhuangchong <zhuangchong8@163.com>
Co-authored-by: NBoYiZhang <39816903+BoYiZhang@users.noreply.github.com>
Co-authored-by: Nmuzhongjiang <mu_zhongjiang@163.com>
Co-authored-by: NJave-Chen <baicai.chen@gmail.com>
Co-authored-by: Nzhuangchong <zhuangchong6@163.com>
Co-authored-by: Nzhuangchong <37063904+zhuangchong@users.noreply.github.com>
Co-authored-by: Nlgcareer <lgcareer@apache.org>
Co-authored-by: Nwulingqi <wulingqi@baijiahulian.com>
Co-authored-by: Nhailin0 <hailin0@yeah.net>
Co-authored-by: Nzhanglong <zhanglong@ysstech.com>
Co-authored-by: Nt1mon <178317391@qq.com>
Co-authored-by: Nyangquan <iyeeku@qq.com>
Co-authored-by: syso1's avatarliliang1991 <liliang_68@126.com>
Co-authored-by: Nliang.li.c <liang.li.c@17zuoye.com>
Co-authored-by: Nfelix.wang <59079269+felix-thinkingdata@users.noreply.github.com>
Co-authored-by: Nchengshiwen <chengshiwen0103@gmail.com>
Co-authored-by: Nyinancx <mockibird@live.cn>
Co-authored-by: NYarlung <turingdojo@163.com>
Co-authored-by: Nkarlsun <karlsun@tencent.com>
Co-authored-by: N曹聚阳 <yinancx@live.com>
Co-authored-by: Nwangxj3 <857234426@qq.com>
Co-authored-by: chengp...'s avatarchengp <5058557@qq.com>
Co-authored-by: Nchengp <chengp@chengp.net>
Co-authored-by: NSaksham Gupta <saksham1319@gmail.com>
Co-authored-by: NTq <36755957+Tianqi-Dotes@users.noreply.github.com>
Co-authored-by: NJatham <59549328+Jatham922@users.noreply.github.com>
Co-authored-by: Nhailin0 <hailin0@foxmail.com>
Co-authored-by: Nzh0122 <zh0122@gmail.com>
Co-authored-by: Ngeosmart <geosmart@hotmail.com>
Co-authored-by: 李丛阳's avatar李丛阳 <liby-1987@163.com>
Co-authored-by: N0002939 <licongyang@mininglamp.com>
Co-authored-by: kamisamak's avatarkamisamak <1057372918@qq.com>
Co-authored-by: Nzt-1997 <41983395+zt-1997@users.noreply.github.com>
Co-authored-by: Nzt-1997 <“18841012545@163.com”>
Co-authored-by: NxiaojingXU <68894048+xxjingcd@users.noreply.github.com>
Co-authored-by: Nguohaozhang <zhishengqianjun@gmail.com>
Co-authored-by: Ncooper <1322849632@qq.com>
Co-authored-by: N李长福 <changfu.li@dmall.com>
Co-authored-by: Nyy0812 <32183971+yy0812@users.noreply.github.com>
Co-authored-by: Nyinyong <yinyong@netposa.com>
Co-authored-by: Nptyp <30622951+ptyp@users.noreply.github.com>
Co-authored-by: NTinaPang <pangtianyang@analysys.com.cn>
Co-authored-by: NDean Wong <wangding85@gmail.com>
Co-authored-by: NK.O <okoahin@gmail.com>
Co-authored-by: Nqiubo <38316980+qiubo369@users.noreply.github.com>
Co-authored-by: Nbobqiu <xiaoqiu369@gmail.com>
Co-authored-by: NHxssssss <huangqt1992@163.com>
Co-authored-by: Nyaoshui <huangqitao@accesscorporate.com.cn>
Co-authored-by: NZhenxu Ke <kezhenxu94@apache.org>
Co-authored-by: NSegun Ogundipe <davephenoms@gmail.com>
Co-authored-by: Nxiagw <fxiaxiaoyu@gmail.com>
Co-authored-by: Nlinyanbin666 <35388422+linyanbin666@users.noreply.github.com>
Co-authored-by: Nlinyanbin <linyanbin@lizhi.fm>
Co-authored-by: Nqmengss <qmengss@users.noreply.github.com>
Co-authored-by: N蒙强 <mengqiang@zhongan.com>
Co-authored-by: N青年 <1043706593@qq.com>
Co-authored-by: Nlei.zou <lei.zou@rootcloud.com>
Co-authored-by: N小二黑 <784445949@qq.com>
Co-authored-by: N花花 <huahua@thinkingdata.cn>
Co-authored-by: Nliuxuedongcn <46193861+liuxuedongcn@users.noreply.github.com>
上级 ffc5420b
...@@ -46,18 +46,14 @@ jobs: ...@@ -46,18 +46,14 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
# In the checkout@v2, it doesn't support git submodule. Execute the commands manually. with:
- name: checkout submodules submodule: true
shell: bash - name: Check License Header
run: | uses: apache/skywalking-eyes@9bd5feb
git submodule sync --recursive
git -c protocol.version=2 submodule update --init --force --recursive --depth=1
- name: Set up JDK 1.8 - name: Set up JDK 1.8
uses: actions/setup-java@v1 uses: actions/setup-java@v1
with: with:
java-version: 1.8 java-version: 1.8
- name: Check license
run: ./mvnw -B apache-rat:check
- name: Compile - name: Compile
run: mvn -B clean compile install -Prelease -Dmaven.test.skip=true run: mvn -B clean compile install -Prelease -Dmaven.test.skip=true
- name: Check dependency license - name: Check dependency license
......
...@@ -30,12 +30,10 @@ jobs: ...@@ -30,12 +30,10 @@ jobs:
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
# In the checkout@v2, it doesn't support git submodule. Execute the commands manually. with:
- name: checkout submodules submodule: true
shell: bash - name: Check License Header
run: | uses: apache/skywalking-eyes@9bd5feb
git submodule sync --recursive
git -c protocol.version=2 submodule update --init --force --recursive --depth=1
- uses: actions/cache@v1 - uses: actions/cache@v1
with: with:
path: ~/.m2/repository path: ~/.m2/repository
......
...@@ -35,12 +35,8 @@ jobs: ...@@ -35,12 +35,8 @@ jobs:
os: [ubuntu-latest, macos-latest] os: [ubuntu-latest, macos-latest]
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
# In the checkout@v2, it doesn't support git submodule. Execute the commands manually. with:
- name: checkout submodules submodule: true
shell: bash
run: |
git submodule sync --recursive
git -c protocol.version=2 submodule update --init --force --recursive --depth=1
- name: Set up Node.js - name: Set up Node.js
uses: actions/setup-node@v1 uses: actions/setup-node@v1
with: with:
...@@ -52,19 +48,3 @@ jobs: ...@@ -52,19 +48,3 @@ jobs:
npm install npm install
npm run lint npm run lint
npm run build npm run build
License-check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
# In the checkout@v2, it doesn't support git submodule. Execute the commands manually.
- name: checkout submodules
shell: bash
run: |
git submodule sync --recursive
git -c protocol.version=2 submodule update --init --force --recursive --depth=1
- name: Set up JDK 1.8
uses: actions/setup-java@v1
with:
java-version: 1.8
- name: Check
run: mvn -B apache-rat:check
\ No newline at end of file
...@@ -33,12 +33,12 @@ jobs: ...@@ -33,12 +33,12 @@ jobs:
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
# In the checkout@v2, it doesn't support git submodule. Execute the commands manually. with:
- name: checkout submodules submodule: true
shell: bash - name: Check License Header
run: | uses: apache/skywalking-eyes@9bd5feb
git submodule sync --recursive env:
git -c protocol.version=2 submodule update --init --force --recursive --depth=1 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Only enable review / suggestion here
- uses: actions/cache@v1 - uses: actions/cache@v1
with: with:
path: ~/.m2/repository path: ~/.m2/repository
...@@ -98,12 +98,8 @@ jobs: ...@@ -98,12 +98,8 @@ jobs:
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v2 uses: actions/checkout@v2
# In the checkout@v2, it doesn't support git submodule. Execute the commands manually. with:
- name: checkout submodules submodule: true
shell: bash
run: |
git submodule sync --recursive
git -c protocol.version=2 submodule update --init --force --recursive --depth=1
- name: check code style - name: check code style
env: env:
WORKDIR: ./ WORKDIR: ./
...@@ -117,4 +113,4 @@ jobs: ...@@ -117,4 +113,4 @@ jobs:
| /opt/reviewdog -f=checkstyle \ | /opt/reviewdog -f=checkstyle \
-reporter="${INPUT_REPORTER:-github-pr-check}" \ -reporter="${INPUT_REPORTER:-github-pr-check}" \
-filter-mode="${INPUT_FILTER_MODE:-added}" \ -filter-mode="${INPUT_FILTER_MODE:-added}" \
-fail-on-error="${INPUT_FAIL_ON_ERROR:-false}" -fail-on-error="${INPUT_FAIL_ON_ERROR:-false}"
\ No newline at end of file
# Licensed to 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. Apache Software Foundation (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.
header:
license:
spdx-id: Apache-2.0
copyright-owner: Apache Software Foundation
paths-ignore:
- dist
- NOTICE
- LICENSE
- DISCLAIMER
- dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/ScriptRunner.java
- mvnw.cmd
- sql/soft_version
- .mvn
- .gitattributes
- '**/licenses/**/LICENSE-*'
- '**/*.md'
- '**/*.json'
- '**/*.iml'
- '**/.babelrc'
- '**/.eslintignore'
- '**/.gitignore'
- '**/LICENSE'
- '**/NOTICE'
comment: on-failure
Apache DolphinScheduler (incubating) is an effort undergoing incubation at The Apache Software Foundation (ASF), sponsored by the Apache Incubator PMC. Apache DolphinScheduler is an effort undergoing incubation at The Apache Software Foundation (ASF), sponsored by the Apache Incubator.
Incubation is required of all newly accepted projects until a further review indicates that the infrastructure, Incubation is required of all newly accepted projects until a further review indicates that the infrastructure,
communications, and decision making process have stabilized in a manner consistent with other successful ASF projects. communications, and decision making process have stabilized in a manner consistent with other successful ASF projects.
While incubation status is not necessarily a reflection of the completeness or stability of the code, While incubation status is not necessarily a reflection of the completeness or stability of the code,
......
Apache DolphinScheduler (incubating) Apache DolphinScheduler (incubating)
Copyright 2019-2020 The Apache Software Foundation Copyright 2019-2021 The Apache Software Foundation
This product includes software developed at This product includes software developed at
The Apache Software Foundation (http://www.apache.org/). The Apache Software Foundation (http://www.apache.org/).
......
...@@ -17,32 +17,33 @@ Dolphin Scheduler Official Website ...@@ -17,32 +17,33 @@ Dolphin Scheduler Official Website
### Design features: ### Design features:
A distributed and easy-to-extend visual DAG workflow scheduling system. Dedicated to solving the complex dependencies in data processing, making the scheduling system `out of the box` for data processing. Dolphin Scheduler is a distributed and easy-to-extend visual DAG workflow scheduling system. It dedicates to solving the complex dependencies in data processing to make the scheduling system `out of the box` for the data processing process.
Its main objectives are as follows: Its main objectives are as follows:
- Associate the Tasks according to the dependencies of the tasks in a DAG graph, which can visualize the running state of task in real time. - Associate the tasks according to the dependencies of the tasks in a DAG graph, which can visualize the running state of the task in real-time.
- Support for many task types: Shell, MR, Spark, SQL (mysql, postgresql, hive, sparksql), Python, Sub_Process, Procedure, etc. - Support many task types: Shell, MR, Spark, SQL (MySQL, PostgreSQL, hive, spark SQL), Python, Sub_Process, Procedure, etc.
- Support process scheduling, dependency scheduling, manual scheduling, manual pause/stop/recovery, support for failed retry/alarm, recovery from specified nodes, Kill task, etc. - Support process scheduling, dependency scheduling, manual scheduling, manual pause/stop/recovery, support for failed retry/alarm, recovery from specified nodes, Kill task, etc.
- Support process priority, task priority and task failover and task timeout alarm/failure - Support the priority of process & task, task failover, and task timeout alarm or failure.
- Support process global parameters and node custom parameter settings - Support process global parameters and node custom parameter settings.
- Support online upload/download of resource files, management, etc. Support online file creation and editing - Support online upload/download of resource files, management, etc. Support online file creation and editing.
- Support task log online viewing and scrolling, online download log, etc. - Support task log online viewing and scrolling, online download log, etc.
- Implement cluster HA, decentralize Master cluster and Worker cluster through Zookeeper - Implement cluster HA, decentralize Master cluster and Worker cluster through Zookeeper.
- Support online viewing of `Master/Worker` cpu load, memory - Support the viewing of Master/Worker CPU load, memory, and CPU usage metrics.
- Support process running history tree/gantt chart display, support task status statistics, process status statistics - Support presenting tree or Gantt chart of workflow history as well as the statistics results of task & process status in each workflow.
- Support backfilling data - Support backfilling data.
- Support multi-tenant - Support multi-tenant.
- Support internationalization - Support internationalization.
- There are more waiting partners to explore - There are more waiting for partners to explore...
### What's in Dolphin Scheduler ### What's in Dolphin Scheduler
Stability | Easy to use | Features | Scalability | Stability | Easy to use | Features | Scalability |
-- | -- | -- | -- -- | -- | -- | --
Decentralized multi-master and multi-worker | Visualization process defines key information such as task status, task type, retry times, task running machine, visual variables and so on at a glance.  |  Support pause, recover operation | support custom task types Decentralized multi-master and multi-worker | Visualization process defines key information such as task status, task type, retry times, task running machine, visual variables, and so on at a glance.  |  Support pause, recover operation | Support custom task types
HA is supported by itself | All process definition operations are visualized, dragging tasks to draw DAGs, configuring data sources and resources. At the same time, for third-party systems, the api mode operation is provided. | Users on DolphinScheduler can achieve many-to-one or one-to-one mapping relationship through tenants and Hadoop users, which is very important for scheduling large data jobs. " | The scheduler uses distributed scheduling, and the overall scheduling capability will increase linearly with the scale of the cluster. Master and Worker support dynamic online and offline. HA is supported by itself | All process definition operations are visualized, dragging tasks to draw DAGs, configuring data sources and resources. At the same time, for third-party systems, the API mode operation is provided. | Users on Dolphin Scheduler can achieve many-to-one or one-to-one mapping relationship through tenants and Hadoop users, which is very important for scheduling large data jobs. | The scheduler uses distributed scheduling, and the overall scheduling capability will increase linearly with the scale of the cluster. Master and Worker support dynamic online and offline.
Overload processing: Task queue mechanism, the number of schedulable tasks on a single machine can be flexibly configured, when too many tasks will be cached in the task queue, will not cause machine jam. | One-click deployment | Supports traditional shell tasks, and also support big data platform task scheduling: MR, Spark, SQL (mysql, postgresql, hive, sparksql), Python, Procedure, Sub_Process | | Overload processing: Overload processing: By using the task queue mechanism, the number of schedulable tasks on a single machine can be flexibly configured. Machine jam can be avoided with high tolerance to numbers of tasks cached in task queue. | One-click deployment | Support traditional shell tasks, and big data platform task scheduling: MR, Spark, SQL (MySQL, PostgreSQL, hive, spark SQL), Python, Procedure, Sub_Process | |
### System partial screenshot ### System partial screenshot
...@@ -55,17 +56,14 @@ Overload processing: Task queue mechanism, the number of schedulable tasks on a ...@@ -55,17 +56,14 @@ Overload processing: Task queue mechanism, the number of schedulable tasks on a
![monitor](https://user-images.githubusercontent.com/59273635/75625839-c698a480-5bfc-11ea-8bbe-895b561b337f.png) ![monitor](https://user-images.githubusercontent.com/59273635/75625839-c698a480-5bfc-11ea-8bbe-895b561b337f.png)
![security](https://user-images.githubusercontent.com/15833811/75236441-bfd2f180-57f8-11ea-88bd-f24311e01b7e.png) ![security](https://user-images.githubusercontent.com/15833811/75236441-bfd2f180-57f8-11ea-88bd-f24311e01b7e.png)
![treeview](https://user-images.githubusercontent.com/15833811/75217191-3fe56100-57d1-11ea-8856-f19180d9a879.png) ![treeview](https://user-images.githubusercontent.com/15833811/75217191-3fe56100-57d1-11ea-8856-f19180d9a879.png)
### Online Demo
- <a href="http://106.75.43.194:8888" target="_blank">Online Demo</a>
### Recent R&D plan ### Recent R&D plan
Work plan of Dolphin Scheduler: [R&D plan](https://github.com/apache/incubator-dolphinscheduler/projects/1), Under the `In Develop` card is what is currently being developed, TODO card is to be done (including feature ideas) The work plan of Dolphin Scheduler: [R&D plan](https://github.com/apache/incubator-dolphinscheduler/projects/1), which `In Develop` card shows the features that are currently being developed and TODO card lists what needs to be done(including feature ideas).
### How to contribute ### How to contribute
Welcome to participate in contributing, please refer to the process of submitting the code: Welcome to participate in contributing, please refer to this website to find out more: [[How to contribute](https://dolphinscheduler.apache.org/en-us/docs/development/contribute.html)]
[[How to contribute](https://dolphinscheduler.apache.org/en-us/docs/development/contribute.html)]
### How to Build ### How to Build
...@@ -82,15 +80,15 @@ dolphinscheduler-dist/target/apache-dolphinscheduler-incubating-${latest.release ...@@ -82,15 +80,15 @@ dolphinscheduler-dist/target/apache-dolphinscheduler-incubating-${latest.release
### Thanks ### Thanks
Dolphin Scheduler uses a lot of excellent open source projects, such as google guava, guice, grpc, netty, ali bonecp, quartz, and many open source projects of apache, etc. Dolphin Scheduler is based on a lot of excellent open-source projects, such as google guava, guice, grpc, netty, ali bonecp, quartz, and many open-source projects of Apache and so on.
It is because of the shoulders of these open source projects that the birth of the Dolphin Scheduler is possible. We are very grateful for all the open source software used! We also hope that we will not only be the beneficiaries of open source, but also be open source contributors. We also hope that partners who have the same passion and conviction for open source will join in and contribute to open source! We would like to express our deep gratitude to all the open-source projects which contribute to making the dream of Dolphin Scheduler comes true. We hope that we are not only the beneficiaries of open-source, but also give back to the community. Besides, we expect the partners who have the same passion and conviction to open-source will join in and contribute to the open-source community!
### Get Help ### Get Help
1. Submit an issue 1. Submit an issue
1. Subscribe the mail list : https://dolphinscheduler.apache.org/en-us/docs/development/subscribe.html. then send mail to dev@dolphinscheduler.apache.org 1. Subscribe to the mail list: https://dolphinscheduler.apache.org/en-us/docs/development/subscribe.html, then email dev@dolphinscheduler.apache.org
1. Slack channel: [![Slack Status](https://img.shields.io/badge/slack-join_chat-white.svg?logo=slack&style=social)](https://join.slack.com/share/zt-do3gvfhj-UUhrAX2GxkVX_~JJt1jpKA)
1. Contact WeChat(dailidong66). This is just for Mandarin(CN) discussion.
### License ### License
Please refer to [LICENSE](https://github.com/apache/incubator-dolphinscheduler/blob/dev/LICENSE) file. Please refer to the [LICENSE](https://github.com/apache/incubator-dolphinscheduler/blob/dev/LICENSE) file.
...@@ -50,10 +50,6 @@ Dolphin Scheduler Official Website ...@@ -50,10 +50,6 @@ Dolphin Scheduler Official Website
![security](https://user-images.githubusercontent.com/15833811/75209633-baa28200-57b9-11ea-9def-94bef2e212a7.jpg) ![security](https://user-images.githubusercontent.com/15833811/75209633-baa28200-57b9-11ea-9def-94bef2e212a7.jpg)
### 我要体验
- <a href="http://106.75.43.194:8888" target="_blank">我要体验</a>
### 近期研发计划 ### 近期研发计划
...@@ -86,7 +82,6 @@ Dolphin Scheduler使用了很多优秀的开源项目,比如google的guava、g ...@@ -86,7 +82,6 @@ Dolphin Scheduler使用了很多优秀的开源项目,比如google的guava、g
### 获得帮助 ### 获得帮助
1. 提交issue 1. 提交issue
1. 先订阅邮件开发列表:[订阅邮件列表](https://dolphinscheduler.apache.org/zh-cn/docs/development/subscribe.html), 订阅成功后发送邮件到dev@dolphinscheduler.apache.org. 1. 先订阅邮件开发列表:[订阅邮件列表](https://dolphinscheduler.apache.org/zh-cn/docs/development/subscribe.html), 订阅成功后发送邮件到dev@dolphinscheduler.apache.org.
1. 联系微信群助手(ID:dailidong66). 微信仅用于中国用户讨论.
### 版权 ### 版权
请参考 [LICENSE](https://github.com/apache/incubator-dolphinscheduler/blob/dev/LICENSE) 文件. 请参考 [LICENSE](https://github.com/apache/incubator-dolphinscheduler/blob/dev/LICENSE) 文件.
......
...@@ -24,7 +24,8 @@ printenv ...@@ -24,7 +24,8 @@ printenv
if [ -z "${VERSION}" ] if [ -z "${VERSION}" ]
then then
echo "set default environment variable [VERSION]" echo "set default environment variable [VERSION]"
export VERSION=$(cat $(pwd)/pom.xml | grep '<version>' -m 1 | awk '{print $1}' | sed 's/<version>//' | sed 's/<\/version>//') VERSION=$(grep '<version>' -m 1 "$(pwd)"/pom.xml | awk '{print $1}' | sed 's/<version>//' | sed 's/<\/version>//')
export VERSION
fi fi
if [ "${DOCKER_REPO}x" = "x" ] if [ "${DOCKER_REPO}x" = "x" ]
...@@ -44,10 +45,10 @@ mvn -B clean compile package -Prelease -Dmaven.test.skip=true ...@@ -44,10 +45,10 @@ mvn -B clean compile package -Prelease -Dmaven.test.skip=true
# mv dolphinscheduler-bin.tar.gz file to docker/build directory # mv dolphinscheduler-bin.tar.gz file to docker/build directory
echo -e "mv $(pwd)/dolphinscheduler-dist/target/apache-dolphinscheduler-incubating-${VERSION}-dolphinscheduler-bin.tar.gz $(pwd)/docker/build/\n" echo -e "mv $(pwd)/dolphinscheduler-dist/target/apache-dolphinscheduler-incubating-${VERSION}-dolphinscheduler-bin.tar.gz $(pwd)/docker/build/\n"
mv $(pwd)/dolphinscheduler-dist/target/apache-dolphinscheduler-incubating-${VERSION}-dolphinscheduler-bin.tar.gz $(pwd)/docker/build/ mv "$(pwd)"/dolphinscheduler-dist/target/apache-dolphinscheduler-incubating-"${VERSION}"-dolphinscheduler-bin.tar.gz $(pwd)/docker/build/
# docker build # docker build
echo -e "docker build --build-arg VERSION=${VERSION} -t $DOCKER_REPO:${VERSION} $(pwd)/docker/build/\n" echo -e "docker build --build-arg VERSION=${VERSION} -t $DOCKER_REPO:${VERSION} $(pwd)/docker/build/\n"
sudo docker build --build-arg VERSION=${VERSION} -t $DOCKER_REPO:${VERSION} $(pwd)/docker/build/ sudo docker build --build-arg VERSION="${VERSION}" -t $DOCKER_REPO:"${VERSION}" "$(pwd)/docker/build/"
echo "------ dolphinscheduler end - build -------" echo "------ dolphinscheduler end - build -------"
...@@ -19,6 +19,6 @@ ...@@ -19,6 +19,6 @@
echo "------ push start -------" echo "------ push start -------"
printenv printenv
docker push $DOCKER_REPO:${VERSION} docker push "$DOCKER_REPO:${VERSION}"
echo "------ push end -------" echo "------ push end -------"
#
# 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.
#
dependencies:
- name: postgresql
version: 8.x.x
repository: https://charts.bitnami.com/bitnami
condition: postgresql.enabled
- name: zookeeper
version: 5.x.x
repository: https://charts.bitnami.com/bitnami
condition: redis.enabled
\ No newline at end of file
#
# 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.
#
dependencies:
- name: postgresql
version: 8.x.x
repository: https://charts.bitnami.com/bitnami
condition: postgresql.enabled
- name: zookeeper
version: 5.x.x
repository: https://charts.bitnami.com/bitnami
condition: redis.enabled
\ No newline at end of file
...@@ -35,7 +35,7 @@ import java.util.List; ...@@ -35,7 +35,7 @@ import java.util.List;
public class DingTalkAlertChannelFactory implements AlertChannelFactory { public class DingTalkAlertChannelFactory implements AlertChannelFactory {
@Override @Override
public String getName() { public String getName() {
return "ding talk alert"; return "DingTalk";
} }
@Override @Override
...@@ -56,24 +56,24 @@ public class DingTalkAlertChannelFactory implements AlertChannelFactory { ...@@ -56,24 +56,24 @@ public class DingTalkAlertChannelFactory implements AlertChannelFactory {
.addParamsOptions(new ParamsOptions("NO", false, false)) .addParamsOptions(new ParamsOptions("NO", false, false))
.setValue(true) .setValue(true)
.addValidate(Validate.newBuilder() .addValidate(Validate.newBuilder()
.setRequired(true) .setRequired(false)
.build()) .build())
.build(); .build();
InputParam proxyParam = InputParam proxyParam =
InputParam.newBuilder(DingTalkParamsConstants.NAME_DING_TALK_PROXY, DingTalkParamsConstants.DING_TALK_PROXY) InputParam.newBuilder(DingTalkParamsConstants.NAME_DING_TALK_PROXY, DingTalkParamsConstants.DING_TALK_PROXY)
.addValidate(Validate.newBuilder() .addValidate(Validate.newBuilder()
.setRequired(true).build()) .setRequired(false).build())
.build(); .build();
InputParam portParam = InputParam.newBuilder(DingTalkParamsConstants.NAME_DING_TALK_PORT, DingTalkParamsConstants.DING_TALK_PORT) InputParam portParam = InputParam.newBuilder(DingTalkParamsConstants.NAME_DING_TALK_PORT, DingTalkParamsConstants.DING_TALK_PORT)
.addValidate(Validate.newBuilder() .addValidate(Validate.newBuilder()
.setRequired(true).build()) .setRequired(false).build())
.build(); .build();
InputParam userParam = InputParam userParam =
InputParam.newBuilder(DingTalkParamsConstants.NAME_DING_TALK_USER, DingTalkParamsConstants.DING_TALK_USER) InputParam.newBuilder(DingTalkParamsConstants.NAME_DING_TALK_USER, DingTalkParamsConstants.DING_TALK_USER)
.addValidate(Validate.newBuilder() .addValidate(Validate.newBuilder()
.setRequired(true).build()) .setRequired(false).build())
.build(); .build();
PasswordParam passwordParam = PasswordParam.newBuilder(DingTalkParamsConstants.NAME_DING_TALK_PASSWORD, DingTalkParamsConstants.DING_TALK_PASSWORD) PasswordParam passwordParam = PasswordParam.newBuilder(DingTalkParamsConstants.NAME_DING_TALK_PASSWORD, DingTalkParamsConstants.DING_TALK_PASSWORD)
.setPlaceholder("if enable use authentication, you need input password") .setPlaceholder("if enable use authentication, you need input password")
......
...@@ -22,6 +22,9 @@ package org.apache.dolphinscheduler.plugin.alert.dingtalk; ...@@ -22,6 +22,9 @@ package org.apache.dolphinscheduler.plugin.alert.dingtalk;
*/ */
public class DingTalkParamsConstants { public class DingTalkParamsConstants {
public DingTalkParamsConstants() {
throw new IllegalStateException("Utility class");
}
static final String DING_TALK_WEB_HOOK = "dingtalk.webhook"; static final String DING_TALK_WEB_HOOK = "dingtalk.webhook";
......
...@@ -113,7 +113,7 @@ public class DingTalkSender { ...@@ -113,7 +113,7 @@ public class DingTalkSender {
} finally { } finally {
response.close(); response.close();
} }
logger.info("Ding Talk send [%s], resp:{%s}", msg, resp); logger.info("Ding Talk send [ %s ], resp:{%s}", msg, resp);
return resp; return resp;
} finally { } finally {
httpClient.close(); httpClient.close();
......
...@@ -38,7 +38,7 @@ import java.util.List; ...@@ -38,7 +38,7 @@ import java.util.List;
public class EmailAlertChannelFactory implements AlertChannelFactory { public class EmailAlertChannelFactory implements AlertChannelFactory {
@Override @Override
public String getName() { public String getName() {
return "email alert"; return "Email";
} }
@Override @Override
......
...@@ -44,13 +44,17 @@ import org.slf4j.LoggerFactory; ...@@ -44,13 +44,17 @@ import org.slf4j.LoggerFactory;
*/ */
public class ExcelUtils { public class ExcelUtils {
public ExcelUtils() {
throw new IllegalStateException("Utility class");
}
private static final Logger logger = LoggerFactory.getLogger(ExcelUtils.class); private static final Logger logger = LoggerFactory.getLogger(ExcelUtils.class);
/** /**
* generate excel file * generate excel file
* *
* @param content the content * @param content the content
* @param title the title * @param title the title
* @param xlsFilePath the xls path * @param xlsFilePath the xls path
*/ */
public static void genExcelFile(String content, String title, String xlsFilePath) { public static void genExcelFile(String content, String title, String xlsFilePath) {
......
...@@ -22,40 +22,44 @@ package org.apache.dolphinscheduler.plugin.alert.email; ...@@ -22,40 +22,44 @@ package org.apache.dolphinscheduler.plugin.alert.email;
*/ */
public class MailParamsConstants { public class MailParamsConstants {
public static final String PLUGIN_DEFAULT_EMAIL_RECEIVERS = "receivers"; public MailParamsConstants() {
throw new IllegalStateException("Utility class");
}
public static final String PLUGIN_DEFAULT_EMAIL_RECEIVERS = "$t('receivers')";
public static final String NAME_PLUGIN_DEFAULT_EMAIL_RECEIVERS = "receivers"; public static final String NAME_PLUGIN_DEFAULT_EMAIL_RECEIVERS = "receivers";
public static final String PLUGIN_DEFAULT_EMAIL_RECEIVERCCS = "receiverCcs"; public static final String PLUGIN_DEFAULT_EMAIL_RECEIVERCCS = "$t('receiverCcs')";
public static final String NAME_PLUGIN_DEFAULT_EMAIL_RECEIVERCCS = "receiverCcs"; public static final String NAME_PLUGIN_DEFAULT_EMAIL_RECEIVERCCS = "receiverCcs";
public static final String MAIL_PROTOCOL = "mail.transport.protocol"; public static final String MAIL_PROTOCOL = "transport.protocol";
public static final String NAME_MAIL_PROTOCOL = "mailProtocol"; public static final String NAME_MAIL_PROTOCOL = "protocol";
public static final String MAIL_SMTP_HOST = "mail.smtp.host"; public static final String MAIL_SMTP_HOST = "smtp.host";
public static final String NAME_MAIL_SMTP_HOST = "mailServerHost"; public static final String NAME_MAIL_SMTP_HOST = "serverHost";
public static final String MAIL_SMTP_PORT = "mail.smtp.port"; public static final String MAIL_SMTP_PORT = "smtp.port";
public static final String NAME_MAIL_SMTP_PORT = "mailServerPort"; public static final String NAME_MAIL_SMTP_PORT = "serverPort";
public static final String MAIL_SENDER = "mail.sender"; public static final String MAIL_SENDER = "sender";
public static final String NAME_MAIL_SENDER = "mailSender"; public static final String NAME_MAIL_SENDER = "sender";
public static final String MAIL_SMTP_AUTH = "mail.smtp.auth"; public static final String MAIL_SMTP_AUTH = "smtp.auth";
public static final String NAME_MAIL_SMTP_AUTH = "enableSmtpAuth"; public static final String NAME_MAIL_SMTP_AUTH = "enableSmtpAuth";
public static final String MAIL_USER = "mail.user"; public static final String MAIL_USER = "user";
public static final String NAME_MAIL_USER = "mailUser"; public static final String NAME_MAIL_USER = "user";
public static final String MAIL_PASSWD = "mail.passwd"; public static final String MAIL_PASSWD = "passwd";
public static final String NAME_MAIL_PASSWD = "mailPasswd"; public static final String NAME_MAIL_PASSWD = "passwd";
public static final String MAIL_SMTP_STARTTLS_ENABLE = "mail.smtp.starttls.enable"; public static final String MAIL_SMTP_STARTTLS_ENABLE = "smtp.starttls.enable";
public static final String NAME_MAIL_SMTP_STARTTLS_ENABLE = "starttlsEnable"; public static final String NAME_MAIL_SMTP_STARTTLS_ENABLE = "starttlsEnable";
public static final String MAIL_SMTP_SSL_ENABLE = "mail.smtp.ssl.enable"; public static final String MAIL_SMTP_SSL_ENABLE = "smtp.ssl.enable";
public static final String NAME_MAIL_SMTP_SSL_ENABLE = "sslEnable"; public static final String NAME_MAIL_SMTP_SSL_ENABLE = "sslEnable";
public static final String MAIL_SMTP_SSL_TRUST = "mail.smtp.ssl.trust"; public static final String MAIL_SMTP_SSL_TRUST = "smtp.ssl.trust";
public static final String NAME_MAIL_SMTP_SSL_TRUST = "mailSmtpSslTrust"; public static final String NAME_MAIL_SMTP_SSL_TRUST = "smtpSslTrust";
} }
...@@ -58,7 +58,7 @@ public class EmailAlertChannelFactoryTest { ...@@ -58,7 +58,7 @@ public class EmailAlertChannelFactoryTest {
public void testGetParams() throws Exception { public void testGetParams() throws Exception {
EmailAlertChannelFactory emailAlertChannelFactory = new EmailAlertChannelFactory(); EmailAlertChannelFactory emailAlertChannelFactory = new EmailAlertChannelFactory();
List<PluginParams> params = emailAlertChannelFactory.getParams(); List<PluginParams> params = emailAlertChannelFactory.getParams();
JSONUtils.toJsonString(params); System.out.println(JSONUtils.toJsonString(params));
Assert.assertEquals(12, params.size()); Assert.assertEquals(12, params.size());
} }
......
...@@ -35,32 +35,19 @@ import java.util.ArrayList; ...@@ -35,32 +35,19 @@ import java.util.ArrayList;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import org.junit.After;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Before;
import org.junit.Test; import org.junit.Test;
/** /**
* EmailAlertChannel Tester. * EmailAlertChannel Tester.
*
* @version 1.0
* @since <pre>Aug 20, 2020</pre>
*/ */
public class EmailAlertChannelTest { public class EmailAlertChannelTest {
@Before
public void before() throws Exception {
}
@After
public void after() throws Exception {
}
/** /**
* Method: process(AlertInfo info) * Method: process(AlertInfo info)
*/ */
@Test @Test
public void testProcess() throws Exception { public void testProcess() {
EmailAlertChannel emailAlertChannel = new EmailAlertChannel(); EmailAlertChannel emailAlertChannel = new EmailAlertChannel();
AlertData alertData = new AlertData(); AlertData alertData = new AlertData();
LinkedHashMap<String, Object> map1 = new LinkedHashMap<>(); LinkedHashMap<String, Object> map1 = new LinkedHashMap<>();
...@@ -92,12 +79,12 @@ public class EmailAlertChannelTest { ...@@ -92,12 +79,12 @@ public class EmailAlertChannelTest {
.addValidate(Validate.newBuilder().setRequired(true).build()) .addValidate(Validate.newBuilder().setRequired(true).build())
.build(); .build();
InputParam mailSmtpHost = InputParam.newBuilder("mailServerHost", "mail.smtp.host") InputParam mailSmtpHost = InputParam.newBuilder("serverHost", "smtp.host")
.addValidate(Validate.newBuilder().setRequired(true).build()) .addValidate(Validate.newBuilder().setRequired(true).build())
.setValue("smtp.126.com") .setValue("smtp.126.com")
.build(); .build();
InputParam mailSmtpPort = InputParam.newBuilder("mailServerPort", "mail.smtp.port") InputParam mailSmtpPort = InputParam.newBuilder("serverPort", "smtp.port")
.addValidate(Validate.newBuilder() .addValidate(Validate.newBuilder()
.setRequired(true) .setRequired(true)
.setType(DataType.NUMBER.getDataType()) .setType(DataType.NUMBER.getDataType())
...@@ -105,43 +92,43 @@ public class EmailAlertChannelTest { ...@@ -105,43 +92,43 @@ public class EmailAlertChannelTest {
.setValue(25) .setValue(25)
.build(); .build();
InputParam mailSender = InputParam.newBuilder("mailSender", "mail.sender") InputParam mailSender = InputParam.newBuilder("sender", "sender")
.addValidate(Validate.newBuilder().setRequired(true).build()) .addValidate(Validate.newBuilder().setRequired(true).build())
.setValue("dolphinscheduler@126.com") .setValue("dolphinscheduler@126.com")
.build(); .build();
RadioParam enableSmtpAuth = RadioParam.newBuilder("enableSmtpAuth", "mail.smtp.auth") RadioParam enableSmtpAuth = RadioParam.newBuilder("enableSmtpAuth", "smtp.auth")
.addParamsOptions(new ParamsOptions("YES", true, false)) .addParamsOptions(new ParamsOptions("YES", true, false))
.addParamsOptions(new ParamsOptions("NO", false, false)) .addParamsOptions(new ParamsOptions("NO", false, false))
.addValidate(Validate.newBuilder().setRequired(true).build()) .addValidate(Validate.newBuilder().setRequired(true).build())
.setValue(false) .setValue(false)
.build(); .build();
InputParam mailUser = InputParam.newBuilder("mailUser", "mail.user") InputParam mailUser = InputParam.newBuilder("user", "user")
.setPlaceholder("if enable use authentication, you need input user") .setPlaceholder("if enable use authentication, you need input user")
.setValue("dolphinscheduler@126.com") .setValue("dolphinscheduler@126.com")
.build(); .build();
PasswordParam mailPassword = PasswordParam.newBuilder("mailPasswd", "mail.passwd") PasswordParam mailPassword = PasswordParam.newBuilder("passwd", "passwd")
.setPlaceholder("if enable use authentication, you need input password") .setPlaceholder("if enable use authentication, you need input password")
.setValue("escheduler123") .setValue("escheduler123")
.build(); .build();
RadioParam enableTls = RadioParam.newBuilder("starttlsEnable", "mail.smtp.starttls.enable") RadioParam enableTls = RadioParam.newBuilder("starttlsEnable", "starttls.enable")
.addParamsOptions(new ParamsOptions("YES", true, false)) .addParamsOptions(new ParamsOptions("YES", true, false))
.addParamsOptions(new ParamsOptions("NO", false, false)) .addParamsOptions(new ParamsOptions("NO", false, false))
.addValidate(Validate.newBuilder().setRequired(true).build()) .addValidate(Validate.newBuilder().setRequired(true).build())
.setValue(true) .setValue(true)
.build(); .build();
RadioParam enableSsl = RadioParam.newBuilder("sslEnable", "mail.smtp.ssl.enable") RadioParam enableSsl = RadioParam.newBuilder("sslEnable", "smtp.ssl.enable")
.addParamsOptions(new ParamsOptions("YES", true, false)) .addParamsOptions(new ParamsOptions("YES", true, false))
.addParamsOptions(new ParamsOptions("NO", false, false)) .addParamsOptions(new ParamsOptions("NO", false, false))
.addValidate(Validate.newBuilder().setRequired(true).build()) .addValidate(Validate.newBuilder().setRequired(true).build())
.setValue(true) .setValue(true)
.build(); .build();
InputParam sslTrust = InputParam.newBuilder("mailSmtpSslTrust", "mail.smtp.ssl.trust") InputParam sslTrust = InputParam.newBuilder("smtpSslTrust", "smtp.ssl.trust")
.addValidate(Validate.newBuilder().setRequired(true).build()) .addValidate(Validate.newBuilder().setRequired(true).build())
.setValue("smtp.126.com") .setValue("smtp.126.com")
.build(); .build();
......
...@@ -32,7 +32,7 @@ import java.util.List; ...@@ -32,7 +32,7 @@ import java.util.List;
public class HttpAlertChannelFactory implements AlertChannelFactory { public class HttpAlertChannelFactory implements AlertChannelFactory {
@Override @Override
public String getName() { public String getName() {
return "http alert"; return "Http";
} }
@Override @Override
......
...@@ -35,7 +35,7 @@ public class ScriptAlertChannelFactory implements AlertChannelFactory { ...@@ -35,7 +35,7 @@ public class ScriptAlertChannelFactory implements AlertChannelFactory {
@Override @Override
public String getName() { public String getName() {
return "script alert"; return "Script";
} }
@Override @Override
......
...@@ -22,15 +22,19 @@ package org.apache.dolphinscheduler.plugin.alert.script; ...@@ -22,15 +22,19 @@ package org.apache.dolphinscheduler.plugin.alert.script;
*/ */
public class ScriptParamsConstants { public class ScriptParamsConstants {
static final String SCRIPT_TYPE = "script.type"; public ScriptParamsConstants() {
throw new IllegalStateException("Utility class");
}
static final String NAME_SCRIPT_TYPE = "scriptType"; static final String SCRIPT_TYPE = "type";
static final String SCRIPT_PATH = "script.path"; static final String NAME_SCRIPT_TYPE = "type";
static final String NAME_SCRIPT_PATH = "scriptPath"; static final String SCRIPT_PATH = "path";
static final String SCRIPT_USER_PARAMS = "script.user.params"; static final String NAME_SCRIPT_PATH = "path";
static final String NAME_SCRIPT_USER_PARAMS = "scriptUserParams"; static final String SCRIPT_USER_PARAMS = "user.params";
static final String NAME_SCRIPT_USER_PARAMS = "userParams";
} }
...@@ -37,7 +37,7 @@ public class WeChatAlertChannelFactory implements AlertChannelFactory { ...@@ -37,7 +37,7 @@ public class WeChatAlertChannelFactory implements AlertChannelFactory {
@Override @Override
public String getName() { public String getName() {
return "we chat alert"; return "WeChat";
} }
@Override @Override
......
...@@ -23,34 +23,34 @@ package org.apache.dolphinscheduler.plugin.alert.wechat; ...@@ -23,34 +23,34 @@ package org.apache.dolphinscheduler.plugin.alert.wechat;
public class WeChatAlertParamsConstants { public class WeChatAlertParamsConstants {
static final String ENTERPRISE_WE_CHAT_CORP_ID = "enterprise.wechat.corp.id"; static final String ENTERPRISE_WE_CHAT_CORP_ID = "corp.id";
static final String NAME_ENTERPRISE_WE_CHAT_CORP_ID = "enterpriseWeChatCorpId"; static final String NAME_ENTERPRISE_WE_CHAT_CORP_ID = "corpId";
static final String ENTERPRISE_WE_CHAT_SECRET = "enterprise.wechat.secret"; static final String ENTERPRISE_WE_CHAT_SECRET = "secret";
static final String NAME_ENTERPRISE_WE_CHAT_SECRET = "enterpriseWeChatSecret"; static final String NAME_ENTERPRISE_WE_CHAT_SECRET = "secret";
static final String ENTERPRISE_WE_CHAT_TEAM_SEND_MSG = "enterprise.wechat.team.send.msg"; static final String ENTERPRISE_WE_CHAT_TEAM_SEND_MSG = "team.send.msg";
static final String NAME_ENTERPRISE_WE_CHAT_TEAM_SEND_MSG = "enterpriseWeChatTeamSendMsg"; static final String NAME_ENTERPRISE_WE_CHAT_TEAM_SEND_MSG = "teamSendMsg";
static final String ENTERPRISE_WE_CHAT_USER_SEND_MSG = "enterprise.wechat.user.send.msg"; static final String ENTERPRISE_WE_CHAT_USER_SEND_MSG = "user.send.msg";
static final String NAME_ENTERPRISE_WE_CHAT_USER_SEND_MSG = "enterpriseWeChatUserSendMsg"; static final String NAME_ENTERPRISE_WE_CHAT_USER_SEND_MSG = "userSendMsg";
static final String ENTERPRISE_WE_CHAT_AGENT_ID = "enterprise.wechat.agent.id"; static final String ENTERPRISE_WE_CHAT_AGENT_ID = "agent.id";
static final String NAME_ENTERPRISE_WE_CHAT_AGENT_ID = "enterpriseWeChatAgentId"; static final String NAME_ENTERPRISE_WE_CHAT_AGENT_ID = "agentId";
static final String ENTERPRISE_WE_CHAT_USERS = "enterprise.wechat.users"; static final String ENTERPRISE_WE_CHAT_USERS = "users";
static final String NAME_ENTERPRISE_WE_CHAT_USERS = "enterpriseWeChatUsers"; static final String NAME_ENTERPRISE_WE_CHAT_USERS = "users";
} }
...@@ -90,8 +90,8 @@ public class WeChatSender { ...@@ -90,8 +90,8 @@ public class WeChatSender {
showType = config.get(AlertConstants.SHOW_TYPE); showType = config.get(AlertConstants.SHOW_TYPE);
requireNonNull(showType, AlertConstants.SHOW_TYPE + " must not null"); requireNonNull(showType, AlertConstants.SHOW_TYPE + " must not null");
weChatTokenUrlReplace = weChatTokenUrl weChatTokenUrlReplace = weChatTokenUrl
.replace(corpIdRegex, weChatCorpId) .replace(corpIdRegex, weChatCorpId)
.replace(secretRegex, weChatSecret); .replace(secretRegex, weChatSecret);
weChatToken = getToken(); weChatToken = getToken();
} }
...@@ -106,8 +106,8 @@ public class WeChatSender { ...@@ -106,8 +106,8 @@ public class WeChatSender {
private String makeUserSendMsg(Collection<String> toUser, String agentId, String msg) { private String makeUserSendMsg(Collection<String> toUser, String agentId, String msg) {
String listUser = mkString(toUser); String listUser = mkString(toUser);
return weChatUserSendMsg.replace(userRegExp, listUser) return weChatUserSendMsg.replace(userRegExp, listUser)
.replace(agentIdRegExp, agentId) .replace(agentIdRegExp, agentId)
.replace(msgRegExp, msg); .replace(msgRegExp, msg);
} }
/** /**
...@@ -117,11 +117,18 @@ public class WeChatSender { ...@@ -117,11 +117,18 @@ public class WeChatSender {
* @throws Exception the Exception * @throws Exception the Exception
*/ */
public AlertResult sendEnterpriseWeChat(String title, String content) { public AlertResult sendEnterpriseWeChat(String title, String content) {
AlertResult alertResult;
List<String> userList = Arrays.asList(weChatUsers.split(",")); List<String> userList = Arrays.asList(weChatUsers.split(","));
String data = markdownByAlert(title, content); String data = markdownByAlert(title, content);
String msg = makeUserSendMsg(userList, weChatAgentId, data); String msg = makeUserSendMsg(userList, weChatAgentId, data);
if (null == weChatToken) {
alertResult = new AlertResult();
alertResult.setMessage("send we chat alert fail,get weChat token error");
alertResult.setStatus("false");
return alertResult;
}
String enterpriseWeChatPushUrlReplace = WeChatAlertConstants.WE_CHAT_PUSH_URL.replace(tokenRegex, weChatToken); String enterpriseWeChatPushUrlReplace = WeChatAlertConstants.WE_CHAT_PUSH_URL.replace(tokenRegex, weChatToken);
AlertResult alertResult;
try { try {
return checkWeChatSendMsgResult(post(enterpriseWeChatPushUrlReplace, msg)); return checkWeChatSendMsgResult(post(enterpriseWeChatPushUrlReplace, msg));
} catch (Exception e) { } catch (Exception e) {
...@@ -147,7 +154,7 @@ public class WeChatSender { ...@@ -147,7 +154,7 @@ public class WeChatSender {
response.close(); response.close();
} }
logger.info("Enterprise WeChat send [{}], param:{}, resp:{}", logger.info("Enterprise WeChat send [{}], param:{}, resp:{}",
url, data, resp); url, data, resp);
return resp; return resp;
} }
} }
...@@ -253,7 +260,7 @@ public class WeChatSender { ...@@ -253,7 +260,7 @@ public class WeChatSender {
} }
HashMap map = JSONUtils.parseObject(resp, HashMap.class); HashMap map = JSONUtils.parseObject(resp, HashMap.class);
if (map != null) { if (map != null && null != map.get("access_token")) {
return map.get("access_token").toString(); return map.get("access_token").toString();
} else { } else {
return null; return null;
......
...@@ -58,9 +58,9 @@ public class WeChatSenderTest { ...@@ -58,9 +58,9 @@ public class WeChatSenderTest {
@Before @Before
public void initDingTalkConfig() { public void initDingTalkConfig() {
// Just for this test, I will delete these configurations before this PR is merged // Just for this test, I will delete these configurations before this PR is merged
weChatConfig.put(WeChatAlertParamsConstants.NAME_ENTERPRISE_WE_CHAT_AGENT_ID, "1000002"); weChatConfig.put(WeChatAlertParamsConstants.NAME_ENTERPRISE_WE_CHAT_AGENT_ID, "100000");
weChatConfig.put(WeChatAlertParamsConstants.NAME_ENTERPRISE_WE_CHAT_CORP_ID, "ww8cc690c06761eaa3"); weChatConfig.put(WeChatAlertParamsConstants.NAME_ENTERPRISE_WE_CHAT_CORP_ID, "NAME_ENTERPRISE_WE_CHAT_CORP_ID");
weChatConfig.put(WeChatAlertParamsConstants.NAME_ENTERPRISE_WE_CHAT_SECRET, "MYL0_O91ICNrdjkAhgeXIOAj4gEKIirf0-xoYnA25vg"); weChatConfig.put(WeChatAlertParamsConstants.NAME_ENTERPRISE_WE_CHAT_SECRET, "NAME_ENTERPRISE_WE_CHAT_SECRET");
weChatConfig.put(WeChatAlertParamsConstants.NAME_ENTERPRISE_WE_CHAT_USER_SEND_MSG, "{\"touser\":\"{toUser}\",\"agentid\":{agentId}" weChatConfig.put(WeChatAlertParamsConstants.NAME_ENTERPRISE_WE_CHAT_USER_SEND_MSG, "{\"touser\":\"{toUser}\",\"agentid\":{agentId}"
+ +
",\"msgtype\":\"markdown\",\"markdown\":{\"content\":\"{msg}\"}}" ",\"msgtype\":\"markdown\",\"markdown\":{\"content\":\"{msg}\"}}"
...@@ -75,7 +75,7 @@ public class WeChatSenderTest { ...@@ -75,7 +75,7 @@ public class WeChatSenderTest {
WeChatSender weChatSender = new WeChatSender(weChatConfig); WeChatSender weChatSender = new WeChatSender(weChatConfig);
AlertResult alertResult = weChatSender.sendEnterpriseWeChat("test", content); AlertResult alertResult = weChatSender.sendEnterpriseWeChat("test", content);
Assert.assertEquals("true", alertResult.getStatus()); Assert.assertEquals("false", alertResult.getStatus());
} }
@Test @Test
...@@ -83,7 +83,7 @@ public class WeChatSenderTest { ...@@ -83,7 +83,7 @@ public class WeChatSenderTest {
weChatConfig.put(AlertConstants.SHOW_TYPE, ShowType.TEXT.getDescp()); weChatConfig.put(AlertConstants.SHOW_TYPE, ShowType.TEXT.getDescp());
WeChatSender weChatSender = new WeChatSender(weChatConfig); WeChatSender weChatSender = new WeChatSender(weChatConfig);
AlertResult alertResult = weChatSender.sendEnterpriseWeChat("test", content); AlertResult alertResult = weChatSender.sendEnterpriseWeChat("test", content);
Assert.assertEquals("true", alertResult.getStatus()); Assert.assertEquals("false", alertResult.getStatus());
} }
} }
...@@ -124,7 +124,6 @@ ...@@ -124,7 +124,6 @@
<dependency> <dependency>
<groupId>mysql</groupId> <groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId> <artifactId>mysql-connector-java</artifactId>
<scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>
......
/* /*
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed to the Apache Software Foundation (ASF) under one or more
* you may not use this file except in compliance with the License. * contributor license agreements. See the NOTICE file distributed with
* You may obtain a copy of the License at * 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 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
......
/* /*
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed to the Apache Software Foundation (ASF) under one or more
* you may not use this file except in compliance with the License. * contributor license agreements. See the NOTICE file distributed with
* You may obtain a copy of the License at * 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 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
......
/* /*
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed to the Apache Software Foundation (ASF) under one or more
* you may not use this file except in compliance with the License. * contributor license agreements. See the NOTICE file distributed with
* You may obtain a copy of the License at * 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 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
......
...@@ -73,12 +73,15 @@ public class AlertSender { ...@@ -73,12 +73,15 @@ public class AlertSender {
//get alert group from alert //get alert group from alert
int alertGroupId = alert.getAlertGroupId(); int alertGroupId = alert.getAlertGroupId();
List<AlertPluginInstance> alertInstanceList = alertDao.listInstanceByAlertGroupId(alertGroupId); List<AlertPluginInstance> alertInstanceList = alertDao.listInstanceByAlertGroupId(alertGroupId);
if (CollectionUtils.isEmpty(alertInstanceList)) {
logger.error("send alert msg fail,no bind plugin instance.");
return;
}
AlertData alertData = new AlertData(); AlertData alertData = new AlertData();
alertData.setId(alert.getId()) alertData.setId(alert.getId())
.setContent(alert.getContent()) .setContent(alert.getContent())
.setLog(alert.getLog()) .setLog(alert.getLog())
.setTitle(alert.getTitle()); .setTitle(alert.getTitle());
for (AlertPluginInstance instance : alertInstanceList) { for (AlertPluginInstance instance : alertInstanceList) {
...@@ -93,6 +96,7 @@ public class AlertSender { ...@@ -93,6 +96,7 @@ public class AlertSender {
/** /**
* sync send alert handler * sync send alert handler
*
* @param alertGroupId alertGroupId * @param alertGroupId alertGroupId
* @param title title * @param title title
* @param content content * @param content content
...@@ -103,7 +107,7 @@ public class AlertSender { ...@@ -103,7 +107,7 @@ public class AlertSender {
List<AlertPluginInstance> alertInstanceList = alertDao.listInstanceByAlertGroupId(alertGroupId); List<AlertPluginInstance> alertInstanceList = alertDao.listInstanceByAlertGroupId(alertGroupId);
AlertData alertData = new AlertData(); AlertData alertData = new AlertData();
alertData.setContent(title) alertData.setContent(title)
.setTitle(content); .setTitle(content);
boolean sendResponseStatus = true; boolean sendResponseStatus = true;
List<AlertSendResponseResult> sendResponseResults = new ArrayList<>(); List<AlertSendResponseResult> sendResponseResults = new ArrayList<>();
...@@ -111,27 +115,28 @@ public class AlertSender { ...@@ -111,27 +115,28 @@ public class AlertSender {
if (CollectionUtils.isEmpty(alertInstanceList)) { if (CollectionUtils.isEmpty(alertInstanceList)) {
sendResponseStatus = false; sendResponseStatus = false;
AlertSendResponseResult alertSendResponseResult = new AlertSendResponseResult(); AlertSendResponseResult alertSendResponseResult = new AlertSendResponseResult();
String message = String.format("Alert GroupId %s send error : not found alert instance",alertGroupId); String message = String.format("Alert GroupId %s send error : not found alert instance", alertGroupId);
alertSendResponseResult.setStatus(sendResponseStatus); alertSendResponseResult.setStatus(sendResponseStatus);
alertSendResponseResult.setMessage(message); alertSendResponseResult.setMessage(message);
sendResponseResults.add(alertSendResponseResult); sendResponseResults.add(alertSendResponseResult);
logger.error("Alert GroupId {} send error : not found alert instance", alertGroupId); logger.error("Alert GroupId {} send error : not found alert instance", alertGroupId);
return new AlertSendResponseCommand(sendResponseStatus,sendResponseResults); return new AlertSendResponseCommand(sendResponseStatus, sendResponseResults);
} }
for (AlertPluginInstance instance : alertInstanceList) { for (AlertPluginInstance instance : alertInstanceList) {
AlertResult alertResult = this.alertResultHandler(instance, alertData); AlertResult alertResult = this.alertResultHandler(instance, alertData);
AlertSendResponseResult alertSendResponseResult = new AlertSendResponseResult( AlertSendResponseResult alertSendResponseResult = new AlertSendResponseResult(
Boolean.parseBoolean(String.valueOf(alertResult.getStatus())),alertResult.getMessage()); Boolean.parseBoolean(String.valueOf(alertResult.getStatus())), alertResult.getMessage());
sendResponseStatus = sendResponseStatus && alertSendResponseResult.getStatus(); sendResponseStatus = sendResponseStatus && alertSendResponseResult.getStatus();
sendResponseResults.add(alertSendResponseResult); sendResponseResults.add(alertSendResponseResult);
} }
return new AlertSendResponseCommand(sendResponseStatus,sendResponseResults); return new AlertSendResponseCommand(sendResponseStatus, sendResponseResults);
} }
/** /**
* alert result handler * alert result handler
*
* @param instance instance * @param instance instance
* @param alertData alertData * @param alertData alertData
* @return AlertResult * @return AlertResult
...@@ -142,7 +147,7 @@ public class AlertSender { ...@@ -142,7 +147,7 @@ public class AlertSender {
AlertResult alertResultExtend = new AlertResult(); AlertResult alertResultExtend = new AlertResult();
String pluginInstanceName = instance.getInstanceName(); String pluginInstanceName = instance.getInstanceName();
if (alertChannel == null) { if (alertChannel == null) {
String message = String.format("Alert Plugin %s send error : return value is null",pluginInstanceName); String message = String.format("Alert Plugin %s send error : return value is null", pluginInstanceName);
alertResultExtend.setStatus(String.valueOf(false)); alertResultExtend.setStatus(String.valueOf(false));
alertResultExtend.setMessage(message); alertResultExtend.setMessage(message);
logger.error("Alert Plugin {} send error : not found plugin {}", pluginInstanceName, pluginName); logger.error("Alert Plugin {} send error : not found plugin {}", pluginInstanceName, pluginName);
...@@ -155,7 +160,7 @@ public class AlertSender { ...@@ -155,7 +160,7 @@ public class AlertSender {
AlertResult alertResult = alertChannel.process(alertInfo); AlertResult alertResult = alertChannel.process(alertInfo);
if (alertResult == null) { if (alertResult == null) {
String message = String.format("Alert Plugin %s send error : return alertResult value is null",pluginInstanceName); String message = String.format("Alert Plugin %s send error : return alertResult value is null", pluginInstanceName);
alertResultExtend.setStatus(String.valueOf(false)); alertResultExtend.setStatus(String.valueOf(false));
alertResultExtend.setMessage(message); alertResultExtend.setMessage(message);
logger.info("Alert Plugin {} send error : return alertResult value is null", pluginInstanceName); logger.info("Alert Plugin {} send error : return alertResult value is null", pluginInstanceName);
...@@ -164,7 +169,7 @@ public class AlertSender { ...@@ -164,7 +169,7 @@ public class AlertSender {
alertResultExtend.setMessage(alertResult.getMessage()); alertResultExtend.setMessage(alertResult.getMessage());
logger.info("Alert Plugin {} send error : {}", pluginInstanceName, alertResult.getMessage()); logger.info("Alert Plugin {} send error : {}", pluginInstanceName, alertResult.getMessage());
} else { } else {
String message = String.format("Alert Plugin %s send success",pluginInstanceName); String message = String.format("Alert Plugin %s send success", pluginInstanceName);
alertResultExtend.setStatus(String.valueOf(true)); alertResultExtend.setStatus(String.valueOf(true));
alertResultExtend.setMessage(message); alertResultExtend.setMessage(message);
logger.info("Alert Plugin {} send success", pluginInstanceName); logger.info("Alert Plugin {} send success", pluginInstanceName);
......
...@@ -33,123 +33,6 @@ public class Constants { ...@@ -33,123 +33,6 @@ public class Constants {
/** default alert plugin dir **/ /** default alert plugin dir **/
public static final String ALERT_PLUGIN_PATH = "./lib/plugin/alert"; public static final String ALERT_PLUGIN_PATH = "./lib/plugin/alert";
public static final String DATA_SOURCE_PROPERTIES_PATH = "/dao/data_source.properties";
public static final String SINGLE_SLASH = "/";
/**
* UTF-8
*/
public static final String UTF_8 = "UTF-8";
public static final String STATUS = "status";
public static final String MESSAGE = "message";
public static final String SPRING_DATASOURCE_DRIVER_CLASS_NAME = "spring.datasource.driver-class-name";
public static final String SPRING_DATASOURCE_URL = "spring.datasource.url";
public static final String SPRING_DATASOURCE_USERNAME = "spring.datasource.username";
public static final String SPRING_DATASOURCE_PASSWORD = "spring.datasource.password";
public static final String SPRING_DATASOURCE_VALIDATION_QUERY_TIMEOUT = "spring.datasource.validationQueryTimeout";
public static final String SPRING_DATASOURCE_INITIAL_SIZE = "spring.datasource.initialSize";
public static final String SPRING_DATASOURCE_MIN_IDLE = "spring.datasource.minIdle";
public static final String SPRING_DATASOURCE_MAX_ACTIVE = "spring.datasource.maxActive";
public static final String SPRING_DATASOURCE_MAX_WAIT = "spring.datasource.maxWait";
public static final String SPRING_DATASOURCE_TIME_BETWEEN_EVICTION_RUNS_MILLIS = "spring.datasource.timeBetweenEvictionRunsMillis";
public static final String SPRING_DATASOURCE_MIN_EVICTABLE_IDLE_TIME_MILLIS = "spring.datasource.minEvictableIdleTimeMillis";
public static final String SPRING_DATASOURCE_VALIDATION_QUERY = "spring.datasource.validationQuery";
public static final String SPRING_DATASOURCE_TEST_WHILE_IDLE = "spring.datasource.testWhileIdle";
public static final String SPRING_DATASOURCE_TEST_ON_BORROW = "spring.datasource.testOnBorrow";
public static final String SPRING_DATASOURCE_TEST_ON_RETURN = "spring.datasource.testOnReturn";
public static final String SPRING_DATASOURCE_POOL_PREPARED_STATEMENTS = "spring.datasource.poolPreparedStatements";
public static final String SPRING_DATASOURCE_DEFAULT_AUTO_COMMIT = "spring.datasource.defaultAutoCommit";
public static final String SPRING_DATASOURCE_KEEP_ALIVE = "spring.datasource.keepAlive";
public static final String SPRING_DATASOURCE_MAX_POOL_PREPARED_STATEMENT_PER_CONNECTION_SIZE = "spring.datasource.maxPoolPreparedStatementPerConnectionSize";
public static final String DEVELOPMENT = "development";
public static final String TR = "<tr>";
public static final String TD = "<td>";
public static final String TD_END = "</td>";
public static final String TR_END = "</tr>";
public static final String TITLE = "title";
public static final String CONTENT = "content";
public static final String TH = "<th>";
public static final String TH_END = "</th>";
public static final int ALERT_SCAN_INTERVAL = 5000; public static final int ALERT_SCAN_INTERVAL = 5000;
public static final String MARKDOWN_QUOTE = ">";
public static final String MARKDOWN_ENTER = "\n";
public static final String ENTERPRISE_WECHAT_ENABLE = "enterprise.wechat.enable";
public static final String ENTERPRISE_WECHAT_CORP_ID = "enterprise.wechat.corp.id";
public static final String ENTERPRISE_WECHAT_SECRET = "enterprise.wechat.secret";
public static final String ENTERPRISE_WECHAT_TOKEN_URL = "enterprise.wechat.token.url";
public static final String ENTERPRISE_WECHAT_PUSH_URL = "enterprise.wechat.push.url";
public static final String ENTERPRISE_WECHAT_TEAM_SEND_MSG = "enterprise.wechat.team.send.msg";
public static final String ENTERPRISE_WECHAT_USER_SEND_MSG = "enterprise.wechat.user.send.msg";
public static final String ENTERPRISE_WECHAT_AGENT_ID = "enterprise.wechat.agent.id";
public static final String ENTERPRISE_WECHAT_USERS = "enterprise.wechat.users";
public static final String DINGTALK_WEBHOOK = "dingtalk.webhook";
public static final String DINGTALK_KEYWORD = "dingtalk.keyword";
public static final String DINGTALK_PROXY_ENABLE = "dingtalk.isEnableProxy";
public static final String DINGTALK_PROXY = "dingtalk.proxy";
public static final String DINGTALK_PORT = "dingtalk.port";
public static final String DINGTALK_USER = "dingtalk.user";
public static final String DINGTALK_PASSWORD = "dingtalk.password";
public static final String DINGTALK_ENABLE = "dingtalk.isEnable";
/**
* plugin config
*/
} }
...@@ -21,6 +21,10 @@ import org.apache.dolphinscheduler.common.utils.StringUtils; ...@@ -21,6 +21,10 @@ import org.apache.dolphinscheduler.common.utils.StringUtils;
public class FuncUtils { public class FuncUtils {
private FuncUtils() {
throw new IllegalStateException(FuncUtils.class.getName());
}
public static String mkString(Iterable<String> list, String split) { public static String mkString(Iterable<String> list, String split) {
if (null == list || StringUtils.isEmpty(split)) { if (null == list || StringUtils.isEmpty(split)) {
......
///*
// * 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.alert.utils;
//
//import org.apache.dolphinscheduler.alert.template.AlertTemplate;
//import org.apache.dolphinscheduler.alert.template.AlertTemplateFactory;
//import org.apache.dolphinscheduler.common.enums.ShowType;
//import org.apache.commons.mail.EmailException;
//import org.apache.commons.mail.HtmlEmail;
//import org.apache.dolphinscheduler.common.utils.CollectionUtils;
//import org.apache.dolphinscheduler.common.utils.StringUtils;
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
//
//import javax.mail.*;
//import javax.mail.internet.*;
//import java.io.*;
//import java.util.*;
//
//
///**
// * mail utils
// */
//public class MailUtils {
//
// public static final Logger logger = LoggerFactory.getLogger(MailUtils.class);
//
// public static final String MAIL_PROTOCOL = PropertyUtils.getString(Constants.MAIL_PROTOCOL);
//
// public static final String MAIL_SERVER_HOST = PropertyUtils.getString(Constants.MAIL_SERVER_HOST);
//
// public static final Integer MAIL_SERVER_PORT = PropertyUtils.getInt(Constants.MAIL_SERVER_PORT);
//
// public static final String MAIL_SENDER = PropertyUtils.getString(Constants.MAIL_SENDER);
//
// public static final String MAIL_USER = PropertyUtils.getString(Constants.MAIL_USER);
//
// public static final String MAIL_PASSWD = PropertyUtils.getString(Constants.MAIL_PASSWD);
//
// public static final Boolean MAIL_USE_START_TLS = PropertyUtils.getBoolean(Constants.MAIL_SMTP_STARTTLS_ENABLE);
//
// public static final Boolean MAIL_USE_SSL = PropertyUtils.getBoolean(Constants.MAIL_SMTP_SSL_ENABLE);
//
// public static final String xlsFilePath = PropertyUtils.getString(Constants.XLS_FILE_PATH,"/tmp/xls");
//
// public static final String STARTTLS_ENABLE = PropertyUtils.getString(Constants.MAIL_SMTP_STARTTLS_ENABLE);
//
// public static final Boolean SSL_ENABLE = PropertyUtils.getBoolean(Constants.MAIL_SMTP_SSL_ENABLE);
//
// public static final String SSL_TRUST = PropertyUtils.getString(Constants.MAIL_SMTP_SSL_TRUST);
//
// public static final AlertTemplate alertTemplate = AlertTemplateFactory.getMessageTemplate();
//
// //Solve the problem of messy Chinese name in excel attachment
// static {
// System.setProperty("mail.mime.splitlongparameters","false");
// }
//
// /**
// * send mail to receivers
// * @param receivers the receiver list
// * @param title the title
// * @param content the content
// * @param showType the show type
// * @return the result map
// */
// public static Map<String,Object> sendMails(Collection<String> receivers, String title, String content,String showType) {
// return sendMails(receivers, null, title, content, showType);
// }
//
// /**
// * send mail
// * @param receivers the receiver list
// * @param receiversCc cc list
// * @param title the title
// * @param content the content
// * @param showType the show type
// * @return the send result
// */
// public static Map<String,Object> sendMails(Collection<String> receivers, Collection<String> receiversCc, String title, String content, String showType) {
// Map<String,Object> retMap = new HashMap<>();
// retMap.put(Constants.STATUS, false);
//
// // if there is no receivers && no receiversCc, no need to process
// if (CollectionUtils.isEmpty(receivers) && CollectionUtils.isEmpty(receiversCc)) {
// return retMap;
// }
//
// receivers.removeIf(StringUtils::isEmpty);
//
// if (showType.equals(ShowType.TABLE.getDescp()) || showType.equals(ShowType.TEXT.getDescp())) {
// // send email
// HtmlEmail email = new HtmlEmail();
//
// try {
// Session session = getSession();
// email.setMailSession(session);
// email.setFrom(MAIL_SENDER);
// email.setCharset(Constants.UTF_8);
// if (CollectionUtils.isNotEmpty(receivers)){
// // receivers mail
// for (String receiver : receivers) {
// email.addTo(receiver);
// }
// }
//
// if (CollectionUtils.isNotEmpty(receiversCc)){
// //cc
// for (String receiverCc : receiversCc) {
// email.addCc(receiverCc);
// }
// }
// // sender mail
// return getStringObjectMap(title, content, showType, retMap, email);
// } catch (Exception e) {
// handleException(receivers, retMap, e);
// }
// }else if (showType.equals(ShowType.ATTACHMENT.getDescp()) || showType.equals(ShowType.TABLEATTACHMENT.getDescp())) {
// try {
//
// String partContent = (showType.equals(ShowType.ATTACHMENT.getDescp()) ? "Please see the attachment " + title + Constants.EXCEL_SUFFIX_XLS : htmlTable(content,false));
//
// attachment(receivers,receiversCc,title,content,partContent);
//
// retMap.put(Constants.STATUS, true);
// return retMap;
// }catch (Exception e){
// handleException(receivers, retMap, e);
// return retMap;
// }
// }
// return retMap;
//
// }
//
// /**
// * html table content
// * @param content the content
// * @param showAll if show the whole content
// * @return the html table form
// */
// private static String htmlTable(String content, boolean showAll){
// return alertTemplate.getMessageFromTemplate(content,ShowType.TABLE,showAll);
// }
//
// /**
// * html table content
// * @param content the content
// * @return the html table form
// */
// private static String htmlTable(String content){
// return htmlTable(content,true);
// }
//
// /**
// * html text content
// * @param content the content
// * @return text in html form
// */
// private static String htmlText(String content){
// return alertTemplate.getMessageFromTemplate(content,ShowType.TEXT);
// }
//
// /**
// * send mail as Excel attachment
// * @param receivers the receiver list
// * @param title the title
// * @throws Exception
// */
// private static void attachment(Collection<String> receivers,Collection<String> receiversCc,String title,String content,String partContent)throws Exception{
// MimeMessage msg = getMimeMessage(receivers);
//
// attachContent(receiversCc, title, content,partContent, msg);
// }
//
// /**
// * get MimeMessage
// * @param receivers receivers
// * @return the MimeMessage
// * @throws MessagingException
// */
// private static MimeMessage getMimeMessage(Collection<String> receivers) throws MessagingException {
//
// // 1. The first step in creating mail: creating session
// Session session = getSession();
// // Setting debug mode, can be turned off
// session.setDebug(false);
//
// // 2. creating mail: Creating a MimeMessage
// MimeMessage msg = new MimeMessage(session);
// // 3. set sender
// msg.setFrom(new InternetAddress(MAIL_SENDER));
// // 4. set receivers
// for (String receiver : receivers) {
// msg.addRecipients(Message.RecipientType.TO, InternetAddress.parse(receiver));
// }
// return msg;
// }
//
// /**
// * get session
// *
// * @return the new Session
// */
// private static Session getSession() {
// Properties props = new Properties();
// props.setProperty(Constants.MAIL_HOST, MAIL_SERVER_HOST);
// props.setProperty(Constants.MAIL_PORT, String.valueOf(MAIL_SERVER_PORT));
// props.setProperty(Constants.MAIL_SMTP_AUTH, Constants.STRING_TRUE);
// props.setProperty(Constants.MAIL_TRANSPORT_PROTOCOL, MAIL_PROTOCOL);
// props.setProperty(Constants.MAIL_SMTP_STARTTLS_ENABLE, STARTTLS_ENABLE);
// if (SSL_ENABLE) {
// props.setProperty(Constants.MAIL_SMTP_SSL_ENABLE, "true");
// props.setProperty(Constants.MAIL_SMTP_SSL_TRUST, SSL_TRUST);
// }
//
// Authenticator auth = new Authenticator() {
// @Override
// protected PasswordAuthentication getPasswordAuthentication() {
// // mail username and password
// return new PasswordAuthentication(MAIL_USER, MAIL_PASSWD);
// }
// };
//
// return Session.getInstance(props, auth);
// }
//
// /**
// * attach content
// * @param receiversCc the cc list
// * @param title the title
// * @param content the content
// * @param partContent the partContent
// * @param msg the message
// * @throws MessagingException
// * @throws IOException
// */
// private static void attachContent(Collection<String> receiversCc, String title, String content, String partContent,MimeMessage msg) throws MessagingException, IOException {
// /**
// * set receiverCc
// */
// if(CollectionUtils.isNotEmpty(receiversCc)){
// for (String receiverCc : receiversCc){
// msg.addRecipients(Message.RecipientType.CC, InternetAddress.parse(receiverCc));
// }
// }
//
// // set subject
// msg.setSubject(title);
// MimeMultipart partList = new MimeMultipart();
// // set signature
// MimeBodyPart part1 = new MimeBodyPart();
// part1.setContent(partContent, Constants.TEXT_HTML_CHARSET_UTF_8);
// // set attach file
// MimeBodyPart part2 = new MimeBodyPart();
// File file = new File(xlsFilePath + Constants.SINGLE_SLASH + title + Constants.EXCEL_SUFFIX_XLS);
// if (!file.getParentFile().exists()) {
// file.getParentFile().mkdirs();
// }
// // make excel file
//
// ExcelUtils.genExcelFile(content,title,xlsFilePath);
//
// part2.attachFile(file);
// part2.setFileName(MimeUtility.encodeText(title + Constants.EXCEL_SUFFIX_XLS,Constants.UTF_8,"B"));
// // add components to collection
// partList.addBodyPart(part1);
// partList.addBodyPart(part2);
// msg.setContent(partList);
// // 5. send Transport
// Transport.send(msg);
// // 6. delete saved file
// deleteFile(file);
// }
//
// /**
// * the string object map
// * @param title the title
// * @param content the content
// * @param showType the showType
// * @param retMap the result map
// * @param email the email
// * @return the result map
// * @throws EmailException
// */
// private static Map<String, Object> getStringObjectMap(String title, String content, String showType, Map<String, Object> retMap, HtmlEmail email) throws EmailException {
//
// /**
// * the subject of the message to be sent
// */
// email.setSubject(title);
// /**
// * to send information, you can use HTML tags in mail content because of the use of HtmlEmail
// */
// if (showType.equals(ShowType.TABLE.getDescp())) {
// email.setMsg(htmlTable(content));
// } else if (showType.equals(ShowType.TEXT.getDescp())) {
// email.setMsg(htmlText(content));
// }
//
// // send
// email.send();
//
// retMap.put(Constants.STATUS, true);
//
// return retMap;
// }
//
// /**
// * file delete
// * @param file the file to delete
// */
// public static void deleteFile(File file){
// if(file.exists()){
// if(file.delete()){
// logger.info("delete success: {}",file.getAbsolutePath() + file.getName());
// }else{
// logger.info("delete fail: {}", file.getAbsolutePath() + file.getName());
// }
// }else{
// logger.info("file not exists: {}", file.getAbsolutePath() + file.getName());
// }
// }
//
//
// /**
// * handle exception
// * @param receivers the receiver list
// * @param retMap the result map
// * @param e the exception
// */
// private static void handleException(Collection<String> receivers, Map<String, Object> retMap, Exception e) {
// logger.error("Send email to {} failed", receivers, e);
// retMap.put(Constants.MESSAGE, "Send email to {" + String.join(",", receivers) + "} failed," + e.toString());
// }
//
//
//}
...@@ -43,6 +43,9 @@ public class PropertyUtils { ...@@ -43,6 +43,9 @@ public class PropertyUtils {
private static final Properties properties = new Properties(); private static final Properties properties = new Properties();
/**
* init properties
*/
private static final PropertyUtils propertyUtils = new PropertyUtils(); private static final PropertyUtils propertyUtils = new PropertyUtils();
private PropertyUtils() { private PropertyUtils() {
...@@ -108,7 +111,7 @@ public class PropertyUtils { ...@@ -108,7 +111,7 @@ public class PropertyUtils {
/** /**
* get int value * get int value
* *
* @param key the key * @param key the key
* @param defaultValue the default value * @param defaultValue the default value
* @return the value related the key or the default value if the key not existed * @return the value related the key or the default value if the key not existed
*/ */
...@@ -159,7 +162,7 @@ public class PropertyUtils { ...@@ -159,7 +162,7 @@ public class PropertyUtils {
/** /**
* get long value * get long value
* *
* @param key the key * @param key the key
* @param defaultVal the default value * @param defaultVal the default value
* @return the value related the key or the default value if the key not existed * @return the value related the key or the default value if the key not existed
*/ */
...@@ -186,14 +189,13 @@ public class PropertyUtils { ...@@ -186,14 +189,13 @@ public class PropertyUtils {
* @return if the value not existed, return -1.0, or will return the related value * @return if the value not existed, return -1.0, or will return the related value
*/ */
public static double getDouble(String key) { public static double getDouble(String key) {
String val = getString(key);
return getDouble(key, -1.0); return getDouble(key, -1.0);
} }
/** /**
* get double value * get double value
* *
* @param key the key * @param key the key
* @param defaultVal the default value * @param defaultVal the default value
* @return the value related the key or the default value if the key not existed * @return the value related the key or the default value if the key not existed
*/ */
...@@ -216,7 +218,7 @@ public class PropertyUtils { ...@@ -216,7 +218,7 @@ public class PropertyUtils {
/** /**
* get array * get array
* *
* @param key property name * @param key property name
* @param splitStr separator * @param splitStr separator
* @return the result array * @return the result array
*/ */
...@@ -236,10 +238,10 @@ public class PropertyUtils { ...@@ -236,10 +238,10 @@ public class PropertyUtils {
/** /**
* get enum * get enum
* *
* @param key the key * @param key the key
* @param type the class type * @param type the class type
* @param defaultValue the default value * @param defaultValue the default value
* @param <T> the generic class type * @param <T> the generic class type
* @return get enum value * @return get enum value
*/ */
public static <T extends Enum<T>> T getEnum(String key, Class<T> type, public static <T extends Enum<T>> T getEnum(String key, Class<T> type,
......
...@@ -21,8 +21,7 @@ ...@@ -21,8 +21,7 @@
#eg : Alert Server Listener port #eg : Alert Server Listener port
#alert.plugin.dir config the Alert Plugin dir . AlertServer while find and load the Alert Plugin Jar from this dir when deploy and start AlertServer on the server . #alert.plugin.dir config the Alert Plugin dir . AlertServer while find and load the Alert Plugin Jar from this dir when deploy and start AlertServer on the server .
#eg : #eg :alert.plugin.dir=/opt/soft/spi/lib/plugin/alert
#alert.plugin.dir=/root/dolphinscheduler/lib/plugin/alert
#maven.local.repository=/Users/gaojun/Documents/jianguoyun/localRepository #maven.local.repository=/Users/gaojun/Documents/jianguoyun/localRepository
......
...@@ -124,7 +124,6 @@ public class EmailAlertPluginTest { ...@@ -124,7 +124,6 @@ public class EmailAlertPluginTest {
//create email alert plugin instance //create email alert plugin instance
AlertPluginInstance alertPluginInstance = new AlertPluginInstance(); AlertPluginInstance alertPluginInstance = new AlertPluginInstance();
alertPluginInstance.setAlertGroupId(alertGroup.getId());
alertPluginInstance.setCreateTime(new Date()); alertPluginInstance.setCreateTime(new Date());
alertPluginInstance.setInstanceName("test email alert"); alertPluginInstance.setInstanceName("test email alert");
......
...@@ -83,7 +83,7 @@ public class AlertSenderTest { ...@@ -83,7 +83,7 @@ public class AlertSenderTest {
String pluginInstanceName = "alert-instance-mail"; String pluginInstanceName = "alert-instance-mail";
List<AlertPluginInstance> alertInstanceList = new ArrayList<>(); List<AlertPluginInstance> alertInstanceList = new ArrayList<>();
AlertPluginInstance alertPluginInstance = new AlertPluginInstance( AlertPluginInstance alertPluginInstance = new AlertPluginInstance(
pluginDefineId,pluginInstanceParams,alertGroupId,pluginInstanceName); pluginDefineId,pluginInstanceParams,pluginInstanceName);
alertInstanceList.add(alertPluginInstance); alertInstanceList.add(alertPluginInstance);
PowerMockito.when(alertDao.listInstanceByAlertGroupId(1)).thenReturn(alertInstanceList); PowerMockito.when(alertDao.listInstanceByAlertGroupId(1)).thenReturn(alertInstanceList);
...@@ -157,7 +157,7 @@ public class AlertSenderTest { ...@@ -157,7 +157,7 @@ public class AlertSenderTest {
String pluginInstanceName = "alert-instance-mail"; String pluginInstanceName = "alert-instance-mail";
List<AlertPluginInstance> alertInstanceList = new ArrayList<>(); List<AlertPluginInstance> alertInstanceList = new ArrayList<>();
AlertPluginInstance alertPluginInstance = new AlertPluginInstance( AlertPluginInstance alertPluginInstance = new AlertPluginInstance(
pluginDefineId,pluginInstanceParams,alertGroupId,pluginInstanceName); pluginDefineId,pluginInstanceParams,pluginInstanceName);
alertInstanceList.add(alertPluginInstance); alertInstanceList.add(alertPluginInstance);
PowerMockito.when(alertDao.listInstanceByAlertGroupId(alertGroupId)).thenReturn(alertInstanceList); PowerMockito.when(alertDao.listInstanceByAlertGroupId(alertGroupId)).thenReturn(alertInstanceList);
......
...@@ -46,11 +46,11 @@ public class PropertyUtilsTest { ...@@ -46,11 +46,11 @@ public class PropertyUtilsTest {
//Expected "EMAIL" //Expected "EMAIL"
String result = PropertyUtils.getString("alert.type"); String result = PropertyUtils.getString("alert.type");
logger.info(result); logger.info(result);
assertEquals(result, "EMAIL"); assertEquals("EMAIL", result);
//Expected "xxx.xxx.test" //Expected "xxx.xxx.test"
result = PropertyUtils.getString("mail.server.host"); result = PropertyUtils.getString("mail.server.host");
assertEquals(result, "xxx.xxx.test"); assertEquals("xxx.xxx.test", result);
//If key is undefine in alert.properties, then return null //If key is undefine in alert.properties, then return null
result = PropertyUtils.getString("abc"); result = PropertyUtils.getString("abc");
...@@ -93,23 +93,23 @@ public class PropertyUtilsTest { ...@@ -93,23 +93,23 @@ public class PropertyUtilsTest {
//Expected 25 //Expected 25
long result = PropertyUtils.getLong("mail.server.port"); long result = PropertyUtils.getLong("mail.server.port");
assertSame(result, 25L); assertSame(25L, result);
//If key is null, then return -1 //If key is null, then return -1
result = PropertyUtils.getLong(null); result = PropertyUtils.getLong(null);
assertSame(result, -1L); assertSame(-1L, result);
//If key is undefine in alert.properties, then return -1 //If key is undefine in alert.properties, then return -1
result = PropertyUtils.getLong("abc"); result = PropertyUtils.getLong("abc");
assertSame(result, -1L); assertSame(-1L, result);
//If key is undefine in alert.properties, and there is a defaultval, then return defaultval //If key is undefine in alert.properties, and there is a defaultval, then return defaultval
result = PropertyUtils.getLong("abc", 200); result = PropertyUtils.getLong("abc", 200);
assertEquals(result, 200L); assertEquals(200L, result);
//If the value can not parse to long ,it will log the error and return -1L //If the value can not parse to long ,it will log the error and return -1L
result = PropertyUtils.getLong("test.server.testnumber"); result = PropertyUtils.getLong("test.server.testnumber");
assertSame(result, -1L); assertSame(-1L, result);
} }
/** /**
...@@ -120,23 +120,23 @@ public class PropertyUtilsTest { ...@@ -120,23 +120,23 @@ public class PropertyUtilsTest {
//Expected 3.0 //Expected 3.0
double result = PropertyUtils.getDouble("test.server.factor"); double result = PropertyUtils.getDouble("test.server.factor");
assertEquals(result, 3.0, 0); assertEquals(3.0, result, 0);
//If key is null, then return -1.0 //If key is null, then return -1.0
result = PropertyUtils.getDouble(null); result = PropertyUtils.getDouble(null);
assertEquals(result, -1.0, 0); assertEquals(-1.0, result, 0);
//If key is undefine in alert.properties, then return -1 //If key is undefine in alert.properties, then return -1
result = PropertyUtils.getDouble("abc"); result = PropertyUtils.getDouble("abc");
assertEquals(result, -1.0, 0); assertEquals(-1.0, result, 0);
//If key is undefine in alert.properties, and there is a defaultval, then return defaultval //If key is undefine in alert.properties, and there is a defaultval, then return defaultval
result = PropertyUtils.getDouble("abc", 5.0); result = PropertyUtils.getDouble("abc", 5.0);
assertEquals(result, 5.0, 0); assertEquals(5.0, result, 0);
//If the value can not parse to double ,it will log the error and return -1.0 //If the value can not parse to double ,it will log the error and return -1.0
result = PropertyUtils.getDouble("test.server.testnumber"); result = PropertyUtils.getDouble("test.server.testnumber");
assertEquals(result, -1.0, 0); assertEquals(-1.0, result, 0);
} }
/** /**
...@@ -150,9 +150,9 @@ public class PropertyUtilsTest { ...@@ -150,9 +150,9 @@ public class PropertyUtilsTest {
assertEquals(result.length, 3); assertEquals(result.length, 3);
//Equal array values //Equal array values
assertEquals(result[0], "xxx.xxx.test1"); assertEquals("xxx.xxx.test1", result[0]);
assertEquals(result[1], "xxx.xxx.test2"); assertEquals("xxx.xxx.test2", result[1]);
assertEquals(result[2], "xxx.xxx.test3"); assertEquals("xxx.xxx.test3", result[2]);
//If key is null, then return -1 //If key is null, then return -1
result = PropertyUtils.getArray(null, ","); result = PropertyUtils.getArray(null, ",");
...@@ -175,23 +175,23 @@ public class PropertyUtilsTest { ...@@ -175,23 +175,23 @@ public class PropertyUtilsTest {
//Expected 25 //Expected 25
int result = PropertyUtils.getInt("mail.server.port"); int result = PropertyUtils.getInt("mail.server.port");
assertSame(result, 25); assertSame(25, result);
//If key is null, then return -1 //If key is null, then return -1
result = PropertyUtils.getInt(null); result = PropertyUtils.getInt(null);
assertSame(result, -1); assertSame(-1, result);
//If key is undefine in alert.properties, then return -1 //If key is undefine in alert.properties, then return -1
result = PropertyUtils.getInt("abc"); result = PropertyUtils.getInt("abc");
assertSame(result, -1); assertSame(-1, result);
//If key is undefine in alert.properties, and there is a defaultval, then return defaultval //If key is undefine in alert.properties, and there is a defaultval, then return defaultval
result = PropertyUtils.getInt("abc", 300); result = PropertyUtils.getInt("abc", 300);
assertEquals(result, 300); assertEquals(300, result);
//If the value can not parse to int ,it will log the error and return -1 //If the value can not parse to int ,it will log the error and return -1
result = PropertyUtils.getInt("test.server.testnumber"); result = PropertyUtils.getInt("test.server.testnumber");
assertSame(result, -1); assertSame(-1, result);
} }
/** /**
...@@ -202,19 +202,19 @@ public class PropertyUtilsTest { ...@@ -202,19 +202,19 @@ public class PropertyUtilsTest {
//Expected MASTER //Expected MASTER
ZKNodeType zkNodeType = PropertyUtils.getEnum("test.server.enum1", ZKNodeType.class, ZKNodeType.WORKER); ZKNodeType zkNodeType = PropertyUtils.getEnum("test.server.enum1", ZKNodeType.class, ZKNodeType.WORKER);
assertEquals(zkNodeType, ZKNodeType.MASTER); assertEquals(ZKNodeType.MASTER, zkNodeType);
//Expected DEAD_SERVER //Expected DEAD_SERVER
zkNodeType = PropertyUtils.getEnum("test.server.enum2", ZKNodeType.class, ZKNodeType.WORKER); zkNodeType = PropertyUtils.getEnum("test.server.enum2", ZKNodeType.class, ZKNodeType.WORKER);
assertEquals(zkNodeType, ZKNodeType.DEAD_SERVER); assertEquals(ZKNodeType.DEAD_SERVER, zkNodeType);
//If key is null, then return defaultval //If key is null, then return defaultval
zkNodeType = PropertyUtils.getEnum(null, ZKNodeType.class, ZKNodeType.WORKER); zkNodeType = PropertyUtils.getEnum(null, ZKNodeType.class, ZKNodeType.WORKER);
assertEquals(zkNodeType, ZKNodeType.WORKER); assertEquals(ZKNodeType.WORKER, zkNodeType);
//If the value doesn't define in enum ,it will log the error and return -1 //If the value doesn't define in enum ,it will log the error and return -1
zkNodeType = PropertyUtils.getEnum("test.server.enum3", ZKNodeType.class, ZKNodeType.WORKER); zkNodeType = PropertyUtils.getEnum("test.server.enum3", ZKNodeType.class, ZKNodeType.WORKER);
assertEquals(zkNodeType, ZKNodeType.WORKER); assertEquals(ZKNodeType.WORKER, zkNodeType);
} }
} }
\ No newline at end of file
...@@ -211,17 +211,6 @@ ...@@ -211,17 +211,6 @@
<artifactId>hadoop-aws</artifactId> <artifactId>hadoop-aws</artifactId>
</dependency> </dependency>
<dependency>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jsp-2.1</artifactId>
<exclusions>
<exclusion>
<groupId>org.mortbay.jetty</groupId>
<artifactId>servlet-api-2.5</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- just for test --> <!-- just for test -->
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
......
...@@ -28,8 +28,8 @@ import org.apache.dolphinscheduler.api.exceptions.ApiException; ...@@ -28,8 +28,8 @@ import org.apache.dolphinscheduler.api.exceptions.ApiException;
import org.apache.dolphinscheduler.api.service.AlertGroupService; import org.apache.dolphinscheduler.api.service.AlertGroupService;
import org.apache.dolphinscheduler.api.utils.Result; import org.apache.dolphinscheduler.api.utils.Result;
import org.apache.dolphinscheduler.common.Constants; import org.apache.dolphinscheduler.common.Constants;
import org.apache.dolphinscheduler.common.enums.AlertType;
import org.apache.dolphinscheduler.common.utils.ParameterUtils; import org.apache.dolphinscheduler.common.utils.ParameterUtils;
import org.apache.dolphinscheduler.common.utils.StringUtils;
import org.apache.dolphinscheduler.dao.entity.User; import org.apache.dolphinscheduler.dao.entity.User;
import java.util.HashMap; import java.util.HashMap;
...@@ -70,28 +70,31 @@ public class AlertGroupController extends BaseController { ...@@ -70,28 +70,31 @@ public class AlertGroupController extends BaseController {
/** /**
* create alert group * create alert group
* *
* @param loginUser login user * @param loginUser login user
* @param groupName group name * @param groupName group name
* @param groupType group type
* @param description description * @param description description
* @return create result code * @return create result code
*/ */
@ApiOperation(value = "createAlertgroup", notes = "CREATE_ALERT_GROUP_NOTES") @ApiOperation(value = "createAlertgroup", notes = "CREATE_ALERT_GROUP_NOTES")
@ApiImplicitParams({ @ApiImplicitParams({
@ApiImplicitParam(name = "groupName", value = "GROUP_NAME", required = true, dataType = "String"), @ApiImplicitParam(name = "groupName", value = "GROUP_NAME", required = true, dataType = "String"),
@ApiImplicitParam(name = "groupType", value = "GROUP_TYPE", required = true, dataType = "AlertType"), @ApiImplicitParam(name = "description", value = "DESC", dataType = "String"),
@ApiImplicitParam(name = "description", value = "DESC", dataType = "String") @ApiImplicitParam(name = "alertInstanceIds", value = "alertInstanceIds", dataType = "String")
}) })
@PostMapping(value = "/create") @PostMapping(value = "/create")
@ResponseStatus(HttpStatus.CREATED) @ResponseStatus(HttpStatus.CREATED)
@ApiException(CREATE_ALERT_GROUP_ERROR) @ApiException(CREATE_ALERT_GROUP_ERROR)
public Result createAlertgroup(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser, public Result createAlertgroup(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser,
@RequestParam(value = "groupName") String groupName, @RequestParam(value = "groupName") String groupName,
@RequestParam(value = "groupType") AlertType groupType, @RequestParam(value = "description", required = false) String description,
@RequestParam(value = "description", required = false) String description) { @RequestParam(value = "alertInstanceIds") String alertInstanceIds) {
logger.info("loginUser user {}, create alertgroup, groupName: {}, groupType: {}, desc: {}", String strUserName = StringUtils.replaceNRTtoUnderline(loginUser.getUserName());
loginUser.getUserName(), groupName, groupType, description); String strGroupName = StringUtils.replaceNRTtoUnderline(groupName);
Map<String, Object> result = alertGroupService.createAlertgroup(loginUser, groupName, groupType, description); String strDescription = StringUtils.replaceNRTtoUnderline(description);
String strAlertInstanceIds = StringUtils.replaceNRTtoUnderline(alertInstanceIds);
logger.info("loginUser user {}, create alert group, groupName: {}, desc: {},alertInstanceIds:{}",
strUserName, strGroupName, strDescription, strAlertInstanceIds);
Map<String, Object> result = alertGroupService.createAlertgroup(loginUser, groupName, description, alertInstanceIds);
return returnDataList(result); return returnDataList(result);
} }
...@@ -107,7 +110,7 @@ public class AlertGroupController extends BaseController { ...@@ -107,7 +110,7 @@ public class AlertGroupController extends BaseController {
@ApiException(QUERY_ALL_ALERTGROUP_ERROR) @ApiException(QUERY_ALL_ALERTGROUP_ERROR)
public Result list(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser) { public Result list(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser) {
logger.info("login user {}, query all alertGroup", logger.info("login user {}, query all alertGroup",
loginUser.getUserName()); loginUser.getUserName());
HashMap<String, Object> result = alertGroupService.queryAlertgroup(); HashMap<String, Object> result = alertGroupService.queryAlertgroup();
return returnDataList(result); return returnDataList(result);
} }
...@@ -116,16 +119,16 @@ public class AlertGroupController extends BaseController { ...@@ -116,16 +119,16 @@ public class AlertGroupController extends BaseController {
* paging query alarm group list * paging query alarm group list
* *
* @param loginUser login user * @param loginUser login user
* @param pageNo page number * @param pageNo page number
* @param searchVal search value * @param searchVal search value
* @param pageSize page size * @param pageSize page size
* @return alert group list page * @return alert group list page
*/ */
@ApiOperation(value = "queryAlertGroupListPaging", notes = "QUERY_ALERT_GROUP_LIST_PAGING_NOTES") @ApiOperation(value = "queryAlertGroupListPaging", notes = "QUERY_ALERT_GROUP_LIST_PAGING_NOTES")
@ApiImplicitParams({ @ApiImplicitParams({
@ApiImplicitParam(name = "searchVal", value = "SEARCH_VAL", type = "String"), @ApiImplicitParam(name = "searchVal", value = "SEARCH_VAL", type = "String"),
@ApiImplicitParam(name = "pageNo", value = "PAGE_NO", dataType = "Int", example = "1"), @ApiImplicitParam(name = "pageNo", value = "PAGE_NO", dataType = "Int", example = "1"),
@ApiImplicitParam(name = "pageSize", value = "PAGE_SIZE", dataType = "Int", example = "20") @ApiImplicitParam(name = "pageSize", value = "PAGE_SIZE", dataType = "Int", example = "20")
}) })
@GetMapping(value = "/list-paging") @GetMapping(value = "/list-paging")
@ResponseStatus(HttpStatus.OK) @ResponseStatus(HttpStatus.OK)
...@@ -135,7 +138,7 @@ public class AlertGroupController extends BaseController { ...@@ -135,7 +138,7 @@ public class AlertGroupController extends BaseController {
@RequestParam("pageNo") Integer pageNo, @RequestParam("pageNo") Integer pageNo,
@RequestParam("pageSize") Integer pageSize) { @RequestParam("pageSize") Integer pageSize) {
logger.info("login user {}, list paging, pageNo: {}, searchVal: {}, pageSize: {}", logger.info("login user {}, list paging, pageNo: {}, searchVal: {}, pageSize: {}",
loginUser.getUserName(), pageNo, searchVal, pageSize); loginUser.getUserName(), pageNo, searchVal, pageSize);
Map<String, Object> result = checkPageParams(pageNo, pageSize); Map<String, Object> result = checkPageParams(pageNo, pageSize);
if (result.get(Constants.STATUS) != Status.SUCCESS) { if (result.get(Constants.STATUS) != Status.SUCCESS) {
return returnDataListPaging(result); return returnDataListPaging(result);
...@@ -149,19 +152,18 @@ public class AlertGroupController extends BaseController { ...@@ -149,19 +152,18 @@ public class AlertGroupController extends BaseController {
/** /**
* updateProcessInstance alert group * updateProcessInstance alert group
* *
* @param loginUser login user * @param loginUser login user
* @param id alert group id * @param id alert group id
* @param groupName group name * @param groupName group name
* @param groupType group type
* @param description description * @param description description
* @return update result code * @return update result code
*/ */
@ApiOperation(value = "updateAlertgroup", notes = "UPDATE_ALERT_GROUP_NOTES") @ApiOperation(value = "updateAlertgroup", notes = "UPDATE_ALERT_GROUP_NOTES")
@ApiImplicitParams({ @ApiImplicitParams({
@ApiImplicitParam(name = "id", value = "ALERT_GROUP_ID", required = true, dataType = "Int", example = "100"), @ApiImplicitParam(name = "id", value = "ALERT_GROUP_ID", required = true, dataType = "Int", example = "100"),
@ApiImplicitParam(name = "groupName", value = "GROUP_NAME", required = true, dataType = "String"), @ApiImplicitParam(name = "groupName", value = "GROUP_NAME", required = true, dataType = "String"),
@ApiImplicitParam(name = "groupType", value = "GROUP_TYPE", required = true, dataType = "AlertType"), @ApiImplicitParam(name = "description", value = "DESC", dataType = "String"),
@ApiImplicitParam(name = "description", value = "DESC", dataType = "String") @ApiImplicitParam(name = "alertInstanceIds", value = "alertInstanceIds", dataType = "String")
}) })
@PostMapping(value = "/update") @PostMapping(value = "/update")
@ResponseStatus(HttpStatus.OK) @ResponseStatus(HttpStatus.OK)
...@@ -169,11 +171,13 @@ public class AlertGroupController extends BaseController { ...@@ -169,11 +171,13 @@ public class AlertGroupController extends BaseController {
public Result updateAlertgroup(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser, public Result updateAlertgroup(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser,
@RequestParam(value = "id") int id, @RequestParam(value = "id") int id,
@RequestParam(value = "groupName") String groupName, @RequestParam(value = "groupName") String groupName,
@RequestParam(value = "groupType") AlertType groupType, @RequestParam(value = "description", required = false) String description,
@RequestParam(value = "description", required = false) String description) { @RequestParam(value = "alertInstanceIds") String alertInstanceIds) {
logger.info("login user {}, updateProcessInstance alertgroup, groupName: {}, groupType: {}, desc: {}", logger.info("login user {}, updateProcessInstance alert group, groupName: {}, desc: {}",
loginUser.getUserName(), groupName, groupType, description); StringUtils.replaceNRTtoUnderline(loginUser.getUserName()),
Map<String, Object> result = alertGroupService.updateAlertgroup(loginUser, id, groupName, groupType, description); StringUtils.replaceNRTtoUnderline(groupName),
StringUtils.replaceNRTtoUnderline(description));
Map<String, Object> result = alertGroupService.updateAlertgroup(loginUser, id, groupName, description, alertInstanceIds);
return returnDataList(result); return returnDataList(result);
} }
...@@ -181,12 +185,12 @@ public class AlertGroupController extends BaseController { ...@@ -181,12 +185,12 @@ public class AlertGroupController extends BaseController {
* delete alert group by id * delete alert group by id
* *
* @param loginUser login user * @param loginUser login user
* @param id alert group id * @param id alert group id
* @return delete result code * @return delete result code
*/ */
@ApiOperation(value = "delAlertgroupById", notes = "DELETE_ALERT_GROUP_BY_ID_NOTES") @ApiOperation(value = "delAlertgroupById", notes = "DELETE_ALERT_GROUP_BY_ID_NOTES")
@ApiImplicitParams({ @ApiImplicitParams({
@ApiImplicitParam(name = "id", value = "ALERT_GROUP_ID", required = true, dataType = "Int", example = "100") @ApiImplicitParam(name = "id", value = "ALERT_GROUP_ID", required = true, dataType = "Int", example = "100")
}) })
@PostMapping(value = "/delete") @PostMapping(value = "/delete")
@ResponseStatus(HttpStatus.OK) @ResponseStatus(HttpStatus.OK)
...@@ -208,7 +212,7 @@ public class AlertGroupController extends BaseController { ...@@ -208,7 +212,7 @@ public class AlertGroupController extends BaseController {
*/ */
@ApiOperation(value = "verifyGroupName", notes = "VERIFY_ALERT_GROUP_NAME_NOTES") @ApiOperation(value = "verifyGroupName", notes = "VERIFY_ALERT_GROUP_NAME_NOTES")
@ApiImplicitParams({ @ApiImplicitParams({
@ApiImplicitParam(name = "groupName", value = "GROUP_NAME", required = true, dataType = "String"), @ApiImplicitParam(name = "groupName", value = "GROUP_NAME", required = true, dataType = "String"),
}) })
@GetMapping(value = "/verify-group-name") @GetMapping(value = "/verify-group-name")
@ResponseStatus(HttpStatus.OK) @ResponseStatus(HttpStatus.OK)
......
...@@ -20,13 +20,16 @@ package org.apache.dolphinscheduler.api.controller; ...@@ -20,13 +20,16 @@ package org.apache.dolphinscheduler.api.controller;
import static org.apache.dolphinscheduler.api.enums.Status.CREATE_ALERT_PLUGIN_INSTANCE_ERROR; import static org.apache.dolphinscheduler.api.enums.Status.CREATE_ALERT_PLUGIN_INSTANCE_ERROR;
import static org.apache.dolphinscheduler.api.enums.Status.DELETE_ALERT_PLUGIN_INSTANCE_ERROR; import static org.apache.dolphinscheduler.api.enums.Status.DELETE_ALERT_PLUGIN_INSTANCE_ERROR;
import static org.apache.dolphinscheduler.api.enums.Status.GET_ALERT_PLUGIN_INSTANCE_ERROR; import static org.apache.dolphinscheduler.api.enums.Status.GET_ALERT_PLUGIN_INSTANCE_ERROR;
import static org.apache.dolphinscheduler.api.enums.Status.LIST_PAGING_ALERT_PLUGIN_INSTANCE_ERROR;
import static org.apache.dolphinscheduler.api.enums.Status.QUERY_ALL_ALERT_PLUGIN_INSTANCE_ERROR;
import static org.apache.dolphinscheduler.api.enums.Status.UPDATE_ALERT_PLUGIN_INSTANCE_ERROR; import static org.apache.dolphinscheduler.api.enums.Status.UPDATE_ALERT_PLUGIN_INSTANCE_ERROR;
import org.apache.dolphinscheduler.api.enums.Status;
import org.apache.dolphinscheduler.api.exceptions.ApiException; import org.apache.dolphinscheduler.api.exceptions.ApiException;
import org.apache.dolphinscheduler.api.service.AlertPluginInstanceService; import org.apache.dolphinscheduler.api.service.AlertPluginInstanceService;
import org.apache.dolphinscheduler.api.utils.Result; import org.apache.dolphinscheduler.api.utils.Result;
import org.apache.dolphinscheduler.common.Constants; import org.apache.dolphinscheduler.common.Constants;
import org.apache.dolphinscheduler.dao.entity.AlertPluginInstance; import org.apache.dolphinscheduler.common.utils.StringUtils;
import org.apache.dolphinscheduler.dao.entity.User; import org.apache.dolphinscheduler.dao.entity.User;
import java.util.Map; import java.util.Map;
...@@ -38,7 +41,6 @@ import org.springframework.http.HttpStatus; ...@@ -38,7 +41,6 @@ import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestAttribute; import org.springframework.web.bind.annotation.RequestAttribute;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseStatus; import org.springframework.web.bind.annotation.ResponseStatus;
...@@ -68,23 +70,28 @@ public class AlertPluginInstanceController extends BaseController { ...@@ -68,23 +70,28 @@ public class AlertPluginInstanceController extends BaseController {
* create alert plugin instance * create alert plugin instance
* *
* @param loginUser login user * @param loginUser login user
* @param alertPluginInstance alertPluginInstance * @param pluginDefineId alert plugin define id
* @return create result code * @param instanceName instance name
* @param pluginInstanceParams instance params
* @return result
*/ */
@ApiOperation(value = "createAlertPluginInstance", notes = "CREATE_ALERT_PLUGIN_INSTANCE_NOTES") @ApiOperation(value = "createAlertPluginInstance", notes = "CREATE_ALERT_PLUGIN_INSTANCE_NOTES")
@ApiImplicitParams({ @ApiImplicitParams({
@ApiImplicitParam(name = "groupName", value = "GROUP_NAME", required = true, dataType = "String"), @ApiImplicitParam(name = "pluginDefineId", value = "ALERT_PLUGIN_DEFINE_ID", required = true, dataType = "Int", example = "100"),
@ApiImplicitParam(name = "groupType", value = "GROUP_TYPE", required = true, dataType = "AlertType"), @ApiImplicitParam(name = "instanceName", value = "ALERT_PLUGIN_INSTANCE_NAME", required = true, dataType = "String", example = "DING TALK"),
@ApiImplicitParam(name = "description", value = "DESC", dataType = "String") @ApiImplicitParam(name = "pluginInstanceParams", value = "ALERT_PLUGIN_INSTANCE_PARAMS", required = true, dataType = "String", example = "ALERT_PLUGIN_INSTANCE_PARAMS")
}) })
@PostMapping(value = "/create") @PostMapping(value = "/create")
@ResponseStatus(HttpStatus.CREATED) @ResponseStatus(HttpStatus.CREATED)
@ApiException(CREATE_ALERT_PLUGIN_INSTANCE_ERROR) @ApiException(CREATE_ALERT_PLUGIN_INSTANCE_ERROR)
public Result createAlertPluginInstance(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser, public Result createAlertPluginInstance(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser,
@RequestBody AlertPluginInstance alertPluginInstance) { @RequestParam(value = "pluginDefineId") int pluginDefineId,
logger.info("loginUser user {}, create alert plugin instance, groupName: " @RequestParam(value = "instanceName") String instanceName,
, loginUser.getUserName()); @RequestParam(value = "pluginInstanceParams") String pluginInstanceParams) {
Map<String, Object> result = alertPluginInstanceService.create(loginUser, alertPluginInstance); logger.info("login user {},create alert plugin instance, instanceName:{} ",
StringUtils.replaceNRTtoUnderline(loginUser.getUserName()),
StringUtils.replaceNRTtoUnderline(instanceName));
Map<String, Object> result = alertPluginInstanceService.create(loginUser, pluginDefineId, instanceName, pluginInstanceParams);
return returnDataList(result); return returnDataList(result);
} }
...@@ -92,18 +99,26 @@ public class AlertPluginInstanceController extends BaseController { ...@@ -92,18 +99,26 @@ public class AlertPluginInstanceController extends BaseController {
* updateAlertPluginInstance * updateAlertPluginInstance
* *
* @param loginUser login user * @param loginUser login user
* @param alertPluginInstance alertPluginInstance * @param alertPluginInstanceId alert plugin instance id
* @param instanceName instance name
* @param pluginInstanceParams instance params
* @return result * @return result
*/ */
@ApiOperation(value = "update", notes = "UPDATE_ALERT_PLUGIN_INSTANCE_NOTES") @ApiOperation(value = "update", notes = "UPDATE_ALERT_PLUGIN_INSTANCE_NOTES")
@ApiImplicitParams({
@ApiImplicitParam(name = "alertPluginInstanceId", value = "ALERT_PLUGIN_INSTANCE_ID", required = true, dataType = "Int", example = "100"),
@ApiImplicitParam(name = "instanceName", value = "ALERT_PLUGIN_INSTANCE_NAME", required = true, dataType = "String", example = "DING TALK"),
@ApiImplicitParam(name = "pluginInstanceParams", value = "ALERT_PLUGIN_INSTANCE_PARAMS", required = true, dataType = "String", example = "ALERT_PLUGIN_INSTANCE_PARAMS")
})
@GetMapping(value = "/update") @GetMapping(value = "/update")
@ResponseStatus(HttpStatus.OK) @ResponseStatus(HttpStatus.OK)
@ApiException(UPDATE_ALERT_PLUGIN_INSTANCE_ERROR) @ApiException(UPDATE_ALERT_PLUGIN_INSTANCE_ERROR)
public Result updateAlertPluginInstance(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser, public Result updateAlertPluginInstance(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser,
@RequestBody AlertPluginInstance alertPluginInstance) { @RequestParam(value = "alertPluginInstanceId") int alertPluginInstanceId,
logger.info("login user {}, update alert plugin instance id {}", @RequestParam(value = "instanceName") String instanceName,
loginUser.getUserName(), alertPluginInstance.getId()); @RequestParam(value = "pluginInstanceParams") String pluginInstanceParams) {
Map<String, Object> result = alertPluginInstanceService.update(loginUser, alertPluginInstance); logger.info("login user {},update alert plugin instance id {}", StringUtils.replaceNRTtoUnderline(loginUser.getUserName()), alertPluginInstanceId);
Map<String, Object> result = alertPluginInstanceService.update(loginUser, alertPluginInstanceId, instanceName, pluginInstanceParams);
return returnDataList(result); return returnDataList(result);
} }
...@@ -111,19 +126,22 @@ public class AlertPluginInstanceController extends BaseController { ...@@ -111,19 +126,22 @@ public class AlertPluginInstanceController extends BaseController {
* deleteAlertPluginInstance * deleteAlertPluginInstance
* *
* @param loginUser login user * @param loginUser login user
* @param alertPluginInstance alertPluginInstance * @param id id
* @return result * @return result
*/ */
@ApiOperation(value = "delete", notes = "DELETE_ALERT_PLUGIN_INSTANCE_NOTES") @ApiOperation(value = "delete", notes = "DELETE_ALERT_PLUGIN_INSTANCE_NOTES")
@ApiImplicitParams({
@ApiImplicitParam(name = "id", value = "ALERT_PLUGIN_ID", required = true, dataType = "Int", example = "100")
})
@GetMapping(value = "/delete") @GetMapping(value = "/delete")
@ResponseStatus(HttpStatus.OK) @ResponseStatus(HttpStatus.OK)
@ApiException(DELETE_ALERT_PLUGIN_INSTANCE_ERROR) @ApiException(DELETE_ALERT_PLUGIN_INSTANCE_ERROR)
public Result deleteAlertPluginInstance(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser, public Result deleteAlertPluginInstance(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser,
@RequestBody AlertPluginInstance alertPluginInstance) { @RequestParam(value = "id") int id) {
logger.info("login user {}, delete alert plugin instance id {}", loginUser.getUserName(), alertPluginInstance.getId()); logger.info("login user {},delete alert plugin instance id {}", StringUtils.replaceNRTtoUnderline(loginUser.getUserName()), id);
Map<String, Object> result = alertPluginInstanceService.delete(loginUser, alertPluginInstance); Map<String, Object> result = alertPluginInstanceService.delete(loginUser, id);
return returnDataListPaging(result); return returnDataList(result);
} }
/** /**
...@@ -139,9 +157,84 @@ public class AlertPluginInstanceController extends BaseController { ...@@ -139,9 +157,84 @@ public class AlertPluginInstanceController extends BaseController {
@ApiException(GET_ALERT_PLUGIN_INSTANCE_ERROR) @ApiException(GET_ALERT_PLUGIN_INSTANCE_ERROR)
public Result getAlertPluginInstance(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser, public Result getAlertPluginInstance(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser,
@RequestParam(value = "id") int id) { @RequestParam(value = "id") int id) {
logger.info("login user {}, get alert plugin instance, id {}", logger.info("login user {},get alert plugin instance, id {}", StringUtils.replaceNRTtoUnderline(loginUser.getUserName()), id);
loginUser.getUserName(), id);
Map<String, Object> result = alertPluginInstanceService.get(loginUser, id); Map<String, Object> result = alertPluginInstanceService.get(loginUser, id);
return returnDataList(result); return returnDataList(result);
} }
/**
* getAlertPluginInstance
*
* @param loginUser login user
* @return result
*/
@ApiOperation(value = "/queryAll", notes = "QUERY_ALL_ALERT_PLUGIN_INSTANCE_NOTES")
@PostMapping(value = "/queryAll")
@ResponseStatus(HttpStatus.OK)
@ApiException(QUERY_ALL_ALERT_PLUGIN_INSTANCE_ERROR)
public Result getAlertPluginInstance(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser) {
logger.info("login user {}, query all alert plugin instance", StringUtils.replaceNRTtoUnderline(loginUser.getUserName()));
Map<String, Object> result = alertPluginInstanceService.queryAll();
return returnDataList(result);
}
/**
* check alert group exist
*
* @param loginUser login user
* @param alertInstanceName alert instance name
* @return check result code
*/
@ApiOperation(value = "verifyAlertInstanceName", notes = "VERIFY_ALERT_INSTANCE_NAME_NOTES")
@ApiImplicitParams({
@ApiImplicitParam(name = "groupName", value = "GROUP_NAME", required = true, dataType = "String"),
})
@GetMapping(value = "/verify-alert-instance-name")
@ResponseStatus(HttpStatus.OK)
public Result verifyGroupName(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser,
@RequestParam(value = "alertInstanceName") String alertInstanceName) {
logger.info("login user {},verify alert instance name: {}", StringUtils.replaceNRTtoUnderline(loginUser.getUserName()), StringUtils.replaceNRTtoUnderline(alertInstanceName));
boolean exist = alertPluginInstanceService.checkExistPluginInstanceName(alertInstanceName);
Result result = new Result();
if (exist) {
logger.error("alert plugin instance {} has exist, can't create again.", alertInstanceName);
result.setCode(Status.PLUGIN_INSTANCE_ALREADY_EXIT.getCode());
result.setMsg(Status.PLUGIN_INSTANCE_ALREADY_EXIT.getMsg());
} else {
result.setCode(Status.SUCCESS.getCode());
result.setMsg(Status.SUCCESS.getMsg());
}
return result;
}
/**
* paging query alert plugin instance group list
*
* @param loginUser login user
* @param pageNo page number
* @param pageSize page size
* @return alert plugin instance list page
*/
@ApiOperation(value = "queryAlertPluginInstanceListPaging", notes = "QUERY_ALERT_PLUGIN_INSTANCE_LIST_PAGING_NOTES")
@ApiImplicitParams({
@ApiImplicitParam(name = "pageNo", value = "PAGE_NO", dataType = "Int", example = "1"),
@ApiImplicitParam(name = "pageSize", value = "PAGE_SIZE", dataType = "Int", example = "20")
})
@GetMapping(value = "/list-paging")
@ResponseStatus(HttpStatus.OK)
@ApiException(LIST_PAGING_ALERT_PLUGIN_INSTANCE_ERROR)
public Result listPaging(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser,
@RequestParam("pageNo") Integer pageNo,
@RequestParam("pageSize") Integer pageSize) {
logger.info("login user {}, list paging, pageNo: {}, pageSize: {}",StringUtils.replaceNRTtoUnderline(loginUser.getUserName()), pageNo, pageSize);
Map<String, Object> result = checkPageParams(pageNo, pageSize);
if (result.get(Constants.STATUS) != Status.SUCCESS) {
return returnDataListPaging(result);
}
result = alertPluginInstanceService.queryPluginPage(pageNo, pageSize);
return returnDataListPaging(result);
}
} }
...@@ -14,12 +14,20 @@ ...@@ -14,12 +14,20 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.apache.dolphinscheduler.api.controller; package org.apache.dolphinscheduler.api.controller;
import io.swagger.annotations.Api; import static org.apache.dolphinscheduler.api.enums.Status.AUTHORIZED_DATA_SOURCE;
import io.swagger.annotations.ApiImplicitParam; import static org.apache.dolphinscheduler.api.enums.Status.CONNECTION_TEST_FAILURE;
import io.swagger.annotations.ApiImplicitParams; import static org.apache.dolphinscheduler.api.enums.Status.CONNECT_DATASOURCE_FAILURE;
import io.swagger.annotations.ApiOperation; import static org.apache.dolphinscheduler.api.enums.Status.CREATE_DATASOURCE_ERROR;
import static org.apache.dolphinscheduler.api.enums.Status.DELETE_DATA_SOURCE_FAILURE;
import static org.apache.dolphinscheduler.api.enums.Status.KERBEROS_STARTUP_STATE;
import static org.apache.dolphinscheduler.api.enums.Status.QUERY_DATASOURCE_ERROR;
import static org.apache.dolphinscheduler.api.enums.Status.UNAUTHORIZED_DATASOURCE;
import static org.apache.dolphinscheduler.api.enums.Status.UPDATE_DATASOURCE_ERROR;
import static org.apache.dolphinscheduler.api.enums.Status.VERIFY_DATASOURCE_NAME_FAILURE;
import org.apache.dolphinscheduler.api.enums.Status; import org.apache.dolphinscheduler.api.enums.Status;
import org.apache.dolphinscheduler.api.exceptions.ApiException; import org.apache.dolphinscheduler.api.exceptions.ApiException;
import org.apache.dolphinscheduler.api.service.DataSourceService; import org.apache.dolphinscheduler.api.service.DataSourceService;
...@@ -30,16 +38,26 @@ import org.apache.dolphinscheduler.common.enums.DbType; ...@@ -30,16 +38,26 @@ import org.apache.dolphinscheduler.common.enums.DbType;
import org.apache.dolphinscheduler.common.utils.CommonUtils; import org.apache.dolphinscheduler.common.utils.CommonUtils;
import org.apache.dolphinscheduler.common.utils.ParameterUtils; import org.apache.dolphinscheduler.common.utils.ParameterUtils;
import org.apache.dolphinscheduler.dao.entity.User; import org.apache.dolphinscheduler.dao.entity.User;
import java.util.Map;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.GetMapping;
import springfox.documentation.annotations.ApiIgnore; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestAttribute;
import java.util.Map; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestController;
import static org.apache.dolphinscheduler.api.enums.Status.*; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import springfox.documentation.annotations.ApiIgnore;
/** /**
* data source controller * data source controller
...@@ -101,8 +119,7 @@ public class DataSourceController extends BaseController { ...@@ -101,8 +119,7 @@ public class DataSourceController extends BaseController {
logger.info("login user {} create datasource name: {}, note: {}, type: {}, host: {}, port: {}, database : {}, principal: {}, userName : {}, connectType: {}, other: {}", logger.info("login user {} create datasource name: {}, note: {}, type: {}, host: {}, port: {}, database : {}, principal: {}, userName : {}, connectType: {}, other: {}",
loginUser.getUserName(), name, note, type, host, port, database, principal, userName, connectType, other); loginUser.getUserName(), name, note, type, host, port, database, principal, userName, connectType, other);
String parameter = dataSourceService.buildParameter(type, host, port, database, principal, userName, password, connectType, other); String parameter = dataSourceService.buildParameter(type, host, port, database, principal, userName, password, connectType, other);
Map<String, Object> result = dataSourceService.createDataSource(loginUser, name, note, type, parameter); return dataSourceService.createDataSource(loginUser, name, note, type, parameter);
return returnDataList(result);
} }
...@@ -156,8 +173,7 @@ public class DataSourceController extends BaseController { ...@@ -156,8 +173,7 @@ public class DataSourceController extends BaseController {
logger.info("login user {} updateProcessInstance datasource name: {}, note: {}, type: {}, connectType: {}, other: {}", logger.info("login user {} updateProcessInstance datasource name: {}, note: {}, type: {}, connectType: {}, other: {}",
loginUser.getUserName(), name, note, type, connectType, other); loginUser.getUserName(), name, note, type, connectType, other);
String parameter = dataSourceService.buildParameter(type, host, port, database, principal, userName, password, connectType, other); String parameter = dataSourceService.buildParameter(type, host, port, database, principal, userName, password, connectType, other);
Map<String, Object> dataSource = dataSourceService.updateDataSource(id, loginUser, name, note, type, parameter); return dataSourceService.updateDataSource(id, loginUser, name, note, type, parameter);
return returnDataList(dataSource);
} }
/** /**
...@@ -281,15 +297,7 @@ public class DataSourceController extends BaseController { ...@@ -281,15 +297,7 @@ public class DataSourceController extends BaseController {
logger.info("login user {}, connect datasource: {}, note: {}, type: {}, connectType: {}, other: {}", logger.info("login user {}, connect datasource: {}, note: {}, type: {}, connectType: {}, other: {}",
loginUser.getUserName(), name, note, type, connectType, other); loginUser.getUserName(), name, note, type, connectType, other);
String parameter = dataSourceService.buildParameter(type, host, port, database, principal, userName, password, connectType, other); String parameter = dataSourceService.buildParameter(type, host, port, database, principal, userName, password, connectType, other);
Boolean isConnection = dataSourceService.checkConnection(type, parameter); return dataSourceService.checkConnection(type, parameter);
Result result = new Result();
if (isConnection) {
putMsg(result, SUCCESS);
} else {
putMsg(result, CONNECT_DATASOURCE_FAILURE);
}
return result;
} }
/** /**
...@@ -309,16 +317,7 @@ public class DataSourceController extends BaseController { ...@@ -309,16 +317,7 @@ public class DataSourceController extends BaseController {
public Result connectionTest(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser, public Result connectionTest(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser,
@RequestParam("id") int id) { @RequestParam("id") int id) {
logger.info("connection test, login user:{}, id:{}", loginUser.getUserName(), id); logger.info("connection test, login user:{}, id:{}", loginUser.getUserName(), id);
return dataSourceService.connectionTest(id);
Boolean isConnection = dataSourceService.connectionTest(id);
Result result = new Result();
if (isConnection) {
putMsg(result, SUCCESS);
} else {
putMsg(result, CONNECTION_TEST_FAILURE);
}
return result;
} }
/** /**
......
...@@ -32,6 +32,7 @@ import org.apache.dolphinscheduler.common.enums.Priority; ...@@ -32,6 +32,7 @@ import org.apache.dolphinscheduler.common.enums.Priority;
import org.apache.dolphinscheduler.common.enums.RunMode; import org.apache.dolphinscheduler.common.enums.RunMode;
import org.apache.dolphinscheduler.common.enums.TaskDependType; import org.apache.dolphinscheduler.common.enums.TaskDependType;
import org.apache.dolphinscheduler.common.enums.WarningType; import org.apache.dolphinscheduler.common.enums.WarningType;
import org.apache.dolphinscheduler.common.utils.JSONUtils;
import org.apache.dolphinscheduler.dao.entity.User; import org.apache.dolphinscheduler.dao.entity.User;
import java.text.ParseException; import java.text.ParseException;
...@@ -72,36 +73,36 @@ public class ExecutorController extends BaseController { ...@@ -72,36 +73,36 @@ public class ExecutorController extends BaseController {
/** /**
* execute process instance * execute process instance
* *
* @param loginUser login user * @param loginUser login user
* @param projectName project name * @param projectName project name
* @param processDefinitionId process definition id * @param processDefinitionId process definition id
* @param scheduleTime schedule time * @param scheduleTime schedule time
* @param failureStrategy failure strategy * @param failureStrategy failure strategy
* @param startNodeList start nodes list * @param startNodeList start nodes list
* @param taskDependType task depend type * @param taskDependType task depend type
* @param execType execute type * @param execType execute type
* @param warningType warning type * @param warningType warning type
* @param warningGroupId warning group id * @param warningGroupId warning group id
* @param runMode run mode * @param runMode run mode
* @param processInstancePriority process instance priority * @param processInstancePriority process instance priority
* @param workerGroup worker group * @param workerGroup worker group
* @param timeout timeout * @param timeout timeout
* @return start process result code * @return start process result code
*/ */
@ApiOperation(value = "startProcessInstance", notes = "RUN_PROCESS_INSTANCE_NOTES") @ApiOperation(value = "startProcessInstance", notes = "RUN_PROCESS_INSTANCE_NOTES")
@ApiImplicitParams({ @ApiImplicitParams({
@ApiImplicitParam(name = "processDefinitionId", value = "PROCESS_DEFINITION_ID", required = true, dataType = "Int", example = "100"), @ApiImplicitParam(name = "processDefinitionId", value = "PROCESS_DEFINITION_ID", required = true, dataType = "Int", example = "100"),
@ApiImplicitParam(name = "scheduleTime", value = "SCHEDULE_TIME", required = true, dataType = "String"), @ApiImplicitParam(name = "scheduleTime", value = "SCHEDULE_TIME", required = true, dataType = "String"),
@ApiImplicitParam(name = "failureStrategy", value = "FAILURE_STRATEGY", required = true, dataType = "FailureStrategy"), @ApiImplicitParam(name = "failureStrategy", value = "FAILURE_STRATEGY", required = true, dataType = "FailureStrategy"),
@ApiImplicitParam(name = "startNodeList", value = "START_NODE_LIST", dataType = "String"), @ApiImplicitParam(name = "startNodeList", value = "START_NODE_LIST", dataType = "String"),
@ApiImplicitParam(name = "taskDependType", value = "TASK_DEPEND_TYPE", dataType = "TaskDependType"), @ApiImplicitParam(name = "taskDependType", value = "TASK_DEPEND_TYPE", dataType = "TaskDependType"),
@ApiImplicitParam(name = "execType", value = "COMMAND_TYPE", dataType = "CommandType"), @ApiImplicitParam(name = "execType", value = "COMMAND_TYPE", dataType = "CommandType"),
@ApiImplicitParam(name = "warningType", value = "WARNING_TYPE", required = true, dataType = "WarningType"), @ApiImplicitParam(name = "warningType", value = "WARNING_TYPE", required = true, dataType = "WarningType"),
@ApiImplicitParam(name = "warningGroupId", value = "WARNING_GROUP_ID", required = true, dataType = "Int", example = "100"), @ApiImplicitParam(name = "warningGroupId", value = "WARNING_GROUP_ID", required = true, dataType = "Int", example = "100"),
@ApiImplicitParam(name = "runMode", value = "RUN_MODE", dataType = "RunMode"), @ApiImplicitParam(name = "runMode", value = "RUN_MODE", dataType = "RunMode"),
@ApiImplicitParam(name = "processInstancePriority", value = "PROCESS_INSTANCE_PRIORITY", required = true, dataType = "Priority"), @ApiImplicitParam(name = "processInstancePriority", value = "PROCESS_INSTANCE_PRIORITY", required = true, dataType = "Priority"),
@ApiImplicitParam(name = "workerGroup", value = "WORKER_GROUP", dataType = "String", example = "default"), @ApiImplicitParam(name = "workerGroup", value = "WORKER_GROUP", dataType = "String", example = "default"),
@ApiImplicitParam(name = "timeout", value = "TIMEOUT", dataType = "Int", example = "100"), @ApiImplicitParam(name = "timeout", value = "TIMEOUT", dataType = "Int", example = "100"),
}) })
@PostMapping(value = "start-process-instance") @PostMapping(value = "start-process-instance")
@ResponseStatus(HttpStatus.OK) @ResponseStatus(HttpStatus.OK)
...@@ -119,21 +120,25 @@ public class ExecutorController extends BaseController { ...@@ -119,21 +120,25 @@ public class ExecutorController extends BaseController {
@RequestParam(value = "runMode", required = false) RunMode runMode, @RequestParam(value = "runMode", required = false) RunMode runMode,
@RequestParam(value = "processInstancePriority", required = false) Priority processInstancePriority, @RequestParam(value = "processInstancePriority", required = false) Priority processInstancePriority,
@RequestParam(value = "workerGroup", required = false, defaultValue = "default") String workerGroup, @RequestParam(value = "workerGroup", required = false, defaultValue = "default") String workerGroup,
@RequestParam(value = "timeout", required = false) Integer timeout) throws ParseException { @RequestParam(value = "timeout", required = false) Integer timeout,
logger.info("login user {}, start process instance, project name: {}, process definition id: {}, schedule time: {}, " @RequestParam(value = "startParams", required = false) String startParams) throws ParseException {
+ "failure policy: {}, node name: {}, node dep: {}, notify type: {}, " logger.info("login user {}, start process instance, project name: {}, process definition id: {}, schedule time: {}, "
+ "notify group id: {}, run mode: {},process instance priority:{}, workerGroup: {}, timeout: {}", + "failure policy: {}, node name: {}, node dep: {}, notify type: {}, "
loginUser.getUserName(), projectName, processDefinitionId, scheduleTime, + "notify group id: {}, run mode: {},process instance priority:{}, workerGroup: {}, timeout: {}, startParams: {} ",
failureStrategy, startNodeList, taskDependType, warningType, workerGroup, runMode, processInstancePriority, loginUser.getUserName(), projectName, processDefinitionId, scheduleTime,
workerGroup, timeout); failureStrategy, startNodeList, taskDependType, warningType, workerGroup, runMode, processInstancePriority,
workerGroup, timeout, startParams);
if (timeout == null) { if (timeout == null) {
timeout = Constants.MAX_TASK_TIMEOUT; timeout = Constants.MAX_TASK_TIMEOUT;
} }
Map<String, String> startParamMap = null;
if (startParams != null) {
startParamMap = JSONUtils.toMap(startParams);
}
Map<String, Object> result = execService.execProcessInstance(loginUser, projectName, processDefinitionId, scheduleTime, execType, failureStrategy, Map<String, Object> result = execService.execProcessInstance(loginUser, projectName, processDefinitionId, scheduleTime, execType, failureStrategy,
startNodeList, taskDependType, warningType, startNodeList, taskDependType, warningType,
warningGroupId, runMode, processInstancePriority, workerGroup, timeout); warningGroupId, runMode, processInstancePriority, workerGroup, timeout, startParamMap);
return returnDataList(result); return returnDataList(result);
} }
...@@ -141,16 +146,16 @@ public class ExecutorController extends BaseController { ...@@ -141,16 +146,16 @@ public class ExecutorController extends BaseController {
/** /**
* do action to process instance:pause, stop, repeat, recover from pause, recover from stop * do action to process instance:pause, stop, repeat, recover from pause, recover from stop
* *
* @param loginUser login user * @param loginUser login user
* @param projectName project name * @param projectName project name
* @param processInstanceId process instance id * @param processInstanceId process instance id
* @param executeType execute type * @param executeType execute type
* @return execute result code * @return execute result code
*/ */
@ApiOperation(value = "execute", notes = "EXECUTE_ACTION_TO_PROCESS_INSTANCE_NOTES") @ApiOperation(value = "execute", notes = "EXECUTE_ACTION_TO_PROCESS_INSTANCE_NOTES")
@ApiImplicitParams({ @ApiImplicitParams({
@ApiImplicitParam(name = "processInstanceId", value = "PROCESS_INSTANCE_ID", required = true, dataType = "Int", example = "100"), @ApiImplicitParam(name = "processInstanceId", value = "PROCESS_INSTANCE_ID", required = true, dataType = "Int", example = "100"),
@ApiImplicitParam(name = "executeType", value = "EXECUTE_TYPE", required = true, dataType = "ExecuteType") @ApiImplicitParam(name = "executeType", value = "EXECUTE_TYPE", required = true, dataType = "ExecuteType")
}) })
@PostMapping(value = "/execute") @PostMapping(value = "/execute")
@ResponseStatus(HttpStatus.OK) @ResponseStatus(HttpStatus.OK)
...@@ -161,7 +166,7 @@ public class ExecutorController extends BaseController { ...@@ -161,7 +166,7 @@ public class ExecutorController extends BaseController {
@RequestParam("executeType") ExecuteType executeType @RequestParam("executeType") ExecuteType executeType
) { ) {
logger.info("execute command, login user: {}, project:{}, process instance id:{}, execute type:{}", logger.info("execute command, login user: {}, project:{}, process instance id:{}, execute type:{}",
loginUser.getUserName(), projectName, processInstanceId, executeType); loginUser.getUserName(), projectName, processInstanceId, executeType);
Map<String, Object> result = execService.execute(loginUser, projectName, processInstanceId, executeType); Map<String, Object> result = execService.execute(loginUser, projectName, processInstanceId, executeType);
return returnDataList(result); return returnDataList(result);
} }
...@@ -169,13 +174,13 @@ public class ExecutorController extends BaseController { ...@@ -169,13 +174,13 @@ public class ExecutorController extends BaseController {
/** /**
* check process definition and all of the son process definitions is on line. * check process definition and all of the son process definitions is on line.
* *
* @param loginUser login user * @param loginUser login user
* @param processDefinitionId process definition id * @param processDefinitionId process definition id
* @return check result code * @return check result code
*/ */
@ApiOperation(value = "startCheckProcessDefinition", notes = "START_CHECK_PROCESS_DEFINITION_NOTES") @ApiOperation(value = "startCheckProcessDefinition", notes = "START_CHECK_PROCESS_DEFINITION_NOTES")
@ApiImplicitParams({ @ApiImplicitParams({
@ApiImplicitParam(name = "processDefinitionId", value = "PROCESS_DEFINITION_ID", required = true, dataType = "Int", example = "100") @ApiImplicitParam(name = "processDefinitionId", value = "PROCESS_DEFINITION_ID", required = true, dataType = "Int", example = "100")
}) })
@PostMapping(value = "/start-check") @PostMapping(value = "/start-check")
@ResponseStatus(HttpStatus.OK) @ResponseStatus(HttpStatus.OK)
......
...@@ -35,6 +35,7 @@ import org.apache.dolphinscheduler.common.enums.Priority; ...@@ -35,6 +35,7 @@ import org.apache.dolphinscheduler.common.enums.Priority;
import org.apache.dolphinscheduler.common.enums.ReleaseState; import org.apache.dolphinscheduler.common.enums.ReleaseState;
import org.apache.dolphinscheduler.common.enums.WarningType; import org.apache.dolphinscheduler.common.enums.WarningType;
import org.apache.dolphinscheduler.common.utils.ParameterUtils; import org.apache.dolphinscheduler.common.utils.ParameterUtils;
import org.apache.dolphinscheduler.common.utils.StringUtils;
import org.apache.dolphinscheduler.dao.entity.User; import org.apache.dolphinscheduler.dao.entity.User;
import java.util.Map; import java.util.Map;
...@@ -113,9 +114,9 @@ public class SchedulerController extends BaseController { ...@@ -113,9 +114,9 @@ public class SchedulerController extends BaseController {
@RequestParam(value = "failureStrategy", required = false, defaultValue = DEFAULT_FAILURE_POLICY) FailureStrategy failureStrategy, @RequestParam(value = "failureStrategy", required = false, defaultValue = DEFAULT_FAILURE_POLICY) FailureStrategy failureStrategy,
@RequestParam(value = "workerGroup", required = false, defaultValue = "default") String workerGroup, @RequestParam(value = "workerGroup", required = false, defaultValue = "default") String workerGroup,
@RequestParam(value = "processInstancePriority", required = false, defaultValue = DEFAULT_PROCESS_INSTANCE_PRIORITY) Priority processInstancePriority) { @RequestParam(value = "processInstancePriority", required = false, defaultValue = DEFAULT_PROCESS_INSTANCE_PRIORITY) Priority processInstancePriority) {
logger.info("login user {}, project name: {}, process name: {}, create schedule: {}, warning type: {}, warning group id: {}," logger.info("login user {},project name: {}, process name: {}, create schedule: {}, warning type: {}, warning group id: {},"
+ "failure policy: {},processInstancePriority : {}, workGroupId:{}", + "failure policy: {},processInstancePriority : {}, workGroupId:{}",
loginUser.getUserName(), projectName, processDefinitionId, schedule, warningType, warningGroupId, StringUtils.replaceNRTtoUnderline(loginUser.getUserName()), StringUtils.replaceNRTtoUnderline(projectName), processDefinitionId, schedule, warningType, warningGroupId,
failureStrategy, processInstancePriority, workerGroup); failureStrategy, processInstancePriority, workerGroup);
Map<String, Object> result = schedulerService.insertSchedule(loginUser, projectName, processDefinitionId, schedule, Map<String, Object> result = schedulerService.insertSchedule(loginUser, projectName, processDefinitionId, schedule,
warningType, warningGroupId, failureStrategy, processInstancePriority, workerGroup); warningType, warningGroupId, failureStrategy, processInstancePriority, workerGroup);
...@@ -158,9 +159,9 @@ public class SchedulerController extends BaseController { ...@@ -158,9 +159,9 @@ public class SchedulerController extends BaseController {
@RequestParam(value = "failureStrategy", required = false, defaultValue = "END") FailureStrategy failureStrategy, @RequestParam(value = "failureStrategy", required = false, defaultValue = "END") FailureStrategy failureStrategy,
@RequestParam(value = "workerGroup", required = false, defaultValue = "default") String workerGroup, @RequestParam(value = "workerGroup", required = false, defaultValue = "default") String workerGroup,
@RequestParam(value = "processInstancePriority", required = false) Priority processInstancePriority) { @RequestParam(value = "processInstancePriority", required = false) Priority processInstancePriority) {
logger.info("login user {}, project name: {},id: {}, updateProcessInstance schedule: {}, notify type: {}, notify mails: {}, " logger.info("login user {},project name: {},id: {}, updateProcessInstance schedule: {}, notify type: {}, notify mails: {}, "
+ "failure policy: {},processInstancePriority : {},workerGroupId:{}", + "failure policy: {},processInstancePriority : {},workerGroupId:{}",
loginUser.getUserName(), projectName, id, schedule, warningType, warningGroupId, failureStrategy, StringUtils.replaceNRTtoUnderline(loginUser.getUserName()), StringUtils.replaceNRTtoUnderline(projectName), id, schedule, warningType, warningGroupId, failureStrategy,
processInstancePriority, workerGroup); processInstancePriority, workerGroup);
Map<String, Object> result = schedulerService.updateSchedule(loginUser, projectName, id, schedule, Map<String, Object> result = schedulerService.updateSchedule(loginUser, projectName, id, schedule,
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
package org.apache.dolphinscheduler.api.controller; package org.apache.dolphinscheduler.api.controller;
import static org.apache.dolphinscheduler.api.enums.Status.FORCE_TASK_SUCCESS_ERROR;
import static org.apache.dolphinscheduler.api.enums.Status.QUERY_TASK_LIST_PAGING_ERROR; import static org.apache.dolphinscheduler.api.enums.Status.QUERY_TASK_LIST_PAGING_ERROR;
import org.apache.dolphinscheduler.api.exceptions.ApiException; import org.apache.dolphinscheduler.api.exceptions.ApiException;
...@@ -36,6 +37,7 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -36,6 +37,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestAttribute; import org.springframework.web.bind.annotation.RequestAttribute;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
...@@ -127,4 +129,27 @@ public class TaskInstanceController extends BaseController { ...@@ -127,4 +129,27 @@ public class TaskInstanceController extends BaseController {
return returnDataListPaging(result); return returnDataListPaging(result);
} }
/**
* change one task instance's state from FAILURE to FORCED_SUCCESS
*
* @param loginUser login user
* @param projectName project name
* @param taskInstanceId task instance id
* @return the result code and msg
*/
@ApiOperation(value = "force-success", notes = "FORCE_TASK_SUCCESS")
@ApiImplicitParams({
@ApiImplicitParam(name = "taskInstanceId", value = "TASK_INSTANCE_ID", required = true, dataType = "Int", example = "12")
})
@PostMapping(value = "/force-success")
@ResponseStatus(HttpStatus.OK)
@ApiException(FORCE_TASK_SUCCESS_ERROR)
public Result<Object> forceTaskSuccess(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser,
@ApiParam(name = "projectName", value = "PROJECT_NAME", required = true) @PathVariable String projectName,
@RequestParam(value = "taskInstanceId") Integer taskInstanceId) {
logger.info("force task success, project: {}, task instance id: {}", projectName, taskInstanceId);
Map<String, Object> result = taskInstanceService.forceTaskSuccess(loginUser, projectName, taskInstanceId);
return returnDataList(result);
}
} }
...@@ -22,7 +22,7 @@ import static org.apache.dolphinscheduler.api.enums.Status.DELETE_TENANT_BY_ID_E ...@@ -22,7 +22,7 @@ import static org.apache.dolphinscheduler.api.enums.Status.DELETE_TENANT_BY_ID_E
import static org.apache.dolphinscheduler.api.enums.Status.QUERY_TENANT_LIST_ERROR; import static org.apache.dolphinscheduler.api.enums.Status.QUERY_TENANT_LIST_ERROR;
import static org.apache.dolphinscheduler.api.enums.Status.QUERY_TENANT_LIST_PAGING_ERROR; import static org.apache.dolphinscheduler.api.enums.Status.QUERY_TENANT_LIST_PAGING_ERROR;
import static org.apache.dolphinscheduler.api.enums.Status.UPDATE_TENANT_ERROR; import static org.apache.dolphinscheduler.api.enums.Status.UPDATE_TENANT_ERROR;
import static org.apache.dolphinscheduler.api.enums.Status.VERIFY_TENANT_CODE_ERROR; import static org.apache.dolphinscheduler.api.enums.Status.VERIFY_OS_TENANT_CODE_ERROR;
import org.apache.dolphinscheduler.api.enums.Status; import org.apache.dolphinscheduler.api.enums.Status;
import org.apache.dolphinscheduler.api.exceptions.ApiException; import org.apache.dolphinscheduler.api.exceptions.ApiException;
...@@ -220,7 +220,7 @@ public class TenantController extends BaseController { ...@@ -220,7 +220,7 @@ public class TenantController extends BaseController {
}) })
@GetMapping(value = "/verify-tenant-code") @GetMapping(value = "/verify-tenant-code")
@ResponseStatus(HttpStatus.OK) @ResponseStatus(HttpStatus.OK)
@ApiException(VERIFY_TENANT_CODE_ERROR) @ApiException(VERIFY_OS_TENANT_CODE_ERROR)
public Result verifyTenantCode(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser, public Result verifyTenantCode(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser,
@RequestParam(value = "tenantCode") String tenantCode) { @RequestParam(value = "tenantCode") String tenantCode) {
logger.info("login user {}, verfiy tenant code: {}", logger.info("login user {}, verfiy tenant code: {}",
......
...@@ -80,7 +80,7 @@ public class UiPluginController extends BaseController { ...@@ -80,7 +80,7 @@ public class UiPluginController extends BaseController {
@ApiImplicitParams({ @ApiImplicitParams({
@ApiImplicitParam(name = "id", value = "id", required = true, dataType = "PluginType"), @ApiImplicitParam(name = "id", value = "id", required = true, dataType = "PluginType"),
}) })
@PostMapping(value = "/queryUiPluginsByID") @PostMapping(value = "/queryUiPluginDetailById")
@ResponseStatus(HttpStatus.CREATED) @ResponseStatus(HttpStatus.CREATED)
@ApiException(QUERY_PLUGINS_ERROR) @ApiException(QUERY_PLUGINS_ERROR)
public Result queryUiPluginDetailById(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser, public Result queryUiPluginDetailById(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser,
......
...@@ -57,6 +57,16 @@ public class TaskCountDto { ...@@ -57,6 +57,16 @@ public class TaskCountDto {
.sum(); .sum();
} }
// remove the specified state
public void removeStateFromCountList(ExecutionStatus status) {
for (TaskStateCount count : this.taskCountDtos) {
if (count.getTaskStateType().equals(status)) {
this.taskCountDtos.remove(count);
break;
}
}
}
public List<TaskStateCount> getTaskCountDtos() { public List<TaskStateCount> getTaskCountDtos() {
return taskCountDtos; return taskCountDtos;
} }
......
...@@ -30,7 +30,7 @@ public enum ExecuteType { ...@@ -30,7 +30,7 @@ public enum ExecuteType {
* 4 stop * 4 stop
* 5 pause * 5 pause
*/ */
NONE,REPEAT_RUNNING, RECOVER_SUSPENDED_PROCESS, START_FAILURE_TASK_PROCESS, STOP, PAUSE; NONE, REPEAT_RUNNING, RECOVER_SUSPENDED_PROCESS, START_FAILURE_TASK_PROCESS, STOP, PAUSE;
public static ExecuteType getEnum(int value){ public static ExecuteType getEnum(int value){
......
...@@ -36,7 +36,7 @@ public enum Status { ...@@ -36,7 +36,7 @@ public enum Status {
USER_NAME_NULL(10004, "user name is null", "用户名不能为空"), USER_NAME_NULL(10004, "user name is null", "用户名不能为空"),
HDFS_OPERATION_ERROR(10006, "hdfs operation error", "hdfs操作错误"), HDFS_OPERATION_ERROR(10006, "hdfs operation error", "hdfs操作错误"),
TASK_INSTANCE_NOT_FOUND(10008, "task instance not found", "任务实例不存在"), TASK_INSTANCE_NOT_FOUND(10008, "task instance not found", "任务实例不存在"),
TENANT_CODE_EXIST(10009, "tenant code {0} already exists", "租户编码[{0}]已存在"), OS_TENANT_CODE_EXIST(10009, "os tenant code {0} already exists", "操作系统租户[{0}]已存在"),
USER_NOT_EXIST(10010, "user {0} not exists", "用户[{0}]不存在"), USER_NOT_EXIST(10010, "user {0} not exists", "用户[{0}]不存在"),
ALERT_GROUP_NOT_EXIST(10011, "alarm group not found", "告警组不存在"), ALERT_GROUP_NOT_EXIST(10011, "alarm group not found", "告警组不存在"),
ALERT_GROUP_EXIST(10012, "alarm group already exists", "告警组名称已存在"), ALERT_GROUP_EXIST(10012, "alarm group already exists", "告警组名称已存在"),
...@@ -116,7 +116,7 @@ public enum Status { ...@@ -116,7 +116,7 @@ public enum Status {
QUERY_TENANT_LIST_ERROR(10086, "query tenant list error", "查询租户列表错误"), QUERY_TENANT_LIST_ERROR(10086, "query tenant list error", "查询租户列表错误"),
UPDATE_TENANT_ERROR(10087, "update tenant error", "更新租户错误"), UPDATE_TENANT_ERROR(10087, "update tenant error", "更新租户错误"),
DELETE_TENANT_BY_ID_ERROR(10088, "delete tenant by id error", "删除租户错误"), DELETE_TENANT_BY_ID_ERROR(10088, "delete tenant by id error", "删除租户错误"),
VERIFY_TENANT_CODE_ERROR(10089, "verify tenant code error", "租户编码验证错误"), VERIFY_OS_TENANT_CODE_ERROR(10089, "verify os tenant code error", "操作系统租户验证错误"),
CREATE_USER_ERROR(10090, "create user error", "创建用户错误"), CREATE_USER_ERROR(10090, "create user error", "创建用户错误"),
QUERY_USER_LIST_PAGING_ERROR(10091, "query user list paging error", "分页查询用户列表错误"), QUERY_USER_LIST_PAGING_ERROR(10091, "query user list paging error", "分页查询用户列表错误"),
UPDATE_USER_ERROR(10092, "update user error", "更新用户错误"), UPDATE_USER_ERROR(10092, "update user error", "更新用户错误"),
...@@ -151,7 +151,7 @@ public enum Status { ...@@ -151,7 +151,7 @@ public enum Status {
ENCAPSULATION_PROCESS_INSTANCE_GANTT_STRUCTURE_ERROR(10121, "encapsulation process instance gantt structure error", "查询工作流实例甘特图数据错误"), ENCAPSULATION_PROCESS_INSTANCE_GANTT_STRUCTURE_ERROR(10121, "encapsulation process instance gantt structure error", "查询工作流实例甘特图数据错误"),
QUERY_PROCESS_DEFINITION_LIST_PAGING_ERROR(10122, "query process definition list paging error", "分页查询工作流定义列表错误"), QUERY_PROCESS_DEFINITION_LIST_PAGING_ERROR(10122, "query process definition list paging error", "分页查询工作流定义列表错误"),
SIGN_OUT_ERROR(10123, "sign out error", "退出错误"), SIGN_OUT_ERROR(10123, "sign out error", "退出错误"),
TENANT_CODE_HAS_ALREADY_EXISTS(10124, "tenant code has already exists", "租户编码已存在"), OS_TENANT_CODE_HAS_ALREADY_EXISTS(10124, "os tenant code has already exists", "操作系统租户已存在"),
IP_IS_EMPTY(10125, "ip is empty", "IP地址不能为空"), IP_IS_EMPTY(10125, "ip is empty", "IP地址不能为空"),
SCHEDULE_CRON_REALEASE_NEED_NOT_CHANGE(10126, "schedule release is already {0}", "调度配置上线错误[{0}]"), SCHEDULE_CRON_REALEASE_NEED_NOT_CHANGE(10126, "schedule release is already {0}", "调度配置上线错误[{0}]"),
CREATE_QUEUE_ERROR(10127, "create queue error", "创建队列错误"), CREATE_QUEUE_ERROR(10127, "create queue error", "创建队列错误"),
...@@ -180,12 +180,12 @@ public enum Status { ...@@ -180,12 +180,12 @@ public enum Status {
MOVE_PROCESS_DEFINITION_ERROR(10150, "move process definition from {0} to {1} error : {2}", "从{0}移动工作流到{1}错误 : {2}"), MOVE_PROCESS_DEFINITION_ERROR(10150, "move process definition from {0} to {1} error : {2}", "从{0}移动工作流到{1}错误 : {2}"),
SWITCH_PROCESS_DEFINITION_VERSION_ERROR(10151, "Switch process definition version error", "切换工作流版本出错"), SWITCH_PROCESS_DEFINITION_VERSION_ERROR(10151, "Switch process definition version error", "切换工作流版本出错"),
SWITCH_PROCESS_DEFINITION_VERSION_NOT_EXIST_PROCESS_DEFINITION_ERROR(10152 SWITCH_PROCESS_DEFINITION_VERSION_NOT_EXIST_PROCESS_DEFINITION_ERROR(10152
, "Switch process definition version error: not exists process definition, [process definition id {0}]", "切换工作流版本出错:工作流不存在,[工作流id {0}]"), , "Switch process definition version error: not exists process definition, [process definition id {0}]", "切换工作流版本出错:工作流不存在,[工作流id {0}]"),
SWITCH_PROCESS_DEFINITION_VERSION_NOT_EXIST_PROCESS_DEFINITION_VERSION_ERROR(10153 SWITCH_PROCESS_DEFINITION_VERSION_NOT_EXIST_PROCESS_DEFINITION_VERSION_ERROR(10153
, "Switch process definition version error: not exists process definition version, [process definition id {0}] [version number {1}]", "切换工作流版本出错:工作流版本信息不存在,[工作流id {0}] [版本号 {1}]"), , "Switch process definition version error: not exists process definition version, [process definition id {0}] [version number {1}]", "切换工作流版本出错:工作流版本信息不存在,[工作流id {0}] [版本号 {1}]"),
QUERY_PROCESS_DEFINITION_VERSIONS_ERROR(10154, "query process definition versions error", "查询工作流历史版本信息出错"), QUERY_PROCESS_DEFINITION_VERSIONS_ERROR(10154, "query process definition versions error", "查询工作流历史版本信息出错"),
QUERY_PROCESS_DEFINITION_VERSIONS_PAGE_NO_OR_PAGE_SIZE_LESS_THAN_1_ERROR(10155 QUERY_PROCESS_DEFINITION_VERSIONS_PAGE_NO_OR_PAGE_SIZE_LESS_THAN_1_ERROR(10155
, "query process definition versions error: [page number:{0}] < 1 or [page size:{1}] < 1", "查询工作流历史版本出错:[pageNo:{0}] < 1 或 [pageSize:{1}] < 1"), , "query process definition versions error: [page number:{0}] < 1 or [page size:{1}] < 1", "查询工作流历史版本出错:[pageNo:{0}] < 1 或 [pageSize:{1}] < 1"),
DELETE_PROCESS_DEFINITION_VERSION_ERROR(10156, "delete process definition version error", "删除工作流历史版本出错"), DELETE_PROCESS_DEFINITION_VERSION_ERROR(10156, "delete process definition version error", "删除工作流历史版本出错"),
QUERY_USER_CREATED_PROJECT_ERROR(10157, "query user created project error error", "查询用户创建的项目错误"), QUERY_USER_CREATED_PROJECT_ERROR(10157, "query user created project error error", "查询用户创建的项目错误"),
...@@ -195,12 +195,10 @@ public enum Status { ...@@ -195,12 +195,10 @@ public enum Status {
QUERY_WORKFLOW_LINEAGE_ERROR(10161, "query workflow lineage error", "查询血缘失败"), QUERY_WORKFLOW_LINEAGE_ERROR(10161, "query workflow lineage error", "查询血缘失败"),
QUERY_AUTHORIZED_AND_USER_CREATED_PROJECT_ERROR(10162, "query authorized and user created project error error", "查询授权的和用户创建的项目错误"), QUERY_AUTHORIZED_AND_USER_CREATED_PROJECT_ERROR(10162, "query authorized and user created project error error", "查询授权的和用户创建的项目错误"),
DELETE_PROCESS_DEFINITION_BY_ID_FAIL(10163,"delete process definition by id fail, for there are {0} process instances in executing using it", "删除工作流定义失败,有[{0}]个运行中的工作流实例正在使用"), DELETE_PROCESS_DEFINITION_BY_ID_FAIL(10163,"delete process definition by id fail, for there are {0} process instances in executing using it", "删除工作流定义失败,有[{0}]个运行中的工作流实例正在使用"),
CHECK_TENANT_CODE_ERROR(10164, "Please enter the English tenant code", "请输入英文租户编码"), CHECK_OS_TENANT_CODE_ERROR(10164, "Please enter the English os tenant code", "请输入英文操作系统租户"),
UPDATE_ALERT_PLUGIN_INSTANCE_ERROR(10165, "update alert plugin instance error", "更新告警组和告警组插件实例错误"), FORCE_TASK_SUCCESS_ERROR(10165, "force task success error", "强制成功任务实例错误"),
DELETE_ALERT_PLUGIN_INSTANCE_ERROR(10166, "delete alert plugin instance error", "删除告警组和告警组插件实例错误"), TASK_INSTANCE_STATE_OPERATION_ERROR(10166, "the status of task instance {0} is {1},Cannot perform force success operation", "任务实例[{0}]的状态是[{1}],无法执行强制成功操作"),
GET_ALERT_PLUGIN_INSTANCE_ERROR(10167, "get alert plugin instance error", "获取告警组和告警组插件实例错误"), DATASOURCE_TYPE_NOT_EXIST(10167, "data source type not exist", "数据源类型不存在"),
CREATE_ALERT_PLUGIN_INSTANCE_ERROR(10168, "create alert plugin instance error", "创建告警组和告警组插件实例错误"),
UDF_FUNCTION_NOT_EXIST(20001, "UDF function not found", "UDF函数不存在"), UDF_FUNCTION_NOT_EXIST(20001, "UDF function not found", "UDF函数不存在"),
UDF_FUNCTION_EXISTS(20002, "UDF function already exists", "UDF函数已存在"), UDF_FUNCTION_EXISTS(20002, "UDF function already exists", "UDF函数已存在"),
...@@ -238,7 +236,7 @@ public enum Status { ...@@ -238,7 +236,7 @@ public enum Status {
COUNT_PROCESS_DEFINITION_USER_ERROR(50013, "count process definition user error", "查询各用户流程定义数错误"), COUNT_PROCESS_DEFINITION_USER_ERROR(50013, "count process definition user error", "查询各用户流程定义数错误"),
START_PROCESS_INSTANCE_ERROR(50014, "start process instance error", "运行工作流实例错误"), START_PROCESS_INSTANCE_ERROR(50014, "start process instance error", "运行工作流实例错误"),
EXECUTE_PROCESS_INSTANCE_ERROR(50015, "execute process instance error", "操作工作流实例错误"), EXECUTE_PROCESS_INSTANCE_ERROR(50015, "execute process instance error", "操作工作流实例错误"),
CHECK_PROCESS_DEFINITION_ERROR(50016, "check process definition error", "检查工作流实例错误"), CHECK_PROCESS_DEFINITION_ERROR(50016, "check process definition error", "工作流定义错误"),
QUERY_RECIPIENTS_AND_COPYERS_BY_PROCESS_DEFINITION_ERROR(50017, "query recipients and copyers by process definition error", "查询收件人和抄送人错误"), QUERY_RECIPIENTS_AND_COPYERS_BY_PROCESS_DEFINITION_ERROR(50017, "query recipients and copyers by process definition error", "查询收件人和抄送人错误"),
DATA_IS_NOT_VALID(50017, "data {0} not valid", "数据[{0}]无效"), DATA_IS_NOT_VALID(50017, "data {0} not valid", "数据[{0}]无效"),
DATA_IS_NULL(50018, "data {0} is null", "数据[{0}]不能为空"), DATA_IS_NULL(50018, "data {0} is null", "数据[{0}]不能为空"),
...@@ -252,7 +250,7 @@ public enum Status { ...@@ -252,7 +250,7 @@ public enum Status {
BATCH_DELETE_PROCESS_DEFINE_BY_IDS_ERROR(50026, "batch delete process definition by ids {0} error", "批量删除工作流定义[{0}]错误"), BATCH_DELETE_PROCESS_DEFINE_BY_IDS_ERROR(50026, "batch delete process definition by ids {0} error", "批量删除工作流定义[{0}]错误"),
TENANT_NOT_SUITABLE(50027, "there is not any tenant suitable, please choose a tenant available.", "没有合适的租户,请选择可用的租户"), TENANT_NOT_SUITABLE(50027, "there is not any tenant suitable, please choose a tenant available.", "没有合适的租户,请选择可用的租户"),
EXPORT_PROCESS_DEFINE_BY_ID_ERROR(50028, "export process definition by id error", "导出工作流定义错误"), EXPORT_PROCESS_DEFINE_BY_ID_ERROR(50028, "export process definition by id error", "导出工作流定义错误"),
BATCH_EXPORT_PROCESS_DEFINE_BY_IDS_ERROR(50028, "batch export process definition by ids error", "批量导出工作流定义错误"), BATCH_EXPORT_PROCESS_DEFINE_BY_IDS_ERROR(50028,"batch export process definition by ids error", "批量导出工作流定义错误"),
IMPORT_PROCESS_DEFINE_ERROR(50029, "import process definition error", "导入工作流定义错误"), IMPORT_PROCESS_DEFINE_ERROR(50029, "import process definition error", "导入工作流定义错误"),
HDFS_NOT_STARTUP(60001, "hdfs not startup", "hdfs未启用"), HDFS_NOT_STARTUP(60001, "hdfs not startup", "hdfs未启用"),
...@@ -284,6 +282,15 @@ public enum Status { ...@@ -284,6 +282,15 @@ public enum Status {
QUERY_PLUGINS_RESULT_IS_NULL(110002, "query plugins result is null", "查询插件为空"), QUERY_PLUGINS_RESULT_IS_NULL(110002, "query plugins result is null", "查询插件为空"),
QUERY_PLUGINS_ERROR(110003, "query plugins error", "查询插件错误"), QUERY_PLUGINS_ERROR(110003, "query plugins error", "查询插件错误"),
QUERY_PLUGIN_DETAIL_RESULT_IS_NULL(110004, "query plugin detail result is null", "查询插件详情结果为空"), QUERY_PLUGIN_DETAIL_RESULT_IS_NULL(110004, "query plugin detail result is null", "查询插件详情结果为空"),
UPDATE_ALERT_PLUGIN_INSTANCE_ERROR(110005, "update alert plugin instance error", "更新告警组和告警组插件实例错误"),
DELETE_ALERT_PLUGIN_INSTANCE_ERROR(110006, "delete alert plugin instance error", "删除告警组和告警组插件实例错误"),
GET_ALERT_PLUGIN_INSTANCE_ERROR(110007, "get alert plugin instance error", "获取告警组和告警组插件实例错误"),
CREATE_ALERT_PLUGIN_INSTANCE_ERROR(110008, "create alert plugin instance error", "创建告警组和告警组插件实例错误"),
QUERY_ALL_ALERT_PLUGIN_INSTANCE_ERROR(110009, "query all alert plugin instance error", "查询所有告警实例失败"),
PLUGIN_INSTANCE_ALREADY_EXIT(110010,"plugin instance already exit","该告警插件实例已存在"),
LIST_PAGING_ALERT_PLUGIN_INSTANCE_ERROR(110011,"query plugin instance page error","分页查询告警实例失败"),
; ;
private final int code; private final int code;
...@@ -307,4 +314,4 @@ public enum Status { ...@@ -307,4 +314,4 @@ public enum Status {
return this.enMsg; return this.enMsg;
} }
} }
} }
\ No newline at end of file
...@@ -72,14 +72,14 @@ public class AlertGroupService extends BaseService { ...@@ -72,14 +72,14 @@ public class AlertGroupService extends BaseService {
* *
* @param loginUser login user * @param loginUser login user
* @param searchVal search value * @param searchVal search value
* @param pageNo page number * @param pageNo page number
* @param pageSize page size * @param pageSize page size
* @return alert group list page * @return alert group list page
*/ */
public Map<String, Object> listPaging(User loginUser, String searchVal, Integer pageNo, Integer pageSize) { public Map<String, Object> listPaging(User loginUser, String searchVal, Integer pageNo, Integer pageSize) {
Map<String, Object> result = new HashMap<>(); Map<String, Object> result = new HashMap<>();
if (checkAdmin(loginUser, result)) { if (isNotAdmin(loginUser, result)) {
return result; return result;
} }
...@@ -100,14 +100,14 @@ public class AlertGroupService extends BaseService { ...@@ -100,14 +100,14 @@ public class AlertGroupService extends BaseService {
* *
* @param loginUser login user * @param loginUser login user
* @param groupName group name * @param groupName group name
* @param groupType group type * @param desc description
* @param desc description * @param alertInstanceIds alertInstanceIds
* @return create result code * @return create result code
*/ */
public Map<String, Object> createAlertgroup(User loginUser, String groupName, AlertType groupType, String desc) { public Map<String, Object> createAlertgroup(User loginUser, String groupName, String desc, String alertInstanceIds) {
Map<String, Object> result = new HashMap<>(); Map<String, Object> result = new HashMap<>();
//only admin can operate //only admin can operate
if (checkAdmin(loginUser, result)) { if (isNotAdmin(loginUser, result)) {
return result; return result;
} }
...@@ -115,6 +115,7 @@ public class AlertGroupService extends BaseService { ...@@ -115,6 +115,7 @@ public class AlertGroupService extends BaseService {
Date now = new Date(); Date now = new Date();
alertGroup.setGroupName(groupName); alertGroup.setGroupName(groupName);
alertGroup.setAlertInstanceIds(alertInstanceIds);
alertGroup.setDescription(desc); alertGroup.setDescription(desc);
alertGroup.setCreateTime(now); alertGroup.setCreateTime(now);
alertGroup.setUpdateTime(now); alertGroup.setUpdateTime(now);
...@@ -135,16 +136,16 @@ public class AlertGroupService extends BaseService { ...@@ -135,16 +136,16 @@ public class AlertGroupService extends BaseService {
* updateProcessInstance alert group * updateProcessInstance alert group
* *
* @param loginUser login user * @param loginUser login user
* @param id alert group id * @param id alert group id
* @param groupName group name * @param groupName group name
* @param groupType group type * @param desc description
* @param desc description * @param alertInstanceIds alertInstanceIds
* @return update result code * @return update result code
*/ */
public Map<String, Object> updateAlertgroup(User loginUser, int id, String groupName, AlertType groupType, String desc) { public Map<String, Object> updateAlertgroup(User loginUser, int id, String groupName, String desc, String alertInstanceIds) {
Map<String, Object> result = new HashMap<>(); Map<String, Object> result = new HashMap<>();
if (checkAdmin(loginUser, result)) { if (isNotAdmin(loginUser, result)) {
return result; return result;
} }
...@@ -164,6 +165,7 @@ public class AlertGroupService extends BaseService { ...@@ -164,6 +165,7 @@ public class AlertGroupService extends BaseService {
alertGroup.setDescription(desc); alertGroup.setDescription(desc);
alertGroup.setUpdateTime(now); alertGroup.setUpdateTime(now);
alertGroup.setCreateUserId(loginUser.getId()); alertGroup.setCreateUserId(loginUser.getId());
alertGroup.setAlertInstanceIds(alertInstanceIds);
// updateProcessInstance // updateProcessInstance
alertGroupMapper.updateById(alertGroup); alertGroupMapper.updateById(alertGroup);
putMsg(result, Status.SUCCESS); putMsg(result, Status.SUCCESS);
...@@ -174,7 +176,7 @@ public class AlertGroupService extends BaseService { ...@@ -174,7 +176,7 @@ public class AlertGroupService extends BaseService {
* delete alert group by id * delete alert group by id
* *
* @param loginUser login user * @param loginUser login user
* @param id alert group id * @param id alert group id
* @return delete result code * @return delete result code
*/ */
@Transactional(rollbackFor = RuntimeException.class) @Transactional(rollbackFor = RuntimeException.class)
...@@ -183,7 +185,7 @@ public class AlertGroupService extends BaseService { ...@@ -183,7 +185,7 @@ public class AlertGroupService extends BaseService {
result.put(Constants.STATUS, false); result.put(Constants.STATUS, false);
//only admin can operate //only admin can operate
if (checkAdmin(loginUser, result)) { if (isNotAdmin(loginUser, result)) {
return result; return result;
} }
//check exist //check exist
......
...@@ -17,7 +17,6 @@ ...@@ -17,7 +17,6 @@
package org.apache.dolphinscheduler.api.service; package org.apache.dolphinscheduler.api.service;
import org.apache.dolphinscheduler.dao.entity.AlertPluginInstance;
import org.apache.dolphinscheduler.dao.entity.User; import org.apache.dolphinscheduler.dao.entity.User;
import java.util.Map; import java.util.Map;
...@@ -31,28 +30,31 @@ public interface AlertPluginInstanceService { ...@@ -31,28 +30,31 @@ public interface AlertPluginInstanceService {
* creat alert plugin instance * creat alert plugin instance
* *
* @param loginUser login user * @param loginUser login user
* @param alertPluginInstance alert plugin instance * @param pluginDefineId plugin define id
* @param instanceName instance name
* @param pluginInstanceParams plugin instance params
* @return result * @return result
*/ */
Map<String, Object> create(User loginUser, AlertPluginInstance alertPluginInstance); Map<String, Object> create(User loginUser,int pluginDefineId,String instanceName,String pluginInstanceParams);
/** /**
* update alert plugin instance * update
*
* @param loginUser login user * @param loginUser login user
* @param alertPluginInstance alert plugin instance * @param alertPluginInstanceId plugin instance id
* @param instanceName instance name
* @param pluginInstanceParams plugin instance params
* @return result * @return result
*/ */
Map<String, Object> update(User loginUser, AlertPluginInstance alertPluginInstance); Map<String, Object> update(User loginUser, int alertPluginInstanceId,String instanceName,String pluginInstanceParams);
/** /**
* delete alert plugin instance * delete alert plugin instance
* *
* @param loginUser login user * @param loginUser login user
* @param alertPluginInstance alert plugin instance * @param id id
* @return result * @return result
*/ */
Map<String, Object> delete(User loginUser, AlertPluginInstance alertPluginInstance); Map<String, Object> delete(User loginUser, int id);
/** /**
* get alert plugin instance * get alert plugin instance
...@@ -62,4 +64,26 @@ public interface AlertPluginInstanceService { ...@@ -62,4 +64,26 @@ public interface AlertPluginInstanceService {
* @return alert plugin * @return alert plugin
*/ */
Map<String, Object> get(User loginUser, int id); Map<String, Object> get(User loginUser, int id);
/**
* queryAll
*
* @return alert plugins
*/
Map<String, Object> queryAll();
/**
* checkExistPluginInstanceName
* @param pluginName plugin name
* @return isExist
*/
boolean checkExistPluginInstanceName(String pluginName);
/**
* queryPluginPage
* @param pageIndex page index
* @param pageSize page size
* @return plugins
*/
Map<String, Object> queryPluginPage(int pageIndex,int pageSize);
} }
...@@ -46,13 +46,13 @@ public class BaseService { ...@@ -46,13 +46,13 @@ public class BaseService {
} }
/** /**
* check admin * isNotAdmin
* *
* @param loginUser login user * @param loginUser login user
* @param result result code * @param result result code
* @return true if administrator, otherwise false * @return true if not administrator, otherwise false
*/ */
protected boolean checkAdmin(User loginUser, Map<String, Object> result) { protected boolean isNotAdmin(User loginUser, Map<String, Object> result) {
//only admin can operate //only admin can operate
if (!isAdmin(loginUser)) { if (!isAdmin(loginUser)) {
putMsg(result, Status.USER_NO_OPERATION_PERM); putMsg(result, Status.USER_NO_OPERATION_PERM);
......
...@@ -14,12 +14,9 @@ ...@@ -14,12 +14,9 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.apache.dolphinscheduler.api.service; package org.apache.dolphinscheduler.api.service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fasterxml.jackson.databind.node.ObjectNode;
import org.apache.commons.lang.StringUtils;
import org.apache.dolphinscheduler.api.enums.Status; import org.apache.dolphinscheduler.api.enums.Status;
import org.apache.dolphinscheduler.api.utils.PageInfo; import org.apache.dolphinscheduler.api.utils.PageInfo;
import org.apache.dolphinscheduler.api.utils.Result; import org.apache.dolphinscheduler.api.utils.Result;
...@@ -27,27 +24,36 @@ import org.apache.dolphinscheduler.common.Constants; ...@@ -27,27 +24,36 @@ import org.apache.dolphinscheduler.common.Constants;
import org.apache.dolphinscheduler.common.enums.DbConnectType; import org.apache.dolphinscheduler.common.enums.DbConnectType;
import org.apache.dolphinscheduler.common.enums.DbType; import org.apache.dolphinscheduler.common.enums.DbType;
import org.apache.dolphinscheduler.common.utils.CommonUtils; import org.apache.dolphinscheduler.common.utils.CommonUtils;
import org.apache.dolphinscheduler.common.utils.*; import org.apache.dolphinscheduler.common.utils.JSONUtils;
import org.apache.dolphinscheduler.dao.datasource.*; import org.apache.dolphinscheduler.common.utils.StringUtils;
import org.apache.dolphinscheduler.dao.datasource.BaseDataSource;
import org.apache.dolphinscheduler.dao.datasource.DataSourceFactory;
import org.apache.dolphinscheduler.dao.datasource.OracleDataSource;
import org.apache.dolphinscheduler.dao.entity.DataSource; import org.apache.dolphinscheduler.dao.entity.DataSource;
import org.apache.dolphinscheduler.dao.entity.Resource; import org.apache.dolphinscheduler.dao.entity.Resource;
import org.apache.dolphinscheduler.dao.entity.User; import org.apache.dolphinscheduler.dao.entity.User;
import org.apache.dolphinscheduler.dao.mapper.DataSourceMapper; import org.apache.dolphinscheduler.dao.mapper.DataSourceMapper;
import org.apache.dolphinscheduler.dao.mapper.DataSourceUserMapper; import org.apache.dolphinscheduler.dao.mapper.DataSourceUserMapper;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.security.UserGroupInformation; import java.sql.Connection;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.sql.Connection; import com.baomidou.mybatisplus.core.metadata.IPage;
import java.sql.DriverManager; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import java.sql.SQLException; import com.fasterxml.jackson.databind.node.ObjectNode;
import java.util.*;
import static org.apache.dolphinscheduler.common.utils.PropertyUtils.getString;
/** /**
* datasource service * datasource service
...@@ -67,11 +73,9 @@ public class DataSourceService extends BaseService { ...@@ -67,11 +73,9 @@ public class DataSourceService extends BaseService {
public static final String USER_NAME = "userName"; public static final String USER_NAME = "userName";
public static final String OTHER = "other"; public static final String OTHER = "other";
@Autowired @Autowired
private DataSourceMapper dataSourceMapper; private DataSourceMapper dataSourceMapper;
@Autowired @Autowired
private DataSourceUserMapper datasourceUserMapper; private DataSourceUserMapper datasourceUserMapper;
...@@ -85,24 +89,16 @@ public class DataSourceService extends BaseService { ...@@ -85,24 +89,16 @@ public class DataSourceService extends BaseService {
* @param parameter datasource parameters * @param parameter datasource parameters
* @return create result code * @return create result code
*/ */
public Map<String, Object> createDataSource(User loginUser, String name, String desc, DbType type, String parameter) { public Result<Object> createDataSource(User loginUser, String name, String desc, DbType type, String parameter) {
Map<String, Object> result = new HashMap<>(); Result<Object> result = new Result<>();
// check name can use or not // check name can use or not
if (checkName(name)) { if (checkName(name)) {
putMsg(result, Status.DATASOURCE_EXIST); putMsg(result, Status.DATASOURCE_EXIST);
return result; return result;
} }
Boolean isConnection = checkConnection(type, parameter); Result<Object> isConnection = checkConnection(type, parameter);
if (!isConnection) { if (Status.SUCCESS.getCode() != isConnection.getCode()) {
logger.info("connect failed, type:{}, parameter:{}", type, parameter);
putMsg(result, Status.DATASOURCE_CONNECT_FAILED);
return result;
}
BaseDataSource datasource = DataSourceFactory.getDatasource(type, parameter);
if (datasource == null) {
putMsg(result, Status.REQUEST_PARAMS_NOT_VALID_ERROR, parameter);
return result; return result;
} }
...@@ -125,7 +121,6 @@ public class DataSourceService extends BaseService { ...@@ -125,7 +121,6 @@ public class DataSourceService extends BaseService {
return result; return result;
} }
/** /**
* updateProcessInstance datasource * updateProcessInstance datasource
* *
...@@ -137,9 +132,9 @@ public class DataSourceService extends BaseService { ...@@ -137,9 +132,9 @@ public class DataSourceService extends BaseService {
* @param id data source id * @param id data source id
* @return update result code * @return update result code
*/ */
public Map<String, Object> updateDataSource(int id, User loginUser, String name, String desc, DbType type, String parameter) { public Result<Object> updateDataSource(int id, User loginUser, String name, String desc, DbType type, String parameter) {
Map<String, Object> result = new HashMap<>(); Result<Object> result = new Result<>();
// determine whether the data source exists // determine whether the data source exists
DataSource dataSource = dataSourceMapper.selectById(id); DataSource dataSource = dataSourceMapper.selectById(id);
if (dataSource == null) { if (dataSource == null) {
...@@ -168,12 +163,11 @@ public class DataSourceService extends BaseService { ...@@ -168,12 +163,11 @@ public class DataSourceService extends BaseService {
// connectionParams json // connectionParams json
String connectionParams = paramObject.toString(); String connectionParams = paramObject.toString();
Boolean isConnection = checkConnection(type, connectionParams); Result<Object> isConnection = checkConnection(type, parameter);
if (!isConnection) { if (Status.SUCCESS.getCode() != isConnection.getCode()) {
logger.info("connect failed, type:{}, parameter:{}", type, parameter);
putMsg(result, Status.DATASOURCE_CONNECT_FAILED);
return result; return result;
} }
Date now = new Date(); Date now = new Date();
dataSource.setName(name.trim()); dataSource.setName(name.trim());
...@@ -192,7 +186,6 @@ public class DataSourceService extends BaseService { ...@@ -192,7 +186,6 @@ public class DataSourceService extends BaseService {
return queryDataSource != null && queryDataSource.size() > 0; return queryDataSource != null && queryDataSource.size() > 0;
} }
/** /**
* updateProcessInstance datasource * updateProcessInstance datasource
* *
...@@ -360,8 +353,8 @@ public class DataSourceService extends BaseService { ...@@ -360,8 +353,8 @@ public class DataSourceService extends BaseService {
* @param name datasource name * @param name datasource name
* @return true if data datasource not exists, otherwise return false * @return true if data datasource not exists, otherwise return false
*/ */
public Result verifyDataSourceName(String name) { public Result<Object> verifyDataSourceName(String name) {
Result result = new Result(); Result<Object> result = new Result<>();
List<DataSource> dataSourceList = dataSourceMapper.queryDataSourceByName(name); List<DataSource> dataSourceList = dataSourceMapper.queryDataSourceByName(name);
if (dataSourceList != null && dataSourceList.size() > 0) { if (dataSourceList != null && dataSourceList.size() > 0) {
logger.error("datasource name:{} has exist, can't create again.", name); logger.error("datasource name:{} has exist, can't create again.", name);
...@@ -373,77 +366,6 @@ public class DataSourceService extends BaseService { ...@@ -373,77 +366,6 @@ public class DataSourceService extends BaseService {
return result; return result;
} }
/**
* get connection
*
* @param dbType datasource type
* @param parameter parameter
* @return connection for datasource
*/
private Connection getConnection(DbType dbType, String parameter) {
Connection connection = null;
BaseDataSource datasource = null;
try {
switch (dbType) {
case POSTGRESQL:
datasource = JSONUtils.parseObject(parameter, PostgreDataSource.class);
Class.forName(Constants.ORG_POSTGRESQL_DRIVER);
break;
case MYSQL:
datasource = JSONUtils.parseObject(parameter, MySQLDataSource.class);
Class.forName(Constants.COM_MYSQL_JDBC_DRIVER);
break;
case HIVE:
case SPARK:
if (CommonUtils.getKerberosStartupState()) {
System.setProperty(org.apache.dolphinscheduler.common.Constants.JAVA_SECURITY_KRB5_CONF,
getString(org.apache.dolphinscheduler.common.Constants.JAVA_SECURITY_KRB5_CONF_PATH));
Configuration configuration = new Configuration();
configuration.set(org.apache.dolphinscheduler.common.Constants.HADOOP_SECURITY_AUTHENTICATION, "kerberos");
UserGroupInformation.setConfiguration(configuration);
UserGroupInformation.loginUserFromKeytab(getString(org.apache.dolphinscheduler.common.Constants.LOGIN_USER_KEY_TAB_USERNAME),
getString(org.apache.dolphinscheduler.common.Constants.LOGIN_USER_KEY_TAB_PATH));
}
if (dbType == DbType.HIVE) {
datasource = JSONUtils.parseObject(parameter, HiveDataSource.class);
} else if (dbType == DbType.SPARK) {
datasource = JSONUtils.parseObject(parameter, SparkDataSource.class);
}
Class.forName(Constants.ORG_APACHE_HIVE_JDBC_HIVE_DRIVER);
break;
case CLICKHOUSE:
datasource = JSONUtils.parseObject(parameter, ClickHouseDataSource.class);
Class.forName(Constants.COM_CLICKHOUSE_JDBC_DRIVER);
break;
case ORACLE:
datasource = JSONUtils.parseObject(parameter, OracleDataSource.class);
Class.forName(Constants.COM_ORACLE_JDBC_DRIVER);
break;
case SQLSERVER:
datasource = JSONUtils.parseObject(parameter, SQLServerDataSource.class);
Class.forName(Constants.COM_SQLSERVER_JDBC_DRIVER);
break;
case DB2:
datasource = JSONUtils.parseObject(parameter, DB2ServerDataSource.class);
Class.forName(Constants.COM_DB2_JDBC_DRIVER);
break;
case PRESTO:
datasource = JSONUtils.parseObject(parameter, PrestoDataSource.class);
Class.forName(Constants.COM_PRESTO_JDBC_DRIVER);
break;
default:
break;
}
if (datasource != null) {
connection = DriverManager.getConnection(datasource.getJdbcUrl(), datasource.getUser(), datasource.getPassword());
}
} catch (Exception e) {
logger.error(e.getMessage(), e);
}
return connection;
}
/** /**
* check connection * check connection
* *
...@@ -451,18 +373,24 @@ public class DataSourceService extends BaseService { ...@@ -451,18 +373,24 @@ public class DataSourceService extends BaseService {
* @param parameter data source parameters * @param parameter data source parameters
* @return true if connect successfully, otherwise false * @return true if connect successfully, otherwise false
*/ */
public boolean checkConnection(DbType type, String parameter) { public Result<Object> checkConnection(DbType type, String parameter) {
Boolean isConnection = false; Result<Object> result = new Result<>();
Connection con = getConnection(type, parameter); BaseDataSource datasource = DataSourceFactory.getDatasource(type, parameter);
if (con != null) { if (datasource == null) {
isConnection = true; putMsg(result, Status.DATASOURCE_TYPE_NOT_EXIST, type);
try { return result;
con.close(); }
} catch (SQLException e) { try (Connection connection = datasource.getConnection()) {
logger.error("close connection fail at DataSourceService::checkConnection()", e); if (connection == null) {
putMsg(result, Status.CONNECTION_TEST_FAILURE);
return result;
} }
putMsg(result, Status.SUCCESS);
return result;
} catch (Exception e) {
logger.error("datasource test connection error, dbType:{}, jdbcUrl:{}, message:{}.", type, datasource.getJdbcUrl(), e.getMessage());
return new Result<>(Status.CONNECTION_TEST_FAILURE.getCode(),e.getMessage());
} }
return isConnection;
} }
/** /**
...@@ -471,13 +399,14 @@ public class DataSourceService extends BaseService { ...@@ -471,13 +399,14 @@ public class DataSourceService extends BaseService {
* @param id datasource id * @param id datasource id
* @return connect result code * @return connect result code
*/ */
public boolean connectionTest(int id) { public Result<Object> connectionTest(int id) {
DataSource dataSource = dataSourceMapper.selectById(id); DataSource dataSource = dataSourceMapper.selectById(id);
if (dataSource != null) { if (dataSource == null) {
return checkConnection(dataSource.getType(), dataSource.getConnectionParams()); Result<Object> result = new Result<>();
} else { putMsg(result, Status.RESOURCE_NOT_EXIST);
return false; return result;
} }
return checkConnection(dataSource.getType(), dataSource.getConnectionParams());
} }
/** /**
...@@ -510,8 +439,8 @@ public class DataSourceService extends BaseService { ...@@ -510,8 +439,8 @@ public class DataSourceService extends BaseService {
parameterMap.put(Constants.ORACLE_DB_CONNECT_TYPE, connectType); parameterMap.put(Constants.ORACLE_DB_CONNECT_TYPE, connectType);
} }
if (CommonUtils.getKerberosStartupState() && if (CommonUtils.getKerberosStartupState()
(type == DbType.HIVE || type == DbType.SPARK)) { && (type == DbType.HIVE || type == DbType.SPARK)) {
jdbcUrl += ";principal=" + principal; jdbcUrl += ";principal=" + principal;
} }
...@@ -535,8 +464,8 @@ public class DataSourceService extends BaseService { ...@@ -535,8 +464,8 @@ public class DataSourceService extends BaseService {
parameterMap.put(Constants.JDBC_URL, jdbcUrl); parameterMap.put(Constants.JDBC_URL, jdbcUrl);
parameterMap.put(Constants.USER, userName); parameterMap.put(Constants.USER, userName);
parameterMap.put(Constants.PASSWORD, CommonUtils.encodePassword(password)); parameterMap.put(Constants.PASSWORD, CommonUtils.encodePassword(password));
if (CommonUtils.getKerberosStartupState() && if (CommonUtils.getKerberosStartupState()
(type == DbType.HIVE || type == DbType.SPARK)) { && (type == DbType.HIVE || type == DbType.SPARK)) {
parameterMap.put(Constants.PRINCIPAL, principal); parameterMap.put(Constants.PRINCIPAL, principal);
} }
...@@ -557,7 +486,6 @@ public class DataSourceService extends BaseService { ...@@ -557,7 +486,6 @@ public class DataSourceService extends BaseService {
} }
return JSONUtils.toJsonString(parameterMap); return JSONUtils.toJsonString(parameterMap);
} }
private String buildAddress(DbType type, String host, String port, DbConnectType connectType) { private String buildAddress(DbType type, String host, String port, DbConnectType connectType) {
...@@ -609,8 +537,8 @@ public class DataSourceService extends BaseService { ...@@ -609,8 +537,8 @@ public class DataSourceService extends BaseService {
* @return delete result code * @return delete result code
*/ */
@Transactional(rollbackFor = RuntimeException.class) @Transactional(rollbackFor = RuntimeException.class)
public Result delete(User loginUser, int datasourceId) { public Result<Object> delete(User loginUser, int datasourceId) {
Result result = new Result(); Result<Object> result = new Result<>();
try { try {
//query datasource by id //query datasource by id
DataSource dataSource = dataSourceMapper.selectById(datasourceId); DataSource dataSource = dataSourceMapper.selectById(datasourceId);
...@@ -673,7 +601,6 @@ public class DataSourceService extends BaseService { ...@@ -673,7 +601,6 @@ public class DataSourceService extends BaseService {
return result; return result;
} }
/** /**
* authorized datasource * authorized datasource
* *
...@@ -695,7 +622,6 @@ public class DataSourceService extends BaseService { ...@@ -695,7 +622,6 @@ public class DataSourceService extends BaseService {
return result; return result;
} }
/** /**
* get host and port by address * get host and port by address
* *
......
...@@ -21,6 +21,7 @@ import static org.apache.dolphinscheduler.common.Constants.CMDPARAM_COMPLEMENT_D ...@@ -21,6 +21,7 @@ import static org.apache.dolphinscheduler.common.Constants.CMDPARAM_COMPLEMENT_D
import static org.apache.dolphinscheduler.common.Constants.CMDPARAM_COMPLEMENT_DATA_START_DATE; import static org.apache.dolphinscheduler.common.Constants.CMDPARAM_COMPLEMENT_DATA_START_DATE;
import static org.apache.dolphinscheduler.common.Constants.CMD_PARAM_RECOVER_PROCESS_ID_STRING; import static org.apache.dolphinscheduler.common.Constants.CMD_PARAM_RECOVER_PROCESS_ID_STRING;
import static org.apache.dolphinscheduler.common.Constants.CMD_PARAM_START_NODE_NAMES; import static org.apache.dolphinscheduler.common.Constants.CMD_PARAM_START_NODE_NAMES;
import static org.apache.dolphinscheduler.common.Constants.CMD_PARAM_START_PARAMS;
import static org.apache.dolphinscheduler.common.Constants.MAX_TASK_TIMEOUT; import static org.apache.dolphinscheduler.common.Constants.MAX_TASK_TIMEOUT;
import org.apache.dolphinscheduler.api.enums.ExecuteType; import org.apache.dolphinscheduler.api.enums.ExecuteType;
...@@ -110,6 +111,7 @@ public class ExecutorService extends BaseService { ...@@ -110,6 +111,7 @@ public class ExecutorService extends BaseService {
* @param workerGroup worker group name * @param workerGroup worker group name
* @param runMode run mode * @param runMode run mode
* @param timeout timeout * @param timeout timeout
* @param startParams the global param values which pass to new process instance
* @return execute process instance code * @return execute process instance code
* @throws ParseException Parse Exception * @throws ParseException Parse Exception
*/ */
...@@ -118,7 +120,8 @@ public class ExecutorService extends BaseService { ...@@ -118,7 +120,8 @@ public class ExecutorService extends BaseService {
FailureStrategy failureStrategy, String startNodeList, FailureStrategy failureStrategy, String startNodeList,
TaskDependType taskDependType, WarningType warningType, int warningGroupId, TaskDependType taskDependType, WarningType warningType, int warningGroupId,
RunMode runMode, RunMode runMode,
Priority processInstancePriority, String workerGroup, Integer timeout) throws ParseException { Priority processInstancePriority, String workerGroup, Integer timeout,
Map<String, String> startParams) throws ParseException {
Map<String, Object> result = new HashMap<>(); Map<String, Object> result = new HashMap<>();
// timeout is invalid // timeout is invalid
if (timeout <= 0 || timeout > MAX_TASK_TIMEOUT) { if (timeout <= 0 || timeout > MAX_TASK_TIMEOUT) {
...@@ -155,7 +158,7 @@ public class ExecutorService extends BaseService { ...@@ -155,7 +158,7 @@ public class ExecutorService extends BaseService {
*/ */
int create = this.createCommand(commandType, processDefinitionId, int create = this.createCommand(commandType, processDefinitionId,
taskDependType, failureStrategy, startNodeList, cronTime, warningType, loginUser.getId(), taskDependType, failureStrategy, startNodeList, cronTime, warningType, loginUser.getId(),
warningGroupId, runMode, processInstancePriority, workerGroup); warningGroupId, runMode, processInstancePriority, workerGroup, startParams);
if (create > 0) { if (create > 0) {
processDefinition.setWarningGroupId(warningGroupId); processDefinition.setWarningGroupId(warningGroupId);
...@@ -461,7 +464,8 @@ public class ExecutorService extends BaseService { ...@@ -461,7 +464,8 @@ public class ExecutorService extends BaseService {
TaskDependType nodeDep, FailureStrategy failureStrategy, TaskDependType nodeDep, FailureStrategy failureStrategy,
String startNodeList, String schedule, WarningType warningType, String startNodeList, String schedule, WarningType warningType,
int executorId, int warningGroupId, int executorId, int warningGroupId,
RunMode runMode, Priority processInstancePriority, String workerGroup) throws ParseException { RunMode runMode, Priority processInstancePriority, String workerGroup,
Map<String, String> startParams) throws ParseException {
/** /**
* instantiate command schedule instance * instantiate command schedule instance
...@@ -488,6 +492,9 @@ public class ExecutorService extends BaseService { ...@@ -488,6 +492,9 @@ public class ExecutorService extends BaseService {
if (warningType != null) { if (warningType != null) {
command.setWarningType(warningType); command.setWarningType(warningType);
} }
if (startParams != null && startParams.size() > 0) {
cmdParam.put(CMD_PARAM_START_PARAMS, JSONUtils.toJsonString(startParams));
}
command.setCommandParam(JSONUtils.toJsonString(cmdParam)); command.setCommandParam(JSONUtils.toJsonString(cmdParam));
command.setExecutorId(executorId); command.setExecutorId(executorId);
command.setWarningGroupId(warningGroupId); command.setWarningGroupId(warningGroupId);
......
...@@ -95,6 +95,19 @@ public interface ProcessDefinitionService { ...@@ -95,6 +95,19 @@ public interface ProcessDefinitionService {
String projectName, String projectName,
Integer processId); Integer processId);
/**
* query datail of process definition
*
* @param loginUser login user
* @param projectName project name
* @param processDefinitionName process definition name
* @return process definition detail
*/
Map<String, Object> queryProcessDefinitionByName(User loginUser,
String projectName,
String processDefinitionName);
/** /**
* batch copy process definition * batch copy process definition
* *
......
...@@ -66,11 +66,13 @@ import java.io.InputStreamReader; ...@@ -66,11 +66,13 @@ import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.text.ParseException; import java.text.ParseException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections;
import java.util.Date; import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Objects; import java.util.Objects;
import java.util.Optional;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import org.slf4j.Logger; import org.slf4j.Logger;
...@@ -448,7 +450,7 @@ public class ProcessInstanceService extends BaseService { ...@@ -448,7 +450,7 @@ public class ProcessInstanceService extends BaseService {
originDefParams = JSONUtils.toJsonString(processData.getGlobalParams()); originDefParams = JSONUtils.toJsonString(processData.getGlobalParams());
List<Property> globalParamList = processData.getGlobalParams(); List<Property> globalParamList = processData.getGlobalParams();
Map<String, String> globalParamMap = globalParamList.stream().collect(Collectors.toMap(Property::getProp, Property::getValue)); Map<String, String> globalParamMap = Optional.ofNullable(globalParamList).orElse(Collections.emptyList()).stream().collect(Collectors.toMap(Property::getProp, Property::getValue));
globalParams = ParameterUtils.curingGlobalParams(globalParamMap, globalParamList, globalParams = ParameterUtils.curingGlobalParams(globalParamMap, globalParamList,
processInstance.getCmdTypeIfComplement(), schedule); processInstance.getCmdTypeIfComplement(), schedule);
timeout = processData.getTimeout(); timeout = processData.getTimeout();
......
...@@ -60,7 +60,7 @@ public class QueueService extends BaseService { ...@@ -60,7 +60,7 @@ public class QueueService extends BaseService {
*/ */
public Map<String, Object> queryList(User loginUser) { public Map<String, Object> queryList(User loginUser) {
Map<String, Object> result = new HashMap<>(); Map<String, Object> result = new HashMap<>();
if (checkAdmin(loginUser, result)) { if (isNotAdmin(loginUser, result)) {
return result; return result;
} }
...@@ -75,14 +75,14 @@ public class QueueService extends BaseService { ...@@ -75,14 +75,14 @@ public class QueueService extends BaseService {
* query queue list paging * query queue list paging
* *
* @param loginUser login user * @param loginUser login user
* @param pageNo page number * @param pageNo page number
* @param searchVal search value * @param searchVal search value
* @param pageSize page size * @param pageSize page size
* @return queue list * @return queue list
*/ */
public Map<String, Object> queryList(User loginUser, String searchVal, Integer pageNo, Integer pageSize) { public Map<String, Object> queryList(User loginUser, String searchVal, Integer pageNo, Integer pageSize) {
Map<String, Object> result = new HashMap<>(); Map<String, Object> result = new HashMap<>();
if (checkAdmin(loginUser, result)) { if (isNotAdmin(loginUser, result)) {
return result; return result;
} }
...@@ -105,13 +105,13 @@ public class QueueService extends BaseService { ...@@ -105,13 +105,13 @@ public class QueueService extends BaseService {
* create queue * create queue
* *
* @param loginUser login user * @param loginUser login user
* @param queue queue * @param queue queue
* @param queueName queue name * @param queueName queue name
* @return create result * @return create result
*/ */
public Map<String, Object> createQueue(User loginUser, String queue, String queueName) { public Map<String, Object> createQueue(User loginUser, String queue, String queueName) {
Map<String, Object> result = new HashMap<>(); Map<String, Object> result = new HashMap<>();
if (checkAdmin(loginUser, result)) { if (isNotAdmin(loginUser, result)) {
return result; return result;
} }
...@@ -153,14 +153,14 @@ public class QueueService extends BaseService { ...@@ -153,14 +153,14 @@ public class QueueService extends BaseService {
* update queue * update queue
* *
* @param loginUser login user * @param loginUser login user
* @param queue queue * @param queue queue
* @param id queue id * @param id queue id
* @param queueName queue name * @param queueName queue name
* @return update result code * @return update result code
*/ */
public Map<String, Object> updateQueue(User loginUser, int id, String queue, String queueName) { public Map<String, Object> updateQueue(User loginUser, int id, String queue, String queueName) {
Map<String, Object> result = new HashMap<>(); Map<String, Object> result = new HashMap<>();
if (checkAdmin(loginUser, result)) { if (isNotAdmin(loginUser, result)) {
return result; return result;
} }
......
...@@ -1158,20 +1158,20 @@ public class ResourcesService extends BaseService { ...@@ -1158,20 +1158,20 @@ public class ResourcesService extends BaseService {
public Map<String, Object> authorizeResourceTree(User loginUser, Integer userId) { public Map<String, Object> authorizeResourceTree(User loginUser, Integer userId) {
Map<String, Object> result = new HashMap<>(); Map<String, Object> result = new HashMap<>();
if (checkAdmin(loginUser, result)) { if (isNotAdmin(loginUser, result)) {
return result; return result;
} }
List<Resource> resourceList = resourcesMapper.queryResourceExceptUserId(userId); List<Resource> resourceList = resourcesMapper.queryResourceExceptUserId(userId);
List<ResourceComponent> list ; List<ResourceComponent> list;
if (CollectionUtils.isNotEmpty(resourceList)) { if (CollectionUtils.isNotEmpty(resourceList)) {
Visitor visitor = new ResourceTreeVisitor(resourceList); Visitor visitor = new ResourceTreeVisitor(resourceList);
list = visitor.visit().getChildren(); list = visitor.visit().getChildren();
}else { } else {
list = new ArrayList<>(0); list = new ArrayList<>(0);
} }
result.put(Constants.DATA_LIST, list); result.put(Constants.DATA_LIST, list);
putMsg(result,Status.SUCCESS); putMsg(result, Status.SUCCESS);
return result; return result;
} }
...@@ -1185,23 +1185,23 @@ public class ResourcesService extends BaseService { ...@@ -1185,23 +1185,23 @@ public class ResourcesService extends BaseService {
public Map<String, Object> unauthorizedFile(User loginUser, Integer userId) { public Map<String, Object> unauthorizedFile(User loginUser, Integer userId) {
Map<String, Object> result = new HashMap<>(); Map<String, Object> result = new HashMap<>();
if (checkAdmin(loginUser, result)) { if (isNotAdmin(loginUser, result)) {
return result; return result;
} }
List<Resource> resourceList = resourcesMapper.queryResourceExceptUserId(userId); List<Resource> resourceList = resourcesMapper.queryResourceExceptUserId(userId);
List<Resource> list ; List<Resource> list;
if (resourceList != null && resourceList.size() > 0) { if (resourceList != null && resourceList.size() > 0) {
Set<Resource> resourceSet = new HashSet<>(resourceList); Set<Resource> resourceSet = new HashSet<>(resourceList);
List<Resource> authedResourceList = resourcesMapper.queryAuthorizedResourceList(userId); List<Resource> authedResourceList = resourcesMapper.queryAuthorizedResourceList(userId);
getAuthorizedResourceList(resourceSet, authedResourceList); getAuthorizedResourceList(resourceSet, authedResourceList);
list = new ArrayList<>(resourceSet); list = new ArrayList<>(resourceSet);
}else { } else {
list = new ArrayList<>(0); list = new ArrayList<>(0);
} }
Visitor visitor = new ResourceTreeVisitor(list); Visitor visitor = new ResourceTreeVisitor(list);
result.put(Constants.DATA_LIST, visitor.visit().getChildren()); result.put(Constants.DATA_LIST, visitor.visit().getChildren());
putMsg(result,Status.SUCCESS); putMsg(result, Status.SUCCESS);
return result; return result;
} }
...@@ -1215,7 +1215,7 @@ public class ResourcesService extends BaseService { ...@@ -1215,7 +1215,7 @@ public class ResourcesService extends BaseService {
public Map<String, Object> unauthorizedUDFFunction(User loginUser, Integer userId) { public Map<String, Object> unauthorizedUDFFunction(User loginUser, Integer userId) {
Map<String, Object> result = new HashMap<>(5); Map<String, Object> result = new HashMap<>(5);
//only admin can operate //only admin can operate
if (checkAdmin(loginUser, result)) { if (isNotAdmin(loginUser, result)) {
return result; return result;
} }
...@@ -1231,13 +1231,11 @@ public class ResourcesService extends BaseService { ...@@ -1231,13 +1231,11 @@ public class ResourcesService extends BaseService {
resultList = new ArrayList<>(udfFuncSet); resultList = new ArrayList<>(udfFuncSet);
} }
result.put(Constants.DATA_LIST, resultList); result.put(Constants.DATA_LIST, resultList);
putMsg(result,Status.SUCCESS); putMsg(result, Status.SUCCESS);
return result; return result;
} }
/** /**
* authorized udf function * authorized udf function
* *
...@@ -1247,12 +1245,12 @@ public class ResourcesService extends BaseService { ...@@ -1247,12 +1245,12 @@ public class ResourcesService extends BaseService {
*/ */
public Map<String, Object> authorizedUDFFunction(User loginUser, Integer userId) { public Map<String, Object> authorizedUDFFunction(User loginUser, Integer userId) {
Map<String, Object> result = new HashMap<>(); Map<String, Object> result = new HashMap<>();
if (checkAdmin(loginUser, result)) { if (isNotAdmin(loginUser, result)) {
return result; return result;
} }
List<UdfFunc> udfFuncs = udfFunctionMapper.queryAuthedUdfFunc(userId); List<UdfFunc> udfFuncs = udfFunctionMapper.queryAuthedUdfFunc(userId);
result.put(Constants.DATA_LIST, udfFuncs); result.put(Constants.DATA_LIST, udfFuncs);
putMsg(result,Status.SUCCESS); putMsg(result, Status.SUCCESS);
return result; return result;
} }
...@@ -1266,7 +1264,7 @@ public class ResourcesService extends BaseService { ...@@ -1266,7 +1264,7 @@ public class ResourcesService extends BaseService {
*/ */
public Map<String, Object> authorizedFile(User loginUser, Integer userId) { public Map<String, Object> authorizedFile(User loginUser, Integer userId) {
Map<String, Object> result = new HashMap<>(5); Map<String, Object> result = new HashMap<>(5);
if (checkAdmin(loginUser, result)){ if (isNotAdmin(loginUser, result)) {
return result; return result;
} }
List<Resource> authedResources = resourcesMapper.queryAuthorizedResourceList(userId); List<Resource> authedResources = resourcesMapper.queryAuthorizedResourceList(userId);
......
...@@ -145,6 +145,50 @@ public class TaskInstanceService extends BaseService { ...@@ -145,6 +145,50 @@ public class TaskInstanceService extends BaseService {
return result; return result;
} }
/**
* change one task instance's state from failure to forced success
*
* @param loginUser login user
* @param projectName project name
* @param taskInstanceId task instance id
* @return the result code and msg
*/
public Map<String, Object> forceTaskSuccess(User loginUser, String projectName, Integer taskInstanceId) {
Map<String, Object> result = new HashMap<>(5);
Project project = projectMapper.queryByName(projectName);
// check user auth
Map<String, Object> checkResult = projectService.checkProjectAndAuth(loginUser, project, projectName);
Status status = (Status) checkResult.get(Constants.STATUS);
if (status != Status.SUCCESS) {
return checkResult;
}
// check whether the task instance can be found
TaskInstance task = taskInstanceMapper.selectById(taskInstanceId);
if (task == null) {
putMsg(result, Status.TASK_INSTANCE_NOT_FOUND);
return result;
}
// check whether the task instance state type is failure
if (!task.getState().typeIsFailure()) {
putMsg(result, Status.TASK_INSTANCE_STATE_OPERATION_ERROR, taskInstanceId, task.getState().toString());
return result;
}
// change the state of the task instance
task.setState(ExecutionStatus.FORCED_SUCCESS);
int changedNum = taskInstanceMapper.updateById(task);
if (changedNum > 0) {
putMsg(result, Status.SUCCESS);
} else {
putMsg(result, Status.FORCE_TASK_SUCCESS_ERROR);
}
return result;
}
/*** /***
* generate {@link org.apache.dolphinscheduler.api.enums.Status#REQUEST_PARAMS_NOT_VALID_ERROR} res with param name * generate {@link org.apache.dolphinscheduler.api.enums.Status#REQUEST_PARAMS_NOT_VALID_ERROR} res with param name
* @param result exist result map * @param result exist result map
......
...@@ -17,9 +17,6 @@ ...@@ -17,9 +17,6 @@
package org.apache.dolphinscheduler.api.service; package org.apache.dolphinscheduler.api.service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.dolphinscheduler.api.dto.resources.ResourceComponent; import org.apache.dolphinscheduler.api.dto.resources.ResourceComponent;
import org.apache.dolphinscheduler.api.dto.resources.visitor.ResourceTreeVisitor; import org.apache.dolphinscheduler.api.dto.resources.visitor.ResourceTreeVisitor;
import org.apache.dolphinscheduler.api.enums.Status; import org.apache.dolphinscheduler.api.enums.Status;
...@@ -114,13 +111,13 @@ public class UsersService extends BaseService { ...@@ -114,13 +111,13 @@ public class UsersService extends BaseService {
/** /**
* create user, only system admin have permission * create user, only system admin have permission
* *
* @param loginUser login user * @param loginUser login user
* @param userName user name * @param userName user name
* @param userPassword user password * @param userPassword user password
* @param email email * @param email email
* @param tenantId tenant id * @param tenantId tenant id
* @param phone phone * @param phone phone
* @param queue queue * @param queue queue
* @return create result code * @return create result code
* @throws Exception exception * @throws Exception exception
*/ */
...@@ -256,7 +253,7 @@ public class UsersService extends BaseService { ...@@ -256,7 +253,7 @@ public class UsersService extends BaseService {
/** /**
* query user * query user
* *
* @param name name * @param name name
* @param password password * @param password password
* @return user info * @return user info
*/ */
...@@ -267,6 +264,7 @@ public class UsersService extends BaseService { ...@@ -267,6 +264,7 @@ public class UsersService extends BaseService {
/** /**
* get user id by user name * get user id by user name
*
* @param name user name * @param name user name
* @return if name empty 0, user not exists -1, user exist user id * @return if name empty 0, user not exists -1, user exist user id
*/ */
...@@ -289,13 +287,13 @@ public class UsersService extends BaseService { ...@@ -289,13 +287,13 @@ public class UsersService extends BaseService {
* query user list * query user list
* *
* @param loginUser login user * @param loginUser login user
* @param pageNo page number * @param pageNo page number
* @param searchVal search avlue * @param searchVal search avlue
* @param pageSize page size * @param pageSize page size
* @return user list page * @return user list page
*/ */
public Map<String, Object> queryUserList(User loginUser, String searchVal, Integer pageNo, Integer pageSize) { public Map<String, Object> queryUserList(User loginUser, String searchVal, Integer pageNo, Integer pageSize) {
Map<String, Object> result = new HashMap<>(); Map<String, Object> result = new HashMap<>(5);
if (check(result, !isAdmin(loginUser), Status.USER_NO_OPERATION_PERM)) { if (check(result, !isAdmin(loginUser), Status.USER_NO_OPERATION_PERM)) {
return result; return result;
...@@ -317,13 +315,15 @@ public class UsersService extends BaseService { ...@@ -317,13 +315,15 @@ public class UsersService extends BaseService {
/** /**
* updateProcessInstance user * updateProcessInstance user
* *
* @param userId user id *
* @param userName user name * @param loginUser
* @param userId user id
* @param userName user name
* @param userPassword user password * @param userPassword user password
* @param email email * @param email email
* @param tenantId tennat id * @param tenantId tennat id
* @param phone phone * @param phone phone
* @param queue queue * @param queue queue
* @return update result code * @return update result code
* @throws Exception exception * @throws Exception exception
*/ */
...@@ -335,7 +335,7 @@ public class UsersService extends BaseService { ...@@ -335,7 +335,7 @@ public class UsersService extends BaseService {
String phone, String phone,
String queue, String queue,
int state) throws Exception { int state) throws Exception {
Map<String, Object> result = new HashMap<>(); Map<String, Object> result = new HashMap<>(5);
result.put(Constants.STATUS, false); result.put(Constants.STATUS, false);
if (check(result, !hasPerm(loginUser, userId), Status.USER_NO_OPERATION_PERM)) { if (check(result, !hasPerm(loginUser, userId), Status.USER_NO_OPERATION_PERM)) {
...@@ -406,7 +406,7 @@ public class UsersService extends BaseService { ...@@ -406,7 +406,7 @@ public class UsersService extends BaseService {
//file resources list //file resources list
List<Resource> fileResourcesList = resourceMapper.queryResourceList( List<Resource> fileResourcesList = resourceMapper.queryResourceList(
null, userId, ResourceType.FILE.ordinal()); null, userId, ResourceType.FILE.ordinal());
if (CollectionUtils.isNotEmpty(fileResourcesList)) { if (CollectionUtils.isNotEmpty(fileResourcesList)) {
ResourceTreeVisitor resourceTreeVisitor = new ResourceTreeVisitor(fileResourcesList); ResourceTreeVisitor resourceTreeVisitor = new ResourceTreeVisitor(fileResourcesList);
ResourceComponent resourceComponent = resourceTreeVisitor.visit(); ResourceComponent resourceComponent = resourceTreeVisitor.visit();
...@@ -415,7 +415,7 @@ public class UsersService extends BaseService { ...@@ -415,7 +415,7 @@ public class UsersService extends BaseService {
//udf resources //udf resources
List<Resource> udfResourceList = resourceMapper.queryResourceList( List<Resource> udfResourceList = resourceMapper.queryResourceList(
null, userId, ResourceType.UDF.ordinal()); null, userId, ResourceType.UDF.ordinal());
if (CollectionUtils.isNotEmpty(udfResourceList)) { if (CollectionUtils.isNotEmpty(udfResourceList)) {
ResourceTreeVisitor resourceTreeVisitor = new ResourceTreeVisitor(udfResourceList); ResourceTreeVisitor resourceTreeVisitor = new ResourceTreeVisitor(udfResourceList);
ResourceComponent resourceComponent = resourceTreeVisitor.visit(); ResourceComponent resourceComponent = resourceTreeVisitor.visit();
...@@ -454,12 +454,12 @@ public class UsersService extends BaseService { ...@@ -454,12 +454,12 @@ public class UsersService extends BaseService {
* delete user * delete user
* *
* @param loginUser login user * @param loginUser login user
* @param id user id * @param id user id
* @return delete result code * @return delete result code
* @throws Exception exception when operate hdfs * @throws Exception exception when operate hdfs
*/ */
public Map<String, Object> deleteUserById(User loginUser, int id) throws Exception { public Map<String, Object> deleteUserById(User loginUser, int id) throws Exception {
Map<String, Object> result = new HashMap<>(); Map<String, Object> result = new HashMap<>(5);
//only admin can operate //only admin can operate
if (!isAdmin(loginUser)) { if (!isAdmin(loginUser)) {
putMsg(result, Status.USER_NO_OPERATION_PERM, id); putMsg(result, Status.USER_NO_OPERATION_PERM, id);
...@@ -492,14 +492,14 @@ public class UsersService extends BaseService { ...@@ -492,14 +492,14 @@ public class UsersService extends BaseService {
/** /**
* grant project * grant project
* *
* @param loginUser login user * @param loginUser login user
* @param userId user id * @param userId user id
* @param projectIds project id array * @param projectIds project id array
* @return grant result code * @return grant result code
*/ */
@Transactional(rollbackFor = RuntimeException.class) @Transactional(rollbackFor = RuntimeException.class)
public Map<String, Object> grantProject(User loginUser, int userId, String projectIds) { public Map<String, Object> grantProject(User loginUser, int userId, String projectIds) {
Map<String, Object> result = new HashMap<>(); Map<String, Object> result = new HashMap<>(5);
result.put(Constants.STATUS, false); result.put(Constants.STATUS, false);
//only admin can operate //only admin can operate
...@@ -542,14 +542,14 @@ public class UsersService extends BaseService { ...@@ -542,14 +542,14 @@ public class UsersService extends BaseService {
/** /**
* grant resource * grant resource
* *
* @param loginUser login user * @param loginUser login user
* @param userId user id * @param userId user id
* @param resourceIds resource id array * @param resourceIds resource id array
* @return grant result code * @return grant result code
*/ */
@Transactional(rollbackFor = RuntimeException.class) @Transactional(rollbackFor = RuntimeException.class)
public Map<String, Object> grantResources(User loginUser, int userId, String resourceIds) { public Map<String, Object> grantResources(User loginUser, int userId, String resourceIds) {
Map<String, Object> result = new HashMap<>(); Map<String, Object> result = new HashMap<>(5);
//only admin can operate //only admin can operate
if (check(result, !isAdmin(loginUser), Status.USER_NO_OPERATION_PERM)) { if (check(result, !isAdmin(loginUser), Status.USER_NO_OPERATION_PERM)) {
return result; return result;
...@@ -640,8 +640,8 @@ public class UsersService extends BaseService { ...@@ -640,8 +640,8 @@ public class UsersService extends BaseService {
* grant udf function * grant udf function
* *
* @param loginUser login user * @param loginUser login user
* @param userId user id * @param userId user id
* @param udfIds udf id array * @param udfIds udf id array
* @return grant result code * @return grant result code
*/ */
@Transactional(rollbackFor = RuntimeException.class) @Transactional(rollbackFor = RuntimeException.class)
...@@ -741,7 +741,7 @@ public class UsersService extends BaseService { ...@@ -741,7 +741,7 @@ public class UsersService extends BaseService {
Map<String, Object> result = new HashMap<>(); Map<String, Object> result = new HashMap<>();
User user; User user = null;
if (loginUser.getUserType() == UserType.ADMIN_USER) { if (loginUser.getUserType() == UserType.ADMIN_USER) {
user = loginUser; user = loginUser;
} else { } else {
...@@ -832,7 +832,7 @@ public class UsersService extends BaseService { ...@@ -832,7 +832,7 @@ public class UsersService extends BaseService {
/** /**
* unauthorized user * unauthorized user
* *
* @param loginUser login user * @param loginUser login user
* @param alertgroupId alert group id * @param alertgroupId alert group id
* @return unauthorize result code * @return unauthorize result code
*/ */
...@@ -869,7 +869,7 @@ public class UsersService extends BaseService { ...@@ -869,7 +869,7 @@ public class UsersService extends BaseService {
/** /**
* authorized user * authorized user
* *
* @param loginUser login user * @param loginUser login user
* @param alertgroupId alert group id * @param alertgroupId alert group id
* @return authorized result code * @return authorized result code
*/ */
......
...@@ -70,7 +70,7 @@ public class WorkerGroupService extends BaseService { ...@@ -70,7 +70,7 @@ public class WorkerGroupService extends BaseService {
Integer toIndex = (pageNo - 1) * pageSize + pageSize; Integer toIndex = (pageNo - 1) * pageSize + pageSize;
Map<String, Object> result = new HashMap<>(); Map<String, Object> result = new HashMap<>();
if (checkAdmin(loginUser, result)) { if (isNotAdmin(loginUser, result)) {
return result; return result;
} }
......
...@@ -20,18 +20,29 @@ package org.apache.dolphinscheduler.api.service.impl; ...@@ -20,18 +20,29 @@ package org.apache.dolphinscheduler.api.service.impl;
import org.apache.dolphinscheduler.api.enums.Status; import org.apache.dolphinscheduler.api.enums.Status;
import org.apache.dolphinscheduler.api.service.AlertPluginInstanceService; import org.apache.dolphinscheduler.api.service.AlertPluginInstanceService;
import org.apache.dolphinscheduler.api.service.BaseService; import org.apache.dolphinscheduler.api.service.BaseService;
import org.apache.dolphinscheduler.api.utils.PageInfo;
import org.apache.dolphinscheduler.api.vo.AlertPluginInstanceVO;
import org.apache.dolphinscheduler.common.Constants; import org.apache.dolphinscheduler.common.Constants;
import org.apache.dolphinscheduler.common.utils.CollectionUtils;
import org.apache.dolphinscheduler.dao.entity.AlertPluginInstance; import org.apache.dolphinscheduler.dao.entity.AlertPluginInstance;
import org.apache.dolphinscheduler.dao.entity.PluginDefine;
import org.apache.dolphinscheduler.dao.entity.User; import org.apache.dolphinscheduler.dao.entity.User;
import org.apache.dolphinscheduler.dao.mapper.AlertPluginInstanceMapper; import org.apache.dolphinscheduler.dao.mapper.AlertPluginInstanceMapper;
import org.apache.dolphinscheduler.dao.mapper.PluginDefineMapper;
import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.stream.Collectors;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy; import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
/** /**
* alert plugin instance service impl * alert plugin instance service impl
*/ */
...@@ -42,18 +53,31 @@ public class AlertPluginInstanceServiceImpl extends BaseService implements Alert ...@@ -42,18 +53,31 @@ public class AlertPluginInstanceServiceImpl extends BaseService implements Alert
@Autowired @Autowired
private AlertPluginInstanceMapper alertPluginInstanceMapper; private AlertPluginInstanceMapper alertPluginInstanceMapper;
@Autowired
private PluginDefineMapper pluginDefineMapper;
/** /**
* creat alert plugin instance * creat alert plugin instance
* *
* @param loginUser login user * @param loginUser login user
* @param alertPluginInstance alert plugin instance * @param pluginDefineId plugin define id
* @return result * @param instanceName instance name
* @param pluginInstanceParams plugin instance params
*/ */
@Override @Override
public Map<String, Object> create(User loginUser, AlertPluginInstance alertPluginInstance) { public Map<String, Object> create(User loginUser, int pluginDefineId, String instanceName, String pluginInstanceParams) {
AlertPluginInstance alertPluginInstance = new AlertPluginInstance();
alertPluginInstance.setPluginInstanceParams(pluginInstanceParams);
alertPluginInstance.setInstanceName(instanceName);
alertPluginInstance.setPluginDefineId(pluginDefineId);
Map<String, Object> result = new HashMap<>(); Map<String, Object> result = new HashMap<>();
if (CollectionUtils.isNotEmpty(alertPluginInstanceMapper.queryByInstanceName(alertPluginInstance.getInstanceName()))) {
putMsg(result, Status.PLUGIN_INSTANCE_ALREADY_EXIT);
return result;
}
int i = alertPluginInstanceMapper.insert(alertPluginInstance); int i = alertPluginInstanceMapper.insert(alertPluginInstance);
if (i > 0) { if (i > 0) {
...@@ -66,12 +90,17 @@ public class AlertPluginInstanceServiceImpl extends BaseService implements Alert ...@@ -66,12 +90,17 @@ public class AlertPluginInstanceServiceImpl extends BaseService implements Alert
* update alert plugin instance * update alert plugin instance
* *
* @param loginUser login user * @param loginUser login user
* @param alertPluginInstance alert plugin instance * @param pluginInstanceId plugin instance id
* @return result * @param instanceName instance name
* @param pluginInstanceParams plugin instance params
*/ */
@Override @Override
public Map<String, Object> update(User loginUser, AlertPluginInstance alertPluginInstance) { public Map<String, Object> update(User loginUser, int pluginInstanceId, String instanceName, String pluginInstanceParams) {
AlertPluginInstance alertPluginInstance = new AlertPluginInstance();
alertPluginInstance.setPluginInstanceParams(pluginInstanceParams);
alertPluginInstance.setInstanceName(instanceName);
alertPluginInstance.setId(pluginInstanceId);
Map<String, Object> result = new HashMap<>(); Map<String, Object> result = new HashMap<>();
int i = alertPluginInstanceMapper.updateById(alertPluginInstance); int i = alertPluginInstanceMapper.updateById(alertPluginInstance);
...@@ -86,13 +115,13 @@ public class AlertPluginInstanceServiceImpl extends BaseService implements Alert ...@@ -86,13 +115,13 @@ public class AlertPluginInstanceServiceImpl extends BaseService implements Alert
* delete alert plugin instance * delete alert plugin instance
* *
* @param loginUser login user * @param loginUser login user
* @param alertPluginInstance alert plugin instance * @param id id
* @return result * @return result
*/ */
@Override @Override
public Map<String, Object> delete(User loginUser, AlertPluginInstance alertPluginInstance) { public Map<String, Object> delete(User loginUser, int id) {
Map<String, Object> result = new HashMap<>(); Map<String, Object> result = new HashMap<>();
int i = alertPluginInstanceMapper.deleteById(alertPluginInstance.getId()); int i = alertPluginInstanceMapper.deleteById(id);
if (i > 0) { if (i > 0) {
putMsg(result, Status.SUCCESS); putMsg(result, Status.SUCCESS);
} }
...@@ -119,4 +148,61 @@ public class AlertPluginInstanceServiceImpl extends BaseService implements Alert ...@@ -119,4 +148,61 @@ public class AlertPluginInstanceServiceImpl extends BaseService implements Alert
return result; return result;
} }
@Override
public Map<String, Object> queryAll() {
Map<String, Object> result = new HashMap<>();
List<AlertPluginInstance> alertPluginInstances = alertPluginInstanceMapper.queryAllAlertPluginInstanceList();
List<AlertPluginInstanceVO> alertPluginInstanceVOS = buildPluginInstanceVOList(alertPluginInstances);
if (null != alertPluginInstances) {
putMsg(result, Status.SUCCESS);
result.put(Constants.DATA_LIST, alertPluginInstanceVOS);
}
return result;
}
@Override
public boolean checkExistPluginInstanceName(String pluginInstanceName) {
return CollectionUtils.isNotEmpty(alertPluginInstanceMapper.queryByInstanceName(pluginInstanceName));
}
@Override
public Map<String, Object> queryPluginPage(int pageIndex, int pageSize) {
IPage<AlertPluginInstance> pluginInstanceIPage = new Page<>(pageIndex, pageSize);
pluginInstanceIPage = alertPluginInstanceMapper.selectPage(pluginInstanceIPage, null);
PageInfo<AlertPluginInstanceVO> pageInfo = new PageInfo<>(pageIndex, pageSize);
pageInfo.setTotalCount((int) pluginInstanceIPage.getTotal());
pageInfo.setLists(buildPluginInstanceVOList(pluginInstanceIPage.getRecords()));
Map<String, Object> result = new HashMap<>();
result.put(Constants.DATA_LIST, pageInfo);
putMsg(result, Status.SUCCESS);
return result;
}
private List<AlertPluginInstanceVO> buildPluginInstanceVOList(List<AlertPluginInstance> alertPluginInstances) {
if (CollectionUtils.isEmpty(alertPluginInstances)) {
return null;
}
List<PluginDefine> pluginDefineList = pluginDefineMapper.queryAllPluginDefineList();
if (CollectionUtils.isEmpty(pluginDefineList)) {
return null;
}
Map<Integer, String> pluginDefineMap = pluginDefineList.stream().collect(Collectors.toMap(PluginDefine::getId, PluginDefine::getPluginName));
List<AlertPluginInstanceVO> alertPluginInstanceVOS = new ArrayList<>();
alertPluginInstances.forEach(alertPluginInstance -> {
AlertPluginInstanceVO alertPluginInstanceVO = new AlertPluginInstanceVO();
alertPluginInstanceVO.setAlertPluginName(pluginDefineMap.get(alertPluginInstance.getPluginDefineId()));
alertPluginInstanceVO.setCreateTime(alertPluginInstance.getCreateTime());
alertPluginInstanceVO.setUpdateTime(alertPluginInstance.getUpdateTime());
alertPluginInstanceVO.setPluginDefineId(alertPluginInstance.getPluginDefineId());
alertPluginInstanceVO.setInstanceName(alertPluginInstance.getInstanceName());
alertPluginInstanceVO.setId(alertPluginInstance.getId());
//todo List pages do not recommend returning this parameter
alertPluginInstanceVO.setPluginInstanceParams(alertPluginInstance.getPluginInstanceParams());
alertPluginInstanceVOS.add(alertPluginInstanceVO);
});
return alertPluginInstanceVOS;
}
} }
...@@ -25,6 +25,7 @@ import org.apache.dolphinscheduler.api.service.DataAnalysisService; ...@@ -25,6 +25,7 @@ import org.apache.dolphinscheduler.api.service.DataAnalysisService;
import org.apache.dolphinscheduler.api.service.ProjectService; import org.apache.dolphinscheduler.api.service.ProjectService;
import org.apache.dolphinscheduler.common.Constants; import org.apache.dolphinscheduler.common.Constants;
import org.apache.dolphinscheduler.common.enums.CommandType; import org.apache.dolphinscheduler.common.enums.CommandType;
import org.apache.dolphinscheduler.common.enums.ExecutionStatus;
import org.apache.dolphinscheduler.common.enums.UserType; import org.apache.dolphinscheduler.common.enums.UserType;
import org.apache.dolphinscheduler.common.utils.DateUtils; import org.apache.dolphinscheduler.common.utils.DateUtils;
import org.apache.dolphinscheduler.common.utils.StringUtils; import org.apache.dolphinscheduler.common.utils.StringUtils;
...@@ -114,12 +115,17 @@ public class DataAnalysisServiceImpl extends BaseService implements DataAnalysis ...@@ -114,12 +115,17 @@ public class DataAnalysisServiceImpl extends BaseService implements DataAnalysis
* @return process instance state count data * @return process instance state count data
*/ */
public Map<String, Object> countProcessInstanceStateByProject(User loginUser, int projectId, String startDate, String endDate) { public Map<String, Object> countProcessInstanceStateByProject(User loginUser, int projectId, String startDate, String endDate) {
return this.countStateByProject( Map<String, Object> result = this.countStateByProject(
loginUser, loginUser,
projectId, projectId,
startDate, startDate,
endDate, endDate,
(start, end, projectIds) -> this.processInstanceMapper.countInstanceStateByUser(start, end, projectIds)); (start, end, projectIds) -> this.processInstanceMapper.countInstanceStateByUser(start, end, projectIds));
// process state count needs to remove state of forced success
if (result.containsKey(Constants.STATUS) && result.get(Constants.STATUS).equals(Status.SUCCESS)) {
((TaskCountDto)result.get(Constants.DATA_LIST)).removeStateFromCountList(ExecutionStatus.FORCED_SUCCESS);
}
return result;
} }
private Map<String, Object> countStateByProject(User loginUser, int projectId, String startDate, String endDate private Map<String, Object> countStateByProject(User loginUser, int projectId, String startDate, String endDate
......
...@@ -220,9 +220,8 @@ public class ProcessDefinitionServiceImpl extends BaseService implements ...@@ -220,9 +220,8 @@ public class ProcessDefinitionServiceImpl extends BaseService implements
processDefineMapper.updateVersionByProcessDefinitionId(processDefine.getId(), version); processDefineMapper.updateVersionByProcessDefinitionId(processDefine.getId(), version);
// return processDefinition object with ID // return processDefinition object with ID
result.put(Constants.DATA_LIST, processDefineMapper.selectById(processDefine.getId())); result.put(Constants.DATA_LIST, processDefine.getId());
putMsg(result, Status.SUCCESS); putMsg(result, Status.SUCCESS);
result.put(PROCESSDEFINITIONID, processDefine.getId());
return result; return result;
} }
...@@ -274,7 +273,7 @@ public class ProcessDefinitionServiceImpl extends BaseService implements ...@@ -274,7 +273,7 @@ public class ProcessDefinitionServiceImpl extends BaseService implements
@Override @Override
public Map<String, Object> queryProcessDefinitionList(User loginUser, String projectName) { public Map<String, Object> queryProcessDefinitionList(User loginUser, String projectName) {
HashMap<String, Object> result = new HashMap<>(); HashMap<String, Object> result = new HashMap<>(5);
Project project = projectMapper.queryByName(projectName); Project project = projectMapper.queryByName(projectName);
Map<String, Object> checkResult = projectService.checkProjectAndAuth(loginUser, project, projectName); Map<String, Object> checkResult = projectService.checkProjectAndAuth(loginUser, project, projectName);
...@@ -348,7 +347,29 @@ public class ProcessDefinitionServiceImpl extends BaseService implements ...@@ -348,7 +347,29 @@ public class ProcessDefinitionServiceImpl extends BaseService implements
ProcessDefinition processDefinition = processDefineMapper.selectById(processId); ProcessDefinition processDefinition = processDefineMapper.selectById(processId);
if (processDefinition == null) { if (processDefinition == null) {
putMsg(result, Status.PROCESS_INSTANCE_NOT_EXIST, processId); putMsg(result, Status.PROCESS_DEFINE_NOT_EXIST, processId);
} else {
result.put(Constants.DATA_LIST, processDefinition);
putMsg(result, Status.SUCCESS);
}
return result;
}
@Override
public Map<String, Object> queryProcessDefinitionByName(User loginUser, String projectName, String processDefinitionName) {
Map<String, Object> result = new HashMap<>();
Project project = projectMapper.queryByName(projectName);
Map<String, Object> checkResult = projectService.checkProjectAndAuth(loginUser, project, projectName);
Status resultStatus = (Status) checkResult.get(Constants.STATUS);
if (resultStatus != Status.SUCCESS) {
return checkResult;
}
ProcessDefinition processDefinition = processDefineMapper.queryByDefineName(project.getId(),processDefinitionName);
if (processDefinition == null) {
putMsg(result, Status.PROCESS_DEFINE_NOT_EXIST, processDefinitionName);
} else { } else {
result.put(Constants.DATA_LIST, processDefinition); result.put(Constants.DATA_LIST, processDefinition);
putMsg(result, Status.SUCCESS); putMsg(result, Status.SUCCESS);
...@@ -491,7 +512,7 @@ public class ProcessDefinitionServiceImpl extends BaseService implements ...@@ -491,7 +512,7 @@ public class ProcessDefinitionServiceImpl extends BaseService implements
@Transactional(rollbackFor = RuntimeException.class) @Transactional(rollbackFor = RuntimeException.class)
public Map<String, Object> deleteProcessDefinitionById(User loginUser, String projectName, Integer processDefinitionId) { public Map<String, Object> deleteProcessDefinitionById(User loginUser, String projectName, Integer processDefinitionId) {
Map<String, Object> result = new HashMap<>(); Map<String, Object> result = new HashMap<>(5);
Project project = projectMapper.queryByName(projectName); Project project = projectMapper.queryByName(projectName);
Map<String, Object> checkResult = projectService.checkProjectAndAuth(loginUser, project, projectName); Map<String, Object> checkResult = projectService.checkProjectAndAuth(loginUser, project, projectName);
...@@ -802,7 +823,7 @@ public class ProcessDefinitionServiceImpl extends BaseService implements ...@@ -802,7 +823,7 @@ public class ProcessDefinitionServiceImpl extends BaseService implements
@Override @Override
@Transactional(rollbackFor = RuntimeException.class) @Transactional(rollbackFor = RuntimeException.class)
public Map<String, Object> importProcessDefinition(User loginUser, MultipartFile file, String currentProjectName) { public Map<String, Object> importProcessDefinition(User loginUser, MultipartFile file, String currentProjectName) {
Map<String, Object> result = new HashMap<>(); Map<String, Object> result = new HashMap<>(5);
String processMetaJson = FileUtils.file2String(file); String processMetaJson = FileUtils.file2String(file);
List<ProcessMeta> processMetaList = JSONUtils.toList(processMetaJson, ProcessMeta.class); List<ProcessMeta> processMetaList = JSONUtils.toList(processMetaJson, ProcessMeta.class);
...@@ -865,8 +886,8 @@ public class ProcessDefinitionServiceImpl extends BaseService implements ...@@ -865,8 +886,8 @@ public class ProcessDefinitionServiceImpl extends BaseService implements
//create process definition //create process definition
Integer processDefinitionId = Integer processDefinitionId =
Objects.isNull(createProcessResult.get(PROCESSDEFINITIONID)) Objects.isNull(createProcessResult.get(Constants.DATA_LIST))
? null : Integer.parseInt(createProcessResult.get(PROCESSDEFINITIONID).toString()); ? null : Integer.parseInt(createProcessResult.get(Constants.DATA_LIST).toString());
//scheduler param //scheduler param
return getImportProcessScheduleResult(loginUser, return getImportProcessScheduleResult(loginUser,
...@@ -1262,7 +1283,7 @@ public class ProcessDefinitionServiceImpl extends BaseService implements ...@@ -1262,7 +1283,7 @@ public class ProcessDefinitionServiceImpl extends BaseService implements
@Override @Override
public Map<String, Object> queryProcessDefinitionAllByProjectId(Integer projectId) { public Map<String, Object> queryProcessDefinitionAllByProjectId(Integer projectId) {
HashMap<String, Object> result = new HashMap<>(); HashMap<String, Object> result = new HashMap<>(5);
List<ProcessDefinition> resourceList = processDefineMapper.queryAllDefinitionList(projectId); List<ProcessDefinition> resourceList = processDefineMapper.queryAllDefinitionList(projectId);
result.put(Constants.DATA_LIST, resourceList); result.put(Constants.DATA_LIST, resourceList);
...@@ -1473,7 +1494,7 @@ public class ProcessDefinitionServiceImpl extends BaseService implements ...@@ -1473,7 +1494,7 @@ public class ProcessDefinitionServiceImpl extends BaseService implements
Integer processId, Integer processId,
Project targetProject) throws JsonProcessingException { Project targetProject) throws JsonProcessingException {
Map<String, Object> result = new HashMap<>(); Map<String, Object> result = new HashMap<>(5);
ProcessDefinition processDefinition = processDefineMapper.selectById(processId); ProcessDefinition processDefinition = processDefineMapper.selectById(processId);
if (processDefinition == null) { if (processDefinition == null) {
...@@ -1492,41 +1513,6 @@ public class ProcessDefinitionServiceImpl extends BaseService implements ...@@ -1492,41 +1513,6 @@ public class ProcessDefinitionServiceImpl extends BaseService implements
} }
} }
/**
* copy process definition
*
* @param loginUser login user
* @param projectName project name
* @param processId process definition id
* @return copy result code
*/
public Map<String, Object> copyProcessDefinition(User loginUser, String projectName, Integer processId) {
Map<String, Object> result = new HashMap<>(5);
Project project = projectMapper.queryByName(projectName);
Map<String, Object> checkResult = projectService.checkProjectAndAuth(loginUser, project, projectName);
Status resultStatus = (Status) checkResult.get(Constants.STATUS);
if (resultStatus != Status.SUCCESS) {
return checkResult;
}
ProcessDefinition processDefinition = processDefineMapper.selectById(processId);
if (processDefinition == null) {
putMsg(result, Status.PROCESS_DEFINE_NOT_EXIST, processId);
return result;
} else {
return createProcessDefinition(
loginUser,
projectName,
processDefinition.getName() + "_copy_" + System.currentTimeMillis(),
processDefinition.getProcessDefinitionJson(),
processDefinition.getDescription(),
processDefinition.getLocations(),
processDefinition.getConnects());
}
}
/** /**
* batch copy process definition * batch copy process definition
* *
......
...@@ -293,7 +293,7 @@ public class ProjectServiceImpl extends BaseService implements ProjectService { ...@@ -293,7 +293,7 @@ public class ProjectServiceImpl extends BaseService implements ProjectService {
*/ */
public Map<String, Object> queryUnauthorizedProject(User loginUser, Integer userId) { public Map<String, Object> queryUnauthorizedProject(User loginUser, Integer userId) {
Map<String, Object> result = new HashMap<>(); Map<String, Object> result = new HashMap<>();
if (checkAdmin(loginUser, result)) { if (isNotAdmin(loginUser, result)) {
return result; return result;
} }
/** /**
...@@ -344,7 +344,7 @@ public class ProjectServiceImpl extends BaseService implements ProjectService { ...@@ -344,7 +344,7 @@ public class ProjectServiceImpl extends BaseService implements ProjectService {
public Map<String, Object> queryAuthorizedProject(User loginUser, Integer userId) { public Map<String, Object> queryAuthorizedProject(User loginUser, Integer userId) {
Map<String, Object> result = new HashMap<>(); Map<String, Object> result = new HashMap<>();
if (checkAdmin(loginUser, result)) { if (isNotAdmin(loginUser, result)) {
return result; return result;
} }
...@@ -364,7 +364,7 @@ public class ProjectServiceImpl extends BaseService implements ProjectService { ...@@ -364,7 +364,7 @@ public class ProjectServiceImpl extends BaseService implements ProjectService {
public Map<String, Object> queryProjectCreatedByUser(User loginUser) { public Map<String, Object> queryProjectCreatedByUser(User loginUser) {
Map<String, Object> result = new HashMap<>(); Map<String, Object> result = new HashMap<>();
if (checkAdmin(loginUser, result)) { if (isNotAdmin(loginUser, result)) {
return result; return result;
} }
......
...@@ -89,12 +89,12 @@ public class TenantServiceImpl extends BaseService implements TenantService { ...@@ -89,12 +89,12 @@ public class TenantServiceImpl extends BaseService implements TenantService {
Map<String, Object> result = new HashMap<>(5); Map<String, Object> result = new HashMap<>(5);
result.put(Constants.STATUS, false); result.put(Constants.STATUS, false);
if (checkAdmin(loginUser, result)) { if (isNotAdmin(loginUser, result)) {
return result; return result;
} }
if (RegexUtils.isNumeric(tenantCode)) { if (RegexUtils.isNumeric(tenantCode)) {
putMsg(result, Status.CHECK_TENANT_CODE_ERROR); putMsg(result, Status.CHECK_OS_TENANT_CODE_ERROR);
return result; return result;
} }
...@@ -107,7 +107,7 @@ public class TenantServiceImpl extends BaseService implements TenantService { ...@@ -107,7 +107,7 @@ public class TenantServiceImpl extends BaseService implements TenantService {
Date now = new Date(); Date now = new Date();
if (!tenantCode.matches("^[0-9a-zA-Z_.-]{1,}$") || tenantCode.startsWith("-") || tenantCode.startsWith(".")) { if (!tenantCode.matches("^[0-9a-zA-Z_.-]{1,}$") || tenantCode.startsWith("-") || tenantCode.startsWith(".")) {
putMsg(result, Status.VERIFY_TENANT_CODE_ERROR); putMsg(result, Status.VERIFY_OS_TENANT_CODE_ERROR);
return result; return result;
} }
tenant.setTenantCode(tenantCode); tenant.setTenantCode(tenantCode);
...@@ -134,14 +134,14 @@ public class TenantServiceImpl extends BaseService implements TenantService { ...@@ -134,14 +134,14 @@ public class TenantServiceImpl extends BaseService implements TenantService {
* *
* @param loginUser login user * @param loginUser login user
* @param searchVal search value * @param searchVal search value
* @param pageNo page number * @param pageNo page number
* @param pageSize page size * @param pageSize page size
* @return tenant list page * @return tenant list page
*/ */
public Map<String, Object> queryTenantList(User loginUser, String searchVal, Integer pageNo, Integer pageSize) { public Map<String, Object> queryTenantList(User loginUser, String searchVal, Integer pageNo, Integer pageSize) {
Map<String, Object> result = new HashMap<>(5); Map<String, Object> result = new HashMap<>(5);
if (checkAdmin(loginUser, result)) { if (isNotAdmin(loginUser, result)) {
return result; return result;
} }
...@@ -174,7 +174,7 @@ public class TenantServiceImpl extends BaseService implements TenantService { ...@@ -174,7 +174,7 @@ public class TenantServiceImpl extends BaseService implements TenantService {
Map<String, Object> result = new HashMap<>(5); Map<String, Object> result = new HashMap<>(5);
result.put(Constants.STATUS, false); result.put(Constants.STATUS, false);
if (checkAdmin(loginUser, result)) { if (isNotAdmin(loginUser, result)) {
return result; return result;
} }
...@@ -200,7 +200,7 @@ public class TenantServiceImpl extends BaseService implements TenantService { ...@@ -200,7 +200,7 @@ public class TenantServiceImpl extends BaseService implements TenantService {
HadoopUtils.getInstance().mkdir(udfsPath); HadoopUtils.getInstance().mkdir(udfsPath);
} }
} else { } else {
putMsg(result, Status.TENANT_CODE_HAS_ALREADY_EXISTS); putMsg(result, Status.OS_TENANT_CODE_HAS_ALREADY_EXISTS);
return result; return result;
} }
} }
...@@ -227,7 +227,7 @@ public class TenantServiceImpl extends BaseService implements TenantService { ...@@ -227,7 +227,7 @@ public class TenantServiceImpl extends BaseService implements TenantService {
* delete tenant * delete tenant
* *
* @param loginUser login user * @param loginUser login user
* @param id tenant id * @param id tenant id
* @return delete result code * @return delete result code
* @throws Exception exception * @throws Exception exception
*/ */
...@@ -235,7 +235,7 @@ public class TenantServiceImpl extends BaseService implements TenantService { ...@@ -235,7 +235,7 @@ public class TenantServiceImpl extends BaseService implements TenantService {
public Map<String, Object> deleteTenantById(User loginUser, int id) throws Exception { public Map<String, Object> deleteTenantById(User loginUser, int id) throws Exception {
Map<String, Object> result = new HashMap<>(5); Map<String, Object> result = new HashMap<>(5);
if (checkAdmin(loginUser, result)) { if (isNotAdmin(loginUser, result)) {
return result; return result;
} }
...@@ -329,7 +329,7 @@ public class TenantServiceImpl extends BaseService implements TenantService { ...@@ -329,7 +329,7 @@ public class TenantServiceImpl extends BaseService implements TenantService {
public Result verifyTenantCode(String tenantCode) { public Result verifyTenantCode(String tenantCode) {
Result result = new Result(); Result result = new Result();
if (checkTenantExists(tenantCode)) { if (checkTenantExists(tenantCode)) {
putMsg(result, Status.TENANT_CODE_EXIST, tenantCode); putMsg(result, Status.OS_TENANT_CODE_EXIST, tenantCode);
} else { } else {
putMsg(result, Status.SUCCESS); putMsg(result, Status.SUCCESS);
} }
......
...@@ -42,6 +42,12 @@ public class UiPluginServiceImpl extends BaseService implements UiPluginService ...@@ -42,6 +42,12 @@ public class UiPluginServiceImpl extends BaseService implements UiPluginService
@Autowired @Autowired
PluginDefineMapper pluginDefineMapper; PluginDefineMapper pluginDefineMapper;
private static final String LANGUAGE_REGEX = "\"([^\"]*)\"";
private static final String LANGUAGE_SYMBOL = "$t";
private static final String ESCAPE_SYMBOL = "\\";
@Override @Override
public Map<String, Object> queryUiPluginsByType(PluginType pluginType) { public Map<String, Object> queryUiPluginsByType(PluginType pluginType) {
Map<String, Object> result = new HashMap<>(); Map<String, Object> result = new HashMap<>();
...@@ -50,10 +56,12 @@ public class UiPluginServiceImpl extends BaseService implements UiPluginService ...@@ -50,10 +56,12 @@ public class UiPluginServiceImpl extends BaseService implements UiPluginService
return result; return result;
} }
List<PluginDefine> pluginDefines = pluginDefineMapper.queryByPluginType(pluginType.getDesc()); List<PluginDefine> pluginDefines = pluginDefineMapper.queryByPluginType(pluginType.getDesc());
if (CollectionUtils.isEmpty(pluginDefines)) { if (CollectionUtils.isEmpty(pluginDefines)) {
putMsg(result, Status.QUERY_PLUGINS_RESULT_IS_NULL); putMsg(result, Status.QUERY_PLUGINS_RESULT_IS_NULL);
return result; return result;
} }
// pluginDefines=buildPluginParams(pluginDefines);
putMsg(result, Status.SUCCESS); putMsg(result, Status.SUCCESS);
result.put(Constants.DATA_LIST, pluginDefines); result.put(Constants.DATA_LIST, pluginDefines);
return result; return result;
...@@ -67,8 +75,11 @@ public class UiPluginServiceImpl extends BaseService implements UiPluginService ...@@ -67,8 +75,11 @@ public class UiPluginServiceImpl extends BaseService implements UiPluginService
putMsg(result, Status.QUERY_PLUGIN_DETAIL_RESULT_IS_NULL); putMsg(result, Status.QUERY_PLUGIN_DETAIL_RESULT_IS_NULL);
return result; return result;
} }
// String params=pluginDefine.getPluginParams();
// pluginDefine.setPluginParams(parseParams(params));
putMsg(result, Status.SUCCESS); putMsg(result, Status.SUCCESS);
result.put(Constants.DATA_LIST, pluginDefine); result.put(Constants.DATA_LIST, pluginDefine);
return result; return result;
} }
} }
/*
* 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.api.vo;
import java.util.Date;
/**
* AlertPluginInstanceVO
*/
public class AlertPluginInstanceVO {
/**
* id
*/
private int id;
/**
* plugin_define_id
*/
private int pluginDefineId;
/**
* alert plugin instance name
*/
private String instanceName;
/**
* plugin_instance_params
*/
private String pluginInstanceParams;
/**
* create_time
*/
private Date createTime;
/**
* update_time
*/
private Date updateTime;
/**
* alert plugin name
*/
private String alertPluginName;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public int getPluginDefineId() {
return pluginDefineId;
}
public void setPluginDefineId(int pluginDefineId) {
this.pluginDefineId = pluginDefineId;
}
public String getInstanceName() {
return instanceName;
}
public void setInstanceName(String instanceName) {
this.instanceName = instanceName;
}
public String getPluginInstanceParams() {
return pluginInstanceParams;
}
public void setPluginInstanceParams(String pluginInstanceParams) {
this.pluginInstanceParams = pluginInstanceParams;
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public Date getUpdateTime() {
return updateTime;
}
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
public String getAlertPluginName() {
return alertPluginName;
}
public void setAlertPluginName(String alertPluginName) {
this.alertPluginName = alertPluginName;
}
}
...@@ -19,7 +19,7 @@ QUERY_SCHEDULE_LIST_NOTES=query schedule list ...@@ -19,7 +19,7 @@ QUERY_SCHEDULE_LIST_NOTES=query schedule list
EXECUTE_PROCESS_TAG=execute process related operation EXECUTE_PROCESS_TAG=execute process related operation
PROCESS_INSTANCE_EXECUTOR_TAG=process instance executor related operation PROCESS_INSTANCE_EXECUTOR_TAG=process instance executor related operation
RUN_PROCESS_INSTANCE_NOTES=run process instance RUN_PROCESS_INSTANCE_NOTES=run process instance
START_NODE_LIST=start node list\uFF08node name\uFF09 START_NODE_LIST=start node list(node name)
TASK_DEPEND_TYPE=task depend type TASK_DEPEND_TYPE=task depend type
COMMAND_TYPE=command type COMMAND_TYPE=command type
RUN_MODE=run mode RUN_MODE=run mode
...@@ -121,7 +121,7 @@ UNAUTHORIZED_UDF_FUNC_NOTES=unauthorized udf func ...@@ -121,7 +121,7 @@ UNAUTHORIZED_UDF_FUNC_NOTES=unauthorized udf func
VERIFY_QUEUE_NOTES=verify queue VERIFY_QUEUE_NOTES=verify queue
TENANT_TAG=tenant related operation TENANT_TAG=tenant related operation
CREATE_TENANT_NOTES=create tenant CREATE_TENANT_NOTES=create tenant
TENANT_CODE=tenant code TENANT_CODE=os tenant code
QUEUE_NAME=queue name QUEUE_NAME=queue name
PASSWORD=password PASSWORD=password
DATA_SOURCE_OTHER=jdbc connection params, format:{"key1":"value1",...} DATA_SOURCE_OTHER=jdbc connection params, format:{"key1":"value1",...}
...@@ -138,7 +138,7 @@ QUERY_ALL_PROJECT_LIST_NOTES=query all project list ...@@ -138,7 +138,7 @@ QUERY_ALL_PROJECT_LIST_NOTES=query all project list
QUERY_AUTHORIZED_PROJECT_NOTES=query authorized project QUERY_AUTHORIZED_PROJECT_NOTES=query authorized project
TASK_RECORD_TAG=task record related operation TASK_RECORD_TAG=task record related operation
QUERY_TASK_RECORD_LIST_PAGING_NOTES=query task record list paging QUERY_TASK_RECORD_LIST_PAGING_NOTES=query task record list paging
CREATE_TOKEN_NOTES=create token \uFF0Cnote: please login first CREATE_TOKEN_NOTES=create token note: please login first
QUERY_ACCESS_TOKEN_LIST_NOTES=query access token list paging QUERY_ACCESS_TOKEN_LIST_NOTES=query access token list paging
SCHEDULE=schedule SCHEDULE=schedule
WARNING_TYPE=warning type(sending strategy) WARNING_TYPE=warning type(sending strategy)
...@@ -177,6 +177,7 @@ PROCESS_DEFINITION_ID=process definition id ...@@ -177,6 +177,7 @@ PROCESS_DEFINITION_ID=process definition id
PROCESS_DEFINITION_IDS=process definition ids PROCESS_DEFINITION_IDS=process definition ids
RELEASE_PROCESS_DEFINITION_NOTES=release process definition RELEASE_PROCESS_DEFINITION_NOTES=release process definition
QUERY_PROCESS_DEFINITION_BY_ID_NOTES=query process definition by id QUERY_PROCESS_DEFINITION_BY_ID_NOTES=query process definition by id
QUERY_PROCESS_DEFINITION_BY_NAME_NOTES=query process definition by name
QUERY_PROCESS_DEFINITION_LIST_NOTES=query process definition list QUERY_PROCESS_DEFINITION_LIST_NOTES=query process definition list
QUERY_PROCESS_DEFINITION_LIST_PAGING_NOTES=query process definition list paging QUERY_PROCESS_DEFINITION_LIST_PAGING_NOTES=query process definition list paging
QUERY_ALL_DEFINITION_LIST_NOTES=query all definition list QUERY_ALL_DEFINITION_LIST_NOTES=query all definition list
......
...@@ -19,7 +19,7 @@ QUERY_SCHEDULE_LIST_NOTES=query schedule list ...@@ -19,7 +19,7 @@ QUERY_SCHEDULE_LIST_NOTES=query schedule list
EXECUTE_PROCESS_TAG=execute process related operation EXECUTE_PROCESS_TAG=execute process related operation
PROCESS_INSTANCE_EXECUTOR_TAG=process instance executor related operation PROCESS_INSTANCE_EXECUTOR_TAG=process instance executor related operation
RUN_PROCESS_INSTANCE_NOTES=run process instance RUN_PROCESS_INSTANCE_NOTES=run process instance
START_NODE_LIST=start node list\uFF08node name\uFF09 START_NODE_LIST=start node list(node name)
TASK_DEPEND_TYPE=task depend type TASK_DEPEND_TYPE=task depend type
COMMAND_TYPE=command type COMMAND_TYPE=command type
RUN_MODE=run mode RUN_MODE=run mode
...@@ -121,7 +121,7 @@ UNAUTHORIZED_UDF_FUNC_NOTES=unauthorized udf func ...@@ -121,7 +121,7 @@ UNAUTHORIZED_UDF_FUNC_NOTES=unauthorized udf func
VERIFY_QUEUE_NOTES=verify queue VERIFY_QUEUE_NOTES=verify queue
TENANT_TAG=tenant related operation TENANT_TAG=tenant related operation
CREATE_TENANT_NOTES=create tenant CREATE_TENANT_NOTES=create tenant
TENANT_CODE=tenant code TENANT_CODE=os tenant code
QUEUE_NAME=queue name QUEUE_NAME=queue name
PASSWORD=password PASSWORD=password
DATA_SOURCE_OTHER=jdbc connection params, format:{"key1":"value1",...} DATA_SOURCE_OTHER=jdbc connection params, format:{"key1":"value1",...}
...@@ -138,7 +138,7 @@ QUERY_UNAUTHORIZED_PROJECT_NOTES=query unauthorized project ...@@ -138,7 +138,7 @@ QUERY_UNAUTHORIZED_PROJECT_NOTES=query unauthorized project
QUERY_AUTHORIZED_PROJECT_NOTES=query authorized project QUERY_AUTHORIZED_PROJECT_NOTES=query authorized project
TASK_RECORD_TAG=task record related operation TASK_RECORD_TAG=task record related operation
QUERY_TASK_RECORD_LIST_PAGING_NOTES=query task record list paging QUERY_TASK_RECORD_LIST_PAGING_NOTES=query task record list paging
CREATE_TOKEN_NOTES=create token \uFF0Cnote: please login first CREATE_TOKEN_NOTES=create token note: please login first
QUERY_ACCESS_TOKEN_LIST_NOTES=query access token list paging QUERY_ACCESS_TOKEN_LIST_NOTES=query access token list paging
SCHEDULE=schedule SCHEDULE=schedule
WARNING_TYPE=warning type(sending strategy) WARNING_TYPE=warning type(sending strategy)
......
...@@ -115,7 +115,7 @@ UNAUTHORIZED_UDF_FUNC_NOTES=取消udf函数授权 ...@@ -115,7 +115,7 @@ UNAUTHORIZED_UDF_FUNC_NOTES=取消udf函数授权
VERIFY_QUEUE_NOTES=验证队列 VERIFY_QUEUE_NOTES=验证队列
TENANT_TAG=租户相关操作 TENANT_TAG=租户相关操作
CREATE_TENANT_NOTES=创建租户 CREATE_TENANT_NOTES=创建租户
TENANT_CODE=租户编码 TENANT_CODE=操作系统租户
QUEUE_NAME=队列名 QUEUE_NAME=队列名
PASSWORD=密码 PASSWORD=密码
DATA_SOURCE_OTHER=jdbc连接参数,格式为:{"key1":"value1",...} DATA_SOURCE_OTHER=jdbc连接参数,格式为:{"key1":"value1",...}
......
...@@ -94,7 +94,7 @@ public class ProcessDefinitionControllerTest { ...@@ -94,7 +94,7 @@ public class ProcessDefinitionControllerTest {
String connects = "[]"; String connects = "[]";
Map<String, Object> result = new HashMap<>(); Map<String, Object> result = new HashMap<>();
putMsg(result, Status.SUCCESS); putMsg(result, Status.SUCCESS);
result.put("processDefinitionId", 1); result.put(Constants.DATA_LIST, 1);
Mockito.when(processDefinitionService.createProcessDefinition(user, projectName, name, json, Mockito.when(processDefinitionService.createProcessDefinition(user, projectName, name, json,
description, locations, connects)).thenReturn(result); description, locations, connects)).thenReturn(result);
...@@ -142,6 +142,7 @@ public class ProcessDefinitionControllerTest { ...@@ -142,6 +142,7 @@ public class ProcessDefinitionControllerTest {
String description = "desc test"; String description = "desc test";
String connects = "[]"; String connects = "[]";
int id = 1; int id = 1;
int releaseState = 0;
Map<String, Object> result = new HashMap<>(); Map<String, Object> result = new HashMap<>();
putMsg(result, Status.SUCCESS); putMsg(result, Status.SUCCESS);
result.put("processDefinitionId", 1); result.put("processDefinitionId", 1);
...@@ -150,7 +151,7 @@ public class ProcessDefinitionControllerTest { ...@@ -150,7 +151,7 @@ public class ProcessDefinitionControllerTest {
description, locations, connects)).thenReturn(result); description, locations, connects)).thenReturn(result);
Result response = processDefinitionController.updateProcessDefinition(user, projectName, name, id, json, Result response = processDefinitionController.updateProcessDefinition(user, projectName, name, id, json,
locations, connects, description); locations, connects, description,releaseState);
Assert.assertEquals(Status.SUCCESS.getCode(), response.getCode().intValue()); Assert.assertEquals(Status.SUCCESS.getCode(), response.getCode().intValue());
} }
......
...@@ -18,8 +18,13 @@ ...@@ -18,8 +18,13 @@
package org.apache.dolphinscheduler.api.controller; package org.apache.dolphinscheduler.api.controller;
import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.eq; import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.when; import static org.mockito.Mockito.when;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
import org.apache.dolphinscheduler.api.enums.Status; import org.apache.dolphinscheduler.api.enums.Status;
import org.apache.dolphinscheduler.api.service.TaskInstanceService; import org.apache.dolphinscheduler.api.service.TaskInstanceService;
...@@ -27,24 +32,28 @@ import org.apache.dolphinscheduler.api.utils.PageInfo; ...@@ -27,24 +32,28 @@ import org.apache.dolphinscheduler.api.utils.PageInfo;
import org.apache.dolphinscheduler.api.utils.Result; import org.apache.dolphinscheduler.api.utils.Result;
import org.apache.dolphinscheduler.common.Constants; import org.apache.dolphinscheduler.common.Constants;
import org.apache.dolphinscheduler.common.enums.ExecutionStatus; import org.apache.dolphinscheduler.common.enums.ExecutionStatus;
import org.apache.dolphinscheduler.common.utils.JSONUtils;
import org.apache.dolphinscheduler.dao.entity.TaskInstance; import org.apache.dolphinscheduler.dao.entity.TaskInstance;
import org.apache.dolphinscheduler.dao.entity.User;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Ignore;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks; import org.mockito.InjectMocks;
import org.mockito.Mock; import org.mockito.Mock;
import org.mockito.Mockito; import org.mockito.Mockito;
import org.mockito.junit.MockitoJUnitRunner; import org.springframework.http.MediaType;
import org.springframework.test.web.servlet.MvcResult;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
/** /**
* task instance controller test * task instance controller test
*/ */
@RunWith(MockitoJUnitRunner.Silent.class) public class TaskInstanceControllerTest extends AbstractControllerTest {
public class TaskInstanceControllerTest {
@InjectMocks @InjectMocks
private TaskInstanceController taskInstanceController; private TaskInstanceController taskInstanceController;
...@@ -67,7 +76,28 @@ public class TaskInstanceControllerTest { ...@@ -67,7 +76,28 @@ public class TaskInstanceControllerTest {
Result taskResult = taskInstanceController.queryTaskListPaging(null, "", 1, "", "", Result taskResult = taskInstanceController.queryTaskListPaging(null, "", 1, "", "",
"", "", ExecutionStatus.SUCCESS,"192.168.xx.xx", "2020-01-01 00:00:00", "2020-01-02 00:00:00",pageNo, pageSize); "", "", ExecutionStatus.SUCCESS,"192.168.xx.xx", "2020-01-01 00:00:00", "2020-01-02 00:00:00",pageNo, pageSize);
Assert.assertEquals(Integer.valueOf(Status.SUCCESS.getCode()), taskResult.getCode()); Assert.assertEquals(Integer.valueOf(Status.SUCCESS.getCode()), taskResult.getCode());
}
@Ignore
@Test
public void testForceTaskSuccess() throws Exception {
MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>();
paramsMap.add("taskInstanceId", "104");
Map<String, Object> mockResult = new HashMap<>(5);
mockResult.put(Constants.STATUS, Status.SUCCESS);
mockResult.put(Constants.MSG, Status.SUCCESS.getMsg());
when(taskInstanceService.forceTaskSuccess(any(User.class), anyString(), anyInt())).thenReturn(mockResult);
MvcResult mvcResult = mockMvc.perform(post("/projects/{projectName}/task-instance/force-success", "cxc_1113")
.header(SESSION_ID, sessionId)
.params(paramsMap))
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8))
.andReturn();
Result result = JSONUtils.parseObject(mvcResult.getResponse().getContentAsString(), Result.class);
Assert.assertEquals(Status.SUCCESS.getCode(), result.getCode().intValue());
} }
} }
...@@ -131,7 +131,7 @@ public class TenantControllerTest extends AbstractControllerTest{ ...@@ -131,7 +131,7 @@ public class TenantControllerTest extends AbstractControllerTest{
.andReturn(); .andReturn();
Result result = JSONUtils.parseObject(mvcResult.getResponse().getContentAsString(), Result.class); Result result = JSONUtils.parseObject(mvcResult.getResponse().getContentAsString(), Result.class);
Assert.assertEquals(Status.TENANT_CODE_EXIST.getCode(), result.getCode().intValue()); Assert.assertEquals(Status.OS_TENANT_CODE_EXIST.getCode(), result.getCode().intValue());
logger.info(mvcResult.getResponse().getContentAsString()); logger.info(mvcResult.getResponse().getContentAsString());
} }
......
/*
* 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.api.security;
import org.apache.dolphinscheduler.api.ApiApplicationServer;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit4.SpringRunner;
@RunWith(SpringRunner.class)
@SpringBootTest(classes = ApiApplicationServer.class)
@TestPropertySource(properties = {
"security.authentication.type=LDAP",
})
public class SecurityConfigLDAPTest {
@Autowired
private SecurityConfig securityConfig;
@Test
public void testAuthenticator() {
Authenticator authenticator = securityConfig.authenticator();
Assert.assertNotNull(authenticator);
}
}
/*
* 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.api.security;
import org.apache.dolphinscheduler.api.ApiApplicationServer;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit4.SpringRunner;
@RunWith(SpringRunner.class)
@SpringBootTest(classes = ApiApplicationServer.class)
@TestPropertySource(properties = {
"security.authentication.type=LDAP",
})
public class SecurityConfigLDAPTest {
@Autowired
private SecurityConfig securityConfig;
@Test
public void testAuthenticator() {
Authenticator authenticator = securityConfig.authenticator();
Assert.assertNotNull(authenticator);
}
}
...@@ -96,12 +96,12 @@ public class AlertGroupServiceTest { ...@@ -96,12 +96,12 @@ public class AlertGroupServiceTest {
Mockito.when(alertGroupMapper.insert(any(AlertGroup.class))).thenReturn(2); Mockito.when(alertGroupMapper.insert(any(AlertGroup.class))).thenReturn(2);
User user = new User(); User user = new User();
//no operate //no operate
Map<String, Object> result = alertGroupService.createAlertgroup(user, groupName, AlertType.EMAIL, groupName); Map<String, Object> result = alertGroupService.createAlertgroup(user, groupName, groupName, null);
logger.info(result.toString()); logger.info(result.toString());
Assert.assertEquals(Status.USER_NO_OPERATION_PERM, result.get(Constants.STATUS)); Assert.assertEquals(Status.USER_NO_OPERATION_PERM, result.get(Constants.STATUS));
user.setUserType(UserType.ADMIN_USER); user.setUserType(UserType.ADMIN_USER);
//success //success
result = alertGroupService.createAlertgroup(user, groupName, AlertType.EMAIL, groupName); result = alertGroupService.createAlertgroup(user, groupName, groupName, null);
logger.info(result.toString()); logger.info(result.toString());
Assert.assertEquals(Status.SUCCESS, result.get(Constants.STATUS)); Assert.assertEquals(Status.SUCCESS, result.get(Constants.STATUS));
} }
...@@ -111,17 +111,17 @@ public class AlertGroupServiceTest { ...@@ -111,17 +111,17 @@ public class AlertGroupServiceTest {
User user = new User(); User user = new User();
// no operate // no operate
Map<String, Object> result = alertGroupService.updateAlertgroup(user, 1, groupName, AlertType.SMS, groupName); Map<String, Object> result = alertGroupService.updateAlertgroup(user, 1, groupName, groupName, null);
logger.info(result.toString()); logger.info(result.toString());
Assert.assertEquals(Status.USER_NO_OPERATION_PERM, result.get(Constants.STATUS)); Assert.assertEquals(Status.USER_NO_OPERATION_PERM, result.get(Constants.STATUS));
user.setUserType(UserType.ADMIN_USER); user.setUserType(UserType.ADMIN_USER);
// not exist // not exist
result = alertGroupService.updateAlertgroup(user, 1, groupName, AlertType.SMS, groupName); result = alertGroupService.updateAlertgroup(user, 1, groupName, groupName, null);
logger.info(result.toString()); logger.info(result.toString());
Assert.assertEquals(Status.ALERT_GROUP_NOT_EXIST, result.get(Constants.STATUS)); Assert.assertEquals(Status.ALERT_GROUP_NOT_EXIST, result.get(Constants.STATUS));
//success //success
Mockito.when(alertGroupMapper.selectById(2)).thenReturn(getEntity()); Mockito.when(alertGroupMapper.selectById(2)).thenReturn(getEntity());
result = alertGroupService.updateAlertgroup(user, 2, groupName, AlertType.SMS, groupName); result = alertGroupService.updateAlertgroup(user, 2, groupName, groupName, null);
logger.info(result.toString()); logger.info(result.toString());
Assert.assertEquals(Status.SUCCESS, result.get(Constants.STATUS)); Assert.assertEquals(Status.SUCCESS, result.get(Constants.STATUS));
...@@ -162,8 +162,6 @@ public class AlertGroupServiceTest { ...@@ -162,8 +162,6 @@ public class AlertGroupServiceTest {
/** /**
* create admin user * create admin user
*
* @return
*/ */
private User getLoginUser() { private User getLoginUser() {
...@@ -175,8 +173,6 @@ public class AlertGroupServiceTest { ...@@ -175,8 +173,6 @@ public class AlertGroupServiceTest {
/** /**
* get list * get list
*
* @return
*/ */
private List<AlertGroup> getList() { private List<AlertGroup> getList() {
List<AlertGroup> alertGroups = new ArrayList<>(); List<AlertGroup> alertGroups = new ArrayList<>();
...@@ -186,8 +182,6 @@ public class AlertGroupServiceTest { ...@@ -186,8 +182,6 @@ public class AlertGroupServiceTest {
/** /**
* get entity * get entity
*
* @return
*/ */
private AlertGroup getEntity() { private AlertGroup getEntity() {
AlertGroup alertGroup = new AlertGroup(); AlertGroup alertGroup = new AlertGroup();
......
...@@ -72,6 +72,8 @@ public class BaseServiceTest { ...@@ -72,6 +72,8 @@ public class BaseServiceTest {
} }
@Test @Test
public void testPutMsg(){ public void testPutMsg(){
......
...@@ -462,6 +462,8 @@ public final class Constants { ...@@ -462,6 +462,8 @@ public final class Constants {
public static final String CMD_PARAM_START_NODE_NAMES = "StartNodeNameList"; public static final String CMD_PARAM_START_NODE_NAMES = "StartNodeNameList";
public static final String CMD_PARAM_START_PARAMS = "StartParams";
/** /**
* complement data start date * complement data start date
*/ */
...@@ -856,7 +858,10 @@ public final class Constants { ...@@ -856,7 +858,10 @@ public final class Constants {
ExecutionStatus.WAITTING_DEPEND.ordinal() ExecutionStatus.WAITTING_DEPEND.ordinal()
}; };
/**
* status
*/
public static final String STATUS = "status";
/** /**
* message * message
...@@ -991,10 +996,6 @@ public final class Constants { ...@@ -991,10 +996,6 @@ public final class Constants {
*/ */
public static final String PLUGIN_JAR_SUFFIX = ".jar"; public static final String PLUGIN_JAR_SUFFIX = ".jar";
/**
* status
*/
public static final String STATUS = "status";
public static final int NORAML_NODE_STATUS = 0; public static final int NORAML_NODE_STATUS = 0;
public static final int ABNORMAL_NODE_STATUS = 1; public static final int ABNORMAL_NODE_STATUS = 1;
......
...@@ -140,8 +140,8 @@ public class ShellExecutor extends AbstractShell { ...@@ -140,8 +140,8 @@ public class ShellExecutor extends AbstractShell {
String line = ""; String line = "";
while ( (nRead = lines.read(buf, 0, buf.length)) > 0 ) { while ( (nRead = lines.read(buf, 0, buf.length)) > 0 ) {
line = new String(buf,0,nRead); line = new String(buf,0,nRead);
output.append(line);
} }
output.append(line);
} }
/** /**
......
...@@ -63,7 +63,7 @@ public class VarPoolUtils { ...@@ -63,7 +63,7 @@ public class VarPoolUtils {
* @throws ParseException ParseException * @throws ParseException ParseException
*/ */
public static void convertVarPoolToMap(Map<String, Object> propToValue, String varPool) throws ParseException { public static void convertVarPoolToMap(Map<String, Object> propToValue, String varPool) throws ParseException {
if (varPool == null || propToValue == null) { if (propToValue == null || StringUtils.isEmpty(varPool)) {
return; return;
} }
String[] splits = varPool.split("\\$VarPool\\$"); String[] splits = varPool.split("\\$VarPool\\$");
......
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册