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 e5e643bd7 [ISSUE-3374][linkis-engineconn-manager-core]errorcode code 
optimization (#3527)
e5e643bd7 is described below

commit e5e643bd7940303b7a34e2f9d4d09415cc2b3c87
Author: 成彬彬 <[email protected]>
AuthorDate: Tue Oct 18 10:37:43 2022 +0800

    [ISSUE-3374][linkis-engineconn-manager-core]errorcode code optimization 
(#3527)
---
 .../linkis-engineconn-manager-core-errorcode.md    |  7 +++
 .../core/errorcode/LinkisECMErrorCodeSummary.java  | 71 ++++++++++++++++++++++
 .../ecm/core/launch/ProcessEngineConnLaunch.scala  | 13 ++--
 3 files changed, 85 insertions(+), 6 deletions(-)

diff --git a/docs/errorcode/linkis-engineconn-manager-core-errorcode.md 
b/docs/errorcode/linkis-engineconn-manager-core-errorcode.md
new file mode 100644
index 000000000..ea269a87b
--- /dev/null
+++ b/docs/errorcode/linkis-engineconn-manager-core-errorcode.md
@@ -0,0 +1,7 @@
+## linkis-engineconn-manager-core  errorcode
+
+| module name(模块名) | error code(错误码)  | describe(描述) |enumeration name(枚举)| 
Exception Class(类名)|
+| -------- | -------- | ----- |-----|-----|
+|linkis-engineconn-manager-core |20001|Process is not be launch, can not get 
InputStream!(进程未启动,无法获取 
InputStream!)|CAN_NOT_GET_INPUTSTREAM|LinkisECMErrorCodeSummary|
+|linkis-engineconn-manager-core |20001| process is not be launch, can not get 
terminated code by 
wait!(进程未启动,无法通过等待获得终止代码!)|CAN_NOT_GET_TERMINATED|LinkisECMErrorCodeSummary|
+
diff --git 
a/linkis-computation-governance/linkis-engineconn-manager/linkis-engineconn-manager-core/src/main/java/org/apache/linkis/ecm/core/errorcode/LinkisECMErrorCodeSummary.java
 
b/linkis-computation-governance/linkis-engineconn-manager/linkis-engineconn-manager-core/src/main/java/org/apache/linkis/ecm/core/errorcode/LinkisECMErrorCodeSummary.java
new file mode 100644
index 000000000..ccefd5678
--- /dev/null
+++ 
b/linkis-computation-governance/linkis-engineconn-manager/linkis-engineconn-manager-core/src/main/java/org/apache/linkis/ecm/core/errorcode/LinkisECMErrorCodeSummary.java
@@ -0,0 +1,71 @@
+/*
+ * 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.core.errorcode;
+
+public enum LinkisECMErrorCodeSummary {
+  CAN_NOT_GET_INPUTSTREAM(
+      20001,
+      "process is not be launch, can not get InputStream!(进程未启动,无法获取 
InputStream!)",
+      "process is not be launch, can not get InputStream!(进程未启动,无法获取 
InputStream!)"),
+  CAN_NOT_GET_TERMINATED(
+      20001,
+      "process is not be launch, can not get terminated code by 
wait!(进程未启动,无法通过等待获得终止代码!)",
+      "process is not be launch, can not get terminated code by 
wait!(进程未启动,无法通过等待获得终止代码!)");
+
+  /** (errorCode)错误码 */
+  private int errorCode;
+  /** (errorDesc)错误描述 */
+  private String errorDesc;
+  /** Possible reasons for the error(错误可能出现的原因) */
+  private String comment;
+
+  LinkisECMErrorCodeSummary(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-core/src/main/scala/org/apache/linkis/ecm/core/launch/ProcessEngineConnLaunch.scala
 
b/linkis-computation-governance/linkis-engineconn-manager/linkis-engineconn-manager-core/src/main/scala/org/apache/linkis/ecm/core/launch/ProcessEngineConnLaunch.scala
index d1759863e..53542ff30 100644
--- 
a/linkis-computation-governance/linkis-engineconn-manager/linkis-engineconn-manager-core/src/main/scala/org/apache/linkis/ecm/core/launch/ProcessEngineConnLaunch.scala
+++ 
b/linkis-computation-governance/linkis-engineconn-manager/linkis-engineconn-manager-core/src/main/scala/org/apache/linkis/ecm/core/launch/ProcessEngineConnLaunch.scala
@@ -21,6 +21,7 @@ import org.apache.linkis.common.conf.{CommonVars, 
Configuration}
 import org.apache.linkis.common.exception.ErrorException
 import org.apache.linkis.common.utils.{Logging, Utils}
 import org.apache.linkis.ecm.core.conf.ECMErrorCode
+import org.apache.linkis.ecm.core.errorcode.LinkisECMErrorCodeSummary._
 import org.apache.linkis.ecm.core.exception.ECMCoreException
 import org.apache.linkis.ecm.core.utils.PortUtils
 import org.apache.linkis.governance.common.conf.GovernanceCommonConf
@@ -132,12 +133,12 @@ trait ProcessEngineConnLaunch extends EngineConnLaunch 
with Logging {
   override def launch(): Unit = {
     request.necessaryEnvironments.foreach { e =>
       val env = CommonVars(e, "")
-      if (StringUtils.isEmpty(env.getValue))
+      if (StringUtils.isEmpty(env.getValue)) {
         throw new ErrorException(
           30000,
           s"Necessary environment $e is not exists!(必须的环境变量 $e 不存在!)"
         ) // TODO exception
-      else request.environment.put(e, env.getValue)
+      } else request.environment.put(e, env.getValue)
     }
     prepareCommand()
     val exec = newProcessEngineConnCommandExec(
@@ -276,8 +277,8 @@ trait ProcessEngineConnLaunch extends EngineConnLaunch with 
Logging {
       process.getInputStream
     } else {
       throw new ECMCoreException(
-        ECMErrorCode.PROCESS_WAITFOR_ERROR,
-        "process is not be launch, can not get InputStream!"
+        CAN_NOT_GET_INPUTSTREAM.getErrorCode,
+        CAN_NOT_GET_INPUTSTREAM.getErrorDesc
       )
     }
   }
@@ -287,8 +288,8 @@ trait ProcessEngineConnLaunch extends EngineConnLaunch with 
Logging {
       process.waitFor
     } else {
       throw new ECMCoreException(
-        ECMErrorCode.PROCESS_WAITFOR_ERROR,
-        "process is not be launch, can not get terminated code by wait!"
+        CAN_NOT_GET_TERMINATED.getErrorCode,
+        CAN_NOT_GET_TERMINATED.getErrorDesc
       )
     }
   }


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

Reply via email to