• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Entry类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.alibaba.otter.canal.protocol.CanalEntry.Entry的典型用法代码示例。如果您正苦于以下问题:Java Entry类的具体用法?Java Entry怎么用?Java Entry使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Entry类属于com.alibaba.otter.canal.protocol.CanalEntry包,在下文中一共展示了Entry类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: buildEvent

import com.alibaba.otter.canal.protocol.CanalEntry.Entry; //导入依赖的package包/类
private Event buildEvent() {
    Event event = new Event();
    event.setLogIdentity(new LogIdentity());

    Header.Builder headBuilder = Header.newBuilder();
    headBuilder.setEventLength(1000L);
    headBuilder.setExecuteTime(new Date().getTime());
    headBuilder.setLogfileName("mysql-bin.000001");
    headBuilder.setLogfileOffset(1000L);
    headBuilder.setSchemaName("test");
    headBuilder.setTableName("ljh");

    Entry.Builder entryBuilder = Entry.newBuilder();
    entryBuilder.setHeader(headBuilder.build());
    entryBuilder.setEntryType(EntryType.ROWDATA);

    RowChange.Builder rowChangeBuilder = RowChange.newBuilder();
    RowData.Builder rowDataBuilder = RowData.newBuilder();
    rowChangeBuilder.addRowDatas(rowDataBuilder.build());

    entryBuilder.setStoreValue(rowChangeBuilder.build().toByteString());
    Entry entry = entryBuilder.build();
    event.setEntry(entry);
    return event;
}
 
开发者ID:luoyaogui,项目名称:otter-G,代码行数:26,代码来源:OtterDownStreamHandlerIntergration.java


示例2: publishCanalEvent

import com.alibaba.otter.canal.protocol.CanalEntry.Entry; //导入依赖的package包/类
private void publishCanalEvent(Entry entry) {
    EventType eventType = entry.getHeader().getEventType();
    switch (eventType) {
        case INSERT:
            applicationContext.publishEvent(new InsertCanalEvent(entry));
            break;
        case UPDATE:
            applicationContext.publishEvent(new UpdateCanalEvent(entry));
            break;
        case DELETE:
            applicationContext.publishEvent(new DeleteCanalEvent(entry));
            break;
        default:
            break;
    }
}
 
开发者ID:starcwang,项目名称:canal_mysql_elasticsearch_sync,代码行数:17,代码来源:CanalScheduling.java


示例3: onApplicationEvent

import com.alibaba.otter.canal.protocol.CanalEntry.Entry; //导入依赖的package包/类
@Override
public void onApplicationEvent(EVENT event) {
    Entry entry = event.getEntry();
    String database = entry.getHeader().getSchemaName();
    String table = entry.getHeader().getTableName();
    IndexTypeModel indexTypeModel = mappingService.getIndexType(new DatabaseTableModel(database, table));
    if (indexTypeModel == null) {
        return;
    }
    String index = indexTypeModel.getIndex();
    String type = indexTypeModel.getType();
    RowChange change;
    try {
        change = RowChange.parseFrom(entry.getStoreValue());
    } catch (InvalidProtocolBufferException e) {
        logger.error("canalEntry_parser_error,根据CanalEntry获取RowChange失败!", e);
        return;
    }
    change.getRowDatasList().forEach(rowData -> doSync(database, table, index, type, rowData));
}
 
开发者ID:starcwang,项目名称:canal_mysql_elasticsearch_sync,代码行数:21,代码来源:AbstractCanalListener.java


示例4: printSummary

import com.alibaba.otter.canal.protocol.CanalEntry.Entry; //导入依赖的package包/类
private void printSummary(Message message, long batchId, int size) {
    long memsize = 0;
    for (Entry entry : message.getEntries()) {
        memsize += entry.getHeader().getEventLength();
    }

    String startPosition = null;
    String endPosition = null;
    if (!CollectionUtils.isEmpty(message.getEntries())) {
        startPosition = buildPositionForDump(message.getEntries().get(0));
        endPosition = buildPositionForDump(message.getEntries().get(message.getEntries().size() - 1));
    }

    SimpleDateFormat format = new SimpleDateFormat(DATE_FORMAT);
    logger.info(context_format, new Object[] { batchId, size, memsize, format.format(new Date()), startPosition,
            endPosition });
}
 
