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 6a74bb8e3 [WIP][linkis-engineconn-manager-server ]module errorcode 
optimization and … (#3542)
6a74bb8e3 is described below

commit 6a74bb8e365a29f29ad941c556c42b3683868684
Author: 成彬彬 <[email protected]>
AuthorDate: Tue Oct 18 10:33:07 2022 +0800

    [WIP][linkis-engineconn-manager-server ]module errorcode optimization and … 
(#3542)
---
 .../linkis-engineconn-manager-server-errorcode.md  | 13 +++
 .../EngineconnServerErrorCodeSummary.java          | 93 ++++++++++++++++++++++
 .../ecm/server/errorcode/ECMErrorConstants.scala   | 22 -----
 .../server/operator/EngineConnLogOperator.scala    |  7 +-
 .../operator/EngineConnYarnLogOperator.scala       |  5 +-
 .../impl/BmlResourceLocalizationService.scala      |  5 +-
 .../impl/ProcessEngineConnLaunchService.scala      | 12 +--
 .../apache/linkis/ecm/server/util/ECMUtils.scala   |  4 +-
 8 files changed, 125 insertions(+), 36 deletions(-)

diff --git a/docs/errorcode/linkis-engineconn-manager-server-errorcode.md 
b/docs/errorcode/linkis-engineconn-manager-server-errorcode.md
new file mode 100644
index 000000000..1f54efa1d
--- /dev/null
+++ b/docs/errorcode/linkis-engineconn-manager-server-errorcode.md
@@ -0,0 +1,13 @@
+## linkis-engineconn-manager-server  errorcode
+
+| module name(模块名) | error code(错误码)  | describe(描述) |enumeration name(枚举)| 
Exception Class(类名)|
+| -------- | -------- | ----- |-----|-----|
+|linkis-engineconn-manager-server |11100|wait for engineConn initial 
timeout(请求引擎超时,可能是因为队列资源不足导致,请重试)|WAIT_FOR_ENGINECONN|EngineconnServerErrorCodeSummary|
+|linkis-engineconn-manager-server |11101|wait for initial 
interrupted(请求引擎被中断,可能是因为你操作了引擎取消操作,请重试)|WAIT_FOR_INITIAL|EngineconnServerErrorCodeSummary|
+|linkis-engineconn-manager-server |11102|Not supported BmlResource visibility 
type: label(不支持的 BmlResource visibility 
类型:label).|NOT_SUPPORTED_TYPE|EngineconnServerErrorCodeSummary|
+|linkis-engineconn-manager-server |11102|  
|EC_START_FAILED|EngineconnServerErrorCodeSummary|
+|linkis-engineconn-manager-server |11110|Cannot fetch more than {} lines of 
logs.(无法获取超过{}行的日志.)|CANNOT_FETCH_MORE_THAN|EngineconnServerErrorCodeSummary|
+|linkis-engineconn-manager-server |11110|LogFile {} is not exists or is not a 
file.(LogFile {} 
不存在或不是文件.)|LOGFILE_IS_NOT_EXISTS|EngineconnServerErrorCodeSummary|
+|linkis-engineconn-manager-server |11110|the parameters of engineConnInstance 
and ticketId are both not exists.(engineConnInstance 和ticketId 
的参数都不存在.)|BOTH_NOT_EXISTS|EngineconnServerErrorCodeSummary|
+|linkis-engineconn-manager-server |11110|Log directory {} is not exists.(日志目录 
{} 不存在.)|LOG_IS_NOT_EXISTS|EngineconnServerErrorCodeSummary|
+|linkis-engineconn-manager-server |911115|failed to 
downLoad(下载失败)|LOG_IS_NOT_EXISTS|EngineconnServerErrorCodeSummary|
diff --git 
a/linkis-computation-governance/linkis-engineconn-manager/linkis-engineconn-manager-server/src/main/java/org/apache/linkis/ecm/errorcode/EngineconnServerErrorCodeSummary.java
 
b/linkis-computation-governance/linkis-engineconn-manager/linkis-engineconn-manager-server/src/main/java/org/apache/linkis/ecm/errorcode/EngineconnServerErrorCodeSummary.java
new file mode 100644
index 000000000..fb3c5f090
--- /dev/null
+++ 
b/linkis-computation-governance/linkis-engineconn-manager/linkis-engineconn-manager-server/src/main/java/org/apache/linkis/ecm/errorcode/EngineconnServerErrorCodeSummary.java
@@ -0,0 +1,93 @@
+/*
+ * 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.ecm.errorcode;
+
+public enum EngineconnServerErrorCodeSummary {
+  EC_START_TIME_OUT(
+      11100,
+      "wait for engineConn initial timeout(请求引擎超时,可能是因为队列资源不足导致,请重试)",
+      "wait for engineConn initial timeout(请求引擎超时,可能是因为队列资源不足导致,请重试)"),
+  EC_INTERRUPT_TIME_OUT(
+      11101,
+      "wait for initial interrupted(请求引擎被中断,可能是因为你操作了引擎取消操作,请重试) ",
+      "wait for initial interrupted(请求引擎被中断,可能是因为你操作了引擎取消操作,请重试) "),
+  NOT_SUPPORTED_TYPE(
+      11102,
+      "Not supported BmlResource visibility type: label(不支持的 BmlResource 
visibility 类型:label).",
+      "Not supported BmlResource visibility type: label(不支持的 BmlResource 
visibility 类型:label)."),
+  EC_START_FAILED(11102, "", ""),
+  CANNOT_FETCH_MORE_THAN(
+      11110,
+      "Cannot fetch more than {} lines of logs.(无法获取超过{}行的日志.)",
+      "Cannot fetch more than {} lines of logs.(无法获取超过{}行的日志.)"),
+  LOGFILE_IS_NOT_EXISTS(
+      11110,
+      "LogFile {} is not exists or is not a file.(LogFile {} 不存在或不是文件.)",
+      "LogFile {} is not exists or is not a file.(LogFile {} 不存在或不是文件.)"),
+  BOTH_NOT_EXISTS(
+      11110,
+      "the parameters of engineConnInstance and ticketId are both not 
exists.(engineConnInstance 和ticketId 的参数都不存在.)",
+      "the parameters of engineConnInstance and ticketId are both not 
exists.(engineConnInstance 和ticketId 的参数都不存在.)"),
+  LOG_IS_NOT_EXISTS(
+      11110,
+      "Log directory {} is not exists.(日志目录 {} 不存在.)",
+      "Log directory {} is not exists.(日志目录 {} 不存在.)"),
+  FAILED_TO_DOWNLOAD(911115, "failed to downLoad(下载失败)", "failed to 
downLoad(下载失败)");
+
+  /** (errorCode)错误码 */
+  private int errorCode;
+  /** (errorDesc)错误描述 */
+  private String errorDesc;
+  /** Possible reasons for the error(错误可能出现的原因) */
+  private String comment;
+
+  EngineconnServerErrorCodeSummary(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-computation-governance/linkis-engineconn-manager/linkis-engineconn-manager-server/src/main/scala/org/apache/linkis/ecm/server/errorcode/ECMErrorConstants.scala
 
b/linkis-computation-governance/linkis-engineconn-manager/linkis-engineconn-manager-server/src/main/scala/org/apache/linkis/ecm/server/errorcode/ECMErrorConstants.scala
deleted file mode 100644
index 603668239..000000000
--- 
a/linkis-computation-governance/linkis-engineconn-manager/linkis-engineconn-manager-server/src/main/scala/org/apache/linkis/ecm/server/errorcode/ECMErrorConstants.scala
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * 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.ecm.server.errorcode
-
-object ECMErrorConstants {
-  val ECM_ERROR = 10000
-}
diff --git 
a/linkis-computation-governance/linkis-engineconn-manager/linkis-engineconn-manager-server/src/main/scala/org/apache/linkis/ecm/server/operator/EngineConnLogOperator.scala
 
b/linkis-computation-governance/linkis-engineconn-manager/linkis-engineconn-manager-server/src/main/scala/org/apache/linkis/ecm/server/operator/EngineConnLogOperator.scala
index 336ac24c6..5f73f8b7e 100644
--- 
a/linkis-computation-governance/linkis-engineconn-manager/linkis-engineconn-manager-server/src/main/scala/org/apache/linkis/ecm/server/operator/EngineConnLogOperator.scala
+++ 
b/linkis-computation-governance/linkis-engineconn-manager/linkis-engineconn-manager-server/src/main/scala/org/apache/linkis/ecm/server/operator/EngineConnLogOperator.scala
@@ -21,6 +21,7 @@ import org.apache.linkis.DataWorkCloudApplication
 import org.apache.linkis.common.conf.CommonVars
 import org.apache.linkis.common.utils.{Logging, Utils}
 import org.apache.linkis.ecm.core.conf.ECMErrorCode
+import org.apache.linkis.ecm.errorcode.EngineconnServerErrorCodeSummary._
 import org.apache.linkis.ecm.server.conf.ECMConfiguration
 import org.apache.linkis.ecm.server.exception.ECMErrorException
 import org.apache.linkis.ecm.server.service.{EngineConnListService, 
LocalDirsHandleService}
@@ -54,7 +55,7 @@ class EngineConnLogOperator extends Operator with Logging {
     val enableTail = getAs("enableTail", false)
     if (lastRows > EngineConnLogOperator.MAX_LOG_FETCH_SIZE.getValue) {
       throw new ECMErrorException(
-        ECMErrorCode.EC_FETCH_LOG_FAILED,
+        CANNOT_FETCH_MORE_THAN.getErrorCode,
         s"Cannot fetch more than 
${EngineConnLogOperator.MAX_LOG_FETCH_SIZE.getValue} lines of logs."
       )
     } else if (lastRows > 0) {
@@ -138,7 +139,7 @@ class EngineConnLogOperator extends Operator with Logging {
       new File(engineConnLogDir, getAs("logType", 
EngineConnLogOperator.LOG_FILE_NAME.getValue));
     if (!logPath.exists() || !logPath.isFile) {
       throw new ECMErrorException(
-        ECMErrorCode.EC_FETCH_LOG_FAILED,
+        LOGFILE_IS_NOT_EXISTS.getErrorCode,
         s"LogFile $logPath is not exists or is not a file."
       )
     }
@@ -185,7 +186,7 @@ class EngineConnLogOperator extends Operator with Logging {
             val ticketId = getAs("ticketId", "")
             if (StringUtils.isBlank(ticketId)) {
               throw new ECMErrorException(
-                ECMErrorCode.EC_FETCH_LOG_FAILED,
+                BOTH_NOT_EXISTS.getErrorCode,
                 s"the parameters of 
${ECMOperateRequest.ENGINE_CONN_INSTANCE_KEY}, engineConnInstance and ticketId 
are both not exists."
               )
             }
diff --git 
a/linkis-computation-governance/linkis-engineconn-manager/linkis-engineconn-manager-server/src/main/scala/org/apache/linkis/ecm/server/operator/EngineConnYarnLogOperator.scala
 
b/linkis-computation-governance/linkis-engineconn-manager/linkis-engineconn-manager-server/src/main/scala/org/apache/linkis/ecm/server/operator/EngineConnYarnLogOperator.scala
index feaaab862..b0f7272c7 100644
--- 
a/linkis-computation-governance/linkis-engineconn-manager/linkis-engineconn-manager-server/src/main/scala/org/apache/linkis/ecm/server/operator/EngineConnYarnLogOperator.scala
+++ 
b/linkis-computation-governance/linkis-engineconn-manager/linkis-engineconn-manager-server/src/main/scala/org/apache/linkis/ecm/server/operator/EngineConnYarnLogOperator.scala
@@ -20,6 +20,7 @@ package org.apache.linkis.ecm.server.operator
 import org.apache.linkis.common.exception.LinkisCommonErrorException
 import org.apache.linkis.common.utils.Utils
 import org.apache.linkis.ecm.core.conf.ECMErrorCode
+import org.apache.linkis.ecm.errorcode.EngineconnServerErrorCodeSummary._
 import org.apache.linkis.ecm.server.exception.ECMErrorException
 
 import java.io.File
@@ -56,7 +57,7 @@ class EngineConnYarnLogOperator extends EngineConnLogOperator 
{
     val rootLogDir = new File(engineConnLogDir)
     if (!rootLogDir.exists() || !rootLogDir.isDirectory) {
       throw new ECMErrorException(
-        ECMErrorCode.EC_FETCH_LOG_FAILED,
+        LOG_IS_NOT_EXISTS.getErrorCode,
         s"Log directory $rootLogDir is not exists."
       )
     }
@@ -97,7 +98,7 @@ class EngineConnYarnLogOperator extends EngineConnLogOperator 
{
     }
     if (!logPath.exists() || !logPath.isFile) {
       throw new ECMErrorException(
-        ECMErrorCode.EC_FETCH_LOG_FAILED,
+        LOGFILE_IS_NOT_EXISTS.getErrorCode,
         s"LogFile $logPath is not exists or is not a file."
       )
     }
diff --git 
a/linkis-computation-governance/linkis-engineconn-manager/linkis-engineconn-manager-server/src/main/scala/org/apache/linkis/ecm/server/service/impl/BmlResourceLocalizationService.scala
 
b/linkis-computation-governance/linkis-engineconn-manager/linkis-engineconn-manager-server/src/main/scala/org/apache/linkis/ecm/server/service/impl/BmlResourceLocalizationService.scala
index 7d1190d91..056d9962f 100644
--- 
a/linkis-computation-governance/linkis-engineconn-manager/linkis-engineconn-manager-server/src/main/scala/org/apache/linkis/ecm/server/service/impl/BmlResourceLocalizationService.scala
+++ 
b/linkis-computation-governance/linkis-engineconn-manager/linkis-engineconn-manager-server/src/main/scala/org/apache/linkis/ecm/server/service/impl/BmlResourceLocalizationService.scala
@@ -23,6 +23,7 @@ import org.apache.linkis.common.utils.{Logging, Utils, 
ZipUtils}
 import org.apache.linkis.ecm.core.conf.ECMErrorCode
 import org.apache.linkis.ecm.core.engineconn.EngineConn
 import org.apache.linkis.ecm.core.launch.EngineConnManagerEnv
+import org.apache.linkis.ecm.errorcode.EngineconnServerErrorCodeSummary._
 import org.apache.linkis.ecm.server.conf.ECMConfiguration._
 import org.apache.linkis.ecm.server.exception.ECMErrorException
 import org.apache.linkis.ecm.server.service.{LocalDirsHandleService, 
ResourceLocalizationService}
@@ -182,8 +183,8 @@ class BmlResourceLocalizationService extends 
ResourceLocalizationService with Lo
           s"Not supported BmlResource visibility type: label. BmlResource: 
resourceId: $resourceId, version: $version, fileName: ${resource.getFileName}."
         )
         throw new ECMErrorException(
-          ECMErrorCode.EC_START_FAILED,
-          s"Not supported BmlResource visibility type: label(不支持的 BmlResource 
visibility 类型:label)."
+          NOT_SUPPORTED_TYPE.getErrorCode,
+          NOT_SUPPORTED_TYPE.getErrorDesc
         )
     }
   }
diff --git 
a/linkis-computation-governance/linkis-engineconn-manager/linkis-engineconn-manager-server/src/main/scala/org/apache/linkis/ecm/server/service/impl/ProcessEngineConnLaunchService.scala
 
b/linkis-computation-governance/linkis-engineconn-manager/linkis-engineconn-manager-server/src/main/scala/org/apache/linkis/ecm/server/service/impl/ProcessEngineConnLaunchService.scala
index aeef3b0e7..6fb472e7d 100644
--- 
a/linkis-computation-governance/linkis-engineconn-manager/linkis-engineconn-manager-server/src/main/scala/org/apache/linkis/ecm/server/service/impl/ProcessEngineConnLaunchService.scala
+++ 
b/linkis-computation-governance/linkis-engineconn-manager/linkis-engineconn-manager-server/src/main/scala/org/apache/linkis/ecm/server/service/impl/ProcessEngineConnLaunchService.scala
@@ -22,10 +22,10 @@ import org.apache.linkis.common.utils.Utils
 import org.apache.linkis.ecm.core.conf.ECMErrorCode
 import org.apache.linkis.ecm.core.engineconn.EngineConn
 import org.apache.linkis.ecm.core.launch.ProcessEngineConnLaunch
+import org.apache.linkis.ecm.errorcode.EngineconnServerErrorCodeSummary._
 import org.apache.linkis.ecm.server.LinkisECMApplication
 import org.apache.linkis.ecm.server.conf.ECMConfiguration
 import org.apache.linkis.ecm.server.conf.ECMConfiguration.MANAGER_SPRING_NAME
-import org.apache.linkis.ecm.server.errorcode.ECMErrorConstants
 import org.apache.linkis.ecm.server.exception.ECMErrorException
 import org.apache.linkis.ecm.server.listener.EngineConnStatusChangeEvent
 import org.apache.linkis.ecm.server.service.LocalDirsHandleService
@@ -142,20 +142,20 @@ abstract class ProcessEngineConnLaunchService extends 
AbstractEngineConnLaunchSe
     ) {
       case e: TimeoutException =>
         throw new ECMErrorException(
-          ECMErrorCode.EC_START_TIME_OUT,
-          s"wait for engineConn initial timeout(请求引擎超时,可能是因为队列资源不足导致,请重试) 
$engineConn ."
+          EC_START_TIME_OUT.getErrorCode,
+          EC_START_TIME_OUT.getErrorDesc + s" $engineConn ."
         )
       case e: InterruptedException => // 比如被ms cancel
         throw new ECMErrorException(
-          ECMErrorCode.EC_INTERRUPT_TIME_OUT,
-          s"wait for initial interrupted(请求引擎被中断,可能是因为你操作了引擎取消操作,请重试) 
$engineConn ."
+          EC_INTERRUPT_TIME_OUT.getErrorCode,
+          EC_INTERRUPT_TIME_OUT.getErrorDesc + s" $engineConn ."
         )
       case t: Throwable =>
         logger.error(s"unexpected error, now shutdown it.")
         throw t
     }
     if (engineConn.getStatus == ShuttingDown) {
-      throw new ECMErrorException(ECMErrorCode.EC_START_FAILED, 
errorMsg.toString())
+      throw new ECMErrorException(EC_START_FAILED.getErrorCode, 
errorMsg.toString())
     }
   }
 
diff --git 
a/linkis-computation-governance/linkis-engineconn-manager/linkis-engineconn-manager-server/src/main/scala/org/apache/linkis/ecm/server/util/ECMUtils.scala
 
b/linkis-computation-governance/linkis-engineconn-manager/linkis-engineconn-manager-server/src/main/scala/org/apache/linkis/ecm/server/util/ECMUtils.scala
index 7917faf40..184b5e3c9 100644
--- 
a/linkis-computation-governance/linkis-engineconn-manager/linkis-engineconn-manager-server/src/main/scala/org/apache/linkis/ecm/server/util/ECMUtils.scala
+++ 
b/linkis-computation-governance/linkis-engineconn-manager/linkis-engineconn-manager-server/src/main/scala/org/apache/linkis/ecm/server/util/ECMUtils.scala
@@ -19,6 +19,7 @@ package org.apache.linkis.ecm.server.util
 
 import org.apache.linkis.bml.client.{BmlClient, BmlClientFactory}
 import org.apache.linkis.bml.protocol.BmlDownloadResponse
+import 
org.apache.linkis.ecm.errorcode.EngineconnServerErrorCodeSummary.FAILED_TO_DOWNLOAD
 import org.apache.linkis.ecm.server.exception.ECMErrorException
 import org.apache.linkis.manager.common.protocol.bml.BmlResource
 import org.apache.linkis.rpc.Sender
@@ -44,7 +45,8 @@ object ECMUtils {
     } else {
       response = client.downloadShareResource(userName, 
resource.getResourceId, resource.getVersion)
     }
-    if (!response.isSuccess) throw new ECMErrorException(911115, "failed to 
downLoad(下载失败)")
+    if (!response.isSuccess)
+      throw new ECMErrorException(FAILED_TO_DOWNLOAD.getErrorCode, 
FAILED_TO_DOWNLOAD.getErrorDesc)
     val map = new util.HashMap[String, Object]
     map.put("path", response.fullFilePath)
     map.put("is", response.inputStream)


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to