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

Java EntryType类代码示例

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

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



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

示例1: buildEvent

import com.alibaba.otter.canal.protocol.CanalEntry.EntryType; //导入依赖的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: doFilter

import com.alibaba.otter.canal.protocol.CanalEntry.EntryType; //导入依赖的package包/类
protected boolean doFilter(Event event) {
    if (filter != null && event.getEntry().getEntryType() == EntryType.ROWDATA) {
        String name = getSchemaNameAndTableName(event.getEntry());
        boolean need = filter.filter(name);
        if (!need) {
            logger.debug("filter name[{}] entry : {}:{}",
                name,
                event.getEntry().getHeader().getLogfileName(),
                event.getEntry().getHeader().getLogfileOffset());
        }

        return need;
    } else {
        return true;
    }
}
 
开发者ID:alibaba,项目名称:canal,代码行数:17,代码来源:EntryEventSink.java


示例3: put

import com.alibaba.otter.canal.protocol.CanalEntry.EntryType; //导入依赖的package包/类
public void put(List<Event> datas) throws InterruptedException, CanalStoreException {
    for (Event data : datas) {
        CanalEntry.Header header = data.getEntry().getHeader();
        Date date = new Date(header.getExecuteTime());
        SimpleDateFormat format = new SimpleDateFormat(DATE_FORMAT);
        if (data.getEntry().getEntryType() == EntryType.TRANSACTIONBEGIN
            || data.getEntry().getEntryType() == EntryType.TRANSACTIONEND) {
            // System.out.println(MessageFormat.format(messgae, new Object[]
            // { Thread.currentThread().getName(),
            // header.getLogfilename(), header.getLogfileoffset(),
            // format.format(date),
            // data.getEntry().getEntryType(), "" }));
            System.out.println(data.getEntry().getEntryType());

        } else {
            System.out.println(MessageFormat.format(messgae,
                new Object[] { Thread.currentThread().getName(), header.getLogfileName(),
                        String.valueOf(header.getLogfileOffset()), format.format(date), header.getEventType(),
                        header.getSchemaName(), header.getTableName() }));
        }
    }
}
 
开发者ID:alibaba,项目名称:canal,代码行数:23,代码来源:DummyEventStore.java


示例4: buildQueryEntry

import com.alibaba.otter.canal.protocol.CanalEntry.EntryType; //导入依赖的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


示例5: createEntry

import com.alibaba.otter.canal.protocol.CanalEntry.EntryType; //导入依赖的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


示例6: sink

import com.alibaba.otter.canal.protocol.CanalEntry.EntryType; //导入依赖的package包/类
public boolean sink(List<CanalEntry.Entry> entrys, InetSocketAddress remoteAddress, String destination)
                                                                                                       throws CanalSinkException,
                                                                                                       InterruptedException {
    List rowDatas = entrys;
    if (filterTransactionEntry) {
        rowDatas = new ArrayList<CanalEntry.Entry>();
        for (CanalEntry.Entry entry : entrys) {
            if (entry.getEntryType() == EntryType.ROWDATA) {
                rowDatas.add(entry);
            }
        }
    }

    return sinkData(rowDatas, remoteAddress);
}
 
开发者ID:alibaba,项目名称:canal,代码行数:16,代码来源:EntryEventSink.java


示例7: sinkData

import com.alibaba.otter.canal.protocol.CanalEntry.EntryType; //导入依赖的package包/类
private boolean sinkData(List<CanalEntry.Entry> entrys, InetSocketAddress remoteAddress)
                                                                                        throws InterruptedException {
    boolean hasRowData = false;
    boolean hasHeartBeat = false;
    List<Event> events = new ArrayList<Event>();
    for (CanalEntry.Entry entry : entrys) {
        Event event = new Event(new LogIdentity(remoteAddress, -1L), entry);
        if (!doFilter(event)) {
            continue;
        }

        events.add(event);
        hasRowData |= (entry.getEntryType() == EntryType.ROWDATA);
        hasHeartBeat |= (entry.getEntryType() == EntryType.HEARTBEAT);
    }

    if (hasRowData) {
        // 存在row记录
        return doSink(events);
    } else if (hasHeartBeat) {
        // 存在heartbeat记录,直接跳给后续处理
        return doSink(events);
    } else {
        // 需要过滤的数据
        if (filterEmtryTransactionEntry && !CollectionUtils.isEmpty(events)) {
            long currentTimestamp = events.get(0).getEntry().getHeader().getExecuteTime();
            // 基于一定的策略控制,放过空的事务头和尾,便于及时更新数据库位点,表明工作正常
            if (Math.abs(currentTimestamp - lastEmptyTransactionTimestamp) > emptyTransactionInterval
                || lastEmptyTransactionCount.incrementAndGet() > emptyTransctionThresold) {
                lastEmptyTransactionCount.set(0L);
                lastEmptyTransactionTimestamp = currentTimestamp;
                return doSink(events);
            }
        }

        // 直接返回true,忽略空的事务头和尾
        return true;
    }
}
 
开发者ID:alibaba,项目名称:canal,代码行数:40,代码来源:EntryEventSink.java


