com.alibaba.otter.canal.protocol.CanalEntry.EventType Java Examples

The following examples show how to use com.alibaba.otter.canal.protocol.CanalEntry.EventType. 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 6 votes vote down vote up
private Entry parseGTIDLogEvent(GtidLogEvent logEvent) {
    LogHeader logHeader = logEvent.getHeader();
    Pair.Builder builder = Pair.newBuilder();
    builder.setKey("gtid");
    builder.setValue(logEvent.getGtidStr());

    if (logEvent.getLastCommitted() != null) {
        builder.setKey("lastCommitted");
        builder.setValue(String.valueOf(logEvent.getLastCommitted()));
        builder.setKey("sequenceNumber");
        builder.setValue(String.valueOf(logEvent.getSequenceNumber()));
    }

    Header header = createHeader(logHeader, "", "", EventType.GTID);
    return createEntry(header, EntryType.GTIDLOG, builder.build().toByteString());
}
 
Example #2
Source File: MysqlWrapperDefaultHandler.java    From DBus with Apache License 2.0 6 votes vote down vote up
/**
 * 创建DBusMessageBuilder对象,同时生成ums schema
 */
private DbusMessageBuilder createBuilderWithSchema(MetaVersion version, MessageEntry msgEntry) {
    DbusMessageBuilder builder = new DbusMessageBuilder();
    String namespace;
    if (outputTablePartition()) {
        namespace = builder.buildNameSpace(Utils.getDataSourceNamespace(),
                msgEntry.getEntryHeader().getSchemaName(), msgEntry.getEntryHeader().getTableName(),
                version.getVersion(), msgEntry.getEntryHeader().getPartitionTableName());
    } else {
        namespace = builder.buildNameSpace(Utils.getDataSourceNamespace(),
                msgEntry.getEntryHeader().getSchemaName(), msgEntry.getEntryHeader().getTableName(),
                version.getVersion());
    }
    builder.build(DbusMessage.ProtocolType.DATA_INCREMENT_DATA, namespace, table.getBatchId());
    EventType eventType = msgEntry.getEntryHeader().getOperType();
    RowData rowData = msgEntry.getMsgColumn().getRowDataLst().get(0);
    List<Column> columns = Support.getFinalColumns(eventType, rowData);
    for (Column column : columns) {
        String colType = Support.getColumnType(column);
        // 这里避免,源端表中包含ums_id_/ums_ts_等字段
        if (Support.isSupported(colType) && !builder.getMessage().containsFiled(column.getName())) {
            builder.appendSchema(column.getName(), DataType.convertMysqlDataType(colType), true);
        }
    }
    return builder;
}
 
Example #3
Source File: LogEventConvert.java    From DBus with Apache License 2.0 6 votes vote down vote up
private Header.Builder createHeaderBuilder(String binlogFile, LogHeader logHeader, String schemaName, String tableName,
                                           EventType eventType) {
    // header会做信息冗余,方便以后做检索或者过滤
    Header.Builder headerBuilder = Header.newBuilder();
    headerBuilder.setVersion(version);
    headerBuilder.setLogfileName(binlogFile);
    headerBuilder.setLogfileOffset(logHeader.getLogPos() - logHeader.getEventLen());
    headerBuilder.setServerId(logHeader.getServerId());
    headerBuilder.setServerenCode(UTF_8);// 经过java输出后所有的编码为unicode
    headerBuilder.setExecuteTime(logHeader.getWhen() * 1000L);
    headerBuilder.setSourceType(Type.MYSQL);
    if (eventType != null) {
        headerBuilder.setEventType(eventType);
    }
    if (schemaName != null) {
        headerBuilder.setSchemaName(schemaName);
    }
    if (tableName != null) {
        headerBuilder.setTableName(tableName);
    }
    headerBuilder.setEventLength(logHeader.getEventLen());
    return headerBuilder;
}
 
