You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dolphinscheduler.apache.org by GitBox <gi...@apache.org> on 2022/04/06 08:09:31 UTC

[GitHub] [dolphinscheduler] zhuangchong commented on a diff in pull request #9327: [Feature][Task-Plugin]Add zeppelin task-plugin to support Apache Zeppelin (#9201)

zhuangchong commented on code in PR #9327:
URL: https://github.com/apache/dolphinscheduler/pull/9327#discussion_r843620696


##########
dolphinscheduler-common/src/main/resources/common.properties:
##########
@@ -91,3 +91,5 @@ development.state=false
 # rpc port
 alert.rpc.port=50052
 
+# Url endpoint for zeppelin RESTful API
+zeppelin.rest.url="http://localhost:8080"

Review Comment:
   zeppelin is a task plugin for dolphin, I recommend this parameter as a parameter of the zeppelin plugin instead of a public parameter.



##########
dolphinscheduler-task-plugin/dolphinscheduler-task-zeppelin/src/main/java/org/apache/dolphinscheduler/plugin/task/zeppelin/ZeppelinTask.java:
##########
@@ -0,0 +1,150 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.dolphinscheduler.plugin.task.zeppelin;
+
+import org.apache.dolphinscheduler.plugin.task.api.AbstractTaskExecutor;
+import org.apache.dolphinscheduler.plugin.task.api.TaskConstants;
+import org.apache.dolphinscheduler.plugin.task.api.TaskExecutionContext;
+import org.apache.dolphinscheduler.plugin.task.api.parameters.AbstractParameters;
+import org.apache.dolphinscheduler.spi.utils.JSONUtils;
+import org.apache.dolphinscheduler.spi.utils.PropertyUtils;
+import org.apache.zeppelin.client.ClientConfig;
+import org.apache.zeppelin.client.ParagraphResult;
+import org.apache.zeppelin.client.Status;
+import org.apache.zeppelin.client.ZeppelinClient;
+
+
+public class ZeppelinTask extends AbstractTaskExecutor {
+
+    /**
+     * taskExecutionContext
+     */
+    private final TaskExecutionContext taskExecutionContext;
+
+    /**
+     * zeppelin parameters
+     */
+    private ZeppelinParameters zeppelinParameters;
+
+    /**
+     * zeppelin api client
+     */
+    private ZeppelinClient zClient;
+
+
+    /**
+     * constructor
+     *
+     * @param taskExecutionContext taskExecutionContext
+     */
+    protected ZeppelinTask(TaskExecutionContext taskExecutionContext) {
+        super(taskExecutionContext);
+        this.taskExecutionContext = taskExecutionContext;
+    }
+
+    @Override
+    public void init() {
+        final String taskParams = taskExecutionContext.getTaskParams();
+        logger.info("zeppelin task params:{}", taskParams);
+        this.zeppelinParameters = JSONUtils.parseObject(taskParams, ZeppelinParameters.class);
+        if (this.zeppelinParameters == null || !this.zeppelinParameters.checkParameters()) {
+            throw new ZeppelinTaskException("zeppelin task params is not valid");
+        }
+        this.zClient = getZeppelinClient();
+    }
+
+    @Override
+    public void handle() throws Exception {
+        try {
+            String noteId = this.zeppelinParameters.getNoteId();
+            String paragraphId = this.zeppelinParameters.getParagraphId();

Review Comment:
   If the Zeppelin task plugin only has two parameters, paragraphId and noteId, is it better to use the Http task node to call it?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org