未验证 提交 1dc838eb 编写于 作者: H He Wang 提交者: GitHub

use safeTimestamp (#48)

上级 444e62ed
...@@ -137,7 +137,12 @@ public class ObReaderConfig extends AbstractConnectionConfig { ...@@ -137,7 +137,12 @@ public class ObReaderConfig extends AbstractConnectionConfig {
@Override @Override
public void updateCheckpoint(String checkpoint) { public void updateCheckpoint(String checkpoint) {
try { try {
startTimestamp.set(Long.parseLong(checkpoint)); long timestamp = Long.parseLong(checkpoint);
if (timestamp < 0) {
throw new IllegalArgumentException(
"update checkpoint with invalid value: " + checkpoint);
}
startTimestamp.set(timestamp);
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
// do nothing // do nothing
} }
......
...@@ -331,10 +331,14 @@ public class ClientHandler extends ChannelInboundHandlerAdapter { ...@@ -331,10 +331,14 @@ public class ClientHandler extends ChannelInboundHandlerAdapter {
throw new LogProxyClientException(ErrorCode.E_PARSE, e); throw new LogProxyClientException(ErrorCode.E_PARSE, e);
} }
if (logger.isTraceEnabled()) {
logger.trace("Log message: {}", logMessage);
}
while (true) { while (true) {
try { try {
recordQueue.put(new StreamContext.TransferPacket(logMessage)); recordQueue.put(new StreamContext.TransferPacket(logMessage));
stream.setCheckpointString(logMessage.getTimestamp()); stream.setCheckpointString(logMessage.getSafeTimestamp());
break; break;
} catch (InterruptedException e) { } catch (InterruptedException e) {
// do nothing // do nothing
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册