Example #4
Source File: LogEventConvert_old.java    From DBus with Apache License 2.0 6 votes vote down vote up
private Header createHeader(String binlogFile, LogHeader logHeader, String schemaName, String tableName,
                            EventType eventType) {
    // header������Ϣ����,�����Ժ����������߹���
    Header.Builder headerBuilder = Header.newBuilder();
    headerBuilder.setVersion(version);
    headerBuilder.setLogfileName(binlogFile);
    headerBuilder.setLogfileOffset(logHeader.getLogPos() - logHeader.getEventLen());
    headerBuilder.setServerId(logHeader.getServerId());
    headerBuilder.setServerenCode(UTF_8);// ����java��������еı���Ϊunicode
    headerBuilder.setExecuteTime(logHeader.getWhen() * 1000L);
    headerBuilder.setSourceType(Type.MYSQL);
    if (eventType != null) {
        headerBuilder.setEventType(eventType);
    }
    if (schemaName != null) {
        headerBuilder.setSchemaName(schemaName);
    }
    if (tableName != null) {
        headerBuilder.setTableName(tableName);
    }
    headerBuilder.setEventLength(logHeader.getEventLen());
    return headerBuilder.build();
}
 
Example #5
Source File: LogEventConvert.java    From DBus with Apache License 2.0 6 votes vote down vote up
private Header.Builder createHeaderBuilder(String binlogFile, LogHeader logHeader, String schemaName, String tableName,
                                           EventType eventType) {
     // header会做信息冗余,方便以后做检索或者过滤
    Header.Builder headerBuilder = Header.newBuilder();
    headerBuilder.setVersion(version);
    headerBuilder.setLogfileName(binlogFile);
    headerBuilder.setLogfileOffset(logHeader.getLogPos() - logHeader.getEventLen());
    headerBuilder.setServerId(logHeader.getServerId());
    headerBuilder.setServerenCode(UTF_8);// 经过java输出后所有的编码为unicode
    headerBuilder.setExecuteTime(logHeader.getWhen() * 1000L);
    headerBuilder.setSourceType(Type.MYSQL);
    if (eventType != null) {
        headerBuilder.setEventType(eventType);
    }
    if (schemaName != null) {
        headerBuilder.setSchemaName(schemaName);
    }
    if (tableName != null) {
        headerBuilder.setTableName(tableName);
    }
    headerBuilder.setEventLength(logHeader.getEventLen());

    return headerBuilder;
}
 
Example #6
Source File: CanalScheduling.java    From canal_mysql_elasticsearch_sync with Apache License 2.0 6 votes vote down vote up
private void publishCanalEvent(Entry entry) {
    EventType eventType = entry.getHeader().getEventType();
    switch (eventType) {
        case INSERT:
            applicationContext.publishEvent(new InsertAbstractCanalEvent(entry));
            break;
        case UPDATE:
            applicationContext.publishEvent(new UpdateAbstractCanalEvent(entry));
            break;
        case DELETE:
            applicationContext.publishEvent(new DeleteAbstractCanalEvent(entry));
            break;
        default:
            break;
    }
}
 
Example #7
Source File: LogEventConvert.java    From canal with Apache License 2.0 6 votes vote down vote up
private Entry parseGTIDLogEvent(GtidLogEvent logEvent) {
    LogHeader logHeader = logEvent.getHeader();
    Pair.Builder builder = Pair.newBuilder();
    builder.setKey("gtid");
    builder.setValue(logEvent.getGtidStr());

    if (logEvent.getLastCommitted() != null) {
        builder.setKey("lastCommitted");
        builder.setValue(String.valueOf(logEvent.getLastCommitted()));
        builder.setKey("sequenceNumber");
        builder.setValue(String.valueOf(logEvent.getSequenceNumber()));
    }

    Header header = createHeader(logHeader, "", "", EventType.GTID);
    return createEntry(header, EntryType.GTIDLOG, builder.build().toByteString());
}
 
Example #8
Source File: LogEventConvert.java    From canal with Apache License 2.0 5 votes vote down vote up
private Entry buildQueryEntry(String queryString, LogHeader logHeader, String tableName) {
    Header header = createHeader(logHeader, "", tableName, EventType.QUERY);
    RowChange.Builder rowChangeBuider = RowChange.newBuilder();
    rowChangeBuider.setSql(queryString);
    rowChangeBuider.setEventType(EventType.QUERY);
    return createEntry(header, EntryType.ROWDATA, rowChangeBuider.build().toByteString());
}
 
