Skip to content

Commit

Permalink
add javadoc, format codeStyle, optimization import
Browse files Browse the repository at this point in the history
  • Loading branch information
slievrly committed Jan 28, 2019
1 parent 35d2c5a commit b3d58e9
Show file tree
Hide file tree
Showing 249 changed files with 6,006 additions and 913 deletions.
20 changes: 17 additions & 3 deletions common/src/main/java/com/alibaba/fescar/common/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 = ",";


Expand Down
36 changes: 33 additions & 3 deletions common/src/main/java/com/alibaba/fescar/common/XID.java
Original file line number Diff line number Diff line change
Expand Up @@ -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:
*/
Expand All @@ -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;
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
*/
Expand All @@ -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失败", ""),

/**
Expand All @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
*/
Expand All @@ -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) {
Expand All @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,42 @@

package com.alibaba.fescar.common.exception;

/**
* The type Not support yet exception.
*/
public class NotSupportYetException extends RuntimeException {

/**
* Instantiates a new Not support yet exception.
*/
public NotSupportYetException() {
super();
}

/**
* Instantiates a new Not support yet exception.
*
* @param message the message
*/
public NotSupportYetException(String message) {
super(message);
}

/**
* Instantiates a new Not support yet exception.
*
* @param message the message
* @param cause the cause
*/
public NotSupportYetException(String message, Throwable cause) {
super(message, cause);
}

/**
* Instantiates a new Not support yet exception.
*
* @param cause the cause
*/
public NotSupportYetException(Throwable cause) {
super(cause);
}
Expand Down
Loading

0 comments on commit b3d58e9

Please sign in to comment.