Skip to content

Commit

Permalink
refactor: move error code from constants to enum (apache#4270)
Browse files Browse the repository at this point in the history
  • Loading branch information
jackxu2011 authored Feb 26, 2023
1 parent 0cef6ec commit 60b9e66
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 82 deletions.
14 changes: 3 additions & 11 deletions docs/errorcode/linkis-rpc-errorcode.md
Original file line number Diff line number Diff line change
Expand Up @@ -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|

Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,16 @@

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(
10003, "The corresponding anti-sequence class was not found:{0}(找不到对应的反序列类:{0})"),
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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)(
Expand All @@ -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
)

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down Expand Up @@ -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
)
}
Expand Down

This file was deleted.

0 comments on commit 60b9e66

Please sign in to comment.