未验证 提交 c853eba4 编写于 作者: S shimengfei 提交者: GitHub

change data parsing errors to retryable errors (#64)

* data parsing errors changed to retryable errors

* The client can continue to retry unless it exceeds the number of retries or actively exits
Co-authored-by: N花轻 <shimengfei.smf@oceanbase.com>
上级 d048654b
...@@ -225,7 +225,8 @@ public class ClientHandler extends ChannelInboundHandlerAdapter { ...@@ -225,7 +225,8 @@ public class ClientHandler extends ChannelInboundHandlerAdapter {
logger.error("LogProxy refused handshake request: {}", response.toString()); logger.error("LogProxy refused handshake request: {}", response.toString());
throw new LogProxyClientException( throw new LogProxyClientException(
ErrorCode.NO_AUTH, ErrorCode.NO_AUTH,
"LogProxy refused handshake request: " + response.toString()); "LogProxy refused handshake request: " + response.toString(),
true);
} else { } else {
dataNotEnough = true; dataNotEnough = true;
} }
......
...@@ -140,7 +140,9 @@ public class ClientHandlerV01 { ...@@ -140,7 +140,9 @@ public class ClientHandlerV01 {
resetState(); resetState();
logger.error("LogProxy refused handshake request: {}", message); logger.error("LogProxy refused handshake request: {}", message);
throw new LogProxyClientException( throw new LogProxyClientException(
ErrorCode.NO_AUTH, "LogProxy refused handshake request: " + message); ErrorCode.NO_AUTH,
"LogProxy refused handshake request: " + message,
true);
} else { } else {
dataNotEnough = true; dataNotEnough = true;
} }
......
...@@ -144,7 +144,8 @@ public class ClientStream { ...@@ -144,7 +144,8 @@ public class ClientStream {
triggerException( triggerException(
new LogProxyClientException( new LogProxyClientException(
ErrorCode.E_MAX_RECONNECT, ErrorCode.E_MAX_RECONNECT,
"Exceed max retry times")); "Exceed max retry times",
true));
break; break;
} }
if (state == ReconnectState.RETRY) { if (state == ReconnectState.RETRY) {
......
...@@ -10,7 +10,6 @@ See the Mulan PSL v2 for more details. */ ...@@ -10,7 +10,6 @@ See the Mulan PSL v2 for more details. */
package com.oceanbase.clogproxy.client.exception; package com.oceanbase.clogproxy.client.exception;
import com.oceanbase.clogproxy.client.enums.ErrorCode; import com.oceanbase.clogproxy.client.enums.ErrorCode;
/** /**
...@@ -22,6 +21,9 @@ public class LogProxyClientException extends RuntimeException { ...@@ -22,6 +21,9 @@ public class LogProxyClientException extends RuntimeException {
/** Error code. */ /** Error code. */
private ErrorCode code = ErrorCode.NONE; private ErrorCode code = ErrorCode.NONE;
/*The flag of whether the client should stop the stream.*/
private boolean needStop = false;
/** /**
* Constructor with error code and message. * Constructor with error code and message.
* *
...@@ -56,19 +58,54 @@ public class LogProxyClientException extends RuntimeException { ...@@ -56,19 +58,54 @@ public class LogProxyClientException extends RuntimeException {
this.code = code; this.code = code;
} }
/**
* Constructor with error code and message.
*
* @param code Error code.
* @param message Error message.
* @param needStop The flag of whether the client should stop the stream.
*/
public LogProxyClientException(ErrorCode code, String message, boolean needStop) {
super(message);
this.code = code;
this.needStop = needStop;
}
/**
* Constructor with error code and exception.
*
* @param code Error code.
* @param exception Exception instance.
* @param needStop The flag of whether the client should stop the stream.
*/
public LogProxyClientException(ErrorCode code, Exception exception, boolean needStop) {
super(exception.getMessage(), exception.getCause());
this.code = code;
this.needStop = needStop;
}
/**
* Constructor with error code, error message and cause.
*
* @param code Error code.
* @param message Error message.
* @param throwable Cause.
* @param needStop The flag of whether the client should stop the stream.
*/
public LogProxyClientException(
ErrorCode code, String message, Throwable throwable, boolean needStop) {
super(message, throwable);
this.code = code;
this.needStop = needStop;
}
/** /**
* Identify whether the client should stop the stream. * Identify whether the client should stop the stream.
* *
* @return The flag of whether the client should stop the stream. * @return The flag of whether the client should stop the stream.
*/ */
public boolean needStop() { public boolean needStop() {
return (code == ErrorCode.E_MAX_RECONNECT) return needStop;
|| (code == ErrorCode.E_PROTOCOL)
|| (code == ErrorCode.E_HEADER_TYPE)
|| (code == ErrorCode.NO_AUTH)
|| (code == ErrorCode.E_COMPRESS_TYPE)
|| (code == ErrorCode.E_LEN)
|| (code == ErrorCode.E_PARSE);
} }
/** /**
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册