Example #9
Source File: LogEventConvert.java    From canal with Apache License 2.0 5 votes vote down vote up
private Entry parseHeartbeatLogEvent(HeartbeatLogEvent logEvent) {
    Header.Builder headerBuilder = Header.newBuilder();
    headerBuilder.setEventType(EventType.MHEARTBEAT);
    Entry.Builder entryBuilder = Entry.newBuilder();
    entryBuilder.setHeader(headerBuilder.build());
    entryBuilder.setEntryType(EntryType.HEARTBEAT);
    return entryBuilder.build();
}
 
Example #10
Source File: LogEventConvert.java    From canal with Apache License 2.0 5 votes vote down vote up
private Entry buildQueryEntry(String queryString, LogHeader logHeader) {
    Header header = createHeader(logHeader, "", "", EventType.QUERY);
    RowChange.Builder rowChangeBuider = RowChange.newBuilder();
    rowChangeBuider.setSql(queryString);
    rowChangeBuider.setEventType(EventType.QUERY);
    return createEntry(header, EntryType.ROWDATA, rowChangeBuider.build().toByteString());
}
 
Example #11
Source File: EventTransactionBuffer.java    From canal with Apache License 2.0 5 votes vote down vote up
public void add(CanalEntry.Entry entry) throws InterruptedException {
    switch (entry.getEntryType()) {
        case TRANSACTIONBEGIN:
            flush();// 刷新上一次的数据
            put(entry);
            break;
        case TRANSACTIONEND:
            put(entry);
            flush();
            break;
        case ROWDATA:
            put(entry);
            // 针对非DML的数据,直接输出,不进行buffer控制
            EventType eventType = entry.getHeader().getEventType();
            if (eventType != null && !isDml(eventType)) {
                flush();
            }
            break;
        case HEARTBEAT:
            // master过来的heartbeat,说明binlog已经读完了,是idle状态
            put(entry);
            flush();
            break;
        default:
            break;
    }
}
 
Example #12
Source File: LogEventConvert.java    From DBus with Apache License 2.0 5 votes vote down vote up
private Entry buildQueryEntry(String queryString, LogHeader logHeader) {
    Header header = createHeader(binlogFileName, logHeader, "", "", EventType.QUERY);
    RowChange.Builder rowChangeBuider = RowChange.newBuilder();
    rowChangeBuider.setSql(queryString);
    rowChangeBuider.setEventType(EventType.QUERY);
    return createEntry(header, EntryType.ROWDATA, rowChangeBuider.build().toByteString());
}
 
Example #13
Source File: DruidDdlParserTest.java    From canal with Apache License 2.0 5 votes vote down vote up
@Test
public void testAlert() {
    String queryString = "alter table retl_mark drop index emp_name";
    DdlResult result = DruidDdlParser.parse(queryString, "retl").get(0);
    Assert.assertNotNull(result);
    Assert.assertEquals("retl_mark", result.getTableName());

    queryString = "alter table retl.retl_mark drop index emp_name";
    result = DruidDdlParser.parse(queryString, "retl").get(0);
    Assert.assertNotNull(result);
    Assert.assertEquals("retl_mark", result.getTableName());

    queryString = "alter table \n retl.`retl_mark` drop index emp_name;";
    result = DruidDdlParser.parse(queryString, "retl").get(0);
    Assert.assertNotNull(result);
    Assert.assertEquals("retl_mark", result.getTableName());

    queryString = "alter table retl.retl_mark drop index emp_name , add index emp_name(id)";
    result = DruidDdlParser.parse(queryString, "retl").get(0);
    Assert.assertNotNull(result);
    Assert.assertEquals("retl_mark", result.getTableName());
    Assert.assertEquals(EventType.DINDEX, result.getType());

    result = DruidDdlParser.parse(queryString, "retl").get(1);
    Assert.assertNotNull(result);
    Assert.assertEquals("retl_mark", result.getTableName());
    Assert.assertEquals(EventType.CINDEX, result.getType());
}
 
