You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@linkis.apache.org by ca...@apache.org on 2022/10/18 02:39:01 UTC
[incubator-linkis] branch dev-1.3.1-errorcode updated: [ISSUE-3387][linkis-engineplugin-pipeline]errorcode code optimization (#3530)
This is an automated email from the ASF dual-hosted git repository.
casion pushed a commit to branch dev-1.3.1-errorcode
in repository https://gitbox.apache.org/repos/asf/incubator-linkis.git
The following commit(s) were added to refs/heads/dev-1.3.1-errorcode by this push:
new 01ba4d2ad [ISSUE-3387][linkis-engineplugin-pipeline]errorcode code optimization (#3530)
01ba4d2ad is described below
commit 01ba4d2ad401031a2b674ff933e2b3e14f68e967
Author: 成彬彬 <10...@users.noreply.github.com>
AuthorDate: Tue Oct 18 10:38:55 2022 +0800
[ISSUE-3387][linkis-engineplugin-pipeline]errorcode code optimization (#3530)
---
docs/errorcode/pipeline -errorcode.md | 18 +++++
.../errorcode/PopelineErrorCodeSummary.java | 83 ++++++++++++++++++++++
.../pipeline/executor/CSVExecutor.scala | 14 ++--
.../pipeline/executor/ExcelExecutor.scala | 12 ++--
.../executor/PipelineEngineConnExecutor.scala | 6 +-
.../executor/PipelineExecutorSelector.scala | 12 +++-
6 files changed, 133 insertions(+), 12 deletions(-)
diff --git a/docs/errorcode/pipeline -errorcode.md b/docs/errorcode/pipeline -errorcode.md
new file mode 100644
index 000000000..a5a377ff3
--- /dev/null
+++ b/docs/errorcode/pipeline -errorcode.md
@@ -0,0 +1,18 @@
+## pipeline errorcode
+
+| module name(模块名) | error code(错误码) | describe(描述) |enumeration name(枚举)| Exception Class(类名)|
+| -------- | -------- | ----- |-----|-----|
+|pipeline |70001|Not a result set file(不是结果集文件)|NOT_A_RESULT_SET_FILE|PopelineErrorCodeSummary|
+|pipeline |70002|Only result sets of type TABLE can be converted to CSV(只有table类型的结果集才能转为csv)|ONLY_RESULT_CONVERTED_TO_CSV|PopelineErrorCodeSummary|
+|pipeline |70003|Not a result set file(不是结果集文件)|NOT_A_RESULT_SET_FILE3|PopelineErrorCodeSummary|
+|pipeline |70004|Only result sets of type Table can be converted to Excel(只有table类型的结果集才能转为excel)|ONLY_RESULT_CONVERTED_TO_EXCEL|PopelineErrorCodeSummary|
+|pipeline |70005|empty dir!(空目录!)|EMPTY_DIR|PopelineErrorCodeSummary|
+|pipeline |70006|Exporting multiple result sets to CSV is not supported(不支持多结果集导出为CSV)|EXPROTING_MULTIPLE|PopelineErrorCodeSummary|
+|pipeline |70007|Illegal out script statement(非法的out脚本语句)|ILLEGAL_OUT_SCRIPT|PopelineErrorCodeSummary|
+|pipeline |70008|Unsupport output type(不支持输出类型)|UNSUPPORT_OUTPUT_TYPE|PopelineErrorCodeSummary|
+
+
+
+
+
+
diff --git a/linkis-engineconn-plugins/pipeline/src/main/java/org/apache/linkis/manager/engineplugin/pipeline/errorcode/PopelineErrorCodeSummary.java b/linkis-engineconn-plugins/pipeline/src/main/java/org/apache/linkis/manager/engineplugin/pipeline/errorcode/PopelineErrorCodeSummary.java
new file mode 100644
index 000000000..b3ba85f3a
--- /dev/null
+++ b/linkis-engineconn-plugins/pipeline/src/main/java/org/apache/linkis/manager/engineplugin/pipeline/errorcode/PopelineErrorCodeSummary.java
@@ -0,0 +1,83 @@
+/*
+ * 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.linkis.manager.engineplugin.pipeline.errorcode;
+
+public enum PopelineErrorCodeSummary {
+ NOT_A_RESULT_SET_FILE(70001, "Not a result set file(不是结果集文件)", "Not a result set file(不是结果集文件)"),
+ ONLY_RESULT_CONVERTED_TO_CSV(
+ 70002,
+ "Only result sets of type TABLE can be converted to CSV(只有table类型的结果集才能转为csv)",
+ "Only result sets of type TABLE can be converted to CSV(只有table类型的结果集才能转为csv)"),
+ NOT_A_RESULT_SET_FILE3(70003, "Not a result set file(不是结果集文件)", "Not a result set file(不是结果集文件)"),
+ ONLY_RESULT_CONVERTED_TO_EXCEL(
+ 70004,
+ "Only result sets of type Table can be converted to Excel(只有table类型的结果集才能转为excel)",
+ "Only result sets of type Table can be converted to Excel(只有table类型的结果集才能转为excel)"),
+ EMPTY_DIR(70005, "empty dir!(空目录!)", "empty dir!(空目录!)"),
+ EXPROTING_MULTIPLE(
+ 70006,
+ "Exporting multiple result sets to CSV is not supported(不支持多结果集导出为CSV)",
+ "Exporting multiple result sets to CSV is not supported(不支持多结果集导出为CSV)"),
+ ILLEGAL_OUT_SCRIPT(
+ 70007,
+ "Illegal out script statement(非法的out脚本语句)",
+ "Illegal out script statement(非法的out脚本语句)"),
+ UNSUPPORT_OUTPUT_TYPE(70008, "unsupport output type(不支持输出类型)", "unsupport output type(不支持输出类型)");
+
+ /** (errorCode)错误码 */
+ private int errorCode;
+ /** (errorDesc)错误描述 */
+ private String errorDesc;
+ /** Possible reasons for the error(错误可能出现的原因) */
+ private String comment;
+
+ PopelineErrorCodeSummary(int errorCode, String errorDesc, String comment) {
+ this.errorCode = errorCode;
+ this.errorDesc = errorDesc;
+ this.comment = comment;
+ }
+
+ public int getErrorCode() {
+ return errorCode;
+ }
+
+ public void setErrorCode(int errorCode) {
+ this.errorCode = errorCode;
+ }
+
+ public String getErrorDesc() {
+ return errorDesc;
+ }
+
+ public void setErrorDesc(String errorDesc) {
+ this.errorDesc = errorDesc;
+ }
+
+ public String getComment() {
+ return comment;
+ }
+
+ public void setComment(String comment) {
+ this.comment = comment;
+ }
+
+ @Override
+ public String toString() {
+ return "errorCode: " + this.errorCode + ", errorDesc:" + this.errorDesc;
+ }
+}
diff --git a/linkis-engineconn-plugins/pipeline/src/main/scala/org/apache/linkis/manager/engineplugin/pipeline/executor/CSVExecutor.scala b/linkis-engineconn-plugins/pipeline/src/main/scala/org/apache/linkis/manager/engineplugin/pipeline/executor/CSVExecutor.scala
index 39d8f37c3..68b5010f1 100644
--- a/linkis-engineconn-plugins/pipeline/src/main/scala/org/apache/linkis/manager/engineplugin/pipeline/executor/CSVExecutor.scala
+++ b/linkis-engineconn-plugins/pipeline/src/main/scala/org/apache/linkis/manager/engineplugin/pipeline/executor/CSVExecutor.scala
@@ -26,6 +26,7 @@ import org.apache.linkis.manager.engineplugin.pipeline.conf.PipelineEngineConfig
PIPELINE_OUTPUT_ISOVERWRITE_SWITCH
}
import org.apache.linkis.manager.engineplugin.pipeline.constant.PipeLineConstant._
+import org.apache.linkis.manager.engineplugin.pipeline.errorcode.PopelineErrorCodeSummary._
import org.apache.linkis.manager.engineplugin.pipeline.exception.PipeLineErrorException
import org.apache.linkis.scheduler.executer.ExecuteResponse
import org.apache.linkis.storage.FSFactory
@@ -46,12 +47,15 @@ class CSVExecutor extends PipeLineExecutor {
): ExecuteResponse = {
if (!sourcePath.contains(STORAGE_RS_FILE_SUFFIX.getValue)) {
throw new PipeLineErrorException(
- 70006,
- "Exporting multiple result sets to CSV is not supported(不支持多结果集导出为CSV)"
+ EXPROTING_MULTIPLE.getErrorCode,
+ EXPROTING_MULTIPLE.getErrorDesc
)
}
if (!FileSource.isResultSet(sourcePath)) {
- throw new PipeLineErrorException(70001, "Not a result set file(不是结果集文件)")
+ throw new PipeLineErrorException(
+ NOT_A_RESULT_SET_FILE.getErrorCode,
+ NOT_A_RESULT_SET_FILE.getErrorDesc
+ )
}
val sourceFsPath = new FsPath(sourcePath)
val destFsPath = new FsPath(destPath)
@@ -62,8 +66,8 @@ class CSVExecutor extends PipeLineExecutor {
val fileSource = FileSource.create(sourceFsPath, sourceFs)
if (!FileSource.isTableResultSet(fileSource)) {
throw new PipeLineErrorException(
- 70002,
- "Only result sets of type TABLE can be converted to CSV(只有table类型的结果集才能转为csv)"
+ ONLY_RESULT_CONVERTED_TO_CSV.getErrorCode,
+ ONLY_RESULT_CONVERTED_TO_CSV.getErrorDesc
)
}
var nullValue = options.getOrDefault(PIPELINE_OUTPUT_SHUFFLE_NULL_TYPE, "NULL")
diff --git a/linkis-engineconn-plugins/pipeline/src/main/scala/org/apache/linkis/manager/engineplugin/pipeline/executor/ExcelExecutor.scala b/linkis-engineconn-plugins/pipeline/src/main/scala/org/apache/linkis/manager/engineplugin/pipeline/executor/ExcelExecutor.scala
index ba5df3185..e678641b7 100644
--- a/linkis-engineconn-plugins/pipeline/src/main/scala/org/apache/linkis/manager/engineplugin/pipeline/executor/ExcelExecutor.scala
+++ b/linkis-engineconn-plugins/pipeline/src/main/scala/org/apache/linkis/manager/engineplugin/pipeline/executor/ExcelExecutor.scala
@@ -22,6 +22,7 @@ import org.apache.linkis.engineconn.computation.executor.execute.EngineExecution
import org.apache.linkis.manager.engineplugin.pipeline.conf.PipelineEngineConfiguration
import org.apache.linkis.manager.engineplugin.pipeline.conf.PipelineEngineConfiguration.PIPELINE_OUTPUT_ISOVERWRITE_SWITCH
import org.apache.linkis.manager.engineplugin.pipeline.constant.PipeLineConstant._
+import org.apache.linkis.manager.engineplugin.pipeline.errorcode.PopelineErrorCodeSummary._
import org.apache.linkis.manager.engineplugin.pipeline.exception.PipeLineErrorException
import org.apache.linkis.scheduler.executer.ExecuteResponse
import org.apache.linkis.storage.FSFactory
@@ -63,7 +64,10 @@ class ExcelExecutor extends PipeLineExecutor {
// sourcePaht 是文件形式
// TODO: fs 加目录判断
if (!FileSource.isResultSet(sourcePath)) {
- throw new PipeLineErrorException(70003, "Not a result set file(不是结果集文件)")
+ throw new PipeLineErrorException(
+ NOT_A_RESULT_SET_FILE3.getErrorCode,
+ NOT_A_RESULT_SET_FILE3.getErrorDesc
+ )
}
fileSource = FileSource.create(sourceFsPath, sourceFs)
excelFsWriter = ExcelFsWriter.getExcelFsWriter(
@@ -78,15 +82,15 @@ class ExcelExecutor extends PipeLineExecutor {
excelFsWriter = new StorageMultiExcelWriter(outputStream, excelAutoFormat)
val fsPathListWithError = sourceFs.asInstanceOf[FileSystem].listPathWithError(sourceFsPath)
if (fsPathListWithError == null) {
- throw new PipeLineErrorException(70005, "empty dir!")
+ throw new PipeLineErrorException(EMPTY_DIR.getErrorCode, EMPTY_DIR.getErrorDesc)
}
fileSource =
FileSource.create(fsPathListWithError.getFsPaths.toArray(Array[FsPath]()), sourceFs)
}
if (!FileSource.isTableResultSet(fileSource)) {
throw new PipeLineErrorException(
- 70004,
- "Only result sets of type Table can be converted to Excel(只有table类型的结果集才能转为excel)"
+ ONLY_RESULT_CONVERTED_TO_EXCEL.getErrorCode,
+ ONLY_RESULT_CONVERTED_TO_EXCEL.getErrorDesc
)
}
var nullValue = options.getOrDefault(PIPELINE_OUTPUT_SHUFFLE_NULL_TYPE, "NULL")
diff --git a/linkis-engineconn-plugins/pipeline/src/main/scala/org/apache/linkis/manager/engineplugin/pipeline/executor/PipelineEngineConnExecutor.scala b/linkis-engineconn-plugins/pipeline/src/main/scala/org/apache/linkis/manager/engineplugin/pipeline/executor/PipelineEngineConnExecutor.scala
index fc1c387ff..332160c51 100644
--- a/linkis-engineconn-plugins/pipeline/src/main/scala/org/apache/linkis/manager/engineplugin/pipeline/executor/PipelineEngineConnExecutor.scala
+++ b/linkis-engineconn-plugins/pipeline/src/main/scala/org/apache/linkis/manager/engineplugin/pipeline/executor/PipelineEngineConnExecutor.scala
@@ -29,6 +29,7 @@ import org.apache.linkis.manager.common.entity.resource.{
NodeResource
}
import org.apache.linkis.manager.engineplugin.common.conf.EngineConnPluginConf
+import org.apache.linkis.manager.engineplugin.pipeline.errorcode.PopelineErrorCodeSummary._
import org.apache.linkis.manager.engineplugin.pipeline.exception.PipeLineErrorException
import org.apache.linkis.manager.label.entity.Label
import org.apache.linkis.protocol.engine.JobProgressInfo
@@ -73,7 +74,10 @@ class PipelineEngineConnExecutor(val id: Int) extends ComputationExecutor with L
.select(sourcePath, destPath, newOptions.asInstanceOf[util.Map[String, String]])
.execute(sourcePath, destPath, engineExecutorContext)
case _ =>
- throw new PipeLineErrorException(70007, "非法的out脚本语句(Illegal out script statement)")
+ throw new PipeLineErrorException(
+ ILLEGAL_OUT_SCRIPT.getErrorCode,
+ ILLEGAL_OUT_SCRIPT.getErrorDesc
+ )
}
} catch {
case e: Exception => failedTasks = 1; succeedTasks = 0; throw e
diff --git a/linkis-engineconn-plugins/pipeline/src/main/scala/org/apache/linkis/manager/engineplugin/pipeline/executor/PipelineExecutorSelector.scala b/linkis-engineconn-plugins/pipeline/src/main/scala/org/apache/linkis/manager/engineplugin/pipeline/executor/PipelineExecutorSelector.scala
index e5fa794fa..aaee37e63 100644
--- a/linkis-engineconn-plugins/pipeline/src/main/scala/org/apache/linkis/manager/engineplugin/pipeline/executor/PipelineExecutorSelector.scala
+++ b/linkis-engineconn-plugins/pipeline/src/main/scala/org/apache/linkis/manager/engineplugin/pipeline/executor/PipelineExecutorSelector.scala
@@ -18,6 +18,7 @@
package org.apache.linkis.manager.engineplugin.pipeline.executor
import org.apache.linkis.common.utils.{Logging, Utils}
+import org.apache.linkis.manager.engineplugin.pipeline.errorcode.PopelineErrorCodeSummary._
import org.apache.linkis.manager.engineplugin.pipeline.exception.PipeLineErrorException
import java.io.File
@@ -41,11 +42,18 @@ object PipelineExecutorSelector extends Logging {
getSuffix(destPath) match {
case ".csv" => PipelineEngineConnExecutor.listPipelineExecutors()(1)
case ".xlsx" => PipelineEngineConnExecutor.listPipelineExecutors()(2)
- case _ => throw new PipeLineErrorException(70008, "unsupport output type")
+ case _ =>
+ throw new PipeLineErrorException(
+ UNSUPPORT_OUTPUT_TYPE.getErrorCode,
+ UNSUPPORT_OUTPUT_TYPE.getErrorDesc
+ )
}
} { case e: Exception =>
logger.error("select executor failed", e);
- throw new PipeLineErrorException(70008, "unsupport output type")
+ throw new PipeLineErrorException(
+ UNSUPPORT_OUTPUT_TYPE.getErrorCode,
+ UNSUPPORT_OUTPUT_TYPE.getErrorDesc
+ )
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@linkis.apache.org
For additional commands, e-mail: commits-help@linkis.apache.org