开发者ID:alibaba,项目名称:canal,代码行数:18,代码来源:AbstractCanalClientTest.java


示例5: receiveMessages

import com.alibaba.otter.canal.protocol.CanalEntry.Entry; //导入依赖的package包/类
private Message receiveMessages() throws IOException {
    Packet p = Packet.parseFrom(readNextPacket());
    switch (p.getType()) {
        case MESSAGES: {
            if (!p.getCompression().equals(Compression.NONE)) {
                throw new CanalClientException("compression is not supported in this connector");
            }

            Messages messages = Messages.parseFrom(p.getBody());
            Message result = new Message(messages.getBatchId());
            for (ByteString byteString : messages.getMessagesList()) {
                result.addEntry(Entry.parseFrom(byteString));
            }
            return result;
        }
        case ACK: {
            Ack ack = Ack.parseFrom(p.getBody());
            throw new CanalClientException("something goes wrong with reason: " + ack.getErrorMessage());
        }
        default: {
            throw new CanalClientException("unexpected packet type: " + p.getType());
        }
    }
}
 
开发者ID:alibaba,项目名称:canal,代码行数:25,代码来源:SimpleCanalConnector.java


示例6: stop

import com.alibaba.otter.canal.protocol.CanalEntry.Entry; //导入依赖的package包/类
public void stop() {
    super.stop();
    for (Map.Entry<String, CanalInstance> entry : canalInstances.entrySet()) {
        try {
            CanalInstance instance = entry.getValue();
            if (instance.isStart()) {
                try {
                    String destination = entry.getKey();
                    MDC.put("destination", destination);
                    entry.getValue().stop();
                    logger.info("stop CanalInstances[{}] successfully", destination);
                } finally {
                    MDC.remove("destination");
                }
            }
        } catch (Exception e) {
            logger.error(String.format("stop CanalInstance[%s] has an error", entry.getKey()), e);
        }
    }
}
 
开发者ID:alibaba,项目名称:canal,代码行数:21,代码来源:CanalServerWithEmbedded.java


示例7: parseRowsQueryEvent

import com.alibaba.otter.canal.protocol.CanalEntry.Entry; //导入依赖的package包/类
private Entry parseRowsQueryEvent(RowsQueryLogEvent event) {
    if (filterQueryDml) {
        return null;
    }
    // mysql5.6支持,需要设置binlog-rows-query-log-events=1,可详细打印原始DML语句
    String queryString = null;
    try {
        queryString = new String(event.getRowsQuery().getBytes(ISO_8859_1), charset.name());
        String tableName = null;
        if (useDruidDdlFilter) {
            List<DdlResult> results = DruidDdlParser.parse(queryString, null);
            if (results.size() > 0) {
                tableName = results.get(0).getTableName();
            }
        }

        return buildQueryEntry(queryString, event.getHeader(), tableName);
    } catch (UnsupportedEncodingException e) {
        throw new CanalParseException(e);
    }
}
 
开发者ID:alibaba,项目名称:canal,代码行数:22,代码来源:LogEventConvert.java


示例8: AbstractEventParser

import com.alibaba.otter.canal.protocol.CanalEntry.Entry; //导入依赖的package包/类
public AbstractEventParser(){
    // 初始化一下
    transactionBuffer = new EventTransactionBuffer(new TransactionFlushCallback() {

        public void flush(List<CanalEntry.Entry> transaction) throws InterruptedException {
            boolean successed = consumeTheEventAndProfilingIfNecessary(transaction);
            if (!running) {
                return;
            }

            if (!successed) {
                throw new CanalParseException("consume failed!");
            }

            LogPosition position = buildLastTransactionPosition(transaction);
            if (position != null) { // 可能position为空
                logPositionManager.persistLogPosition(AbstractEventParser.this.destination, position);
            }
        }
    });
}
 
