You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@linkis.apache.org by pe...@apache.org on 2022/09/20 06:39:29 UTC

[incubator-linkis] branch dev-1.3.1 updated: persto module errorcode optimization and documentation (#3472)

This is an automated email from the ASF dual-hosted git repository.

peacewong pushed a commit to branch dev-1.3.1
in repository https://gitbox.apache.org/repos/asf/incubator-linkis.git


The following commit(s) were added to refs/heads/dev-1.3.1 by this push:
     new ce336f151 persto module errorcode optimization and documentation (#3472)
ce336f151 is described below

commit ce336f1515b7511dd5f21114497c2537021b6b3a
Author: huangxiaoping <35...@users.noreply.github.com>
AuthorDate: Tue Sep 20 14:39:24 2022 +0800

    persto module errorcode optimization and documentation (#3472)
---
 docs/errorcode/linkis-engineplugin-presto.md       |   8 ++
 .../presto/errorcode/PrestoErrorCodeSummary.java   |  91 ++++++++++++++++
 .../presto/exception/PrestoException.scala         |  10 +-
 .../presto/executor/PrestoEngineConnExecutor.scala |  11 +-
 .../errorcode/PrestoErrorCodeSummaryTest.java      | 116 +++++++++++++++++++++
 5 files changed, 228 insertions(+), 8 deletions(-)

diff --git a/docs/errorcode/linkis-engineplugin-presto.md b/docs/errorcode/linkis-engineplugin-presto.md
new file mode 100644
index 000000000..cf5c37b1e
--- /dev/null
+++ b/docs/errorcode/linkis-engineplugin-presto.md
@@ -0,0 +1,8 @@
+## linkis-engineplugin-presto errorcode
+
+
+| 模块名(服务名) | 错误码   | 描述 | module|
+| -------- |-------| ---- |-----|
+|linkis-engineplugin-presto| 26001 |Presto status error,statement is not finished(Presto服务状态异常, 查询语句没有执行结束)|prestoEngine|
+|linkis-engineplugin-presto| 26002 |Presto client error(Presto客户端异常)|prestoEngine|
+
diff --git a/linkis-engineconn-plugins/presto/src/main/java/org/apache/linkis/engineplugin/presto/errorcode/PrestoErrorCodeSummary.java b/linkis-engineconn-plugins/presto/src/main/java/org/apache/linkis/engineplugin/presto/errorcode/PrestoErrorCodeSummary.java
new file mode 100644
index 000000000..720cd9f1a
--- /dev/null
+++ b/linkis-engineconn-plugins/presto/src/main/java/org/apache/linkis/engineplugin/presto/errorcode/PrestoErrorCodeSummary.java
@@ -0,0 +1,91 @@
+/*
+ * 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.engineplugin.presto.errorcode;
+
+import org.apache.linkis.common.errorcode.ErrorCodeUtils;
+
+public enum PrestoErrorCodeSummary {
+  /**
+   * 10000-10999 linkis-frame 11000-12999 linkis-commons 13000-14999 linkis-spring-cloud-services
+   * 15000-19999 linkis-public-enhancements 20000-24999 linkis-computation-governance 25000-25999
+   * linkis-extensions 26000-29999 linkis-engineconn-plugins
+   */
+  PRESTO_STATE_INVALID(
+      26001,
+      "Presto status error,statement is not finished(Presto服务状态异常, 查询语句没有执行结束)",
+      "The presto service is abnormal, resulting in the query statement not being completed(presto服务出现异常,导致查询语句未执行完成)",
+      "prestoEngine"),
+  PRESTO_CLIENT_ERROR(
+      26002,
+      "Presto client error(Presto客户端异常)",
+      "Presto client is abnormal for some reason(presto客户端由于某些原因异常)",
+      "prestoEngine");
+
+  private int errorCode;
+
+  private String errorDesc;
+
+  private String comment;
+
+  private String module;
+
+  PrestoErrorCodeSummary(int errorCode, String errorDesc, String comment, String module) {
+    ErrorCodeUtils.validateErrorCode(errorCode, 26000, 29999);
+    this.errorCode = errorCode;
+    this.errorDesc = errorDesc;
+    this.comment = comment;
+    this.module = module;
+  }
+
+  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;
+  }
+
+  public String getModule() {
+    return module;
+  }
+
+  public void setModule(String module) {
+    this.module = module;
+  }
+
+  @Override
+  public String toString() {
+    return "errorCode: " + this.errorCode + ", errorDesc:" + this.errorDesc;
+  }
+}
diff --git a/linkis-engineconn-plugins/presto/src/main/scala/org/apache/linkis/engineplugin/presto/exception/PrestoException.scala b/linkis-engineconn-plugins/presto/src/main/scala/org/apache/linkis/engineplugin/presto/exception/PrestoException.scala
index 426f28630..221bc0c9f 100644
--- a/linkis-engineconn-plugins/presto/src/main/scala/org/apache/linkis/engineplugin/presto/exception/PrestoException.scala
+++ b/linkis-engineconn-plugins/presto/src/main/scala/org/apache/linkis/engineplugin/presto/exception/PrestoException.scala
@@ -19,10 +19,8 @@ package org.apache.linkis.engineplugin.presto.exception
 
 import org.apache.linkis.common.exception.ErrorException
 
-case class PrestoStateInvalidException(message: String)
-    extends ErrorException(60011, message: String)
+case class PrestoStateInvalidException(errorCode: Int, message: String)
+    extends ErrorException(errorCode, message: String)
 
-case class PrestoClientException(message: String) extends ErrorException(60012, message: String)
-
-case class PrestoSourceGroupException(message: String)
-    extends ErrorException(60013, message: String)
+case class PrestoClientException(errorCode: Int, message: String)
+    extends ErrorException(errorCode, message: String)
diff --git a/linkis-engineconn-plugins/presto/src/main/scala/org/apache/linkis/engineplugin/presto/executor/PrestoEngineConnExecutor.scala b/linkis-engineconn-plugins/presto/src/main/scala/org/apache/linkis/engineplugin/presto/executor/PrestoEngineConnExecutor.scala
index bc7e625ea..f8040dc02 100644
--- a/linkis-engineconn-plugins/presto/src/main/scala/org/apache/linkis/engineplugin/presto/executor/PrestoEngineConnExecutor.scala
+++ b/linkis-engineconn-plugins/presto/src/main/scala/org/apache/linkis/engineplugin/presto/executor/PrestoEngineConnExecutor.scala
@@ -28,6 +28,7 @@ import org.apache.linkis.engineconn.computation.executor.execute.{
 import org.apache.linkis.engineconn.core.EngineConnObject
 import org.apache.linkis.engineplugin.presto.conf.PrestoConfiguration._
 import org.apache.linkis.engineplugin.presto.conf.PrestoEngineConf
+import org.apache.linkis.engineplugin.presto.errorcode.PrestoErrorCodeSummary
 import org.apache.linkis.engineplugin.presto.exception.{
   PrestoClientException,
   PrestoStateInvalidException
@@ -360,9 +361,15 @@ class PrestoEngineConnExecutor(override val outputPrintLimit: Int, val id: Int)
       logger.warn(s"Presto statement is killed.")
       null
     } else if (statement.isClientError) {
-      throw PrestoClientException("Presto client error.")
+      throw PrestoClientException(
+        PrestoErrorCodeSummary.PRESTO_CLIENT_ERROR.getErrorCode,
+        PrestoErrorCodeSummary.PRESTO_CLIENT_ERROR.getErrorDesc
+      )
     } else {
-      throw PrestoStateInvalidException("Presto status error. Statement is not finished.")
+      throw PrestoStateInvalidException(
+        PrestoErrorCodeSummary.PRESTO_STATE_INVALID.getErrorCode,
+        PrestoErrorCodeSummary.PRESTO_STATE_INVALID.getErrorDesc
+      )
     }
   }
 
diff --git a/linkis-engineconn-plugins/presto/src/test/java/org/apache/linkis/engineplugin/presto/errorcode/PrestoErrorCodeSummaryTest.java b/linkis-engineconn-plugins/presto/src/test/java/org/apache/linkis/engineplugin/presto/errorcode/PrestoErrorCodeSummaryTest.java
new file mode 100644
index 000000000..c63ea98c3
--- /dev/null
+++ b/linkis-engineconn-plugins/presto/src/test/java/org/apache/linkis/engineplugin/presto/errorcode/PrestoErrorCodeSummaryTest.java
@@ -0,0 +1,116 @@
+/*
+ * 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.engineplugin.presto.errorcode;
+
+import org.junit.jupiter.api.Test;
+
+import static org.apache.linkis.engineplugin.presto.errorcode.PrestoErrorCodeSummary.PRESTO_CLIENT_ERROR;
+import static org.apache.linkis.engineplugin.presto.errorcode.PrestoErrorCodeSummary.PRESTO_STATE_INVALID;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+public class PrestoErrorCodeSummaryTest {
+  @Test
+  void testGetErrorCode() {
+    assertEquals(26001, PRESTO_STATE_INVALID.getErrorCode());
+    assertEquals(26002, PRESTO_CLIENT_ERROR.getErrorCode());
+  }
+
+  @Test
+  void testSetErrorCode() {
+    PRESTO_STATE_INVALID.setErrorCode(1);
+    assertEquals(1, PRESTO_STATE_INVALID.getErrorCode());
+    PRESTO_STATE_INVALID.setErrorCode(26001);
+    assertEquals(26001, PRESTO_STATE_INVALID.getErrorCode());
+
+    PRESTO_CLIENT_ERROR.setErrorCode(1);
+    assertEquals(1, PRESTO_CLIENT_ERROR.getErrorCode());
+    PRESTO_CLIENT_ERROR.setErrorCode(26002);
+    assertEquals(26002, PRESTO_CLIENT_ERROR.getErrorCode());
+  }
+
+  @Test
+  void testGetErrorDesc() {
+    assertEquals(
+        "Presto status error,statement is not finished(Presto服务状态异常, 查询语句没有执行结束)",
+        PRESTO_STATE_INVALID.getErrorDesc());
+    assertEquals("Presto client error(Presto客户端异常)", PRESTO_CLIENT_ERROR.getErrorDesc());
+  }
+
+  @Test
+  void testSetErrorDesc() {
+    PRESTO_STATE_INVALID.setErrorDesc("test");
+    assertEquals("test", PRESTO_STATE_INVALID.getErrorDesc());
+    PRESTO_STATE_INVALID.setErrorDesc(
+        "Presto status error,statement is not finished(Presto服务状态异常, 查询语句没有执行结束)");
+    assertEquals(
+        "Presto status error,statement is not finished(Presto服务状态异常, 查询语句没有执行结束)",
+        PRESTO_STATE_INVALID.getErrorDesc());
+
+    PRESTO_CLIENT_ERROR.setErrorDesc("test");
+    assertEquals("test", PRESTO_CLIENT_ERROR.getErrorDesc());
+    PRESTO_CLIENT_ERROR.setErrorDesc("Presto client error(Presto客户端异常)");
+    assertEquals("Presto client error(Presto客户端异常)", PRESTO_CLIENT_ERROR.getErrorDesc());
+  }
+
+  @Test
+  void testGetComment() {
+    assertEquals(
+        "The presto service is abnormal, resulting in the query statement not being completed(presto服务出现异常,导致查询语句未执行完成)",
+        PRESTO_STATE_INVALID.getComment());
+    assertEquals(
+        "Presto client is abnormal for some reason(presto客户端由于某些原因异常)",
+        PRESTO_CLIENT_ERROR.getComment());
+  }
+
+  @Test
+  void testSetComment() {
+    PRESTO_STATE_INVALID.setComment("test");
+    assertEquals("test", PRESTO_STATE_INVALID.getComment());
+    PRESTO_STATE_INVALID.setComment(
+        "The presto service is abnormal, resulting in the query statement not being completed(presto服务出现异常,导致查询语句未执行完成)");
+    assertEquals(
+        "The presto service is abnormal, resulting in the query statement not being completed(presto服务出现异常,导致查询语句未执行完成)",
+        PRESTO_STATE_INVALID.getComment());
+
+    PRESTO_CLIENT_ERROR.setComment("test");
+    assertEquals("test", PRESTO_CLIENT_ERROR.getComment());
+    PRESTO_CLIENT_ERROR.setComment("Presto client is abnormal for some reason(presto客户端由于某些原因异常)");
+    assertEquals(
+        "Presto client is abnormal for some reason(presto客户端由于某些原因异常)",
+        PRESTO_CLIENT_ERROR.getComment());
+  }
+
+  @Test
+  void testGetModule() {
+    assertEquals("prestoEngine", PRESTO_STATE_INVALID.getModule());
+    assertEquals("prestoEngine", PRESTO_CLIENT_ERROR.getModule());
+  }
+
+  @Test
+  void testSetModule() {
+    PRESTO_STATE_INVALID.setModule("test");
+    assertEquals("test", PRESTO_STATE_INVALID.getModule());
+    PRESTO_STATE_INVALID.setModule("prestoEngine");
+    assertEquals("prestoEngine", PRESTO_STATE_INVALID.getModule());
+
+    PRESTO_CLIENT_ERROR.setModule("test");
+    assertEquals("test", PRESTO_CLIENT_ERROR.getModule());
+    PRESTO_CLIENT_ERROR.setModule("prestoEngine");
+    assertEquals("prestoEngine", PRESTO_CLIENT_ERROR.getModule());
+  }
+}


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@linkis.apache.org
For additional commands, e-mail: commits-help@linkis.apache.org