Example #14
Source File: LogEventConvert_old.java    From DBus with Apache License 2.0 5 votes vote down vote up
private Entry buildQueryEntry(String queryString, LogHeader logHeader) {
    Header header = createHeader(binlogFileName, logHeader, "", "", EventType.QUERY);
    RowChange.Builder rowChangeBuider = RowChange.newBuilder();
    rowChangeBuider.setSql(queryString);
    rowChangeBuider.setEventType(EventType.QUERY);
    return createEntry(header, EntryType.ROWDATA, rowChangeBuider.build().toByteString());
}
 
Example #15
Source File: DdlResultTest.java    From canal with Apache License 2.0 5 votes vote down vote up
@Test
public void getTypeOutputNull() {

  // Arrange
  final DdlResult objectUnderTest = new DdlResult();

  // Act
  final EventType actual = objectUnderTest.getType();

  // Assert result
  Assert.assertNull(actual);
}
 
Example #16
Source File: LogEventConvert.java    From canal-1.1.3 with Apache License 2.0 5 votes vote down vote up
private Entry parseHeartbeatLogEvent(HeartbeatLogEvent logEvent) {
    Header.Builder headerBuilder = Header.newBuilder();
    headerBuilder.setEventType(EventType.MHEARTBEAT);
    Entry.Builder entryBuilder = Entry.newBuilder();
    entryBuilder.setHeader(headerBuilder.build());
    entryBuilder.setEntryType(EntryType.HEARTBEAT);
    return entryBuilder.build();
}
 
Example #17
Source File: LogEventConvert.java    From DBus with Apache License 2.0 5 votes vote down vote up
private Entry buildQueryEntry(String queryString, LogHeader logHeader) {
    Header header = createHeader(binlogFileName, logHeader, "", "", EventType.QUERY);
    RowChange.Builder rowChangeBuider = RowChange.newBuilder();
    rowChangeBuider.setSql(queryString);
    rowChangeBuider.setEventType(EventType.QUERY);
    return createEntry(header, EntryType.ROWDATA, rowChangeBuider.build().toByteString());
}
 
Example #18
Source File: Support.java    From DBus with Apache License 2.0 5 votes vote down vote up
public static List<Column> getFinalColumns(EventType type, RowData rowData) {
    List<Column> Columns = null;
    if (type == EventType.INSERT || type == EventType.UPDATE) {
        Columns = rowData.getAfterColumnsList();
    } else if (type == EventType.DELETE) {
        Columns = rowData.getBeforeColumnsList();
    }
    return Columns;
}
 
Example #19
Source File: EventTransactionBuffer.java    From canal-1.1.3 with Apache License 2.0 5 votes vote down vote up
public void add(CanalEntry.Entry entry) throws InterruptedException {
    switch (entry.getEntryType()) {
        case TRANSACTIONBEGIN:
            flush();// 刷新上一次的数据
            put(entry);
            break;
        case TRANSACTIONEND:
            put(entry);
            flush();
            break;
        case ROWDATA:
            put(entry);
            // 针对非DML的数据,直接输出,不进行buffer控制
            EventType eventType = entry.getHeader().getEventType();
            if (eventType != null && !isDml(eventType)) {
                flush();
            }
            break;
        case HEARTBEAT:
            // master过来的heartbeat,说明binlog已经读完了,是idle状态
            put(entry);
            flush();
            break;
        default:
            break;
    }
}
 
Example #20
Source File: LogEventConvert.java    From canal-1.1.3 with Apache License 2.0 5 votes vote down vote up
private Entry buildQueryEntry(String queryString, LogHeader logHeader, String tableName) {
    Header header = createHeader(logHeader, "", tableName, EventType.QUERY);
    RowChange.Builder rowChangeBuider = RowChange.newBuilder();
    rowChangeBuider.setSql(queryString);
    rowChangeBuider.setEventType(EventType.QUERY);
    return createEntry(header, EntryType.ROWDATA, rowChangeBuider.build().toByteString());
}
 
