支持用户自定义的CanalAlarmHandler (#1736)

* 支持用户自定义的CanalAlarmHandler

* RowsLogEvent增加对TableMapLogEvent判空检查,防止NPE异常
This commit is contained in:
dataccs
2019-04-24 09:56:32 +08:00
committed by agapple
parent 2b738f4e04
commit 3165cb9640
6 changed files with 61 additions and 4 deletions

View File

@@ -2,6 +2,7 @@ package com.taobao.tddl.dbsync.binlog.event;
import java.util.BitSet;
import com.taobao.tddl.dbsync.binlog.exception.TableIdNotFoundException;
import com.taobao.tddl.dbsync.binlog.LogBuffer;
import com.taobao.tddl.dbsync.binlog.LogContext;
import com.taobao.tddl.dbsync.binlog.LogEvent;
@@ -179,6 +180,10 @@ public abstract class RowsLogEvent extends LogEvent {
public final void fillTable(LogContext context) {
table = context.getTable(tableId);
if (table == null) {
throw new TableIdNotFoundException("not found tableId:" + tableId);
}
// end of statement check:
if ((flags & RowsLogEvent.STMT_END_F) != 0) {
// Now is safe to clear ignored map (clear_tables will also

View File

@@ -0,0 +1,29 @@
package com.taobao.tddl.dbsync.binlog.exception;
import com.alibaba.otter.canal.common.CanalException;
public class TableIdNotFoundException extends CanalException {
private static final long serialVersionUID = -7288830284122672209L;
public TableIdNotFoundException(String errorCode){
super(errorCode);
}
public TableIdNotFoundException(String errorCode, Throwable cause){
super(errorCode, cause);
}
public TableIdNotFoundException(String errorCode, String errorDesc){
super(errorCode + ":" + errorDesc);
}
public TableIdNotFoundException(String errorCode, String errorDesc, Throwable cause){
super(errorCode + ":" + errorDesc, cause);
}
public TableIdNotFoundException(Throwable cause){
super(cause);
}
}