forked from apache/incubator-seata
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add javadoc, format codeStyle, optimization import
- Loading branch information
Showing
249 changed files
with
6,006 additions
and
913 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,16 +17,30 @@ | |
package com.alibaba.fescar.common; | ||
|
||
/** | ||
* @Author: [email protected] | ||
* @Project: fescar-all | ||
* @DateTime: 2018/10/9 17:14 | ||
* The type Constants. | ||
* | ||
* @Author: jimin.jm @alibaba-inc.com | ||
* @Project: fescar -all | ||
* @DateTime: 2018 /10/9 17:14 | ||
* @FileName: Constants | ||
* @Description: | ||
*/ | ||
public class Constants { | ||
/** | ||
* The constant IP_PORT_SPLIT_CHAR. | ||
*/ | ||
public static final String IP_PORT_SPLIT_CHAR = ":"; | ||
/** | ||
* The constant CLIENT_ID_SPLIT_CHAR. | ||
*/ | ||
public static final String CLIENT_ID_SPLIT_CHAR = ":"; | ||
/** | ||
* The constant ENDPOINT_BEGIN_CHAR. | ||
*/ | ||
public static final String ENDPOINT_BEGIN_CHAR = "/"; | ||
/** | ||
* The constant DBKEYS_SPLIT_CHAR. | ||
*/ | ||
public static final String DBKEYS_SPLIT_CHAR = ","; | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,9 +17,11 @@ | |
package com.alibaba.fescar.common; | ||
|
||
/** | ||
* @Author: [email protected] | ||
* @Project: fescar-all | ||
* @DateTime: 2018/10/10 12:27 | ||
* The type Xid. | ||
* | ||
* @Author: jimin.jm @alibaba-inc.com | ||
* @Project: fescar -all | ||
* @DateTime: 2018 /10/10 12:27 | ||
* @FileName: XID | ||
* @Description: | ||
*/ | ||
|
@@ -29,18 +31,40 @@ public class XID { | |
|
||
private static String ipAddress; | ||
|
||
/** | ||
* Sets port. | ||
* | ||
* @param port the port | ||
*/ | ||
public static void setPort(int port) { | ||
XID.port = port; | ||
} | ||
|
||
/** | ||
* Sets ip address. | ||
* | ||
* @param ipAddress the ip address | ||
*/ | ||
public static void setIpAddress(String ipAddress) { | ||
XID.ipAddress = ipAddress; | ||
} | ||
|
||
/** | ||
* Generate xid string. | ||
* | ||
* @param tranId the tran id | ||
* @return the string | ||
*/ | ||
public static String generateXID(long tranId) { | ||
return ipAddress + ":" + port + ":" + tranId; | ||
} | ||
|
||
/** | ||
* Gets transaction id. | ||
* | ||
* @param xid the xid | ||
* @return the transaction id | ||
*/ | ||
public static long getTransactionId(String xid) { | ||
if (xid == null) { | ||
return -1; | ||
|
@@ -50,6 +74,12 @@ public static long getTransactionId(String xid) { | |
return Long.parseLong(xid.substring(idx + 1)); | ||
} | ||
|
||
/** | ||
* Gets server address. | ||
* | ||
* @param xid the xid | ||
* @return the server address | ||
*/ | ||
public static String getServerAddress(String xid) { | ||
if (xid == null) { | ||
return null; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,9 +17,11 @@ | |
package com.alibaba.fescar.common.exception; | ||
|
||
/** | ||
* @Author: [email protected] | ||
* @Project: fescar-all | ||
* @DateTime: 2018/10/9 15:37 | ||
* The enum Framework error code. | ||
* | ||
* @Author: jimin.jm @alibaba-inc.com | ||
* @Project: fescar -all | ||
* @DateTime: 2018 /10/9 15:37 | ||
* @FileName: FrameworkErrorCode | ||
* @Description: | ||
*/ | ||
|
@@ -28,28 +30,69 @@ public enum FrameworkErrorCode { | |
* 0001 ~ 0099 与配置相关的错误 | ||
*/ | ||
ThreadPoolFull("0004", "netty线程池满", "请在配置文件中调整线程数, corePoolSize 的值调大一些"), | ||
/** | ||
* The Init fescar client error. | ||
*/ | ||
InitFescarClientError("0008", "fescarAppName or fescarServerGroup is null", ""), | ||
/** | ||
* The Null rule error. | ||
*/ | ||
NullRuleError("0010", "fescar rules is null", ""), | ||
|
||
/** | ||
* 0101 ~ 0199 网络有关的错误,连接不上,断开,dispatch等 | ||
*/ | ||
NetConnect("0101", "无法连接服务器", "请检查fescar server是否启动,到fescar server的网络连接是否正常"), | ||
/** | ||
* The Net reg appname. | ||
*/ | ||
NetRegAppname("0102", "register client app name failed", "请检查fescar server是否启动,到fescar server的网络连接是否正常"), | ||
/** | ||
* The Net disconnect. | ||
*/ | ||
NetDisconnect("0103", "fescarConnection closed", "网络断开,请检查到对端(client 或fescar server)的网络连接"), | ||
/** | ||
* The Net dispatch. | ||
*/ | ||
NetDispatch("0104", "dispatch 错误", "网络处理错误,请检查到对端(client 或fescar server)的网络连接 "), | ||
/** | ||
* The Net on message. | ||
*/ | ||
NetOnMessage("0105", "on message 错误", "网络处理错误,请检查到对端(client 或fescar server)的网络连接 "), | ||
/** | ||
* Get channel error framework error code. | ||
*/ | ||
getChannelError("0106", "getChannelError", "getChannelError"), | ||
/** | ||
* Channel not writable framework error code. | ||
*/ | ||
ChannelNotWritable("0107", "ChannelNotWritable", "ChannelNotWritable"), | ||
/** | ||
* Send half message failed framework error code. | ||
*/ | ||
SendHalfMessageFailed("0108", "SendHalfMessageFailed", "SendHalfMessageFailed"), | ||
|
||
/** | ||
* Channel is not writable framework error code. | ||
*/ | ||
ChannelIsNotWritable("0109", "ChannelIsNotWritable", "ChannelIsNotWritable"), | ||
/** | ||
* No available service framework error code. | ||
*/ | ||
NoAvailableService("0110", "NoAvailableService", "NoAvailableService"), | ||
|
||
|
||
/** | ||
* Invalid configuration framework error code. | ||
*/ | ||
InvalidConfiguration("0201", "InvalidConfiguration", "InvalidConfiguration"), | ||
|
||
/** | ||
* Exception caught framework error code. | ||
*/ | ||
ExceptionCaught("0318", "异常", ""), | ||
/** | ||
* Regist rm framework error code. | ||
*/ | ||
RegistRM("0304", "注册RM失败", ""), | ||
|
||
/** | ||
|
@@ -58,8 +101,17 @@ public enum FrameworkErrorCode { | |
UnknownAppError("10000","unknown error","内部错误"), | ||
; | ||
|
||
/** | ||
* The Err code. | ||
*/ | ||
public String errCode; | ||
/** | ||
* The Err message. | ||
*/ | ||
public String errMessage; | ||
/** | ||
* The Err dispose. | ||
*/ | ||
public String errDispose; | ||
|
||
FrameworkErrorCode(String errCode, String errMessage, String errDispose) { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,9 +22,11 @@ | |
import org.slf4j.LoggerFactory; | ||
|
||
/** | ||
* @Author: [email protected] | ||
* @Project: fescar-all | ||
* @DateTime: 2018/10/9 15:34 | ||
* The type Framework exception. | ||
* | ||
* @Author: jimin.jm @alibaba-inc.com | ||
* @Project: fescar -all | ||
* @DateTime: 2018 /10/9 15:34 | ||
* @FileName: FrameworkException | ||
* @Description: | ||
*/ | ||
|
@@ -35,43 +37,98 @@ public class FrameworkException extends RuntimeException { | |
|
||
private final FrameworkErrorCode errcode; | ||
|
||
/** | ||
* Instantiates a new Framework exception. | ||
*/ | ||
public FrameworkException() { | ||
this(FrameworkErrorCode.UnknownAppError); | ||
} | ||
|
||
/** | ||
* Instantiates a new Framework exception. | ||
* | ||
* @param err the err | ||
*/ | ||
public FrameworkException(FrameworkErrorCode err) { | ||
this(err.errMessage, err); | ||
} | ||
|
||
/** | ||
* Instantiates a new Framework exception. | ||
* | ||
* @param msg the msg | ||
*/ | ||
public FrameworkException(String msg) { | ||
this(msg, FrameworkErrorCode.UnknownAppError); | ||
} | ||
|
||
/** | ||
* Instantiates a new Framework exception. | ||
* | ||
* @param msg the msg | ||
* @param errCode the err code | ||
*/ | ||
public FrameworkException(String msg, FrameworkErrorCode errCode) { | ||
this(null, msg, errCode); | ||
} | ||
|
||
/** | ||
* Instantiates a new Framework exception. | ||
* | ||
* @param cause the cause | ||
* @param msg the msg | ||
* @param errCode the err code | ||
*/ | ||
public FrameworkException(Throwable cause, String msg, FrameworkErrorCode errCode) { | ||
super(msg, cause); | ||
this.errcode = errCode; | ||
} | ||
|
||
/** | ||
* Instantiates a new Framework exception. | ||
* | ||
* @param th the th | ||
*/ | ||
public FrameworkException(Throwable th) { | ||
this(th, th.getMessage()); | ||
} | ||
|
||
/** | ||
* Instantiates a new Framework exception. | ||
* | ||
* @param th the th | ||
* @param msg the msg | ||
*/ | ||
public FrameworkException(Throwable th, String msg) { | ||
this(th, msg, FrameworkErrorCode.UnknownAppError); | ||
} | ||
|
||
/** | ||
* Gets errcode. | ||
* | ||
* @return the errcode | ||
*/ | ||
public FrameworkErrorCode getErrcode() { | ||
return errcode; | ||
} | ||
|
||
/** | ||
* Nested exception framework exception. | ||
* | ||
* @param e the e | ||
* @return the framework exception | ||
*/ | ||
public static FrameworkException nestedException(Throwable e) { | ||
return nestedException("", e); | ||
} | ||
|
||
/** | ||
* Nested exception framework exception. | ||
* | ||
* @param msg the msg | ||
* @param e the e | ||
* @return the framework exception | ||
*/ | ||
public static FrameworkException nestedException(String msg, Throwable e) { | ||
LOGGER.error(msg, e.getMessage(), e); | ||
if (e instanceof FrameworkException) { | ||
|
@@ -81,10 +138,23 @@ public static FrameworkException nestedException(String msg, Throwable e) { | |
return new FrameworkException(e, msg); | ||
} | ||
|
||
/** | ||
* Nested sql exception sql exception. | ||
* | ||
* @param e the e | ||
* @return the sql exception | ||
*/ | ||
public static SQLException nestedSQLException(Throwable e) { | ||
return nestedSQLException("", e); | ||
} | ||
|
||
/** | ||
* Nested sql exception sql exception. | ||
* | ||
* @param msg the msg | ||
* @param e the e | ||
* @return the sql exception | ||
*/ | ||
public static SQLException nestedSQLException(String msg, Throwable e) { | ||
LOGGER.error(msg, e.getMessage(), e); | ||
if (e instanceof SQLException) { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.