Example #21
Source File: DruidDdlParserTest.java    From canal-1.1.3 with Apache License 2.0 5 votes vote down vote up
@Test
public void testAlert() {
    String queryString = "alter table retl_mark drop index emp_name";
    DdlResult result = DruidDdlParser.parse(queryString, "retl").get(0);
    Assert.assertNotNull(result);
    Assert.assertEquals("retl_mark", result.getTableName());

    queryString = "alter table retl.retl_mark drop index emp_name";
    result = DruidDdlParser.parse(queryString, "retl").get(0);
    Assert.assertNotNull(result);
    Assert.assertEquals("retl_mark", result.getTableName());

    queryString = "alter table \n retl.`retl_mark` drop index emp_name;";
    result = DruidDdlParser.parse(queryString, "retl").get(0);
    Assert.assertNotNull(result);
    Assert.assertEquals("retl_mark", result.getTableName());

    queryString = "alter table retl.retl_mark drop index emp_name , add index emp_name(id)";
    result = DruidDdlParser.parse(queryString, "retl").get(0);
    Assert.assertNotNull(result);
    Assert.assertEquals("retl_mark", result.getTableName());
    Assert.assertEquals(EventType.DINDEX, result.getType());

    result = DruidDdlParser.parse(queryString, "retl").get(1);
    Assert.assertNotNull(result);
    Assert.assertEquals("retl_mark", result.getTableName());
    Assert.assertEquals(EventType.CINDEX, result.getType());
}
 
Example #22
Source File: LogEventConvert.java    From canal-1.1.3 with Apache License 2.0 5 votes vote down vote up
private Entry buildQueryEntry(String queryString, LogHeader logHeader) {
    Header header = createHeader(logHeader, "", "", EventType.QUERY);
    RowChange.Builder rowChangeBuider = RowChange.newBuilder();
    rowChangeBuider.setSql(queryString);
    rowChangeBuider.setEventType(EventType.QUERY);
    return createEntry(header, EntryType.ROWDATA, rowChangeBuider.build().toByteString());
}
 
Example #23
Source File: LogEventConvert.java    From canal with Apache License 2.0 4 votes vote down vote up
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 #24
Source File: SimpleDdlParser.java    From canal-1.1.3 with Apache License 2.0 4 votes vote down vote up
public static DdlResult parse(String queryString, String schmeaName) {
    queryString = removeComment(queryString); // 去除/* */的sql注释内容
    DdlResult result = parseDdl(queryString, schmeaName, ALERT_PATTERN, 2);
    if (result != null) {
        result.setType(EventType.ALTER);
        return result;
    }

    result = parseDdl(queryString, schmeaName, CREATE_PATTERN, 2);
    if (result != null) {
        result.setType(EventType.CREATE);
        return result;
    }

    result = parseDdl(queryString, schmeaName, DROP_PATTERN, 2);
    if (result != null) {
        result.setType(EventType.ERASE);
        return result;
    }

    result = parseDdl(queryString, schmeaName, TRUNCATE_PATTERN, 2);
    if (result != null) {
        result.setType(EventType.TRUNCATE);
        return result;
    }

    result = parseRename(queryString, schmeaName, RENAME_PATTERN);
    if (result != null) {
        result.setType(EventType.RENAME);

        String[] renameStrings = queryString.split(",");
        if (renameStrings.length > 1) {
            DdlResult lastResult = result;
            for (int i = 1; i < renameStrings.length; i++) {
                DdlResult ddlResult = parseRename(renameStrings[i], schmeaName, RENAME_REMNANT_PATTERN);
                ddlResult.setType(EventType.RENAME);
                lastResult.setRenameTableResult(ddlResult);
                lastResult = ddlResult;
            }
        }

        return result;
    }

    result = parseDdl(queryString, schmeaName, CREATE_INDEX_PATTERN, 5);
    if (result != null) {
        result.setType(EventType.CINDEX);
        return result;
    }

    result = parseDdl(queryString, schmeaName, DROP_INDEX_PATTERN, 2);
    if (result != null) {
        result.setType(EventType.DINDEX);
        return result;
    }

    result = new DdlResult(schmeaName);
    if (isDml(queryString, INSERT_PATTERN)) {
        result.setType(EventType.INSERT);
        return result;
    }

    if (isDml(queryString, UPDATE_PATTERN)) {
        result.setType(EventType.UPDATE);
        return result;
    }

    if (isDml(queryString, DELETE_PATTERN)) {
        result.setType(EventType.DELETE);
        return result;
    }

    result.setType(EventType.QUERY);
    return result;
}
 