示例8: buildQueryEntry

import com.alibaba.otter.canal.protocol.CanalEntry.EntryType; //导入依赖的package包/类
private Entry buildQueryEntry(String queryString, LogHeader logHeader, String tableName) {
    Header header = createHeader(binlogFileName, logHeader, "", tableName, EventType.QUERY);
    RowChange.Builder rowChangeBuider = RowChange.newBuilder();
    rowChangeBuider.setSql(queryString);
    rowChangeBuider.setEventType(EventType.QUERY);
    return createEntry(header, EntryType.ROWDATA, rowChangeBuider.build().toByteString());
}
 
开发者ID:alibaba,项目名称:canal,代码行数:8,代码来源:LogEventConvert.java


示例9: buildLastTransactionPosition

import com.alibaba.otter.canal.protocol.CanalEntry.EntryType; //导入依赖的package包/类
protected LogPosition buildLastTransactionPosition(List<CanalEntry.Entry> entries) { // 初始化一下
    for (int i = entries.size() - 1; i > 0; i--) {
        CanalEntry.Entry entry = entries.get(i);
        if (entry.getEntryType() == CanalEntry.EntryType.TRANSACTIONEND) {// 尽量记录一个事务做为position
            return buildLastPosition(entry);
        }
    }

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


示例10: buildHeartBeatTimeTask

import com.alibaba.otter.canal.protocol.CanalEntry.EntryType; //导入依赖的package包/类
protected TimerTask buildHeartBeatTimeTask(ErosaConnection connection) {
    return new TimerTask() {

        public void run() {
            try {
                if (exception == null || lastEntryTime > 0) {
                    // 如果未出现异常,或者有第一条正常数据
                    long now = System.currentTimeMillis();
                    long inteval = (now - lastEntryTime) / 1000;
                    if (inteval >= detectingIntervalInSeconds) {
                        Header.Builder headerBuilder = Header.newBuilder();
                        headerBuilder.setExecuteTime(now);
                        Entry.Builder entryBuilder = Entry.newBuilder();
                        entryBuilder.setHeader(headerBuilder.build());
                        entryBuilder.setEntryType(EntryType.HEARTBEAT);
                        Entry entry = entryBuilder.build();
                        // 提交到sink中,目前不会提交到store中,会在sink中进行忽略
                        consumeTheEventAndProfilingIfNecessary(Arrays.asList(entry));
                    }
                }

            } catch (Throwable e) {
                logger.warn("heartBeat run failed ", e);
            }
        }

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


示例11: tryPut

import com.alibaba.otter.canal.protocol.CanalEntry.EntryType; //导入依赖的package包/类
public boolean tryPut(List<Event> datas) throws CanalStoreException {
    System.out.println("\n>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
    for (Event data : datas) {

        CanalEntry.Header header = data.getEntry().getHeader();
        Date date = new Date(header.getExecuteTime());
        SimpleDateFormat format = new SimpleDateFormat(DATE_FORMAT);
        if (data.getEntry().getEntryType() == EntryType.TRANSACTIONBEGIN
            || data.getEntry().getEntryType() == EntryType.TRANSACTIONEND) {
            // System.out.println(MessageFormat.format(messgae, new Object[]
            // { Thread.currentThread().getName(),
            // header.getLogfilename(), header.getLogfileoffset(),
            // format.format(date),
            // data.getEntry().getEntryType(), "" }));
            System.out.println(data.getEntry().getEntryType());

        } else {
            System.out.println(MessageFormat.format(messgae,
                new Object[] { Thread.currentThread().getName(), header.getLogfileName(),
                        String.valueOf(header.getLogfileOffset()), format.format(date), header.getEventType(),
                        header.getSchemaName(), header.getTableName() }));
        }

    }
    System.out.println("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n");
    return true;
}
 
开发者ID:alibaba,项目名称:canal,代码行数:28,代码来源:DummyEventStore.java


示例12: buildEntry

import com.alibaba.otter.canal.protocol.CanalEntry.EntryType; //导入依赖的package包/类
private static Entry buildEntry(String binlogFile, long offset, long timestamp, EntryType type) {
    Header.Builder headerBuilder = Header.newBuilder();
    headerBuilder.setLogfileName(binlogFile);
    headerBuilder.setLogfileOffset(offset);
    headerBuilder.setExecuteTime(timestamp);
    Entry.Builder entryBuilder = Entry.newBuilder();
    entryBuilder.setHeader(headerBuilder.build());
    entryBuilder.setEntryType(type);
    return entryBuilder.build();
}
 
开发者ID:alibaba,项目名称:canal,代码行数:11,代码来源:EventTransactionBufferTest.java


示例13: parseXidEvent

import com.alibaba.otter.canal.protocol.CanalEntry.EntryType; //导入依赖的package包/类
private Entry parseXidEvent(XidLogEvent event) {
    TransactionEnd transactionEnd = createTransactionEnd(event.getXid());
    Header header = createHeader(binlogFileName, event.getHeader(), "", "", null);
    return createEntry(header, EntryType.TRANSACTIONEND, transactionEnd.toByteString());
}
 
开发者ID:BriData,项目名称:DBus,代码行数:6,代码来源:LogEventConvert 原始文件.java


示例14: isTransactionBegin

import com.alibaba.otter.canal.protocol.CanalEntry.EntryType; //导入依赖的package包/类
private boolean isTransactionBegin(Event event) {
    return event.getEntry().getEntryType() == EntryType.TRANSACTIONBEGIN;
}
 
开发者ID:alibaba,项目名称:canal,代码行数:4,代码来源:TimelineTransactionBarrier.java


示例15: isTransactionEnd

import com.alibaba.otter.canal.protocol.CanalEntry.EntryType; //导入依赖的package包/类
private boolean isTransactionEnd(Event event) {
    return event.getEntry().getEntryType() == EntryType.TRANSACTIONEND;
}
 
开发者ID:alibaba,项目名称:canal,代码行数:4,代码来源:TimelineTransactionBarrier.java


示例16: testTransactionFlush

import com.alibaba.otter.canal.protocol.CanalEntry.EntryType; //导入依赖的package包/类
@Test
public void testTransactionFlush() {
    final int bufferSize = 64;
    final int transactionSize = 5;
    EventTransactionBuffer buffer = new EventTransactionBuffer();
    buffer.setBufferSize(bufferSize);
    buffer.setFlushCallback(new TransactionFlushCallback() {

        public void flush(List<Entry> transaction) throws InterruptedException {
            Assert.assertEquals(transactionSize, transaction.size());
            System.out.println("\n>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
            for (Entry data : transaction) {

                CanalEntry.Header header = data.getHeader();
                Date date = new Date(header.getExecuteTime());
                SimpleDateFormat format = new SimpleDateFormat(DATE_FORMAT);
                if (data.getEntryType() == EntryType.TRANSACTIONBEGIN
                    || data.getEntryType() == EntryType.TRANSACTIONEND) {
                    System.out.println(data.getEntryType());

                } else {
                    System.out.println(MessageFormat.format(messgae, new Object[] {
                            Thread.currentThread().getName(), header.getLogfileName(), header.getLogfileOffset(),
                            format.format(date), header.getSchemaName(), header.getTableName() }));
                }

            }
            System.out.println("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n");
        }
    });
    buffer.start();

    try {
        for (int i = 0; i < transactionSize * 10; i++) {
            if (i % transactionSize == 0) {
                buffer.add(buildEntry("1", 1L + i, 40L + i, EntryType.TRANSACTIONBEGIN));
            } else if ((i + 1) % transactionSize == 0) {
                buffer.add(buildEntry("1", 1L + i, 40L + i, EntryType.TRANSACTIONEND));
            } else {
                buffer.add(buildEntry("1", 1L + i, 40L + i));
            }
        }
    } catch (InterruptedException e) {
        Assert.fail(e.getMessage());
    }

    buffer.stop();
}
 
开发者ID:alibaba,项目名称:canal,代码行数:49,代码来源:EventTransactionBufferTest.java


示例17: testForceFlush

import com.alibaba.otter.canal.protocol.CanalEntry.EntryType; //导入依赖的package包/类
@Test
public void testForceFlush() {
    final int bufferSize = 64;
    EventTransactionBuffer buffer = new EventTransactionBuffer();
    buffer.setBufferSize(bufferSize);
    buffer.setFlushCallback(new TransactionFlushCallback() {

        public void flush(List<Entry> transaction) throws InterruptedException {
            Assert.assertEquals(bufferSize, transaction.size());
            System.out.println("\n>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
            for (Entry data : transaction) {

                CanalEntry.Header header = data.getHeader();
                Date date = new Date(header.getExecuteTime());
                SimpleDateFormat format = new SimpleDateFormat(DATE_FORMAT);
                if (data.getEntryType() == EntryType.TRANSACTIONBEGIN
                    || data.getEntryType() == EntryType.TRANSACTIONEND) {
                    // System.out.println(MessageFormat.format(messgae, new
                    // Object[] {
                    // Thread.currentThread().getName(),
                    // header.getLogfilename(), header.getLogfileoffset(),
                    // format.format(date),
                    // data.getEntry().getEntryType(), "" }));
                    System.out.println(data.getEntryType());

                } else {
                    System.out.println(MessageFormat.format(messgae, new Object[] {
                            Thread.currentThread().getName(), header.getLogfileName(), header.getLogfileOffset(),
                            format.format(date), header.getSchemaName(), header.getTableName() }));
                }

            }
            System.out.println("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n");
        }
    });
    buffer.start();

    try {
        for (int i = 0; i < bufferSize * 2 + 1; i++) {
            buffer.add(buildEntry("1", 1L + i, 40L + i));
        }
    } catch (InterruptedException e) {
        Assert.fail(e.getMessage());
    }

    buffer.stop();
}
 
开发者ID:alibaba,项目名称:canal,代码行数:48,代码来源:EventTransactionBufferTest.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Java LoadBalancingKMSClientProvider类代码示例发布时间:2022-05-22
下一篇:
Java PPath类代码示例发布时间: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