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 6fc8744db openlookeng module errorcode optimization and documentation 
(#3481)
6fc8744db is described below

commit 6fc8744db6af82984ec755305a0537ecdac787c5
Author: huangxiaoping <[email protected]>
AuthorDate: Fri Sep 23 17:56:35 2022 +0800

    openlookeng module errorcode optimization and documentation (#3481)
---
 .../linkis-engineplugin-openlookeng-errorcode.md   |  12 +++
 .../errorcode/OpenLooKengErrorCodeSummary.java     |  92 ++++++++++++++++
 .../exception/OpenLooKengSourceGroupException.java |  27 -----
 .../executor/OpenLooKengEngineConnExecutor.java    |   7 +-
 .../errorcode/OpenLooKengErrorCodeSummaryTest.java | 119 +++++++++++++++++++++
 5 files changed, 228 insertions(+), 29 deletions(-)

diff --git a/docs/errorcode/linkis-engineplugin-openlookeng-errorcode.md 
b/docs/errorcode/linkis-engineplugin-openlookeng-errorcode.md
new file mode 100644
index 000000000..8b2e6857e
--- /dev/null
+++ b/docs/errorcode/linkis-engineplugin-openlookeng-errorcode.md
@@ -0,0 +1,12 @@
+## linkis-engineplugin-openlookeng errorcode
+
+
+| 模块名(服务名) | 错误码   | 描述 | module                      |
+| -------- |-------| ----- |-----------------------------|
+|linkis-engineplugin-openlookeng| 26030 |openlookeng client 
error(openlookeng客户端异常)|openlookengEngineConnExecutor|
+|linkis-engineplugin-openlookeng| 26031 |openlookeng status error,Statement is 
not finished(openlookeng状态异常, 查询语句未完成)|openlookengEngineConnExecutor|
+
+
+
+
+
diff --git 
a/linkis-engineconn-plugins/openlookeng/src/main/java/org/apache/linkis/engineplugin/openlookeng/errorcode/OpenLooKengErrorCodeSummary.java
 
b/linkis-engineconn-plugins/openlookeng/src/main/java/org/apache/linkis/engineplugin/openlookeng/errorcode/OpenLooKengErrorCodeSummary.java
new file mode 100644
index 000000000..1971eee09
--- /dev/null
+++ 
b/linkis-engineconn-plugins/openlookeng/src/main/java/org/apache/linkis/engineplugin/openlookeng/errorcode/OpenLooKengErrorCodeSummary.java
@@ -0,0 +1,92 @@
+/*
+ * 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.openlookeng.errorcode;
+
+import org.apache.linkis.common.errorcode.ErrorCodeUtils;
+
+public enum OpenLooKengErrorCodeSummary {
+  /**
+   * 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
+   */
+  OPENLOOKENG_CLIENT_ERROR(
+      26030,
+      "openlookeng client error(openlookeng客户端异常)",
+      "openlookeng client is abnormal due to some circumstances(openlookeng 
client由于某些情况异常)",
+      "jdbcEngineConnExecutor"),
+
+  OPENLOOKENG_STATUS_ERROR(
+      26031,
+      "openlookeng status error,Statement is not finished(openlookeng状态异常, 
查询语句未完成)",
+      "The status of openlookeng is abnormal, and the query statement cannot 
be executed and ended(openlookeng状态出现异常,查询语句无法执行结束)",
+      "jdbcEngineConnExecutor");
+
+  private int errorCode;
+
+  private String errorDesc;
+
+  private String comment;
+
+  private String module;
+
+  OpenLooKengErrorCodeSummary(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/openlookeng/src/main/java/org/apache/linkis/engineplugin/openlookeng/exception/OpenLooKengSourceGroupException.java
 
b/linkis-engineconn-plugins/openlookeng/src/main/java/org/apache/linkis/engineplugin/openlookeng/exception/OpenLooKengSourceGroupException.java
deleted file mode 100644
index 236b52793..000000000
--- 
a/linkis-engineconn-plugins/openlookeng/src/main/java/org/apache/linkis/engineplugin/openlookeng/exception/OpenLooKengSourceGroupException.java
+++ /dev/null
@@ -1,27 +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.engineplugin.openlookeng.exception;
-
-import org.apache.linkis.common.exception.ErrorException;
-
-public class OpenLooKengSourceGroupException extends ErrorException {
-
-  public OpenLooKengSourceGroupException(int errCode, String desc) {
-    super(errCode, desc);
-  }
-}
diff --git 
a/linkis-engineconn-plugins/openlookeng/src/main/java/org/apache/linkis/engineplugin/openlookeng/executor/OpenLooKengEngineConnExecutor.java
 
b/linkis-engineconn-plugins/openlookeng/src/main/java/org/apache/linkis/engineplugin/openlookeng/executor/OpenLooKengEngineConnExecutor.java
index 994ff2a50..d964195c0 100644
--- 
a/linkis-engineconn-plugins/openlookeng/src/main/java/org/apache/linkis/engineplugin/openlookeng/executor/OpenLooKengEngineConnExecutor.java
+++ 
b/linkis-engineconn-plugins/openlookeng/src/main/java/org/apache/linkis/engineplugin/openlookeng/executor/OpenLooKengEngineConnExecutor.java
@@ -80,6 +80,8 @@ import org.slf4j.LoggerFactory;
 
 import static 
org.apache.linkis.engineplugin.openlookeng.conf.OpenLooKengConfiguration.OPENLOOKENG_HTTP_CONNECT_TIME_OUT;
 import static 
org.apache.linkis.engineplugin.openlookeng.conf.OpenLooKengConfiguration.OPENLOOKENG_HTTP_READ_TIME_OUT;
+import static 
org.apache.linkis.engineplugin.openlookeng.errorcode.OpenLooKengErrorCodeSummary.OPENLOOKENG_CLIENT_ERROR;
+import static 
org.apache.linkis.engineplugin.openlookeng.errorcode.OpenLooKengErrorCodeSummary.OPENLOOKENG_STATUS_ERROR;
 
 public class OpenLooKengEngineConnExecutor extends 
ConcurrentComputationExecutor {
 
@@ -375,10 +377,11 @@ public class OpenLooKengEngineConnExecutor extends 
ConcurrentComputationExecutor
     } else if (statement.isClientAborted()) {
       LOG.warn("openlookeng statement is killed.");
     } else if (statement.isClientError()) {
-      throw new OpenLooKengClientException(60001, "openlookeng client error.");
+      throw new OpenLooKengClientException(
+          OPENLOOKENG_CLIENT_ERROR.getErrorCode(), 
OPENLOOKENG_CLIENT_ERROR.getErrorDesc());
     } else {
       throw new OpenLooKengStateInvalidException(
-          60002, "openlookeng status error. Statement is not finished.");
+          OPENLOOKENG_STATUS_ERROR.getErrorCode(), 
OPENLOOKENG_STATUS_ERROR.getErrorDesc());
     }
     return null;
   }
