From 94b826f2be8baf71b610aa5714e9c30acd9ef1e1 Mon Sep 17 00:00:00 2001 From: liangyongrui Date: Mon, 28 Oct 2019 15:38:28 +0800 Subject: [PATCH] first commit --- .gitignore | 81 ++++ LICENSE | 202 ++++++++++ VERSION | 1 + ...50\347\275\262\346\265\201\347\250\213.md" | 30 ++ ...56\345\272\223\351\205\215\347\275\256.md" | 18 + ...50\346\210\267\347\256\241\347\220\206.md" | 140 +++++++ ...33\345\273\272\344\273\273\345\212\241.md" | 50 +++ ...62\346\234\211\347\273\204\344\273\266.md" | 13 + ...32\344\271\211\347\273\204\344\273\266.md" | 70 ++++ docs/images/logo.png | Bin 0 -> 4181 bytes ...50\347\275\262\346\265\201\347\250\213.md" | 30 ++ ...56\345\272\223\351\205\215\347\275\256.md" | 21 ++ ...50\346\210\267\347\256\241\347\220\206.md" | 142 +++++++ ...33\345\273\272\344\273\273\345\212\241.md" | 51 +++ ...62\346\234\211\347\273\204\344\273\266.md" | 13 + ...32\344\271\211\347\273\204\344\273\266.md" | 68 ++++ pom.xml | 24 ++ readme.md | 46 +++ readme_zh.md | 47 +++ thain-common/pom.xml | 170 +++++++++ .../common/constant/FlowExecutionStatus.java | 54 +++ .../common/constant/FlowLastRunStatus.java | 56 +++ .../common/constant/FlowSchedulingStatus.java | 34 ++ .../common/constant/HttpCallbackStatus.java | 41 ++ .../common/constant/JobExecutionStatus.java | 37 ++ .../xiaomi/thain/common/entity/ApiResult.java | 52 +++ .../common/entity/ComponentItemDefine.java | 45 +++ .../com/xiaomi/thain/common/entity/X5.java | 85 +++++ .../thain/common/entity/X5Response.java | 40 ++ .../CreateFlowExecutionException.java | 39 ++ .../common/exception/JobExecuteException.java | 31 ++ .../exception/JsonValidateException.java | 36 ++ .../common/exception/ThainException.java | 35 ++ .../exception/ThainFlowRunningException.java | 39 ++ .../ThainMissRequiredArgumentsException.java | 35 ++ .../exception/ThainRuntimeException.java | 35 ++ .../thain/common/exception/X5Exception.java | 16 + .../scheduler/ThainSchedulerException.java | 36 ++ .../ThainSchedulerInitException.java | 36 ++ .../ThainSchedulerStartException.java | 36 ++ .../common/model/FlowExecutionModel.java | 67 ++++ .../xiaomi/thain/common/model/FlowModel.java | 107 ++++++ .../thain/common/model/JobExecutionModel.java | 41 ++ .../xiaomi/thain/common/model/JobModel.java | 80 ++++ .../xiaomi/thain/common/model/dto/AddDto.java | 32 ++ .../xiaomi/thain/common/utils/HttpUtils.java | 110 ++++++ .../xiaomi/thain/common/utils/X5Utils.java | 118 ++++++ thain-component/pom.xml | 34 ++ .../component/annotation/ThainComponent.java | 48 +++ .../thain/component/std/HttpComponent.java | 106 ++++++ .../thain/component/std/MailComponent.java | 73 ++++ .../thain/component/std/ShellComponent.java | 89 +++++ .../thain/component/tools/ComponentTools.java | 108 ++++++ .../resources/componentDefineJson/readme.md | 7 + .../componentDefineJson/std-http.json | 55 +++ .../componentDefineJson/std-mail.json | 26 ++ .../componentDefineJson/std-shell.json | 17 + thain-core/.gitignore | 72 ++++ thain-core/pom.xml | 129 +++++++ .../com/xiaomi/thain/core/ThainFacade.java | 188 ++++++++++ .../thain/core/config/DatabaseHandler.java | 64 ++++ .../constant/FlowExecutionTriggerType.java | 20 + .../xiaomi/thain/core/constant/LogLevel.java | 22 ++ .../com/xiaomi/thain/core/dao/FlowDao.java | 133 +++++++ .../thain/core/dao/FlowExecutionDao.java | 118 ++++++ .../com/xiaomi/thain/core/dao/JobDao.java | 61 +++ .../thain/core/dao/JobExecutionDao.java | 97 +++++ .../com/xiaomi/thain/core/dao/UserDao.java | 58 +++ .../xiaomi/thain/core/entity/LogEntity.java | 37 ++ .../xiaomi/thain/core/entity/ThainUser.java | 29 ++ .../core/mapper/FlowExecutionMapper.java | 60 +++ .../xiaomi/thain/core/mapper/FlowMapper.java | 55 +++ .../thain/core/mapper/JobExecutionMapper.java | 37 ++ .../xiaomi/thain/core/mapper/JobMapper.java | 21 ++ .../xiaomi/thain/core/mapper/UserMapper.java | 20 + .../thain/core/process/ProcessEngine.java | 221 +++++++++++ .../process/ProcessEngineConfiguration.java | 74 ++++ .../core/process/ProcessEngineStorage.java | 64 ++++ .../tools/impl/ComponentToolsImpl.java | 149 ++++++++ .../runtime/checker/JobConditionChecker.java | 98 +++++ .../runtime/executor/FlowExecutor.java | 245 ++++++++++++ .../process/runtime/executor/JobExecutor.java | 133 +++++++ .../service/FlowExecutionService.java | 172 +++++++++ .../runtime/executor/service/FlowService.java | 53 +++ .../executor/service/JobExecutionService.java | 81 ++++ .../runtime/log/FlowExecutionLogHandler.java | 66 ++++ .../runtime/log/JobExecutionLogHandler.java | 59 +++ .../process/runtime/notice/HttpNotice.java | 100 +++++ .../process/runtime/notice/MailNotice.java | 46 +++ .../runtime/storage/FlowExecutionStorage.java | 75 ++++ .../process/service/ComponentService.java | 64 ++++ .../core/process/service/MailService.java | 124 ++++++ .../thain/core/scheduler/SchedulerEngine.java | 144 +++++++ .../SchedulerEngineConfiguration.java | 33 ++ .../thain/core/scheduler/job/CleanJob.java | 52 +++ .../thain/core/scheduler/job/FlowJob.java | 54 +++ .../thain/core/scheduler/job/SlaJob.java | 71 ++++ .../core/thread/pool/ThainThreadPool.java | 40 ++ .../xiaomi/thain/core/utils/H2Extended.java | 12 + .../xiaomi/thain/core/utils/ReflectUtils.java | 128 +++++++ .../thain/core/utils/SendModifyUtils.java | 36 ++ .../thain/core/mapper/FlowExecutionMapper.xml | 86 +++++ .../xiaomi/thain/core/mapper/FlowMapper.xml | 215 +++++++++++ .../thain/core/mapper/JobExecutionMapper.xml | 50 +++ .../xiaomi/thain/core/mapper/JobMapper.xml | 28 ++ .../xiaomi/thain/core/mapper/UserMapper.xml | 17 + .../resources/schema/componentJsonSchema.json | 94 +++++ .../src/main/resources/sql/h2/init_data.sql | 2 + .../src/main/resources/sql/h2/quartz.sql | 147 ++++++++ .../main/resources/sql/h2/spring_session.sql | 24 ++ .../src/main/resources/sql/h2/thain.sql | 95 +++++ .../main/resources/sql/mysql/init_data.sql | 2 + .../src/main/resources/sql/mysql/quartz.sql | 147 ++++++++ .../resources/sql/mysql/spring_session.sql | 32 ++ .../src/main/resources/sql/mysql/thain.sql | 106 ++++++ thain-fe/.editorconfig | 20 + thain-fe/.eslintignore | 4 + thain-fe/.eslintrc.js | 47 +++ thain-fe/.gitignore | 38 ++ thain-fe/.npmrc | 11 + thain-fe/.prettierignore | 10 + thain-fe/.prettierrc | 20 + thain-fe/.stylelintrc.json | 13 + thain-fe/config/config.ts | 165 ++++++++ thain-fe/config/defaultSettings.ts | 65 ++++ thain-fe/config/plugin.config.ts | 89 +++++ thain-fe/config/router.config.ts | 97 +++++ thain-fe/jsconfig.json | 10 + thain-fe/package.json | 139 +++++++ thain-fe/public/favicon.ico | Bin 0 -> 4286 bytes thain-fe/src/assets/logo.svg | 43 +++ thain-fe/src/assets/xdata_logo.png | Bin 0 -> 4361 bytes thain-fe/src/commonModels/FlowAllInfo.ts | 12 + .../src/commonModels/FlowExecutionAllInfo.ts | 14 + .../src/commonModels/FlowExecutionModel.ts | 18 + thain-fe/src/commonModels/FlowModel.ts | 25 ++ .../src/commonModels/JobExecutionModel.ts | 21 ++ thain-fe/src/commonModels/JobModel.ts | 35 ++ .../src/components/Authorized/Authorized.tsx | 34 ++ .../components/Authorized/AuthorizedRoute.tsx | 38 ++ .../Authorized/CheckPermissions.tsx | 88 +++++ .../components/Authorized/PromiseRender.tsx | 99 +++++ .../src/components/Authorized/Secured.tsx | 73 ++++ thain-fe/src/components/Authorized/index.tsx | 18 + .../components/Authorized/renderAuthorize.ts | 32 ++ thain-fe/src/components/Exception/index.less | 97 +++++ thain-fe/src/components/Exception/index.tsx | 88 +++++ .../src/components/Exception/typeConfig.ts | 49 +++ .../src/components/GlobalFooter/index.less | 34 ++ .../src/components/GlobalFooter/index.tsx | 45 +++ .../GlobalHeader/AvatarDropdown.tsx | 72 ++++ .../components/GlobalHeader/RightContent.tsx | 56 +++ .../src/components/GlobalHeader/index.less | 125 +++++++ .../src/components/HeaderDropdown/index.less | 21 ++ .../src/components/HeaderDropdown/index.tsx | 24 ++ .../components/PageHeaderWrapper/index.less | 16 + .../components/PageHeaderWrapper/index.tsx | 47 +++ thain-fe/src/components/PageLoading/index.tsx | 16 + thain-fe/src/components/SelectLang/index.less | 29 ++ thain-fe/src/components/SelectLang/index.tsx | 51 +++ thain-fe/src/enums/FlowExecutionStatus.ts | 41 ++ thain-fe/src/enums/FlowLastRunStatus.ts | 44 +++ thain-fe/src/enums/FlowSchedulingStatus.ts | 58 +++ thain-fe/src/enums/JobExecutionStatus.ts | 41 ++ thain-fe/src/global.less | 52 +++ thain-fe/src/global.tsx | 70 ++++ thain-fe/src/layouts/BasicLayout.tsx | 108 ++++++ thain-fe/src/layouts/BlankLayout.tsx | 10 + thain-fe/src/layouts/UserLayout.less | 76 ++++ thain-fe/src/layouts/UserLayout.tsx | 72 ++++ thain-fe/src/locales/en-US.ts | 29 ++ thain-fe/src/locales/en-US/admin.ts | 18 + thain-fe/src/locales/en-US/dashboard.ts | 21 ++ thain-fe/src/locales/en-US/flow.ts | 56 +++ thain-fe/src/locales/en-US/flowExecution.ts | 26 ++ thain-fe/src/locales/en-US/global.ts | 31 ++ thain-fe/src/locales/en-US/httpCode.ts | 22 ++ thain-fe/src/locales/en-US/menu.ts | 20 + thain-fe/src/locales/zh-CN.ts | 29 ++ thain-fe/src/locales/zh-CN/admin.ts | 18 + thain-fe/src/locales/zh-CN/dashboard.ts | 21 ++ thain-fe/src/locales/zh-CN/flow.ts | 56 +++ thain-fe/src/locales/zh-CN/flowExecution.ts | 26 ++ thain-fe/src/locales/zh-CN/global.ts | 31 ++ thain-fe/src/locales/zh-CN/httpCode.ts | 22 ++ thain-fe/src/locales/zh-CN/menu.ts | 20 + thain-fe/src/manifest.json | 22 ++ thain-fe/src/models/connect.d.ts | 81 ++++ thain-fe/src/models/global.ts | 141 +++++++ thain-fe/src/models/login.ts | 56 +++ thain-fe/src/models/setting.ts | 146 ++++++++ thain-fe/src/models/user.ts | 102 +++++ thain-fe/src/pages/Authorized.tsx | 55 +++ .../FlowExecutionStatusCountChart.tsx | 113 ++++++ .../pages/Dashboard/FlowSourceCountChart.tsx | 153 ++++++++ .../Dashboard/IncreaseFlowCountChart.tsx | 35 ++ .../pages/Dashboard/IncreaseJobCountChart.tsx | 32 ++ .../JobExecutionStatusCountChart.tsx | 113 ++++++ .../JobExecutionStatusHistoryCountChart.tsx | 87 +++++ .../src/pages/Dashboard/LoadingWrapper.tsx | 32 ++ .../pages/Dashboard/RunningFlowCountChart.tsx | 32 ++ .../pages/Dashboard/RunningJobCountChart.tsx | 32 ++ .../Dashboard/ScheduleStatusCountChart.tsx | 161 ++++++++ thain-fe/src/pages/Dashboard/index.tsx | 248 ++++++++++++ thain-fe/src/pages/Dashboard/model.ts | 276 ++++++++++++++ thain-fe/src/pages/Dashboard/service.ts | 91 +++++ thain-fe/src/pages/Exception/403/index.tsx | 18 + .../src/pages/Exception/403/locales/en-US.ts | 9 + .../src/pages/Exception/403/locales/zh-CN.ts | 9 + thain-fe/src/pages/Exception/404/index.tsx | 18 + .../src/pages/Exception/404/locales/en-US.ts | 9 + .../src/pages/Exception/404/locales/zh-CN.ts | 9 + thain-fe/src/pages/Exception/500/index.tsx | 18 + .../src/pages/Exception/500/locales/en-US.ts | 9 + .../src/pages/Exception/500/locales/zh-CN.ts | 9 + thain-fe/src/pages/Flow/List/FlowTable.tsx | 354 ++++++++++++++++++ thain-fe/src/pages/Flow/List/SearchForm.tsx | 207 ++++++++++ thain-fe/src/pages/Flow/List/TableList.less | 59 +++ thain-fe/src/pages/Flow/List/index.tsx | 43 +++ thain-fe/src/pages/Flow/List/model.ts | 180 +++++++++ thain-fe/src/pages/Flow/List/service.ts | 29 ++ thain-fe/src/pages/FlowEditor/EditorEdge.ts | 14 + .../src/pages/FlowEditor/EditorFlowEntity.ts | 236 ++++++++++++ thain-fe/src/pages/FlowEditor/EditorNode.ts | 22 ++ .../FlowEditor/components/Contextmenu.tsx | 100 +++++ .../FlowEditor/components/FlowDetailPanel.tsx | 163 ++++++++ .../pages/FlowEditor/components/ItemPanel.tsx | 71 ++++ .../pages/FlowEditor/components/Navigator.tsx | 40 ++ .../FlowEditor/components/NodeDetail.tsx | 131 +++++++ .../src/pages/FlowEditor/components/Page.tsx | 105 ++++++ .../pages/FlowEditor/components/Toolbar.tsx | 103 +++++ .../FlowEditor/components/input/InputProps.ts | 19 + .../FlowEditor/components/input/LineInput.tsx | 39 ++ .../components/input/RichTextInput.tsx | 63 ++++ .../components/input/SelectInput.tsx | 49 +++ .../components/input/ShellInput.tsx | 73 ++++ .../FlowEditor/components/input/SqlInput.tsx | 70 ++++ .../components/input/TextareaInput.tsx | 45 +++ .../components/input/UploadBase64Input.tsx | 42 +++ thain-fe/src/pages/FlowEditor/editor.d.ts | 34 ++ thain-fe/src/pages/FlowEditor/editor.js | 20 + .../pages/FlowEditor/font/toolbar-font.eot | Bin 0 -> 5824 bytes .../pages/FlowEditor/font/toolbar-font.svg | 89 +++++ .../pages/FlowEditor/font/toolbar-font.ttf | Bin 0 -> 5656 bytes thain-fe/src/pages/FlowEditor/index.tsx | 163 ++++++++ .../src/pages/FlowEditor/item-icon/node.svg | 30 ++ thain-fe/src/pages/FlowEditor/model.ts | 155 ++++++++ thain-fe/src/pages/FlowEditor/service.ts | 34 ++ .../FlowEditor/style/UploadBase64Input.less | 36 ++ .../FlowEditor/style/baseFlowEditor.less | 79 ++++ .../pages/FlowEditor/style/contextmenu.less | 47 +++ .../src/pages/FlowEditor/style/editor.less | 14 + .../src/pages/FlowEditor/style/itempanel.less | 33 ++ .../src/pages/FlowEditor/style/navigator.less | 37 ++ .../src/pages/FlowEditor/style/toolbar.less | 140 +++++++ .../List/FlowExecutionDetail.tsx | 183 +++++++++ .../FlowExecution/List/FlowExecutionTable.tsx | 185 +++++++++ .../pages/FlowExecution/List/LineChart.tsx | 44 +++ .../src/pages/FlowExecution/List/Logs.tsx | 75 ++++ .../src/pages/FlowExecution/List/index.tsx | 88 +++++ .../List/models/flowExecutionDetail.ts | 118 ++++++ .../List/models/flowExecutionList.ts | 92 +++++ .../src/pages/FlowExecution/List/service.ts | 25 ++ .../src/pages/FlowExecution/List/table.less | 22 ++ .../Login/components/Login/LoginContext.tsx | 18 + .../User/Login/components/Login/LoginItem.tsx | 195 ++++++++++ .../Login/components/Login/LoginSubmit.tsx | 26 ++ .../User/Login/components/Login/LoginTab.tsx | 55 +++ .../User/Login/components/Login/index.less | 58 +++ .../User/Login/components/Login/index.tsx | 162 ++++++++ .../pages/User/Login/components/Login/map.tsx | 70 ++++ thain-fe/src/pages/User/Login/index.tsx | 130 +++++++ .../src/pages/User/Login/locales/en-US.ts | 83 ++++ .../src/pages/User/Login/locales/zh-CN.ts | 79 ++++ .../src/pages/User/Login/locales/zh-TW.ts | 79 ++++ thain-fe/src/pages/User/Login/model.ts | 79 ++++ thain-fe/src/pages/User/Login/service.ts | 11 + thain-fe/src/pages/User/Login/style.less | 45 +++ thain-fe/src/pages/User/Login/utils/utils.ts | 15 + thain-fe/src/pages/admin/AddUserForm.tsx | 135 +++++++ thain-fe/src/pages/admin/AdminTabs.tsx | 26 ++ thain-fe/src/pages/admin/UserAdminTable.tsx | 118 ++++++ thain-fe/src/pages/admin/index.tsx | 39 ++ thain-fe/src/pages/admin/model.ts | 87 +++++ thain-fe/src/pages/admin/service.ts | 20 + thain-fe/src/pages/document.ejs | 173 +++++++++ thain-fe/src/service-worker.js | 70 ++++ thain-fe/src/services/login.ts | 10 + thain-fe/src/services/user.ts | 28 ++ thain-fe/src/typings.d.ts | 36 ++ thain-fe/src/typings/ApiResult.ts | 19 + .../typings/entity/ComponentDefineJsons.ts | 10 + .../src/typings/schema/ComponentDefineJson.ts | 42 +++ thain-fe/src/utils/Authorized.ts | 17 + thain-fe/src/utils/authority.ts | 24 ++ thain-fe/src/utils/delay.ts | 16 + thain-fe/src/utils/hooks.ts | 22 ++ thain-fe/src/utils/humpToLine.ts | 11 + thain-fe/src/utils/request.ts | 121 ++++++ thain-fe/src/utils/utils.less | 55 +++ thain-fe/src/utils/utils.ts | 23 ++ thain-fe/tsconfig.json | 36 ++ thain-fe/tslint.yml | 88 +++++ thain-sdk/pom.xml | 27 ++ .../com/xiaomi/thain/sdk/ThainClient.java | 92 +++++ thain-server/.gitignore | 38 ++ thain-server/pom.xml | 216 +++++++++++ .../com/xiaomi/thain/server/Application.java | 21 ++ .../com/xiaomi/thain/server/aop/X5Aop.java | 99 +++++ .../xiaomi/thain/server/config/AppConfig.java | 70 ++++ .../config/CustomOauth2UserServiceImpl.java | 61 +++ .../server/config/DBAuthenticationConfig.java | 43 +++ .../config/LdapAuthenticationConfig.java | 69 ++++ .../thain/server/config/ThainDataSource.java | 39 ++ .../xiaomi/thain/server/config/WebConfig.java | 41 ++ .../server/config/WebSecurityConfig.java | 121 ++++++ .../server/controller/AdminController.java | 70 ++++ .../controller/DashboardController.java | 123 ++++++ .../server/controller/FlowController.java | 204 ++++++++++ .../controller/FlowExecutionController.java | 112 ++++++ .../server/controller/LoginController.java | 69 ++++ .../controller/x5/X5FlowController.java | 126 +++++++ .../x5/X5FlowExecutionController.java | 73 ++++ .../xiaomi/thain/server/dao/DashboardDao.java | 65 ++++ .../com/xiaomi/thain/server/dao/FlowDao.java | 65 ++++ .../thain/server/dao/FlowExecutionDao.java | 62 +++ .../com/xiaomi/thain/server/dao/UserDao.java | 62 +++ .../com/xiaomi/thain/server/dao/X5Dao.java | 31 ++ .../xiaomi/thain/server/entity/X5Config.java | 28 ++ .../server/entity/query/FlowAllInfoQuery.java | 27 ++ .../query/FlowExecutionAllInfoQuery.java | 30 ++ .../server/entity/query/FlowListQuery.java | 89 +++++ .../entity/request/FlowListRequest.java | 42 +++ .../server/entity/request/UserRequest.java | 20 + .../entity/response/StatusHistoryCount.java | 22 ++ .../server/entity/response/UserResponse.java | 17 + .../thain/server/entity/user/ThainUser.java | 107 ++++++ .../thain/server/handler/ThreadLocalUser.java | 51 +++ .../thain/server/mapper/DashboardMapper.java | 96 +++++ .../server/mapper/FlowExecutionMapper.java | 42 +++ .../thain/server/mapper/FlowMapper.java | 45 +++ .../thain/server/mapper/UserMapper.java | 52 +++ .../xiaomi/thain/server/mapper/X5Mapper.java | 25 ++ .../thain/server/service/CheckService.java | 31 ++ .../server/service/DashboardService.java | 96 +++++ .../server/service/FlowExecutionService.java | 40 ++ .../thain/server/service/FlowService.java | 60 +++ .../server/service/PermissionService.java | 57 +++ .../thain/server/service/UserService.java | 29 ++ .../thain/server/service/X5Service.java | 20 + .../server/service/impl/CheckServiceImpl.java | 118 ++++++ .../service/impl/DashboardServiceImpl.java | 113 ++++++ .../impl/DbUserDetailsServiceImpl.java | 34 ++ .../impl/FlowExecutionServiceImpl.java | 69 ++++ .../server/service/impl/FlowServiceImpl.java | 121 ++++++ .../service/impl/PermissionServiceImpl.java | 54 +++ .../server/service/impl/UserServiceImpl.java | 64 ++++ .../server/service/impl/X5ServiceImpl.java | 35 ++ .../src/main/resources/application.properties | 65 ++++ .../Dashboard.xml | 109 ++++++ .../FlowExecutionMapper.xml | 85 +++++ .../FlowMapper.xml | 170 +++++++++ .../com.xiaomi.thain.server.mapper/User.xml | 53 +++ thain-server/src/main/resources/log4j2.xml | 61 +++ .../src/main/resources/quartz.properties | 20 + .../xiaomi/thain/server/ApplicationTests.java | 30 ++ 366 files changed, 23552 insertions(+) create mode 100644 .gitignore create mode 100644 LICENSE create mode 100644 VERSION create mode 100644 "docs/en/1.\351\203\250\347\275\262\345\220\257\345\212\250/1.\351\203\250\347\275\262\346\265\201\347\250\213.md" create mode 100644 "docs/en/1.\351\203\250\347\275\262\345\220\257\345\212\250/2.\346\225\260\346\215\256\345\272\223\351\205\215\347\275\256.md" create mode 100644 "docs/en/1.\351\203\250\347\275\262\345\220\257\345\212\250/3.\347\224\250\346\210\267\347\256\241\347\220\206.md" create mode 100644 "docs/en/2.\344\275\277\347\224\250\346\225\231\347\250\213/\345\210\233\345\273\272\344\273\273\345\212\241.md" create mode 100644 "docs/en/3.\347\273\204\344\273\266\350\257\264\346\230\216/1.\345\267\262\346\234\211\347\273\204\344\273\266.md" create mode 100644 "docs/en/3.\347\273\204\344\273\266\350\257\264\346\230\216/2.\350\207\252\345\256\232\344\271\211\347\273\204\344\273\266.md" create mode 100755 docs/images/logo.png create mode 100644 "docs/zh/1.\351\203\250\347\275\262\345\220\257\345\212\250/1.\351\203\250\347\275\262\346\265\201\347\250\213.md" create mode 100644 "docs/zh/1.\351\203\250\347\275\262\345\220\257\345\212\250/2.\346\225\260\346\215\256\345\272\223\351\205\215\347\275\256.md" create mode 100644 "docs/zh/1.\351\203\250\347\275\262\345\220\257\345\212\250/3.\347\224\250\346\210\267\347\256\241\347\220\206.md" create mode 100644 "docs/zh/2.\344\275\277\347\224\250\346\225\231\347\250\213/\345\210\233\345\273\272\344\273\273\345\212\241.md" create mode 100644 "docs/zh/3.\347\273\204\344\273\266\350\257\264\346\230\216/1.\345\267\262\346\234\211\347\273\204\344\273\266.md" create mode 100644 "docs/zh/3.\347\273\204\344\273\266\350\257\264\346\230\216/2.\350\207\252\345\256\232\344\271\211\347\273\204\344\273\266.md" create mode 100644 pom.xml create mode 100644 readme.md create mode 100644 readme_zh.md create mode 100644 thain-common/pom.xml create mode 100644 thain-common/src/main/java/com/xiaomi/thain/common/constant/FlowExecutionStatus.java create mode 100644 thain-common/src/main/java/com/xiaomi/thain/common/constant/FlowLastRunStatus.java create mode 100644 thain-common/src/main/java/com/xiaomi/thain/common/constant/FlowSchedulingStatus.java create mode 100644 thain-common/src/main/java/com/xiaomi/thain/common/constant/HttpCallbackStatus.java create mode 100644 thain-common/src/main/java/com/xiaomi/thain/common/constant/JobExecutionStatus.java create mode 100644 thain-common/src/main/java/com/xiaomi/thain/common/entity/ApiResult.java create mode 100644 thain-common/src/main/java/com/xiaomi/thain/common/entity/ComponentItemDefine.java create mode 100644 thain-common/src/main/java/com/xiaomi/thain/common/entity/X5.java create mode 100644 thain-common/src/main/java/com/xiaomi/thain/common/entity/X5Response.java create mode 100644 thain-common/src/main/java/com/xiaomi/thain/common/exception/CreateFlowExecutionException.java create mode 100644 thain-common/src/main/java/com/xiaomi/thain/common/exception/JobExecuteException.java create mode 100644 thain-common/src/main/java/com/xiaomi/thain/common/exception/JsonValidateException.java create mode 100644 thain-common/src/main/java/com/xiaomi/thain/common/exception/ThainException.java create mode 100644 thain-common/src/main/java/com/xiaomi/thain/common/exception/ThainFlowRunningException.java create mode 100644 thain-common/src/main/java/com/xiaomi/thain/common/exception/ThainMissRequiredArgumentsException.java create mode 100644 thain-common/src/main/java/com/xiaomi/thain/common/exception/ThainRuntimeException.java create mode 100644 thain-common/src/main/java/com/xiaomi/thain/common/exception/X5Exception.java create mode 100644 thain-common/src/main/java/com/xiaomi/thain/common/exception/scheduler/ThainSchedulerException.java create mode 100644 thain-common/src/main/java/com/xiaomi/thain/common/exception/scheduler/ThainSchedulerInitException.java create mode 100644 thain-common/src/main/java/com/xiaomi/thain/common/exception/scheduler/ThainSchedulerStartException.java create mode 100644 thain-common/src/main/java/com/xiaomi/thain/common/model/FlowExecutionModel.java create mode 100644 thain-common/src/main/java/com/xiaomi/thain/common/model/FlowModel.java create mode 100644 thain-common/src/main/java/com/xiaomi/thain/common/model/JobExecutionModel.java create mode 100644 thain-common/src/main/java/com/xiaomi/thain/common/model/JobModel.java create mode 100644 thain-common/src/main/java/com/xiaomi/thain/common/model/dto/AddDto.java create mode 100644 thain-common/src/main/java/com/xiaomi/thain/common/utils/HttpUtils.java create mode 100644 thain-common/src/main/java/com/xiaomi/thain/common/utils/X5Utils.java create mode 100644 thain-component/pom.xml create mode 100644 thain-component/src/main/java/com/xiaomi/thain/component/annotation/ThainComponent.java create mode 100644 thain-component/src/main/java/com/xiaomi/thain/component/std/HttpComponent.java create mode 100644 thain-component/src/main/java/com/xiaomi/thain/component/std/MailComponent.java create mode 100644 thain-component/src/main/java/com/xiaomi/thain/component/std/ShellComponent.java create mode 100644 thain-component/src/main/java/com/xiaomi/thain/component/tools/ComponentTools.java create mode 100644 thain-component/src/main/resources/componentDefineJson/readme.md create mode 100644 thain-component/src/main/resources/componentDefineJson/std-http.json create mode 100644 thain-component/src/main/resources/componentDefineJson/std-mail.json create mode 100644 thain-component/src/main/resources/componentDefineJson/std-shell.json create mode 100644 thain-core/.gitignore create mode 100644 thain-core/pom.xml create mode 100644 thain-core/src/main/java/com/xiaomi/thain/core/ThainFacade.java create mode 100644 thain-core/src/main/java/com/xiaomi/thain/core/config/DatabaseHandler.java create mode 100644 thain-core/src/main/java/com/xiaomi/thain/core/constant/FlowExecutionTriggerType.java create mode 100644 thain-core/src/main/java/com/xiaomi/thain/core/constant/LogLevel.java create mode 100644 thain-core/src/main/java/com/xiaomi/thain/core/dao/FlowDao.java create mode 100644 thain-core/src/main/java/com/xiaomi/thain/core/dao/FlowExecutionDao.java create mode 100644 thain-core/src/main/java/com/xiaomi/thain/core/dao/JobDao.java create mode 100644 thain-core/src/main/java/com/xiaomi/thain/core/dao/JobExecutionDao.java create mode 100644 thain-core/src/main/java/com/xiaomi/thain/core/dao/UserDao.java create mode 100644 thain-core/src/main/java/com/xiaomi/thain/core/entity/LogEntity.java create mode 100644 thain-core/src/main/java/com/xiaomi/thain/core/entity/ThainUser.java create mode 100644 thain-core/src/main/java/com/xiaomi/thain/core/mapper/FlowExecutionMapper.java create mode 100644 thain-core/src/main/java/com/xiaomi/thain/core/mapper/FlowMapper.java create mode 100644 thain-core/src/main/java/com/xiaomi/thain/core/mapper/JobExecutionMapper.java create mode 100644 thain-core/src/main/java/com/xiaomi/thain/core/mapper/JobMapper.java create mode 100644 thain-core/src/main/java/com/xiaomi/thain/core/mapper/UserMapper.java create mode 100644 thain-core/src/main/java/com/xiaomi/thain/core/process/ProcessEngine.java create mode 100644 thain-core/src/main/java/com/xiaomi/thain/core/process/ProcessEngineConfiguration.java create mode 100644 thain-core/src/main/java/com/xiaomi/thain/core/process/ProcessEngineStorage.java create mode 100644 thain-core/src/main/java/com/xiaomi/thain/core/process/component/tools/impl/ComponentToolsImpl.java create mode 100644 thain-core/src/main/java/com/xiaomi/thain/core/process/runtime/checker/JobConditionChecker.java create mode 100644 thain-core/src/main/java/com/xiaomi/thain/core/process/runtime/executor/FlowExecutor.java create mode 100644 thain-core/src/main/java/com/xiaomi/thain/core/process/runtime/executor/JobExecutor.java create mode 100644 thain-core/src/main/java/com/xiaomi/thain/core/process/runtime/executor/service/FlowExecutionService.java create mode 100644 thain-core/src/main/java/com/xiaomi/thain/core/process/runtime/executor/service/FlowService.java create mode 100644 thain-core/src/main/java/com/xiaomi/thain/core/process/runtime/executor/service/JobExecutionService.java create mode 100644 thain-core/src/main/java/com/xiaomi/thain/core/process/runtime/log/FlowExecutionLogHandler.java create mode 100644 thain-core/src/main/java/com/xiaomi/thain/core/process/runtime/log/JobExecutionLogHandler.java create mode 100644 thain-core/src/main/java/com/xiaomi/thain/core/process/runtime/notice/HttpNotice.java create mode 100644 thain-core/src/main/java/com/xiaomi/thain/core/process/runtime/notice/MailNotice.java create mode 100644 thain-core/src/main/java/com/xiaomi/thain/core/process/runtime/storage/FlowExecutionStorage.java create mode 100644 thain-core/src/main/java/com/xiaomi/thain/core/process/service/ComponentService.java create mode 100644 thain-core/src/main/java/com/xiaomi/thain/core/process/service/MailService.java create mode 100644 thain-core/src/main/java/com/xiaomi/thain/core/scheduler/SchedulerEngine.java create mode 100644 thain-core/src/main/java/com/xiaomi/thain/core/scheduler/SchedulerEngineConfiguration.java create mode 100644 thain-core/src/main/java/com/xiaomi/thain/core/scheduler/job/CleanJob.java create mode 100644 thain-core/src/main/java/com/xiaomi/thain/core/scheduler/job/FlowJob.java create mode 100644 thain-core/src/main/java/com/xiaomi/thain/core/scheduler/job/SlaJob.java create mode 100644 thain-core/src/main/java/com/xiaomi/thain/core/thread/pool/ThainThreadPool.java create mode 100644 thain-core/src/main/java/com/xiaomi/thain/core/utils/H2Extended.java create mode 100644 thain-core/src/main/java/com/xiaomi/thain/core/utils/ReflectUtils.java create mode 100644 thain-core/src/main/java/com/xiaomi/thain/core/utils/SendModifyUtils.java create mode 100644 thain-core/src/main/resources/com/xiaomi/thain/core/mapper/FlowExecutionMapper.xml create mode 100644 thain-core/src/main/resources/com/xiaomi/thain/core/mapper/FlowMapper.xml create mode 100644 thain-core/src/main/resources/com/xiaomi/thain/core/mapper/JobExecutionMapper.xml create mode 100644 thain-core/src/main/resources/com/xiaomi/thain/core/mapper/JobMapper.xml create mode 100644 thain-core/src/main/resources/com/xiaomi/thain/core/mapper/UserMapper.xml create mode 100644 thain-core/src/main/resources/schema/componentJsonSchema.json create mode 100644 thain-core/src/main/resources/sql/h2/init_data.sql create mode 100644 thain-core/src/main/resources/sql/h2/quartz.sql create mode 100644 thain-core/src/main/resources/sql/h2/spring_session.sql create mode 100644 thain-core/src/main/resources/sql/h2/thain.sql create mode 100644 thain-core/src/main/resources/sql/mysql/init_data.sql create mode 100644 thain-core/src/main/resources/sql/mysql/quartz.sql create mode 100644 thain-core/src/main/resources/sql/mysql/spring_session.sql create mode 100644 thain-core/src/main/resources/sql/mysql/thain.sql create mode 100644 thain-fe/.editorconfig create mode 100644 thain-fe/.eslintignore create mode 100644 thain-fe/.eslintrc.js create mode 100644 thain-fe/.gitignore create mode 100644 thain-fe/.npmrc create mode 100644 thain-fe/.prettierignore create mode 100644 thain-fe/.prettierrc create mode 100644 thain-fe/.stylelintrc.json create mode 100644 thain-fe/config/config.ts create mode 100644 thain-fe/config/defaultSettings.ts create mode 100644 thain-fe/config/plugin.config.ts create mode 100644 thain-fe/config/router.config.ts create mode 100644 thain-fe/jsconfig.json create mode 100644 thain-fe/package.json create mode 100644 thain-fe/public/favicon.ico create mode 100644 thain-fe/src/assets/logo.svg create mode 100644 thain-fe/src/assets/xdata_logo.png create mode 100644 thain-fe/src/commonModels/FlowAllInfo.ts create mode 100644 thain-fe/src/commonModels/FlowExecutionAllInfo.ts create mode 100644 thain-fe/src/commonModels/FlowExecutionModel.ts create mode 100644 thain-fe/src/commonModels/FlowModel.ts create mode 100644 thain-fe/src/commonModels/JobExecutionModel.ts create mode 100644 thain-fe/src/commonModels/JobModel.ts create mode 100644 thain-fe/src/components/Authorized/Authorized.tsx create mode 100644 thain-fe/src/components/Authorized/AuthorizedRoute.tsx create mode 100644 thain-fe/src/components/Authorized/CheckPermissions.tsx create mode 100644 thain-fe/src/components/Authorized/PromiseRender.tsx create mode 100644 thain-fe/src/components/Authorized/Secured.tsx create mode 100644 thain-fe/src/components/Authorized/index.tsx create mode 100644 thain-fe/src/components/Authorized/renderAuthorize.ts create mode 100644 thain-fe/src/components/Exception/index.less create mode 100644 thain-fe/src/components/Exception/index.tsx create mode 100644 thain-fe/src/components/Exception/typeConfig.ts create mode 100644 thain-fe/src/components/GlobalFooter/index.less create mode 100644 thain-fe/src/components/GlobalFooter/index.tsx create mode 100644 thain-fe/src/components/GlobalHeader/AvatarDropdown.tsx create mode 100644 thain-fe/src/components/GlobalHeader/RightContent.tsx create mode 100644 thain-fe/src/components/GlobalHeader/index.less create mode 100644 thain-fe/src/components/HeaderDropdown/index.less create mode 100644 thain-fe/src/components/HeaderDropdown/index.tsx create mode 100644 thain-fe/src/components/PageHeaderWrapper/index.less create mode 100644 thain-fe/src/components/PageHeaderWrapper/index.tsx create mode 100644 thain-fe/src/components/PageLoading/index.tsx create mode 100644 thain-fe/src/components/SelectLang/index.less create mode 100644 thain-fe/src/components/SelectLang/index.tsx create mode 100644 thain-fe/src/enums/FlowExecutionStatus.ts create mode 100644 thain-fe/src/enums/FlowLastRunStatus.ts create mode 100644 thain-fe/src/enums/FlowSchedulingStatus.ts create mode 100644 thain-fe/src/enums/JobExecutionStatus.ts create mode 100644 thain-fe/src/global.less create mode 100644 thain-fe/src/global.tsx create mode 100644 thain-fe/src/layouts/BasicLayout.tsx create mode 100644 thain-fe/src/layouts/BlankLayout.tsx create mode 100644 thain-fe/src/layouts/UserLayout.less create mode 100644 thain-fe/src/layouts/UserLayout.tsx create mode 100644 thain-fe/src/locales/en-US.ts create mode 100644 thain-fe/src/locales/en-US/admin.ts create mode 100644 thain-fe/src/locales/en-US/dashboard.ts create mode 100644 thain-fe/src/locales/en-US/flow.ts create mode 100644 thain-fe/src/locales/en-US/flowExecution.ts create mode 100644 thain-fe/src/locales/en-US/global.ts create mode 100644 thain-fe/src/locales/en-US/httpCode.ts create mode 100644 thain-fe/src/locales/en-US/menu.ts create mode 100644 thain-fe/src/locales/zh-CN.ts create mode 100644 thain-fe/src/locales/zh-CN/admin.ts create mode 100644 thain-fe/src/locales/zh-CN/dashboard.ts create mode 100644 thain-fe/src/locales/zh-CN/flow.ts create mode 100644 thain-fe/src/locales/zh-CN/flowExecution.ts create mode 100644 thain-fe/src/locales/zh-CN/global.ts create mode 100644 thain-fe/src/locales/zh-CN/httpCode.ts create mode 100644 thain-fe/src/locales/zh-CN/menu.ts create mode 100644 thain-fe/src/manifest.json create mode 100644 thain-fe/src/models/connect.d.ts create mode 100644 thain-fe/src/models/global.ts create mode 100644 thain-fe/src/models/login.ts create mode 100644 thain-fe/src/models/setting.ts create mode 100644 thain-fe/src/models/user.ts create mode 100644 thain-fe/src/pages/Authorized.tsx create mode 100644 thain-fe/src/pages/Dashboard/FlowExecutionStatusCountChart.tsx create mode 100644 thain-fe/src/pages/Dashboard/FlowSourceCountChart.tsx create mode 100644 thain-fe/src/pages/Dashboard/IncreaseFlowCountChart.tsx create mode 100644 thain-fe/src/pages/Dashboard/IncreaseJobCountChart.tsx create mode 100644 thain-fe/src/pages/Dashboard/JobExecutionStatusCountChart.tsx create mode 100644 thain-fe/src/pages/Dashboard/JobExecutionStatusHistoryCountChart.tsx create mode 100644 thain-fe/src/pages/Dashboard/LoadingWrapper.tsx create mode 100644 thain-fe/src/pages/Dashboard/RunningFlowCountChart.tsx create mode 100644 thain-fe/src/pages/Dashboard/RunningJobCountChart.tsx create mode 100644 thain-fe/src/pages/Dashboard/ScheduleStatusCountChart.tsx create mode 100644 thain-fe/src/pages/Dashboard/index.tsx create mode 100644 thain-fe/src/pages/Dashboard/model.ts create mode 100644 thain-fe/src/pages/Dashboard/service.ts create mode 100644 thain-fe/src/pages/Exception/403/index.tsx create mode 100644 thain-fe/src/pages/Exception/403/locales/en-US.ts create mode 100644 thain-fe/src/pages/Exception/403/locales/zh-CN.ts create mode 100644 thain-fe/src/pages/Exception/404/index.tsx create mode 100644 thain-fe/src/pages/Exception/404/locales/en-US.ts create mode 100644 thain-fe/src/pages/Exception/404/locales/zh-CN.ts create mode 100644 thain-fe/src/pages/Exception/500/index.tsx create mode 100644 thain-fe/src/pages/Exception/500/locales/en-US.ts create mode 100644 thain-fe/src/pages/Exception/500/locales/zh-CN.ts create mode 100644 thain-fe/src/pages/Flow/List/FlowTable.tsx create mode 100644 thain-fe/src/pages/Flow/List/SearchForm.tsx create mode 100644 thain-fe/src/pages/Flow/List/TableList.less create mode 100644 thain-fe/src/pages/Flow/List/index.tsx create mode 100644 thain-fe/src/pages/Flow/List/model.ts create mode 100644 thain-fe/src/pages/Flow/List/service.ts create mode 100644 thain-fe/src/pages/FlowEditor/EditorEdge.ts create mode 100644 thain-fe/src/pages/FlowEditor/EditorFlowEntity.ts create mode 100644 thain-fe/src/pages/FlowEditor/EditorNode.ts create mode 100644 thain-fe/src/pages/FlowEditor/components/Contextmenu.tsx create mode 100644 thain-fe/src/pages/FlowEditor/components/FlowDetailPanel.tsx create mode 100644 thain-fe/src/pages/FlowEditor/components/ItemPanel.tsx create mode 100644 thain-fe/src/pages/FlowEditor/components/Navigator.tsx create mode 100644 thain-fe/src/pages/FlowEditor/components/NodeDetail.tsx create mode 100644 thain-fe/src/pages/FlowEditor/components/Page.tsx create mode 100644 thain-fe/src/pages/FlowEditor/components/Toolbar.tsx create mode 100644 thain-fe/src/pages/FlowEditor/components/input/InputProps.ts create mode 100644 thain-fe/src/pages/FlowEditor/components/input/LineInput.tsx create mode 100644 thain-fe/src/pages/FlowEditor/components/input/RichTextInput.tsx create mode 100644 thain-fe/src/pages/FlowEditor/components/input/SelectInput.tsx create mode 100644 thain-fe/src/pages/FlowEditor/components/input/ShellInput.tsx create mode 100644 thain-fe/src/pages/FlowEditor/components/input/SqlInput.tsx create mode 100644 thain-fe/src/pages/FlowEditor/components/input/TextareaInput.tsx create mode 100644 thain-fe/src/pages/FlowEditor/components/input/UploadBase64Input.tsx create mode 100644 thain-fe/src/pages/FlowEditor/editor.d.ts create mode 100644 thain-fe/src/pages/FlowEditor/editor.js create mode 100644 thain-fe/src/pages/FlowEditor/font/toolbar-font.eot create mode 100644 thain-fe/src/pages/FlowEditor/font/toolbar-font.svg create mode 100644 thain-fe/src/pages/FlowEditor/font/toolbar-font.ttf create mode 100644 thain-fe/src/pages/FlowEditor/index.tsx create mode 100644 thain-fe/src/pages/FlowEditor/item-icon/node.svg create mode 100644 thain-fe/src/pages/FlowEditor/model.ts create mode 100644 thain-fe/src/pages/FlowEditor/service.ts create mode 100644 thain-fe/src/pages/FlowEditor/style/UploadBase64Input.less create mode 100644 thain-fe/src/pages/FlowEditor/style/baseFlowEditor.less create mode 100644 thain-fe/src/pages/FlowEditor/style/contextmenu.less create mode 100644 thain-fe/src/pages/FlowEditor/style/editor.less create mode 100644 thain-fe/src/pages/FlowEditor/style/itempanel.less create mode 100644 thain-fe/src/pages/FlowEditor/style/navigator.less create mode 100644 thain-fe/src/pages/FlowEditor/style/toolbar.less create mode 100644 thain-fe/src/pages/FlowExecution/List/FlowExecutionDetail.tsx create mode 100644 thain-fe/src/pages/FlowExecution/List/FlowExecutionTable.tsx create mode 100644 thain-fe/src/pages/FlowExecution/List/LineChart.tsx create mode 100644 thain-fe/src/pages/FlowExecution/List/Logs.tsx create mode 100644 thain-fe/src/pages/FlowExecution/List/index.tsx create mode 100644 thain-fe/src/pages/FlowExecution/List/models/flowExecutionDetail.ts create mode 100644 thain-fe/src/pages/FlowExecution/List/models/flowExecutionList.ts create mode 100644 thain-fe/src/pages/FlowExecution/List/service.ts create mode 100644 thain-fe/src/pages/FlowExecution/List/table.less create mode 100644 thain-fe/src/pages/User/Login/components/Login/LoginContext.tsx create mode 100644 thain-fe/src/pages/User/Login/components/Login/LoginItem.tsx create mode 100644 thain-fe/src/pages/User/Login/components/Login/LoginSubmit.tsx create mode 100644 thain-fe/src/pages/User/Login/components/Login/LoginTab.tsx create mode 100644 thain-fe/src/pages/User/Login/components/Login/index.less create mode 100644 thain-fe/src/pages/User/Login/components/Login/index.tsx create mode 100644 thain-fe/src/pages/User/Login/components/Login/map.tsx create mode 100644 thain-fe/src/pages/User/Login/index.tsx create mode 100644 thain-fe/src/pages/User/Login/locales/en-US.ts create mode 100644 thain-fe/src/pages/User/Login/locales/zh-CN.ts create mode 100644 thain-fe/src/pages/User/Login/locales/zh-TW.ts create mode 100644 thain-fe/src/pages/User/Login/model.ts create mode 100644 thain-fe/src/pages/User/Login/service.ts create mode 100644 thain-fe/src/pages/User/Login/style.less create mode 100644 thain-fe/src/pages/User/Login/utils/utils.ts create mode 100644 thain-fe/src/pages/admin/AddUserForm.tsx create mode 100644 thain-fe/src/pages/admin/AdminTabs.tsx create mode 100644 thain-fe/src/pages/admin/UserAdminTable.tsx create mode 100644 thain-fe/src/pages/admin/index.tsx create mode 100644 thain-fe/src/pages/admin/model.ts create mode 100644 thain-fe/src/pages/admin/service.ts create mode 100644 thain-fe/src/pages/document.ejs create mode 100644 thain-fe/src/service-worker.js create mode 100644 thain-fe/src/services/login.ts create mode 100644 thain-fe/src/services/user.ts create mode 100644 thain-fe/src/typings.d.ts create mode 100644 thain-fe/src/typings/ApiResult.ts create mode 100644 thain-fe/src/typings/entity/ComponentDefineJsons.ts create mode 100644 thain-fe/src/typings/schema/ComponentDefineJson.ts create mode 100644 thain-fe/src/utils/Authorized.ts create mode 100644 thain-fe/src/utils/authority.ts create mode 100644 thain-fe/src/utils/delay.ts create mode 100644 thain-fe/src/utils/hooks.ts create mode 100644 thain-fe/src/utils/humpToLine.ts create mode 100644 thain-fe/src/utils/request.ts create mode 100644 thain-fe/src/utils/utils.less create mode 100644 thain-fe/src/utils/utils.ts create mode 100644 thain-fe/tsconfig.json create mode 100644 thain-fe/tslint.yml create mode 100644 thain-sdk/pom.xml create mode 100644 thain-sdk/src/main/java/com/xiaomi/thain/sdk/ThainClient.java create mode 100644 thain-server/.gitignore create mode 100644 thain-server/pom.xml create mode 100644 thain-server/src/main/java/com/xiaomi/thain/server/Application.java create mode 100644 thain-server/src/main/java/com/xiaomi/thain/server/aop/X5Aop.java create mode 100644 thain-server/src/main/java/com/xiaomi/thain/server/config/AppConfig.java create mode 100644 thain-server/src/main/java/com/xiaomi/thain/server/config/CustomOauth2UserServiceImpl.java create mode 100644 thain-server/src/main/java/com/xiaomi/thain/server/config/DBAuthenticationConfig.java create mode 100644 thain-server/src/main/java/com/xiaomi/thain/server/config/LdapAuthenticationConfig.java create mode 100644 thain-server/src/main/java/com/xiaomi/thain/server/config/ThainDataSource.java create mode 100644 thain-server/src/main/java/com/xiaomi/thain/server/config/WebConfig.java create mode 100644 thain-server/src/main/java/com/xiaomi/thain/server/config/WebSecurityConfig.java create mode 100644 thain-server/src/main/java/com/xiaomi/thain/server/controller/AdminController.java create mode 100644 thain-server/src/main/java/com/xiaomi/thain/server/controller/DashboardController.java create mode 100644 thain-server/src/main/java/com/xiaomi/thain/server/controller/FlowController.java create mode 100644 thain-server/src/main/java/com/xiaomi/thain/server/controller/FlowExecutionController.java create mode 100644 thain-server/src/main/java/com/xiaomi/thain/server/controller/LoginController.java create mode 100644 thain-server/src/main/java/com/xiaomi/thain/server/controller/x5/X5FlowController.java create mode 100644 thain-server/src/main/java/com/xiaomi/thain/server/controller/x5/X5FlowExecutionController.java create mode 100644 thain-server/src/main/java/com/xiaomi/thain/server/dao/DashboardDao.java create mode 100644 thain-server/src/main/java/com/xiaomi/thain/server/dao/FlowDao.java create mode 100644 thain-server/src/main/java/com/xiaomi/thain/server/dao/FlowExecutionDao.java create mode 100644 thain-server/src/main/java/com/xiaomi/thain/server/dao/UserDao.java create mode 100644 thain-server/src/main/java/com/xiaomi/thain/server/dao/X5Dao.java create mode 100644 thain-server/src/main/java/com/xiaomi/thain/server/entity/X5Config.java create mode 100644 thain-server/src/main/java/com/xiaomi/thain/server/entity/query/FlowAllInfoQuery.java create mode 100644 thain-server/src/main/java/com/xiaomi/thain/server/entity/query/FlowExecutionAllInfoQuery.java create mode 100644 thain-server/src/main/java/com/xiaomi/thain/server/entity/query/FlowListQuery.java create mode 100644 thain-server/src/main/java/com/xiaomi/thain/server/entity/request/FlowListRequest.java create mode 100644 thain-server/src/main/java/com/xiaomi/thain/server/entity/request/UserRequest.java create mode 100644 thain-server/src/main/java/com/xiaomi/thain/server/entity/response/StatusHistoryCount.java create mode 100644 thain-server/src/main/java/com/xiaomi/thain/server/entity/response/UserResponse.java create mode 100644 thain-server/src/main/java/com/xiaomi/thain/server/entity/user/ThainUser.java create mode 100644 thain-server/src/main/java/com/xiaomi/thain/server/handler/ThreadLocalUser.java create mode 100644 thain-server/src/main/java/com/xiaomi/thain/server/mapper/DashboardMapper.java create mode 100644 thain-server/src/main/java/com/xiaomi/thain/server/mapper/FlowExecutionMapper.java create mode 100644 thain-server/src/main/java/com/xiaomi/thain/server/mapper/FlowMapper.java create mode 100644 thain-server/src/main/java/com/xiaomi/thain/server/mapper/UserMapper.java create mode 100644 thain-server/src/main/java/com/xiaomi/thain/server/mapper/X5Mapper.java create mode 100644 thain-server/src/main/java/com/xiaomi/thain/server/service/CheckService.java create mode 100644 thain-server/src/main/java/com/xiaomi/thain/server/service/DashboardService.java create mode 100644 thain-server/src/main/java/com/xiaomi/thain/server/service/FlowExecutionService.java create mode 100644 thain-server/src/main/java/com/xiaomi/thain/server/service/FlowService.java create mode 100644 thain-server/src/main/java/com/xiaomi/thain/server/service/PermissionService.java create mode 100644 thain-server/src/main/java/com/xiaomi/thain/server/service/UserService.java create mode 100644 thain-server/src/main/java/com/xiaomi/thain/server/service/X5Service.java create mode 100644 thain-server/src/main/java/com/xiaomi/thain/server/service/impl/CheckServiceImpl.java create mode 100644 thain-server/src/main/java/com/xiaomi/thain/server/service/impl/DashboardServiceImpl.java create mode 100644 thain-server/src/main/java/com/xiaomi/thain/server/service/impl/DbUserDetailsServiceImpl.java create mode 100644 thain-server/src/main/java/com/xiaomi/thain/server/service/impl/FlowExecutionServiceImpl.java create mode 100644 thain-server/src/main/java/com/xiaomi/thain/server/service/impl/FlowServiceImpl.java create mode 100644 thain-server/src/main/java/com/xiaomi/thain/server/service/impl/PermissionServiceImpl.java create mode 100644 thain-server/src/main/java/com/xiaomi/thain/server/service/impl/UserServiceImpl.java create mode 100644 thain-server/src/main/java/com/xiaomi/thain/server/service/impl/X5ServiceImpl.java create mode 100644 thain-server/src/main/resources/application.properties create mode 100644 thain-server/src/main/resources/com.xiaomi.thain.server.mapper/Dashboard.xml create mode 100644 thain-server/src/main/resources/com.xiaomi.thain.server.mapper/FlowExecutionMapper.xml create mode 100644 thain-server/src/main/resources/com.xiaomi.thain.server.mapper/FlowMapper.xml create mode 100644 thain-server/src/main/resources/com.xiaomi.thain.server.mapper/User.xml create mode 100755 thain-server/src/main/resources/log4j2.xml create mode 100644 thain-server/src/main/resources/quartz.properties create mode 100644 thain-server/src/test/java/com/xiaomi/thain/server/ApplicationTests.java diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..116ac5b3 --- /dev/null +++ b/.gitignore @@ -0,0 +1,81 @@ +# Copyright (c) 2019, Xiaomi, Inc. All rights reserved. +# This source code is licensed under the Apache License Version 2.0, which +# can be found in the LICENSE file in the root directory of this source tree. +# +### Maven template +target/ +logs/ +pom.xml.tag +pom.xml.releaseBackup +pom.xml.versionsBackup +pom.xml.next +release.properties +dependency-reduced-pom.xml +buildNumber.properties +.mvn/timing.properties + +# Avoid ignoring Maven wrapper jar file (.jar files are usually ignored) +!/.mvn/wrapper/maven-wrapper.jar +### Example user template template +### Example user template + +# IntelliJ project files +.idea +*.iml +out +gen### Java template +# Compiled class file +*.class + +# Log file +*.log + +# BlueJ files +*.ctxt + +# Mobile Tools for Java (J2ME) +.mtj.tmp/ + +# Package Files # +*.jar +*.war +*.ear +*.zip +*.tar.gz +*.rar + +# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml +hs_err_pid* +### macOS template +*.DS_Store +.AppleDouble +.LSOverride + +# Icon must end with two \r +Icon + + +# Thumbnails +._* + +# Files that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns +.com.apple.timemachine.donotpresent + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk + +**/node_modules/ +**/node/ +**/package-lock.json +**/junit-report +/shell/job_execution* \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100644 index 00000000..7a4a3ea2 --- /dev/null +++ b/LICENSE @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. \ No newline at end of file diff --git a/VERSION b/VERSION new file mode 100644 index 00000000..afaf360d --- /dev/null +++ b/VERSION @@ -0,0 +1 @@ +1.0.0 \ No newline at end of file diff --git "a/docs/en/1.\351\203\250\347\275\262\345\220\257\345\212\250/1.\351\203\250\347\275\262\346\265\201\347\250\213.md" "b/docs/en/1.\351\203\250\347\275\262\345\220\257\345\212\250/1.\351\203\250\347\275\262\346\265\201\347\250\213.md" new file mode 100644 index 00000000..1b1cc5d5 --- /dev/null +++ "b/docs/en/1.\351\203\250\347\275\262\345\220\257\345\212\250/1.\351\203\250\347\275\262\346\265\201\347\250\213.md" @@ -0,0 +1,30 @@ + +# Deployment process + +1. Download the full code + +1. The operating environment requires jdk 8 or above, maven3 + + 1. Configuration database + + 1. Execute in order under the project root directory + + ```shell + cd thain-fe + npm install + npm run build + cd .. + mvn -U clean package + ``` + + 1. Once the package is complete, you can run it. + + ```shell + java -jar thain-server/target/thain-server-1.0.0.jar + ``` + + 1. Open localhost:9900 to see the effect diff --git "a/docs/en/1.\351\203\250\347\275\262\345\220\257\345\212\250/2.\346\225\260\346\215\256\345\272\223\351\205\215\347\275\256.md" "b/docs/en/1.\351\203\250\347\275\262\345\220\257\345\212\250/2.\346\225\260\346\215\256\345\272\223\351\205\215\347\275\256.md" new file mode 100644 index 00000000..b4a87dc9 --- /dev/null +++ "b/docs/en/1.\351\203\250\347\275\262\345\220\257\345\212\250/2.\346\225\260\346\215\256\345\272\223\351\205\215\347\275\256.md" @@ -0,0 +1,18 @@ + +# Database configuration + +modify ```thain-server/src/main/resources/application.properties``` + +The following three items are set for the database. + +```properties +spring.datasource.url= +spring.datasource.username= +spring.datasource.password= +``` + +Execute sql build table ```/sql``` \ No newline at end of file diff --git "a/docs/en/1.\351\203\250\347\275\262\345\220\257\345\212\250/3.\347\224\250\346\210\267\347\256\241\347\220\206.md" "b/docs/en/1.\351\203\250\347\275\262\345\220\257\345\212\250/3.\347\224\250\346\210\267\347\256\241\347\220\206.md" new file mode 100644 index 00000000..aa3f3991 --- /dev/null +++ "b/docs/en/1.\351\203\250\347\275\262\345\220\257\345\212\250/3.\347\224\250\346\210\267\347\256\241\347\220\206.md" @@ -0,0 +1,140 @@ + +# User Management + +## DB user management + +1. Configure the database connection and set the authentication method to DB + + After properly configuring the database connection through [Database Configuration](./2.数据库配置.md) + + modify thain-web/src/main/resources/application.properties + + ```properties + #User authentication via database + thain.login.source=DBAuthentication + ``` + +1. Add user + + The current version does not provide background management yet. Adding users can use this method.`com.xiaomi.thain.server.dao.UserDao.insertUser(ThainUser user)` + +## Ldap User Management + +1. Configuring Ldap and starting the service[Reference openLdap](http://www.openldap.org/doc) + + The LDIF is defined as follows (the basic user admin: admin is defined) + + ```ldif + dn: {your base DN} + objectClass: dcObject + objectClass: organization + objectClass: top + dc: {your DC} + o: {your organization} + + dn: ou=people,{your base DN} + objectClass: organizationalUnit + objectClass: top + ou: people + + dn: uid=admin,ou=people,{your base DN} + objectClass: inetOrgPerson + objectClass: organizationalPerson + objectClass: person + objectClass: top + cn: admin + sn: admin + uid: admin + userPassword:: e0NSWVBUfVo2VGdhNGVkQkFjekU= + ``` + +1. Configure the Ldap connection and set the authentication method to Ldap + + thain-server/src/main/resources/application.properties中添加 + + ```properties + spring.ldap.urls=ldap:{ldap-url} + spring.ldap.username={ldap-username} + spring.ldap.password={ldap-password} + spring.ldap.base={ldap-baseDn} + ``` + And modify + ```properties + #User authentication via Ldap + thain.login.source=LdapAuthentication + ``` + +1. Add user + + Adding users can use this method`com.xiaomi.thain.server.dao.LdapUserDao.save(LdapUser user)` + +## Third party authorized login + +1. Apply the client-id and client-secret of the third-party application that needs to log in and add two basic configurations: + + spring.security.oauth2.client.registration.{clientName}.client-id=${clientId} + spring.security.oauth2.client.registration.{clientName}.client-secret=${clientSecret} + + More specific configuration can refer to the spring-security document + +1. To manually register ClientRegistration, you can configure it as follows + + ```java + @Configuration + public class OAuth2LoginConfig { + //添加客户端并注册bean + @Bean + public ClientRegistrationRepository clientRegistrationRepository() { + return new InMemoryClientRegistrationRepository(this.googleClientRegistration()); + } + + //添加google客户端的配置 + private ClientRegistration googleClientRegistration() { + return ClientRegistration.withRegistrationId("google") + .clientId("google-client-id") + .clientSecret("google-client-secret") + //... + .clientName("Google") + .build(); + } + } + ``` + + And modify + + ```java + @EnableWebSecurity + @Slf4j + public class WebSecurityConfig extends WebSecurityConfigurerAdapter { + + @Autowired + private final ClientRegistrationRepository clientRegistrationRepository; + + //... + /** + * Third-party login configuration + * + * @param http HttpSecurity + */ + private void thirdConfig(HttpSecurity http) throws Exception { + http.oauth2Login() + .clientRegistrationRepository(clientRegistrationRepository); + //... + } + } + ``` + +1. Modify the login page of the front-end project thain-fe, add the corresponding third-party login link, and the system provides google third-party login by default. + + ```html + + ``` +1. If you do not need a third-party login, delete the configuration + +## More + +Project user permission verification uses spring security framework, more content reference [spring-security](https://docs.spring.io/spring-security/site/docs/5.2.0.BUILD-SNAPSHOT/reference/htmlsingle) diff --git "a/docs/en/2.\344\275\277\347\224\250\346\225\231\347\250\213/\345\210\233\345\273\272\344\273\273\345\212\241.md" "b/docs/en/2.\344\275\277\347\224\250\346\225\231\347\250\213/\345\210\233\345\273\272\344\273\273\345\212\241.md" new file mode 100644 index 00000000..3aeb5eb7 --- /dev/null +++ "b/docs/en/2.\344\275\277\347\224\250\346\225\231\347\250\213/\345\210\233\345\273\272\344\273\273\345\212\241.md" @@ -0,0 +1,50 @@ + +# Create a task + +A Thain Flow is composed of multiple jobs. + +There are two ways to create a task, one is through page creation, and the other is created through the http interface. + +## Page creation + +Open the editing page of Thain. + +## httpinterface creation + +Reference java sdk + +## flowParameter description + +### Required parameters + +1. id: If you modify the required id of the task, you do not need to fill in the new task. +1. name: flow name +1. createUser: the user who created the task, if it is the page creation will get the current login user + +### Optional parameters + +1. cron: trigger flow according to cron timing, do not fill will not automatically trigger +1. modifyCallbackUrl: Pause scheduling and continue scheduling will call back this address, post form, pause {"status":1}, continue {"status":2} +1. pauseContinuousFailure: fill in the number, after pauseuseContinuousFailure times, pause the schedule +1. emailContinuousFailure: mailbox, after the pauseContinuousFailure time, send a notification email +1. callbackUrl: The task status changes the url of the callback, the post form starts executing `{"code":1}`, the execution fails `{"code":3, "message": the reason for the failure}`, the run succeeds `{"code ": 2}` +1. "sla related": + - slaKill: You can only fill in the truth temporarily. + - slaDuration: flow runs for the longest number of seconds, the timeout will be killed + - slaEmail: Mailbox for task timeout notification + +## job parameter description + +### Required parameters + +- name: job name, job name in a flow cannot be repeated +- component: component name + +### Optional parameters +- condition: If this job depends on other jobs, you need to fill in the job name here, multiple separated by && +- properties: component parameters, what needs to be filled out refer to specific components +- callbackUrl: The job status changes the url of the callback, the post form starts executing `{"code":1}`, the execution fails `{"code":3, "message": the reason for the failure}`, the run succeeds `{"code" : 2}` \ No newline at end of file diff --git "a/docs/en/3.\347\273\204\344\273\266\350\257\264\346\230\216/1.\345\267\262\346\234\211\347\273\204\344\273\266.md" "b/docs/en/3.\347\273\204\344\273\266\350\257\264\346\230\216/1.\345\267\262\346\234\211\347\273\204\344\273\266.md" new file mode 100644 index 00000000..85c8dc16 --- /dev/null +++ "b/docs/en/3.\347\273\204\344\273\266\350\257\264\346\230\216/1.\345\267\262\346\234\211\347\273\204\344\273\266.md" @@ -0,0 +1,13 @@ + +# Existing components + + +|Component Name|Required Parameters|Optional Parameters|Production Results|Others| +|:------|:------|:-----|:------|:--| +Std::http|1. url: url 2. method: GET or POST|1. contentType: Content-Type
2. referenceData: Process data reference, separated by commas, such as: ` aName: a.name, bAge:b.age`, in front of the colon is the key sent by http, followed by value
3. forwardData: forward data, this will be sent to the url intact, key is forwardData |result : The result of the http request || +Std::mail|1. title: mail header
2. contentHtml: mail content
3. recipient: recipient (multiple separated by commas) | | | can be in the message header and content Use ${} to quote the results of other jobs, such as: `${a.name}`| +Std::shell|1. shellBase64: shell script file base64|1.environmentVariable: shell variable (xxx=yyy form, multiple separated by newline)| |Recommended to use this component when creating the page, if it is a third-party system recommendation Implemented in http with your own system| \ No newline at end of file diff --git "a/docs/en/3.\347\273\204\344\273\266\350\257\264\346\230\216/2.\350\207\252\345\256\232\344\271\211\347\273\204\344\273\266.md" "b/docs/en/3.\347\273\204\344\273\266\350\257\264\346\230\216/2.\350\207\252\345\256\232\344\271\211\347\273\204\344\273\266.md" new file mode 100644 index 00000000..98da5e8d --- /dev/null +++ "b/docs/en/3.\347\273\204\344\273\266\350\257\264\346\230\216/2.\350\207\252\345\256\232\344\271\211\347\273\204\344\273\266.md" @@ -0,0 +1,70 @@ + +# Custom component + +1. Can refer to + - com.xiaomi.thain.component.std.MailComponent + - com.xiaomi.thain.component.std.HttpComponent + + +1. Use annotations: com.xiaomi.thain.component.annotation.ThainComponent + + - group: The group to which the component belongs, such as std, xdata, etc., used to distinguish components + - name: the component name, such as: http + - defineJson + - component-defined json + - This json is used for field validation, front-end component display, etc. + +1. json definition + - Format: + + ```ts + /** + * https://app.quicktype.io/#l=schema This site generates json + * + * Component front-end schema + * + */ + Export type ComponentDefineJson = Array<{ + /** + * Key passed to the backend + */ + Property: string; + /** + * Required or not, false or not written is not required + */ + Required?: boolean; + /** + * Enter the identifier in front of the box, do not write the default property + */ + Label?: string; + Input: + | { + Id: 'line' | 'textarea' | 'sql' | 'shell' | 'richText'; + } + | { + Id: 'select'; + Options: Array<{ + /** + * the value of the attribute + */ + Id: string; + /** + * The candidate in the drop-down box is not written with id instead + */ + Name?: string; + }>; + }; + }>; + ``` + +1. java class design + - Define the property in json in the java class, and the runtime will automatically inject according to the information filled in by the user. + - You can define a property of type com.xiaomi.thain.component.tools.ComponentTools + - ComponentTools has many features in this interface + +1. ComponentTools interface + - com.xiaomi.thain.component.tools.ComponentTools See comments \ No newline at end of file diff --git a/docs/images/logo.png b/docs/images/logo.png new file mode 100755 index 0000000000000000000000000000000000000000..2b70d51f3ce57b787d704768559e34ba82e70aa0 GIT binary patch literal 4181 zcmaJ^cQ{*p|F%bhE;VX}qDG7mD^{gSQnRQ=wIz)pB7-D^+OtC|My=9es}$Wv?YBlz zYCct?RtJhFs*2(l&-?Uwe}BAv&vnlEuKT_}^E%gct~%OV3j>Y-I5;?jkqApC_UO0w z2=KArF7p4%WDkSv@;#JMsyvFAfnJ zh;F-Ber=4K!hI*ctqz*5m5I>DbvfzeGB{?di9=X={)3ZTCrRJ^Ieznwza zIf71*0@g$jX(^L;4-7Qapf6mCIOWa`b^YWTwplYQMtC{DW{iwmGuENtx4F)5+a->b~ zj}f`Xl;tpg*zBL)lecx(XAC}#QQp)qi=hw5Omm#)0+J6WHDCYs=}GmWof_0=!ga1b zC^Mc@nv;{%5x!;!j_;|K*$I_(8DM;G(f4}=oh6w~WKU%$)6Z2FqC`I|J zjk|)V_;=5n4Rr_1g&lJF&onB3&3}_DFKA`M@U#d>j5rWSh(HO#!BcNKS4)gi{UiQCdy^RToqU%vKHVW7LP>hk!Pds#1!XCu3BH}^@6 z4cMa|@+g^|U^t?e3_td^Dc-#J{u1hsP`l|+I($GuYU83Y8m+E}^fl2-`&6Qv7`E|8 zv+n`0|6xVnrm-?}{9&-alA^rK;!v}HLz)o_J{=}H=gtju=SFJBoONTJ@p(Pg@q$ZC zUj(V$bK!}#w2z)ZImGc&a6VF6w~#d(g=-t@FaQ9hVxjZnWiT6wZl`S)g>0c)RRyt| zUwSJ5X3F&Yij6`07Va#0&wcVl*0WC##W$Zo9C|uN06=`=)9Rb_V*1@k6iP~w^CgZS zEkJyKOs?JS4myNa$*ibjyz`~j&EVmSAL>WZlJkM;yU(-t_1!J3fKHqqt?`B-Pn zn((}DfPk%^)$RuR!79dC0er0x@V8>*<8-^Bc$M*#V396Kl}D}G;ly)zpZP0GoyPHV zJn4T3x|ikiKf}-4PNcmV%bGp#ra!pEH;f*=1LNh4&lgbt5_Y)Wbs$(gRKr6<&S7El zf=q^#W8IX_=hl5+zNO~ac1K+_Ph3g#v-uD(28?u^AUZq+OcSWJW}$*~=N{#LL2z)f z);^oe2UA&+jE|$6-*&A#3d3aATUV9Z-x{Q~eJvSSKbPszuyYGtLsN#MfP&zmn1f3# z>G?k~-$ri?toR(Gjf;%*zvm3S&!6RHifUMTSz(Pdh!kG$ z`yx{$Eg+?9I0y#wcR4hb$6#~9HTW2jB_sSR96tx~5Aeoe=@SiBbIDIAkuNumW8*V~ zbFT3%hm&K3Z4lj{D%%dB`pTn-C$!nfQo?fKi;~i@A|@?L9}m1f(k3YcMEN^TS5R-X zf}3+ZTXP(sT}xT_M|dWc(C9~xR|VqZAtTKh2s&QhJ7;! z!1vb}a7ufE;`3(X&l*YT%B7UcPOGtRhj}N9)_eQIcRK>LBX}F{4ZKh>em6UneST{( zB)3_+2`;8M6m=~lNAIq$m|C~Yp@XxkOGR?VZ;Mui_Me)_{`pO*vKa1!;=sf0xjfq944;1R?KDqCGLst(kg%h*P z(evRg+t=&Z>S`Rw68TVH)#})L$YrAZ{>0InPa3j@!0B)u;UqsTZ?O!wru^tT!nkPA zt8DVttw$`pSchb7jBQTyAgu!k5^tXLo>V#0NI62@{@ylX zLe{Jw@2IPQPp^HImnd1#WVtpV&6tx1tCf1zPM4Ti%h|u>h3DMniaqCJnwzbHT=4AI zig~6O{Ypa)deQam_sH9_gCSU6d&>cp()7x64fe7MlT*c0LcvEqOlN+usP(krxsKto zfShR_EbObBp~tF%J8rm1lK@ZOEt=JTKXT2Za_z%|^vblvQliwA&KHI6D39YkZnaF0 z=RQQH0A(4#iBC04lBgK8Rh)cBQgZCzM59Do$=c}mv+5q2a+Mdx5DeJ?dx~XMC=c)u zs%6D1JzlgOiEqJep2|^rx}h_~u?>CM!Z6xZWGcPu%KG|3-9yPdjw&auXHO|yuaPmc zm)VShI3I?Ibb&#_sbIRkxET9$+|^y1teN%5V`bMkbbn>R8^Z#PPlw1!ORGyxH74WF zDSjJdzR*~qgIUD17CyBxwndI%h<1;J;;pwvJ$ZfVAoXW(L!=rx8x7WyoL)Q z4llNNMLsX@n`vImN;eN}do;EGhFeS<^R4^YXhq=WoAD81_mPn#w-8Eul&Fjk8pe$b z>WzYYT$$z9w#xB}`d5ExlD7raTjoU!G&lR%I})jySjF_l_BaaQWcX97h4mSW2KaYc z+B;wR_?+Sjm|6XPn^XEf5Lv?Qtrq;A%vZS02<3Yp=}bO+VRsu|+tCZT6602^9KwAj%7xZwf^anm zKwCg*k!^s3ij1Gj;wV5W#Zgr;B?%dW6SFN3grj0S$9tn_#xE0+MjDwQP77A!q{m`R zX4I^x3oKmZ&G7i)9?&7N@`i#Om&BTKj!sFHfQ624HND%cP@*Rmv@yA?71XSL{L-t_ z-F0z|u@{QENnav{nmUt(=VHBR177h%b|(+9Idnc>~`v zw*!i&%Y$E}%>O98tz1V{R!$oODX*{9cwFoiapg z^{yu=a!tHFa6euZC9sb{C3VCwE4<1L@sRUYOR8PUk8v%BV{(^+HKGR993@c?#_rwS zW(_v`+kl>lxNwRYY-4mNL9B^&=nW6=}R~ z*Q5jGpB-`G%$O_~Vw~Hj#%&`Zoy6LjdzBWk@0qyMvExNmTvsKT4IUR4^vay?0jkD$ zUIu7yIc~|*04@ML19>e2ek6RL^mKAW%nEwO2<8HnH literal 0 HcmV?d00001 diff --git "a/docs/zh/1.\351\203\250\347\275\262\345\220\257\345\212\250/1.\351\203\250\347\275\262\346\265\201\347\250\213.md" "b/docs/zh/1.\351\203\250\347\275\262\345\220\257\345\212\250/1.\351\203\250\347\275\262\346\265\201\347\250\213.md" new file mode 100644 index 00000000..d565369b --- /dev/null +++ "b/docs/zh/1.\351\203\250\347\275\262\345\220\257\345\212\250/1.\351\203\250\347\275\262\346\265\201\347\250\213.md" @@ -0,0 +1,30 @@ + +# 部署流程 + +1. 下载完整代码 + +1. 运行环境需要jdk 8 以上, maven3 + + 1. 配置数据库 + + 1. 在项目根目录下依次执行 + + ```shell + cd thain-fe + npm install + npm run build + cd .. + mvn -U clean package + ``` + + 1. 打包完成后,即可运行 + + ```shell + java -jar thain-server/target/thain-server-1.0.0.jar + ``` + + 1. 打开 localhost:9900 就可以看到效果了 diff --git "a/docs/zh/1.\351\203\250\347\275\262\345\220\257\345\212\250/2.\346\225\260\346\215\256\345\272\223\351\205\215\347\275\256.md" "b/docs/zh/1.\351\203\250\347\275\262\345\220\257\345\212\250/2.\346\225\260\346\215\256\345\272\223\351\205\215\347\275\256.md" new file mode 100644 index 00000000..da448910 --- /dev/null +++ "b/docs/zh/1.\351\203\250\347\275\262\345\220\257\345\212\250/2.\346\225\260\346\215\256\345\272\223\351\205\215\347\275\256.md" @@ -0,0 +1,21 @@ + +# 数据库配置 + +修改 thain-server/src/main/resources/application.properties + +下面三项为数据库设置 + +```properties +spring.datasource.url= +spring.datasource.username= +spring.datasource.password= +``` + +数据库初始化 (1 建表并初始化数据, 2 初始化数据, 其他 不做初始化) +datasource.initialization.level=1 + +建表sql ```/thain-core/src/main/resources/sql``` \ No newline at end of file diff --git "a/docs/zh/1.\351\203\250\347\275\262\345\220\257\345\212\250/3.\347\224\250\346\210\267\347\256\241\347\220\206.md" "b/docs/zh/1.\351\203\250\347\275\262\345\220\257\345\212\250/3.\347\224\250\346\210\267\347\256\241\347\220\206.md" new file mode 100644 index 00000000..635d540b --- /dev/null +++ "b/docs/zh/1.\351\203\250\347\275\262\345\220\257\345\212\250/3.\347\224\250\346\210\267\347\256\241\347\220\206.md" @@ -0,0 +1,142 @@ + +# 用户管理 + +## DB用户管理 + +1. 创建数据库(推荐Mysql) + +1. 配置数据库连接并设置验证方式为DB + + 通过[数据库配置](./2.数据库配置.md)正确配置数据库连接之后 + + 修改 thain-web/src/main/resources/application.properties中 + + ```properties + #通过数据库进行用户验证 + thain.login.source=DBAuthentication + ``` + +1. 添加用户 + + 当前版本暂未提供后台管理,添加用户可以通过此方法`com.xiaomi.thain.server.dao.UserDao.insertUser(ThainUser user)` + +## Ldap用户管理 + +1. 配置Ldap并启动服务[参考openLdap](http://www.openldap.org/doc) + + LDIF定义如下(定义了基本的用户admin:admin) + + ```ldif + dn: {your base DN} + objectClass: dcObject + objectClass: organization + objectClass: top + dc: {your DC} + o: {your organization} + + dn: ou=people,{your base DN} + objectClass: organizationalUnit + objectClass: top + ou: people + + dn: uid=admin,ou=people,{your base DN} + objectClass: inetOrgPerson + objectClass: organizationalPerson + objectClass: person + objectClass: top + cn: admin + sn: admin + uid: admin + userPassword:: e0NSWVBUfVo2VGdhNGVkQkFjekU= + ``` + +1. 配置Ldap连接并设置验证方式为Ldap + + thain-server/src/main/resources/application.properties中添加 + + ```properties + spring.ldap.urls=ldap:{ldap-url} + spring.ldap.username={ldap-username} + spring.ldap.password={ldap-password} + spring.ldap.base={ldap-baseDn} + ``` + 并修改 + ```properties + #通过Ldap进行用户验证 + thain.login.source=LdapAuthentication + ``` + +1. 添加用户 + + 添加用户可以通过此方法`com.xiaomi.thain.server.dao.LdapUserDao.save(LdapUser user)` + +## 第三方授权登录 + +1. 申请需要登录的第三方应用的client-id和client-secret并添加两条基本配置: + + spring.security.oauth2.client.registration.{clientName}.client-id=${clientId} + spring.security.oauth2.client.registration.{clientName}.client-secret=${clientSecret} + + 更具体配置可以参考spring-security文档 + +1. 如需手动注册ClientRegistration,可以按照如下配置 + + ```java + @Configuration + public class OAuth2LoginConfig { + //添加客户端并注册bean + @Bean + public ClientRegistrationRepository clientRegistrationRepository() { + return new InMemoryClientRegistrationRepository(this.googleClientRegistration()); + } + + //添加google客户端的配置 + private ClientRegistration googleClientRegistration() { + return ClientRegistration.withRegistrationId("google") + .clientId("google-client-id") + .clientSecret("google-client-secret") + //... + .clientName("Google") + .build(); + } + } + ``` + + 并修改 + + ```java + @EnableWebSecurity + @Slf4j + public class WebSecurityConfig extends WebSecurityConfigurerAdapter { + + @Autowired + private final ClientRegistrationRepository clientRegistrationRepository; + + //... + /** + * 第三方登录配置 + * + * @param http HttpSecurity + */ + private void thirdConfig(HttpSecurity http) throws Exception { + http.oauth2Login() + .clientRegistrationRepository(clientRegistrationRepository); + //... + } + } + ``` + +1. 修改前端项目thain-fe的登录页面,添加相应第三方登录链接,系统默认提供了google的第三方登录 + + ```html + + ``` +1. 如果不需要第三方登录,则删除配置 + +## 更多 + +项目用户权限验证采用spring security框架,更多内容参考[spring-security](https://docs.spring.io/spring-security/site/docs/5.2.0.BUILD-SNAPSHOT/reference/htmlsingle) diff --git "a/docs/zh/2.\344\275\277\347\224\250\346\225\231\347\250\213/\345\210\233\345\273\272\344\273\273\345\212\241.md" "b/docs/zh/2.\344\275\277\347\224\250\346\225\231\347\250\213/\345\210\233\345\273\272\344\273\273\345\212\241.md" new file mode 100644 index 00000000..e8956e4a --- /dev/null +++ "b/docs/zh/2.\344\275\277\347\224\250\346\225\231\347\250\213/\345\210\233\345\273\272\344\273\273\345\212\241.md" @@ -0,0 +1,51 @@ + +# 创建任务 + +一个Thain Flow 是由多个Job组成的. + +创建任务有两种方法, 一种是通过页面创建, 另一种是通过http接口创建. + +## 页面创建 + +打开Thain的编辑页面, 多拽即可 + +## http接口创建 + +参考java sdk + +## flow参数说明 + +### 必填参数 + +1. id: 如果修改任务必填id, 创建新任务不需要填写 +1. name: flow名称 +1. createUser: 创建任务的用户, 如果是页面创建会获取当前登录用户 + +### 选填参数 + +1. cron: 根据cron定时触发flow, 不填写不会自动触发 +1. modifyCallbackUrl: 暂停调度 和 继续调度 会回调这个地址, post form, 暂停{"status":1}, 继续{"status":2} +1. pauseContinuousFailure: 填数字, 失败pauseContinuousFailure次后, 暂停调度 +1. emailContinuousFailure: 邮箱, 失败pauseContinuousFailure次后 发送通知邮件 +1. callbackUrl: 任务状态改变回调的url, post form 开始执行 `{"code":1}`, 执行失败 `{"code":3, "message":失败原因}`, 运行成功`{"code": 2}` +1. "sla相关": + - slaKill: 暂时只能填true + - slaDuration: flow运行最长秒数, 超时将会被kill + - slaEmail: 任务超时通知的邮箱 + +## job参数说明 + +### 必填参数 + +- name: job名称, 一个flow中job name 不能重复 +- component: 组件名称 + +### 选填参数 + +- condition: 如果这个job依赖于其他job, 需要在这填写job name, 多个用&&分隔 +- properties: 组件参数, 需要填写的内容参考具体的组件 +- callbackUrl: Job状态改变回调的url, post form 开始执行 `{"code":1}`, 执行失败 `{"code":3, "message":失败原因}`, 运行成功`{"code": 2}` diff --git "a/docs/zh/3.\347\273\204\344\273\266\350\257\264\346\230\216/1.\345\267\262\346\234\211\347\273\204\344\273\266.md" "b/docs/zh/3.\347\273\204\344\273\266\350\257\264\346\230\216/1.\345\267\262\346\234\211\347\273\204\344\273\266.md" new file mode 100644 index 00000000..6b2d7d8e --- /dev/null +++ "b/docs/zh/3.\347\273\204\344\273\266\350\257\264\346\230\216/1.\345\267\262\346\234\211\347\273\204\344\273\266.md" @@ -0,0 +1,13 @@ + +# 已有组件 + + +|组件名称|必填参数|选填参数|产生结果|其他| +|:------|:------|:-----|:------|:--| +std::http|1. url: url
2. method: GET 或 POST|1. contentType: Content-Type
2. referenceData: 流程数据引用, 多个用逗号分开, 如: `aName:a.name,bAge:b.age`, 冒号前面的是http发过去的key, 后面是value
3. forwardData: 转发数据, 这个会原封不动的发给url, key是forwardData|result : http请求的返回结果|| +std::mail|1. title: 邮件标题
2. contentHtml:邮件内容
3. recipient:收件人(多个用逗号隔开)| | |可以在邮件标题和内容中用${}引用别的job产生的结果, 如: `${a.name}`| +std::shell|1. shellBase64: shell 脚本文件 base64|1.environmentVariable: shell 变量(xxx=yyy 形式,多个用换行隔开)| |推荐在页面创建时候使用该组件, 如果是第三方系统建议用http在自己的系统实现| diff --git "a/docs/zh/3.\347\273\204\344\273\266\350\257\264\346\230\216/2.\350\207\252\345\256\232\344\271\211\347\273\204\344\273\266.md" "b/docs/zh/3.\347\273\204\344\273\266\350\257\264\346\230\216/2.\350\207\252\345\256\232\344\271\211\347\273\204\344\273\266.md" new file mode 100644 index 00000000..72449a88 --- /dev/null +++ "b/docs/zh/3.\347\273\204\344\273\266\350\257\264\346\230\216/2.\350\207\252\345\256\232\344\271\211\347\273\204\344\273\266.md" @@ -0,0 +1,68 @@ + +# 自定义组件 + +1. 可以参考 + - com.xiaomi.thain.component.std.MailComponent + - com.xiaomi.thain.component.std.HttpComponent + + +1. 使用注解: com.xiaomi.thain.component.annotation.ThainComponent + - group: 组件所属的组,如:std, xdata等,用于区分组件 + - name: 组件名称, 如:http + - defineJson + - 组件定义的json + - 这个json用来字段校验,前端组件展示等 + +1. json 定义 + - 格式: + ```ts + /** + * https://app.quicktype.io/#l=schema 这个网站生成json + * + * 组件前端 schema + * + */ + export type ComponentDefineJson = Array<{ + /** + * 传到后端的key + */ + property: string; + /** + * 是否必填,false 或不写 则为不是必填 + */ + required?: boolean; + /** + * 输入框前面的标识,不写默认用property + */ + label?: string; + input: + | { + id: 'line' | 'textarea' | 'sql' | 'shell' | 'richText'; + } + | { + id: 'select'; + options: Array<{ + /** + * 属性的值 + */ + id: string; + /** + * 下拉框中的候选项,不写用id代替 + */ + name?: string; + }>; + }; + }>; + ``` + +1. java Class 设计 + - 把json中的property 定义在java class 中, 运行时会根据用户填写的信息自动注入 + - 可以定义一个 com.xiaomi.thain.component.tools.ComponentTools 类型的属性 + - ComponentTools 这个接口中有很多的功能 + +1. ComponentTools 接口 + - com.xiaomi.thain.component.tools.ComponentTools 见注释 diff --git a/pom.xml b/pom.xml new file mode 100644 index 00000000..26200323 --- /dev/null +++ b/pom.xml @@ -0,0 +1,24 @@ + + + + + 4.0.0 + com.xiaomi.thain + thain + pom + 1.0.0 + thain + + + thain-common + thain-component + thain-core + thain-server + thain-sdk + + diff --git a/readme.md b/readme.md new file mode 100644 index 00000000..0d05fbb4 --- /dev/null +++ b/readme.md @@ -0,0 +1,46 @@ + +# Thain + +![Thain Logo](./docs/images/logo.png) + +## Other language versions + +[简体中文](./readme_zh.md) + +## Introduction + +Thain is a distributed flow schedule platform, it was invented at XiaoMi Technology and the project has been proven easily-learning, developed-rapidly, stable in the XiaoMi internal departments. +Thain has completed backend management system which supports depending, re-run, roll-back and monitoring of the flows. + +## Documentation Contents + +1. Product Introduction +1. Deployment + - [deployment process](./docs/en/1.部署启动/1.部署流程.md) + - [database configuration](./docs/en/1.部署启动/2.数据库配置.md) + - [user management](./docs/en/1.部署启动/3.用户管理.md) +1. Use Tutorial + - [Create Flow](./docs/en/2.使用教程/创建任务.md) +1. Component + - [Existing component](./docs/en/3.组件说明/1.已有组件.md) + - [Custom component](./docs/en/3.组件说明/2.自定义组件.md) + +## Maintainers + +@liangyongrui + +## Help Us Do Better + +Now Thain continues to be developed by xiaomi internal developers. If you have any questions, you can ask in the issues or send email to: + +- zuojianguang@xiaomi.com +- liangyongrui@xiaomi.com +- miaoyu3@xiaomi.com + +## License + +[Apache License Version 2.0](LICENSE) © Xiaomi \ No newline at end of file diff --git a/readme_zh.md b/readme_zh.md new file mode 100644 index 00000000..69c203ac --- /dev/null +++ b/readme_zh.md @@ -0,0 +1,47 @@ + +# Thain + +![Thain Logo](./docs/images/logo.png) + +## Other language versions + +[English](./readme.md) + +## 产品简介 + +Thain是小米自研的新一代分布式任务调度平台,提供定时、任务编排、分布式跑等功能。 +Thain提供了任务调度与执行的一整套解决方案,在小米集团内部使用并久经考验,具有易学习、易上手、开发高效稳定的特点。 +有完善的后台管理界面,支持任务的依赖,重跑,回溯,任务执行情况查看。 + +## 文档目录 + +1. 产品简介 +1. 部署启动 + - [部署流程](./docs/zh/1.部署启动/1.部署流程.md) + - [数据库配置](./docs/zh/1.部署启动/2.数据库配置.md) + - [用户管理](./docs/zh/1.部署启动/3.用户管理.md) +1. 使用教程 + - [创建任务](./docs/zh/2.使用教程/创建任务.md) +1. 组件说明 + - [已有组件](./docs/zh/3.组件说明/1.已有组件.md) + - [自定义组件](./docs/zh/3.组件说明/2.自定义组件.md) + +## Maintainers + +@liangyongrui + +## 帮助我们做的更好 + +有任何疑问都可以在issues中提出,或发送邮件到: + +- zuojianguang@xiaomi.com +- liangyongrui@xiaomi.com +- miaoyu3@xiaomi.com + +## License + +[Apache License Version 2.0](LICENSE) © Xiaomi \ No newline at end of file diff --git a/thain-common/pom.xml b/thain-common/pom.xml new file mode 100644 index 00000000..0508b304 --- /dev/null +++ b/thain-common/pom.xml @@ -0,0 +1,170 @@ + + + + + + thain + com.xiaomi.thain + 1.0.0 + + 4.0.0 + + thain-common + + thain-common + + + UTF-8 + 1.8 + 1.8 + + + + + org.json + json + 20180130 + + + org.everit.json + org.everit.json.schema + 1.5.1 + + + json + org.json + + + guava + com.google.guava + + + commons-collections + commons-collections + + + commons-logging + commons-logging + + + + + org.apache.logging.log4j + log4j-slf4j-impl + 2.10.0 + compile + + + log4j-core + org.apache.logging.log4j + + + + + org.apache.logging.log4j + log4j-core + 2.10.0 + compile + + + org.slf4j + jul-to-slf4j + 1.7.25 + compile + + + slf4j-api + org.slf4j + + + + + com.google.guava + guava + 28.0-jre + + + + + org.projectlombok + lombok + 1.18.8 + + + + org.junit.jupiter + junit-jupiter-api + 5.5.0-RC1 + test + + + org.apache.commons + commons-collections4 + 4.3 + + + org.apache.httpcomponents + httpcore + 4.4.11 + + + org.apache.commons + commons-lang3 + 3.9 + + + org.apache.httpcomponents + httpclient + 4.5.8 + + + httpcore + org.apache.httpcomponents + + + + + com.fasterxml.jackson.core + jackson-annotations + 2.9.5 + + + com.alibaba + fastjson + 1.2.58 + + + com.fasterxml.jackson.core + jackson-core + 2.9.8 + + + com.fasterxml.jackson.core + jackson-databind + 2.9.8 + + + jackson-core + com.fasterxml.jackson.core + + + jackson-annotations + com.fasterxml.jackson.core + + + + + + javax.mail + javax.mail-api + 1.6.2 + + + + + diff --git a/thain-common/src/main/java/com/xiaomi/thain/common/constant/FlowExecutionStatus.java b/thain-common/src/main/java/com/xiaomi/thain/common/constant/FlowExecutionStatus.java new file mode 100644 index 00000000..0ac3260c --- /dev/null +++ b/thain-common/src/main/java/com/xiaomi/thain/common/constant/FlowExecutionStatus.java @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2019, Xiaomi, Inc. All rights reserved. + * This source code is licensed under the Apache License Version 2.0, which + * can be found in the LICENSE file in the root directory of this source tree. + */ + +package com.xiaomi.thain.common.constant; + +/** + * flow的最后一次运行状态 + * + * @author liangyongrui + */ +public enum FlowExecutionStatus { + + /** + * 1 正在运行 + */ + RUNNING(1), + /** + * 2 运行成功 + */ + SUCCESS(2), + /** + * 3 运行异常 + */ + ERROR(3), + + /** + * 4 手动kill + */ + KILLED(4); + + public final int code; + + FlowExecutionStatus(int code) { + this.code = code; + } + + public static FlowExecutionStatus getInstance(int status) { + switch (status) { + case 1: + return RUNNING; + case 2: + return SUCCESS; + case 3: + return ERROR; + case 4: + return KILLED; + default: + } + return RUNNING; + } +} diff --git a/thain-common/src/main/java/com/xiaomi/thain/common/constant/FlowLastRunStatus.java b/thain-common/src/main/java/com/xiaomi/thain/common/constant/FlowLastRunStatus.java new file mode 100644 index 00000000..20deeefd --- /dev/null +++ b/thain-common/src/main/java/com/xiaomi/thain/common/constant/FlowLastRunStatus.java @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2019, Xiaomi, Inc. All rights reserved. + * This source code is licensed under the Apache License Version 2.0, which + * can be found in the LICENSE file in the root directory of this source tree. + */ + +package com.xiaomi.thain.common.constant; + +import lombok.val; + +/** + * flow的最后一次运行状态 + * + * @author liangyongrui + */ +public enum FlowLastRunStatus { + /** + * 1 未运行 + */ + NEVER(1), + /** + * 2 运行成功 + */ + SUCCESS(2), + /** + * 3 运行异常 + */ + ERROR(3), + /** + * 4 正在运行 + */ + RUNNING(4), + /** + * 5 手动杀死 + */ + KILLED(5), + /** + * 6 暂停运行 + */ + PAUSE(6); + + public final int code; + + FlowLastRunStatus(int code) { + this.code = code; + } + + public static FlowLastRunStatus getInstance(int code) { + for (val t : FlowLastRunStatus.values()) { + if (t.code == code) { + return t; + } + } + return SUCCESS; + } +} diff --git a/thain-common/src/main/java/com/xiaomi/thain/common/constant/FlowSchedulingStatus.java b/thain-common/src/main/java/com/xiaomi/thain/common/constant/FlowSchedulingStatus.java new file mode 100644 index 00000000..0b9ffc66 --- /dev/null +++ b/thain-common/src/main/java/com/xiaomi/thain/common/constant/FlowSchedulingStatus.java @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2019, Xiaomi, Inc. All rights reserved. + * This source code is licensed under the Apache License Version 2.0, which + * can be found in the LICENSE file in the root directory of this source tree. + */ +package com.xiaomi.thain.common.constant; + +/** + * flow的调度状态 + * + * @author liangyongrui + */ +public enum FlowSchedulingStatus { + /** + * 1 调度中 + */ + SCHEDULING(1), + /** + * 2 暂停调度 + */ + PAUSE(2), + + /** + * 3 未设置调度(只运行一次的任务) + */ + NOT_SET(3); + + public final int code; + + FlowSchedulingStatus(int code) { + this.code = code; + } + +} diff --git a/thain-common/src/main/java/com/xiaomi/thain/common/constant/HttpCallbackStatus.java b/thain-common/src/main/java/com/xiaomi/thain/common/constant/HttpCallbackStatus.java new file mode 100644 index 00000000..e6a3f558 --- /dev/null +++ b/thain-common/src/main/java/com/xiaomi/thain/common/constant/HttpCallbackStatus.java @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2019, Xiaomi, Inc. All rights reserved. + * This source code is licensed under the Apache License Version 2.0, which + * can be found in the LICENSE file in the root directory of this source tree. + */ +package com.xiaomi.thain.common.constant; + +/** + * Date 19-5-21 上午10:23 + * http 回调状态 + * + * @author liangyongrui@xiaomi.com + */ +public enum HttpCallbackStatus { + /** + * 1 开始运行 + */ + START(1), + /** + * 2 运行成功 + */ + SUCCESS(2), + /** + * 3 运行异常 + */ + ERROR(3), + /** + * 4 手动杀死 + */ + KILLED(4), + /** + * 5 暂停运行 + */ + PAUSE(5); + + public final int code; + + HttpCallbackStatus(int code) { + this.code = code; + } +} diff --git a/thain-common/src/main/java/com/xiaomi/thain/common/constant/JobExecutionStatus.java b/thain-common/src/main/java/com/xiaomi/thain/common/constant/JobExecutionStatus.java new file mode 100644 index 00000000..a28ab239 --- /dev/null +++ b/thain-common/src/main/java/com/xiaomi/thain/common/constant/JobExecutionStatus.java @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2019, Xiaomi, Inc. All rights reserved. + * This source code is licensed under the Apache License Version 2.0, which + * can be found in the LICENSE file in the root directory of this source tree. + */ +package com.xiaomi.thain.common.constant; + +/** + * JobExecution的执行状态 + * + * @author liangyongrui + */ +public enum JobExecutionStatus { + /** + * 1 未运行 + */ + NEVER(1), + /** + * 2 正在运行 + */ + RUNNING(2), + /** + * 3 执行成功 + */ + SUCCESS(3), + /** + * 4 执行异常 + */ + ERROR(4); + + public final int code; + + JobExecutionStatus(int code) { + this.code = code; + } + +} diff --git a/thain-common/src/main/java/com/xiaomi/thain/common/entity/ApiResult.java b/thain-common/src/main/java/com/xiaomi/thain/common/entity/ApiResult.java new file mode 100644 index 00000000..be5d9f18 --- /dev/null +++ b/thain-common/src/main/java/com/xiaomi/thain/common/entity/ApiResult.java @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2019, Xiaomi, Inc. All rights reserved. + * This source code is licensed under the Apache License Version 2.0, which + * can be found in the LICENSE file in the root directory of this source tree. + */ + +package com.xiaomi.thain.common.entity; + +import com.google.common.collect.ImmutableMap; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.NonNull; +import lombok.ToString; + +import javax.annotation.Nullable; +import java.util.List; + +/** + * @author liangyongrui + */ +@Builder +@ToString +@AllArgsConstructor +public class ApiResult { + public final int status; + @NonNull + public final String message; + @Nullable + public final Object data; + + public static ApiResult success() { + return success(""); + } + + public static ApiResult success(@NonNull List data, long count, int page, int pageSize) { + return new ApiResult(200, "success", ImmutableMap.of( + "data", data, + "count", count, + "page", page, + "pageSize", pageSize + )); + } + + public static ApiResult success(@Nullable Object data) { + return new ApiResult(200, "success", data); + } + + public static ApiResult fail(@Nullable String message) { + return new ApiResult(400, message == null ? "unknown error" : message, ""); + } +} + diff --git a/thain-common/src/main/java/com/xiaomi/thain/common/entity/ComponentItemDefine.java b/thain-common/src/main/java/com/xiaomi/thain/common/entity/ComponentItemDefine.java new file mode 100644 index 00000000..5ec582e9 --- /dev/null +++ b/thain-common/src/main/java/com/xiaomi/thain/common/entity/ComponentItemDefine.java @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2019, Xiaomi, Inc. All rights reserved. + * This source code is licensed under the Apache License Version 2.0, which + * can be found in the LICENSE file in the root directory of this source tree. + */ +package com.xiaomi.thain.common.entity; + +import lombok.AllArgsConstructor; +import lombok.NonNull; + +import java.util.List; + +/** + * Date 19-5-27 下午5:28 + * + * @author liangyongrui@xiaomi.com + */ +@AllArgsConstructor +public class ComponentItemDefine { + + @AllArgsConstructor + public static class Option { + @NonNull + public final String id; + @NonNull + public final String name; + } + + @AllArgsConstructor + public static class Input { + @NonNull + public final String id; + @NonNull + public final List