开发者ID:alibaba,项目名称:canal,代码行数:22,代码来源:AbstractEventParser.java


示例9: consumeTheEventAndProfilingIfNecessary

import com.alibaba.otter.canal.protocol.CanalEntry.Entry; //导入依赖的package包/类
protected boolean consumeTheEventAndProfilingIfNecessary(List<CanalEntry.Entry> entrys) throws CanalSinkException,
                                                                                       InterruptedException {
    long startTs = -1;
    boolean enabled = getProfilingEnabled();
    if (enabled) {
        startTs = System.currentTimeMillis();
    }

    boolean result = eventSink.sink(entrys, (runningInfo == null) ? null : runningInfo.getAddress(), destination);

    if (enabled) {
        this.processingInterval = System.currentTimeMillis() - startTs;
    }

    if (consumedEventCount.incrementAndGet() < 0) {
        consumedEventCount.set(0);
    }

    return result;
}
 
开发者ID:alibaba,项目名称:canal,代码行数:21,代码来源:AbstractEventParser.java


示例10: parseAndProfilingIfNecessary

import com.alibaba.otter.canal.protocol.CanalEntry.Entry; //导入依赖的package包/类
protected CanalEntry.Entry parseAndProfilingIfNecessary(EVENT bod, boolean isSeek) throws Exception {
    long startTs = -1;
    boolean enabled = getProfilingEnabled();
    if (enabled) {
        startTs = System.currentTimeMillis();
    }
    CanalEntry.Entry event = binlogParser.parse(bod, isSeek);
    if (enabled) {
        this.parsingInterval = System.currentTimeMillis() - startTs;
    }

    if (parsedEventCount.incrementAndGet() < 0) {
        parsedEventCount.set(0);
    }
    return event;
}
 
开发者ID:alibaba,项目名称:canal,代码行数:17,代码来源:AbstractEventParser.java


示例11: parseAnnotateRowsEvent

import com.alibaba.otter.canal.protocol.CanalEntry.Entry; //导入依赖的package包/类
private Entry parseAnnotateRowsEvent(AnnotateRowsEvent event) {
    if (filterQueryDml) {
        return null;
    }
    // mariaDb֧�֣���Ҫ����binlog_annotate_row_events=true������ϸ��ӡԭʼDML���
    String queryString = null;
    try {
        queryString = new String(event.getRowsQuery().getBytes(ISO_8859_1), charset.name());
        return buildQueryEntry(queryString, event.getHeader());
    } catch (UnsupportedEncodingException e) {
        throw new CanalParseException(e);
    }
}
 
开发者ID:BriData,项目名称:DBus,代码行数:14,代码来源:LogEventConvert 原始文件.java


示例12: parseRowsQueryEvent

import com.alibaba.otter.canal.protocol.CanalEntry.Entry; //导入依赖的package包/类
private Entry parseRowsQueryEvent(RowsQueryLogEvent event) {
    if (filterQueryDml) {
        return null;
    }
    // mysql5.6֧�֣���Ҫ����binlog-rows-query-log-events=1������ϸ��ӡԭʼDML���
    String queryString = null;
    try {
        queryString = new String(event.getRowsQuery().getBytes(ISO_8859_1), charset.name());
        return buildQueryEntry(queryString, event.getHeader());
    } catch (UnsupportedEncodingException e) {
        throw new CanalParseException(e);
    }
}
 
开发者ID:BriData,项目名称:DBus,代码行数:14,代码来源:LogEventConvert 原始文件.java


示例13: parseUserVarLogEvent

import com.alibaba.otter.canal.protocol.CanalEntry.Entry; //导入依赖的package包/类
private Entry parseUserVarLogEvent(UserVarLogEvent event) {
    if (filterQueryDml) {
        return null;
    }

    return buildQueryEntry(event.getQuery(), event.getHeader());
}
 
开发者ID:BriData,项目名称:DBus,代码行数:8,代码来源:LogEventConvert 原始文件.java


示例14: parseIntrvarLogEvent