diff --git 
a/linkis-engineconn-plugins/openlookeng/src/test/java/org/apache/linkis/engineplugin/openlookeng/errorcode/OpenLooKengErrorCodeSummaryTest.java
 
b/linkis-engineconn-plugins/openlookeng/src/test/java/org/apache/linkis/engineplugin/openlookeng/errorcode/OpenLooKengErrorCodeSummaryTest.java
new file mode 100644
index 000000000..a76a5e99d
--- /dev/null
+++ 
b/linkis-engineconn-plugins/openlookeng/src/test/java/org/apache/linkis/engineplugin/openlookeng/errorcode/OpenLooKengErrorCodeSummaryTest.java
@@ -0,0 +1,119 @@
+/*
+ * 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.openlookeng.errorcode;
+
+import org.junit.jupiter.api.Test;
+
+import static 
org.apache.linkis.engineplugin.openlookeng.errorcode.OpenLooKengErrorCodeSummary.OPENLOOKENG_CLIENT_ERROR;
+import static 
org.apache.linkis.engineplugin.openlookeng.errorcode.OpenLooKengErrorCodeSummary.OPENLOOKENG_STATUS_ERROR;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+public class OpenLooKengErrorCodeSummaryTest {
+  @Test
+  void testGetErrorCode() {
+    assertEquals(26030, OPENLOOKENG_CLIENT_ERROR.getErrorCode());
+    assertEquals(26031, OPENLOOKENG_STATUS_ERROR.getErrorCode());
+  }
+
+  @Test
+  void testSetErrorCode() {
+    OPENLOOKENG_CLIENT_ERROR.setErrorCode(1);
+    assertEquals(1, OPENLOOKENG_CLIENT_ERROR.getErrorCode());
+    OPENLOOKENG_CLIENT_ERROR.setErrorCode(26030);
+    assertEquals(26030, OPENLOOKENG_CLIENT_ERROR.getErrorCode());
+
+    OPENLOOKENG_STATUS_ERROR.setErrorCode(1);
+    assertEquals(1, OPENLOOKENG_STATUS_ERROR.getErrorCode());
+    OPENLOOKENG_STATUS_ERROR.setErrorCode(26031);
+    assertEquals(26031, OPENLOOKENG_STATUS_ERROR.getErrorCode());
+  }
+
+  @Test
+  void testGetErrorDesc() {
+    assertEquals(
+        "openlookeng client error(openlookeng客户端异常)", 
OPENLOOKENG_CLIENT_ERROR.getErrorDesc());
+    assertEquals(
+        "openlookeng status error,Statement is not finished(openlookeng状态异常, 
查询语句未完成)",
+        OPENLOOKENG_STATUS_ERROR.getErrorDesc());
+  }
+
+  @Test
+  void testSetErrorDesc() {
+    OPENLOOKENG_CLIENT_ERROR.setErrorDesc("test");
+    assertEquals("test", OPENLOOKENG_CLIENT_ERROR.getErrorDesc());
+    OPENLOOKENG_CLIENT_ERROR.setErrorDesc("openlookeng client 
error(openlookeng客户端异常)");
+    assertEquals(
+        "openlookeng client error(openlookeng客户端异常)", 
OPENLOOKENG_CLIENT_ERROR.getErrorDesc());
+
+    OPENLOOKENG_STATUS_ERROR.setErrorDesc("test");
+    assertEquals("test", OPENLOOKENG_STATUS_ERROR.getErrorDesc());
+    OPENLOOKENG_STATUS_ERROR.setErrorDesc(
+        "openlookeng status error,Statement is not finished(openlookeng状态异常, 
查询语句未完成)");
+    assertEquals(
+        "openlookeng status error,Statement is not finished(openlookeng状态异常, 
查询语句未完成)",
+        OPENLOOKENG_STATUS_ERROR.getErrorDesc());
+  }
+
+  @Test
+  void testGetComment() {
+    assertEquals(
+        "openlookeng client is abnormal due to some circumstances(openlookeng 
client由于某些情况异常)",
+        OPENLOOKENG_CLIENT_ERROR.getComment());
+    assertEquals(
+        "The status of openlookeng is abnormal, and the query statement cannot 
be executed and ended(openlookeng状态出现异常,查询语句无法执行结束)",
+        OPENLOOKENG_STATUS_ERROR.getComment());
+  }
+
+  @Test
+  void testSetComment() {
+    OPENLOOKENG_CLIENT_ERROR.setComment("test");
+    assertEquals("test", OPENLOOKENG_CLIENT_ERROR.getComment());
+    OPENLOOKENG_CLIENT_ERROR.setComment(
+        "openlookeng client is abnormal due to some circumstances(openlookeng 
client由于某些情况异常)");
+    assertEquals(
+        "openlookeng client is abnormal due to some circumstances(openlookeng 
client由于某些情况异常)",
+        OPENLOOKENG_CLIENT_ERROR.getComment());
+
+    OPENLOOKENG_STATUS_ERROR.setComment("test");
+    assertEquals("test", OPENLOOKENG_STATUS_ERROR.getComment());
+    OPENLOOKENG_STATUS_ERROR.setComment(
+        "The status of openlookeng is abnormal, and the query statement cannot 
be executed and ended(openlookeng状态出现异常,查询语句无法执行结束)");
+    assertEquals(
+        "The status of openlookeng is abnormal, and the query statement cannot 
be executed and ended(openlookeng状态出现异常,查询语句无法执行结束)",
+        OPENLOOKENG_STATUS_ERROR.getComment());
+  }
+
+  @Test
+  void testGetModule() {
+    assertEquals("jdbcEngineConnExecutor", 
OPENLOOKENG_CLIENT_ERROR.getModule());
+    assertEquals("jdbcEngineConnExecutor", 
OPENLOOKENG_STATUS_ERROR.getModule());
+  }
+
+  @Test
+  void testSetModule() {
+    OPENLOOKENG_CLIENT_ERROR.setModule("test");
+    assertEquals("test", OPENLOOKENG_CLIENT_ERROR.getModule());
+    OPENLOOKENG_CLIENT_ERROR.setModule("jdbcEngineConnExecutor");
+    assertEquals("jdbcEngineConnExecutor", 
OPENLOOKENG_CLIENT_ERROR.getModule());
+
+    OPENLOOKENG_STATUS_ERROR.setModule("test");
+    assertEquals("test", OPENLOOKENG_STATUS_ERROR.getModule());
+    OPENLOOKENG_STATUS_ERROR.setModule("jdbcEngineConnExecutor");
+    assertEquals("jdbcEngineConnExecutor", 
OPENLOOKENG_STATUS_ERROR.getModule());
+  }
+}


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

Reply via email to