Java Code Examples for com.alibaba.otter.canal.protocol.CanalEntry.EventType#ERASE
The following examples show how to use
com.alibaba.otter.canal.protocol.CanalEntry.EventType#ERASE .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LogEventConvert.java From canal-1.1.3 with Apache License 2.0 | 4 votes |
private boolean processFilter(String queryString, DdlResult result) { String schemaName = result.getSchemaName(); String tableName = result.getTableName(); // fixed issue https://github.com/alibaba/canal/issues/58 // 更新下table meta cache if (tableMetaCache != null && (result.getType() == EventType.ALTER || result.getType() == EventType.ERASE || result.getType() == EventType.RENAME)) { // 对外返回,保证兼容,还是返回QUERY类型,这里暂不解析tableName,所以无法支持过滤 for (DdlResult renameResult = result; renameResult != null; renameResult = renameResult.getRenameTableResult()) { String schemaName0 = renameResult.getSchemaName(); String tableName0 = renameResult.getTableName(); if (StringUtils.isNotEmpty(tableName0)) { // 如果解析到了正确的表信息,则根据全名进行清除 tableMetaCache.clearTableMeta(schemaName0, tableName0); } else { // 如果无法解析正确的表信息,则根据schema进行清除 tableMetaCache.clearTableMetaWithSchemaName(schemaName0); } } } // fixed issue https://github.com/alibaba/canal/issues/58 if (result.getType() == EventType.ALTER || result.getType() == EventType.ERASE || result.getType() == EventType.CREATE || result.getType() == EventType.TRUNCATE || result.getType() == EventType.RENAME || result.getType() == EventType.CINDEX || result.getType() == EventType.DINDEX) { // 针对DDL类型 if (filterQueryDdl) { return true; } if (StringUtils.isEmpty(tableName) || (result.getType() == EventType.RENAME && StringUtils.isEmpty(result.getOriTableName()))) { // 如果解析不出tableName,记录一下日志,方便bugfix,目前直接抛出异常,中断解析 throw new CanalParseException("SimpleDdlParser process query failed. pls submit issue with this queryString: " + queryString + " , and DdlResult: " + result.toString()); // return null; } else { // check name filter String name = schemaName + "." + tableName; if (nameFilter != null && !nameFilter.filter(name)) { if (result.getType() == EventType.RENAME) { // rename校验只要源和目标满足一个就进行操作 if (nameFilter != null && !nameFilter.filter(result.getOriSchemaName() + "." + result.getOriTableName())) { return true; } } else { // 其他情况返回null return true; } } if (nameBlackFilter != null && nameBlackFilter.filter(name)) { if (result.getType() == EventType.RENAME) { // rename校验只要源和目标满足一个就进行操作 if (nameBlackFilter != null && nameBlackFilter.filter(result.getOriSchemaName() + "." + result.getOriTableName())) { return true; } } else { // 其他情况返回null return true; } } } } else if (result.getType() == EventType.INSERT || result.getType() == EventType.UPDATE || result.getType() == EventType.DELETE) { // 对外返回,保证兼容,还是返回QUERY类型,这里暂不解析tableName,所以无法支持过滤 if (filterQueryDml) { return true; } } else if (filterQueryDcl) { return true; } return false; }
Example 2
Source File: MemoryEventStoreWithBuffer.java From canal-1.1.3 with Apache License 2.0 | 4 votes |
private boolean isDdl(EventType type) { return type == EventType.ALTER || type == EventType.CREATE || type == EventType.ERASE || type == EventType.RENAME || type == EventType.TRUNCATE || type == EventType.CINDEX || type == EventType.DINDEX; }
Example 3
Source File: LogEventConvert.java From canal with Apache License 2.0 | 4 votes |
private boolean processFilter(String queryString, DdlResult result) { String schemaName = result.getSchemaName(); String tableName = result.getTableName(); // fixed issue https://github.com/alibaba/canal/issues/58 // 更新下table meta cache if (tableMetaCache != null && (result.getType() == EventType.ALTER || result.getType() == EventType.ERASE || result.getType() == EventType.RENAME)) { // 对外返回,保证兼容,还是返回QUERY类型,这里暂不解析tableName,所以无法支持过滤 for (DdlResult renameResult = result; renameResult != null; renameResult = renameResult.getRenameTableResult()) { String schemaName0 = renameResult.getSchemaName(); String tableName0 = renameResult.getTableName(); if (StringUtils.isNotEmpty(tableName0)) { // 如果解析到了正确的表信息,则根据全名进行清除 tableMetaCache.clearTableMeta(schemaName0, tableName0); } else { // 如果无法解析正确的表信息,则根据schema进行清除 tableMetaCache.clearTableMetaWithSchemaName(schemaName0); } } } // fixed issue https://github.com/alibaba/canal/issues/58 if (result.getType() == EventType.ALTER || result.getType() == EventType.ERASE || result.getType() == EventType.CREATE || result.getType() == EventType.TRUNCATE || result.getType() == EventType.RENAME || result.getType() == EventType.CINDEX || result.getType() == EventType.DINDEX) { // 针对DDL类型 if (filterQueryDdl) { return true; } if (StringUtils.isEmpty(tableName) || (result.getType() == EventType.RENAME && StringUtils.isEmpty(result.getOriTableName()))) { // 如果解析不出tableName,记录一下日志,方便bugfix,目前直接抛出异常,中断解析 throw new CanalParseException("SimpleDdlParser process query failed. pls submit issue with this queryString: " + queryString + " , and DdlResult: " + result.toString()); // return null; } else { // check name filter String name = schemaName + "." + tableName; if (nameFilter != null && !nameFilter.filter(name)) { if (result.getType() == EventType.RENAME) { // rename校验只要源和目标满足一个就进行操作 if (nameFilter != null && !nameFilter.filter(result.getOriSchemaName() + "." + result.getOriTableName())) { return true; } } else { // 其他情况返回null return true; } } if (nameBlackFilter != null && nameBlackFilter.filter(name)) { if (result.getType() == EventType.RENAME) { // rename校验只要源和目标满足一个就进行操作 if (nameBlackFilter != null && nameBlackFilter.filter(result.getOriSchemaName() + "." + result.getOriTableName())) { return true; } } else { // 其他情况返回null return true; } } } } else if (result.getType() == EventType.INSERT || result.getType() == EventType.UPDATE || result.getType() == EventType.DELETE) { // 对外返回,保证兼容,还是返回QUERY类型,这里暂不解析tableName,所以无法支持过滤 if (filterQueryDml) { return true; } } else if (filterQueryDcl) { return true; } return false; }
Example 4
Source File: MemoryEventStoreWithBuffer.java From canal with Apache License 2.0 | 4 votes |
private boolean isDdl(EventType type) { return type == EventType.ALTER || type == EventType.CREATE || type == EventType.ERASE || type == EventType.RENAME || type == EventType.TRUNCATE || type == EventType.CINDEX || type == EventType.DINDEX; }