import com.alibaba.otter.canal.protocol.CanalEntry.Entry; //导入依赖的package包/类
private Entry parseIntrvarLogEvent(IntvarLogEvent event) {
    if (filterQueryDml) {
        return null;
    }

    return buildQueryEntry(event.getQuery(), event.getHeader());
}
 
开发者ID:BriData,项目名称:DBus,代码行数:8,代码来源:LogEventConvert 原始文件.java


示例15: parseRandLogEvent

import com.alibaba.otter.canal.protocol.CanalEntry.Entry; //导入依赖的package包/类
private Entry parseRandLogEvent(RandLogEvent event) {
    if (filterQueryDml) {
        return null;
    }

    return buildQueryEntry(event.getQuery(), event.getHeader());
}
 
开发者ID:BriData,项目名称:DBus,代码行数:8,代码来源:LogEventConvert 原始文件.java


示例16: buildQueryEntry

import com.alibaba.otter.canal.protocol.CanalEntry.Entry; //导入依赖的package包/类
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());
}
 
开发者ID:BriData,项目名称:DBus,代码行数:8,代码来源:LogEventConvert 原始文件.java


示例17: createEntry

import com.alibaba.otter.canal.protocol.CanalEntry.Entry; //导入依赖的package包/类
public static Entry createEntry(Header header, EntryType entryType, ByteString storeValue) {
    Entry.Builder entryBuilder = Entry.newBuilder();
    entryBuilder.setHeader(header);
    entryBuilder.setEntryType(entryType);
    entryBuilder.setStoreValue(storeValue);
    return entryBuilder.build();
}
 
开发者ID:BriData,项目名称:DBus,代码行数:8,代码来源:LogEventConvert 原始文件.java


示例18: parseRowsQueryEvent

import com.alibaba.otter.canal.protocol.CanalEntry.Entry; //导入依赖的package包/类
private Entry parseRowsQueryEvent(RowsQueryLogEvent event) {
    if (filterQueryDml) {
        return null;
    }
    // mysql5.6支持,需要设置binlog-rows-query-log-events=1,可详细打印原始DML语句
    String queryString = null;
    try {
        queryString = new String(event.getRowsQuery().getBytes(ISO_8859_1), charset.name());
        return buildQueryEntry(queryString, event.getHeader());
    } catch (UnsupportedEncodingException e) {
        throw new CanalParseException(e);
    }
}
 
开发者ID:BriData,项目名称:DBus,代码行数:14,代码来源:LogEventConvert.java


示例19: parseAnnotateRowsEvent

import com.alibaba.otter.canal.protocol.CanalEntry.Entry; //导入依赖的package包/类
private Entry parseAnnotateRowsEvent(AnnotateRowsEvent event) {
    if (filterQueryDml) {
        return null;
    }
    // mariaDb支持,需要设置binlog_annotate_row_events=true,可详细打印原始DML语句
    String queryString = null;
    try {
        queryString = new String(event.getRowsQuery().getBytes(ISO_8859_1), charset.name());
        return buildQueryEntry(queryString, event.getHeader());
    } catch (UnsupportedEncodingException e) {
        throw new CanalParseException(e);
    }
}
 
开发者ID:BriData,项目名称:DBus,代码行数:14,代码来源:LogEventConvert.java


示例20: buildPositionForDump

import com.alibaba.otter.canal.protocol.CanalEntry.Entry; //导入依赖的package包/类
private String buildPositionForDump(Entry entry) {
    long time = entry.getHeader().getExecuteTime();
    Date date = new Date(time);
    SimpleDateFormat format = new SimpleDateFormat(DATE_FORMAT);
    return entry.getHeader().getLogfileName() + ":" + entry.getHeader().getLogfileOffset() + ":"
           + entry.getHeader().getExecuteTime() + "(" + format.format(date) + ")";
}
 
开发者ID:luoyaogui,项目名称:otter-G,代码行数:8,代码来源:CanalEmbedSelector.java



注:本文中的com.alibaba.otter.canal.protocol.CanalEntry.Entry类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java NelderMead类代码示例发布时间:2022-05-22
下一篇:
Java JsonToWebElementConverter类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap