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

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


The following commit(s) were added to refs/heads/dev-1.3.2 by this push:
     new 60b9e66e6 refactor: move error code from constants to enum (#4270)
60b9e66e6 is described below

commit 60b9e66e65ea2025c3f4a5ced7ce30776cd8bdfd
Author: Jack Xu <[email protected]>
AuthorDate: Sun Feb 26 23:14:23 2023 +0800

    refactor: move error code from constants to enum (#4270)
---
 docs/errorcode/linkis-rpc-errorcode.md             | 14 ++------
 .../rpc/errorcode/LinkisRpcErrorCodeSummary.java   |  4 ++-
 .../org/apache/linkis/rpc/AsynRPCMessageBus.scala  |  6 ++--
 .../scala/org/apache/linkis/rpc/RPCMapCache.scala  |  1 -
 .../linkis/rpc/errorcode/RPCErrorConstants.scala   | 24 --------------
 .../apache/linkis/rpc/transform/RPCProduct.scala   |  7 ++--
 .../rpc/errorcode/RPCErrorConstantsTest.scala      | 38 ----------------------
 7 files changed, 12 insertions(+), 82 deletions(-)

diff --git a/docs/errorcode/linkis-rpc-errorcode.md 
b/docs/errorcode/linkis-rpc-errorcode.md
index f6608602d..cb9b25f87 100644
--- a/docs/errorcode/linkis-rpc-errorcode.md
+++ b/docs/errorcode/linkis-rpc-errorcode.md
@@ -3,21 +3,13 @@
 
 | 模块名(服务名) | 错误码  | 描述 | enumeration name(枚举)| Exception Class(类名)|
 | -------- | -------- | ----- |-----|-----|
-|linkis-rpc|10000|The service does not exist for the available 
Receiver.(服务不存在可用的Receiver.)|URL_ERROR|EngineConnManager|
+|linkis-rpc|10000|The service does not exist for the available 
Receiver.(服务不存在可用的Receiver.)|URL_ERROR|LinkisRpcErrorCodeSummary|
 |linkis-rpc|10000|method call 
failed:(方法调用失败:)|METHON_CALL_FAILED|LinkisRpcErrorCodeSummary|
 |linkis-rpc|10001|The transmitted bean is 
Null.(传输的bean为Null.|TRANSMITTED_BEAN_IS_NULL|LinkisRpcErrorCodeSummary|
 |linkis-rpc|10002|The timeout period is not 
set!(超时时间未设置!)|TIMEOUT_PERIOD|LinkisRpcErrorCodeSummary|
 |linkis-rpc|10003|The corresponding anti-sequence class $objectClass was not 
found:(找不到对应的反序列类:)|CORRESPONDING_NOT_FOUND|LinkisRpcErrorCodeSummary|
 |linkis-rpc|10004|The corresponding anti-sequence class:{0} failed to 
initialize(对应的反序列类:{0} 
初始化失败|CORRESPONDING_TO_INITIALIZE|LinkisRpcErrorCodeSummary|
-|linkis-rpc|10021|Failed to get user parameters! Reason: RPC request{0} 
Service 
failed!(获取用户参数失败!原因:RPC请求{0}服务失败!)|FETCH_MAPCACHE_ERROR|RPCErrorConstants|
 |linkis-rpc|10051|The instance {0} of application {1} does not exist.(应用程序{0} 
的实例{1} 不存在.)|APPLICATION_IS_NOT_EXISTS|LinkisRpcErrorCodeSummary|
-|linkis-rpc|10054|Asyn RPC Consumer Thread has stopped!(Asyn RPC Consumer 
线程已停止!)|RPC_INIT_ERROR|RPCErrorConstants|
-|linkis-rpc|15555| Asyn RPC Consumer Queue is full, please retry after some 
times.(Asyn RPC Consumer Queue 
已满,请稍后重试。)|RPC_RETRY_ERROR_CODE|DWCRPCRetryException|
-
-
-
-
-
-
-
+|linkis-rpc|10054|Asyn RPC Consumer Thread has stopped!(Asyn RPC Consumer 
线程已停止!)|RPC_INIT_ERROR|LinkisRpcErrorCodeSummary|
+|linkis-rpc|15555|Asyn RPC Consumer Queue is full, please retry after some 
times.(Asyn RPC Consumer Queue 
已满,请稍后重试。)|RPC_RETRY_ERROR_CODE|DWCRPCRetryException|
 
diff --git 
a/linkis-commons/linkis-rpc/src/main/java/org/apache/linkis/rpc/errorcode/LinkisRpcErrorCodeSummary.java
 
b/linkis-commons/linkis-rpc/src/main/java/org/apache/linkis/rpc/errorcode/LinkisRpcErrorCodeSummary.java
index 9014a2b19..3723ca145 100644
--- 
a/linkis-commons/linkis-rpc/src/main/java/org/apache/linkis/rpc/errorcode/LinkisRpcErrorCodeSummary.java
+++ 
b/linkis-commons/linkis-rpc/src/main/java/org/apache/linkis/rpc/errorcode/LinkisRpcErrorCodeSummary.java
@@ -21,6 +21,7 @@ import org.apache.linkis.common.errorcode.LinkisErrorCode;
 
 public enum LinkisRpcErrorCodeSummary implements LinkisErrorCode {
   METHOD_CALL_FAILED(10000, "method call failed:(方法调用失败:)"),
+  URL_ERROR(10000, "The service does not exist for the available 
Receiver.(服务不存在可用的Receiver.)"),
   TRANSMITTED_BEAN_IS_NULL(10001, "The transmitted bean is 
Null.(传输的bean为Null."),
   TIMEOUT_PERIOD(10002, "The timeout period is not set!(超时时间未设置!)"),
   CORRESPONDING_NOT_FOUND(
@@ -28,7 +29,8 @@ public enum LinkisRpcErrorCodeSummary implements 
LinkisErrorCode {
   CORRESPONDING_TO_INITIALIZE(
       10004, "The corresponding anti-sequence class:{0} failed to 
initialize(对应的反序列类:{0} 初始化失败)"),
   APPLICATION_IS_NOT_EXISTS(
-      10051, "The instance:{0} of application {1} does not exist(应用程序:{0} 
的实例:{1} 不存在).");
+      10051, "The instance:{0} of application {1} does not exist(应用程序:{0} 
的实例:{1} 不存在)."),
+  RPC_INIT_ERROR(10054, "Asyn RPC Consumer Thread has stopped!(Asyn RPC 
Consumer 线程已停止!)");
 
   /** 错误码 */
   private final int errorCode;
diff --git 
a/linkis-commons/linkis-rpc/src/main/scala/org/apache/linkis/rpc/AsynRPCMessageBus.scala
 
b/linkis-commons/linkis-rpc/src/main/scala/org/apache/linkis/rpc/AsynRPCMessageBus.scala
index 554c0c95b..61311f068 100644
--- 
a/linkis-commons/linkis-rpc/src/main/scala/org/apache/linkis/rpc/AsynRPCMessageBus.scala
+++ 
b/linkis-commons/linkis-rpc/src/main/scala/org/apache/linkis/rpc/AsynRPCMessageBus.scala
@@ -19,7 +19,7 @@ package org.apache.linkis.rpc
 
 import org.apache.linkis.common.ServiceInstance
 import org.apache.linkis.common.listener.{Event, EventListener, 
ListenerEventBus}
-import org.apache.linkis.rpc.errorcode.RPCErrorConstants
+import org.apache.linkis.rpc.errorcode.LinkisRpcErrorCodeSummary
 import org.apache.linkis.rpc.exception.{DWCRPCRetryException, 
RPCInitFailedException}
 
 class AsynRPCMessageBus(capacity: Int, busName: String)(
@@ -46,8 +46,8 @@ class AsynRPCMessageBus(capacity: Int, busName: String)(
     )
 
     override def onBusStopped(event: RPCMessageEvent): Unit = throw new 
RPCInitFailedException(
-      RPCErrorConstants.RPC_INIT_ERROR,
-      "Async RPC Consumer Thread has stopped!"
+      LinkisRpcErrorCodeSummary.RPC_INIT_ERROR.getErrorCode,
+      LinkisRpcErrorCodeSummary.RPC_INIT_ERROR.getErrorDesc
     )
 
   }
diff --git 
a/linkis-commons/linkis-rpc/src/main/scala/org/apache/linkis/rpc/RPCMapCache.scala
 
b/linkis-commons/linkis-rpc/src/main/scala/org/apache/linkis/rpc/RPCMapCache.scala
index 6ed67d5ce..9560ec67c 100644
--- 
a/linkis-commons/linkis-rpc/src/main/scala/org/apache/linkis/rpc/RPCMapCache.scala
+++ 
b/linkis-commons/linkis-rpc/src/main/scala/org/apache/linkis/rpc/RPCMapCache.scala
@@ -21,7 +21,6 @@ import org.apache.linkis.common.exception.ErrorException
 import org.apache.linkis.common.utils.Utils
 import 
org.apache.linkis.errorcode.LinkisModuleErrorCodeSummary.FETCH_MAPCACHE_ERROR
 import org.apache.linkis.protocol.CacheableProtocol
-import org.apache.linkis.rpc.errorcode.RPCErrorConstants
 import org.apache.linkis.server.exception.FetchMapCacheFailedException
 
 import java.text.MessageFormat
diff --git 
a/linkis-commons/linkis-rpc/src/main/scala/org/apache/linkis/rpc/errorcode/RPCErrorConstants.scala
 
b/linkis-commons/linkis-rpc/src/main/scala/org/apache/linkis/rpc/errorcode/RPCErrorConstants.scala
deleted file mode 100644
index d32068ac6..000000000
--- 
a/linkis-commons/linkis-rpc/src/main/scala/org/apache/linkis/rpc/errorcode/RPCErrorConstants.scala
+++ /dev/null
@@ -1,24 +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.rpc.errorcode
-
-object RPCErrorConstants {
-  val FETCH_MAPCACHE_ERROR = 10021
-  val RPC_INIT_ERROR = 10054
-  val URL_ERROR = 10000
-}
diff --git 
a/linkis-commons/linkis-rpc/src/main/scala/org/apache/linkis/rpc/transform/RPCProduct.scala
 
b/linkis-commons/linkis-rpc/src/main/scala/org/apache/linkis/rpc/transform/RPCProduct.scala
index 238e41dfd..a2b9ae95e 100644
--- 
a/linkis-commons/linkis-rpc/src/main/scala/org/apache/linkis/rpc/transform/RPCProduct.scala
+++ 
b/linkis-commons/linkis-rpc/src/main/scala/org/apache/linkis/rpc/transform/RPCProduct.scala
@@ -20,8 +20,8 @@ package org.apache.linkis.rpc.transform
 import org.apache.linkis.DataWorkCloudApplication
 import org.apache.linkis.common.utils.Logging
 import org.apache.linkis.protocol.message.RequestProtocol
+import org.apache.linkis.rpc.errorcode.LinkisRpcErrorCodeSummary
 import 
org.apache.linkis.rpc.errorcode.LinkisRpcErrorCodeSummary.TRANSMITTED_BEAN_IS_NULL
-import org.apache.linkis.rpc.errorcode.RPCErrorConstants
 import org.apache.linkis.rpc.exception.DWCURIException
 import org.apache.linkis.rpc.serializer.ProtostuffSerializeUtil
 import org.apache.linkis.server.{EXCEPTION_MSG, Message}
@@ -91,9 +91,8 @@ private[linkis] object RPCProduct extends Logging {
       message.data(
         EXCEPTION_MSG,
         new DWCURIException(
-          RPCErrorConstants.URL_ERROR,
-          "The service does not " +
-            "exist for the available Receiver.(服务不存在可用的Receiver.)"
+          LinkisRpcErrorCodeSummary.URL_ERROR.getErrorCode,
+          LinkisRpcErrorCodeSummary.URL_ERROR.getErrorDesc
         ).toMap
       )
     }
diff --git 
a/linkis-commons/linkis-rpc/src/test/scala/org/apache/linkis/rpc/errorcode/RPCErrorConstantsTest.scala
 
b/linkis-commons/linkis-rpc/src/test/scala/org/apache/linkis/rpc/errorcode/RPCErrorConstantsTest.scala
deleted file mode 100644
index 175287f6d..000000000
--- 
a/linkis-commons/linkis-rpc/src/test/scala/org/apache/linkis/rpc/errorcode/RPCErrorConstantsTest.scala
+++ /dev/null
@@ -1,38 +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.rpc.errorcode
-
-import org.junit.jupiter.api.{Assertions, DisplayName, Test}
-
-class RPCErrorConstantsTest {
-
-  @Test
-  @DisplayName("constTest")
-  def constTest(): Unit = {
-
-    val fetchmapcacheerror = RPCErrorConstants.FETCH_MAPCACHE_ERROR
-    val rpciniterror = RPCErrorConstants.RPC_INIT_ERROR
-    val urlerror = RPCErrorConstants.URL_ERROR
-
-    Assertions.assertTrue(10021 == fetchmapcacheerror.intValue())
-    Assertions.assertTrue(10054 == rpciniterror.intValue())
-    Assertions.assertTrue(10000 == urlerror.intValue())
-
-  }
-
-}


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

Reply via email to