Example #25
Source File: DdlResult.java    From canal-1.1.3 with Apache License 2.0 4 votes vote down vote up
public EventType getType() {
    return type;
}
 
Example #26
Source File: LogEventConvert.java    From canal-1.1.3 with Apache License 2.0 4 votes vote down vote up
private Header createHeader(LogHeader logHeader, String schemaName, String tableName, EventType eventType) {
    return createHeader(logHeader, schemaName, tableName, eventType, -1);
}
 
Example #27
Source File: LogEventConvert.java    From canal with Apache License 2.0 4 votes vote down vote up
private Header createHeader(LogHeader logHeader, String schemaName, String tableName, EventType eventType) {
    return createHeader(logHeader, schemaName, tableName, eventType, -1);
}
 
Example #28
Source File: DdlResult.java    From canal with Apache License 2.0 4 votes vote down vote up
public EventType getType() {
    return type;
}
 
Example #29
Source File: DdlResult.java    From canal with Apache License 2.0 4 votes vote down vote up
public void setType(EventType type) {
    this.type = type;
}
 
Example #30
Source File: SimpleDdlParser.java    From canal with Apache License 2.0 4 votes vote down vote up
public static DdlResult parse(String queryString, String schmeaName) {
    queryString = removeComment(queryString); // 去除/* */的sql注释内容
    DdlResult result = parseDdl(queryString, schmeaName, ALERT_PATTERN, 2);
    if (result != null) {
        result.setType(EventType.ALTER);
        return result;
    }

    result = parseDdl(queryString, schmeaName, CREATE_PATTERN, 2);
    if (result != null) {
        result.setType(EventType.CREATE);
        return result;
    }

    result = parseDdl(queryString, schmeaName, DROP_PATTERN, 2);
    if (result != null) {
        result.setType(EventType.ERASE);
        return result;
    }

    result = parseDdl(queryString, schmeaName, TRUNCATE_PATTERN, 2);
    if (result != null) {
        result.setType(EventType.TRUNCATE);
        return result;
    }

    result = parseRename(queryString, schmeaName, RENAME_PATTERN);
    if (result != null) {
        result.setType(EventType.RENAME);

        String[] renameStrings = queryString.split(",");
        if (renameStrings.length > 1) {
            DdlResult lastResult = result;
            for (int i = 1; i < renameStrings.length; i++) {
                DdlResult ddlResult = parseRename(renameStrings[i], schmeaName, RENAME_REMNANT_PATTERN);
                ddlResult.setType(EventType.RENAME);
                lastResult.setRenameTableResult(ddlResult);
                lastResult = ddlResult;
            }
        }

        return result;
    }

    result = parseDdl(queryString, schmeaName, CREATE_INDEX_PATTERN, 5);
    if (result != null) {
        result.setType(EventType.CINDEX);
        return result;
    }

    result = parseDdl(queryString, schmeaName, DROP_INDEX_PATTERN, 2);
    if (result != null) {
        result.setType(EventType.DINDEX);
        return result;
    }

    result = new DdlResult(schmeaName);
    if (isDml(queryString, INSERT_PATTERN)) {
        result.setType(EventType.INSERT);
        return result;
    }

    if (isDml(queryString, UPDATE_PATTERN)) {
        result.setType(EventType.UPDATE);
        return result;
    }

    if (isDml(queryString, DELETE_PATTERN)) {
        result.setType(EventType.DELETE);
        return result;
    }

    result.setType(EventType.QUERY);
    return result;
}