Pārlūkot izejas kodu

[Improvement][Task Plugin] Integrate zeppelin password authentication with DS zeppelin task plugin (#13861)

---------

Co-authored-by: Eric Gao <ericgao.apache@gmail.com>
zzm 1 gadu atpakaļ
vecāks
revīzija
35bb533a50

+ 5 - 1
docs/docs/en/guide/task/zeppelin.md

@@ -22,7 +22,11 @@ it will call `Zeppelin Client API` to trigger zeppelin notebook paragraph. Click
 | Zeppelin Note ID                   | The unique note id for a zeppelin notebook note.                                                                                   |
 | Zeppelin Paragraph ID              | The unique paragraph id for a zeppelin notebook paragraph. If you want to schedule a whole note at a time, leave this field blank. |
 | Zeppelin Production Note Directory | The directory for cloned note in production mode.                                                                                  |
-| Zeppelin Rest Endpoint             | The REST endpoint of your zeppelin server                                                                                          |
+| Zeppelin username                  | the login username of your zeppelin server .                                                                                       |
+|                                    |
+| Zeppelin password                  | the login password of your zeppelin server .                                                                                       |
+|                                    |
+| Zeppelin Rest Endpoint             | The REST endpoint of your zeppelin server .                                                                                        |
 | Zeppelin Parameters                | Parameters in json format used for zeppelin dynamic form.                                                                          |
 
 ## Production (Clone) Mode

+ 2 - 0
docs/docs/zh/guide/task/zeppelin.md

@@ -22,6 +22,8 @@
 | Zeppelin Note ID                   | Zeppelin Note对应的唯一ID                              |
 | Zeppelin Paragraph ID              | Zeppelin Paragraph对应的唯一ID。如果你想一次性调度整个note,这一栏不填即可 |
 | Zeppelin Rest Endpoint             | 您的Zeppelin服务的REST Endpoint                        |
+| Zeppelin username                  | 您的Zeppelin服务的登陆用户名                                |
+| Zeppelin password                  | 您的Zeppelin服务的登陆密码                                 |
 | Zeppelin Production Note Directory | 生产模式下存放克隆note的目录                                  |
 | Zeppelin Parameters                | 用于传入Zeppelin Dynamic Form的参数                      |
 

+ 2 - 0
dolphinscheduler-task-plugin/dolphinscheduler-task-zeppelin/src/main/java/org/apache/dolphinscheduler/plugin/task/zeppelin/ZeppelinParameters.java

@@ -43,6 +43,8 @@ public class ZeppelinParameters extends AbstractParameters {
     private String restEndpoint;
     private String productionNoteDirectory;
     private String parameters;
+    private String username;
+    private String password;
 
     @Override
     public boolean checkParameters() {

+ 12 - 0
dolphinscheduler-task-plugin/dolphinscheduler-task-zeppelin/src/main/java/org/apache/dolphinscheduler/plugin/task/zeppelin/ZeppelinTask.java

@@ -26,6 +26,7 @@ import org.apache.dolphinscheduler.plugin.task.api.TaskException;
 import org.apache.dolphinscheduler.plugin.task.api.TaskExecutionContext;
 import org.apache.dolphinscheduler.plugin.task.api.parameters.AbstractParameters;
 
+import org.apache.commons.lang3.StringUtils;
 import org.apache.zeppelin.client.ClientConfig;
 import org.apache.zeppelin.client.NoteResult;
 import org.apache.zeppelin.client.ParagraphResult;
@@ -79,10 +80,21 @@ public class ZeppelinTask extends AbstractRemoteTask {
         this.zClient = getZeppelinClient();
     }
 
+    public boolean login() throws Exception {
+        String username = this.zeppelinParameters.getUsername();
+        String password = this.zeppelinParameters.getPassword();
+        if (StringUtils.isNotBlank(username) && StringUtils.isNotBlank(password)) {
+            this.zClient.login(username, password);
+            log.info("username : {}  login  success ", username);
+        }
+        return true;
+    }
+
     // todo split handle to submit and track
     @Override
     public void handle(TaskCallBack taskCallBack) throws TaskException {
         try {
+            login();
             final String paragraphId = this.zeppelinParameters.getParagraphId();
             final String productionNoteDirectory = this.zeppelinParameters.getProductionNoteDirectory();
             final String parameters = this.zeppelinParameters.getParameters();

+ 4 - 0
dolphinscheduler-ui/src/locales/en_US/project.ts

@@ -680,6 +680,10 @@ export default {
       'Directory for cloned zeppelin note in production mode',
     zeppelin_production_note_directory_tips:
       'Please enter the production note directory to enable production mode',
+    zeppelin_username: 'zeppelinUsername',
+    zeppelin_username_tips: 'Please enter the zeppelin server username',
+    zeppelin_password: 'zeppelinPassword',
+    zeppelin_password_tips: 'Please enter the zeppelin server password',  
     hive_cli_task_execution_type: 'Hive Cli Task Execution Type',
     hive_sql_script: 'Hive SQL Script',
     hive_cli_options: 'Hive Cli Options',

+ 4 - 0
dolphinscheduler-ui/src/locales/zh_CN/project.ts

@@ -668,6 +668,10 @@ export default {
     zeppelin_parameters_tips: '请输入zeppelin dynamic form参数',
     zeppelin_rest_endpoint: 'zeppelinRestEndpoint',
     zeppelin_rest_endpoint_tips: '请输入zeppelin server的rest endpoint',
+    zeppelin_username: 'zeppelinUsername',
+    zeppelin_username_tips: '请输入zeppelin server的登陆用户名',
+    zeppelin_password: 'zeppelinPassword',
+    zeppelin_password_tips: '请输入zeppelin server的登陆密码',
     hive_cli_task_execution_type: 'Hive Cli 任务类型',
     hive_sql_script: 'Hive SQL 脚本',
     hive_cli_options: 'Hive Cli 选项',

+ 16 - 0
dolphinscheduler-ui/src/views/projects/task/components/node/fields/use-zeppelin.ts

@@ -72,6 +72,22 @@ export function useZeppelin(model: { [field: string]: any }): IJsonItem[] {
         placeholder: t('project.node.zeppelin_production_note_directory_tips')
       }
     },
+    {
+      type: 'input',
+      field: 'username',
+      name: t('project.node.zeppelin_username'),
+      props: {
+        placeholder: t('project.node.zeppelin_username_tips')
+      }
+    },
+    {
+      type: 'input',
+      field: 'password',
+      name: t('project.node.zeppelin_password'),
+      props: {
+        placeholder:  t('project.node.zeppelin_password_tips')
+      }
+    },
     {
       type: 'input',
       field: 'parameters',

+ 2 - 0
dolphinscheduler-ui/src/views/projects/task/components/node/format-data.ts

@@ -334,6 +334,8 @@ export function formatParams(data: INodeData): {
     taskParams.noteId = data.noteId
     taskParams.paragraphId = data.paragraphId
     taskParams.restEndpoint = data.restEndpoint
+    taskParams.username = data.username
+    taskParams.password = data.password
     taskParams.productionNoteDirectory = data.productionNoteDirectory
     taskParams.parameters = data.parameters
   }

+ 4 - 0
dolphinscheduler-ui/src/views/projects/task/components/node/types.ts

@@ -320,6 +320,10 @@ interface ITaskParams {
   zeppelinParagraphId?: string
   zeppelinRestEndpoint?: string
   restEndpoint?: string
+  zeppelinUsername?: string
+  username?: string
+  zeppelinPassword?: string
+  password?: string
   zeppelinProductionNoteDirectory?: string
   productionNoteDirectory?: string
   hiveCliOptions?: string