當前位置: 首頁>>代碼示例>>Java>>正文


Java LogIdentity類代碼示例

本文整理匯總了Java中com.alibaba.otter.canal.protocol.position.LogIdentity的典型用法代碼示例。如果您正苦於以下問題:Java LogIdentity類的具體用法?Java LogIdentity怎麽用?Java LogIdentity使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


LogIdentity類屬於com.alibaba.otter.canal.protocol.position包,在下文中一共展示了LogIdentity類的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: buildEvent

import com.alibaba.otter.canal.protocol.position.LogIdentity; //導入依賴的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: buildRange

import com.alibaba.otter.canal.protocol.position.LogIdentity; //導入依賴的package包/類
private PositionRange<LogPosition> buildRange(int number) {
    LogPosition start = new LogPosition();
    start.setIdentity(new LogIdentity(new InetSocketAddress(MYSQL_ADDRESS, 3306), 1234L));
    start.setPostion(new EntryPosition("mysql-bin.000000" + number, 106L, new Date().getTime()));

    LogPosition end = new LogPosition();
    end.setIdentity(new LogIdentity(new InetSocketAddress(MYSQL_ADDRESS, 3306), 1234L));
    end.setPostion(new EntryPosition("mysql-bin.000000" + (number + 1), 106L, (new Date().getTime()) + 1000 * 1000L));
    return new PositionRange<LogPosition>(start, end);
}
 
開發者ID:alibaba,項目名稱:canal,代碼行數:11,代碼來源:AbstractMetaManagerTest.java

示例3: sinkData

import com.alibaba.otter.canal.protocol.position.LogIdentity; //導入依賴的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

示例4: buildLastPosition

import com.alibaba.otter.canal.protocol.position.LogIdentity; //導入依賴的package包/類
protected LogPosition buildLastPosition(CanalEntry.Entry entry) { // 初始化一下
    LogPosition logPosition = new LogPosition();
    EntryPosition position = new EntryPosition();
    position.setJournalName(entry.getHeader().getLogfileName());
    position.setPosition(entry.getHeader().getLogfileOffset());
    position.setTimestamp(entry.getHeader().getExecuteTime());
    // add serverId at 2016-06-28
    position.setServerId(entry.getHeader().getServerId());
    logPosition.setPostion(position);

    LogIdentity identity = new LogIdentity(runningInfo.getAddress(), -1L);
    logPosition.setIdentity(identity);
    return logPosition;
}
 
開發者ID:alibaba,項目名稱:canal,代碼行數:15,代碼來源:AbstractEventParser.java

示例5: buildEvent

import com.alibaba.otter.canal.protocol.position.LogIdentity; //導入依賴的package包/類
protected Event buildEvent(String binlogFile, long offset, long timestamp) {
    Header.Builder headerBuilder = Header.newBuilder();
    headerBuilder.setLogfileName(binlogFile);
    headerBuilder.setLogfileOffset(offset);
    headerBuilder.setExecuteTime(timestamp);
    headerBuilder.setEventLength(1024);
    Entry.Builder entryBuilder = Entry.newBuilder();
    entryBuilder.setHeader(headerBuilder.build());
    Entry entry = entryBuilder.build();

    return new Event(new LogIdentity(new InetSocketAddress(MYSQL_ADDRESS, 3306), 1234L), entry);
}
 
開發者ID:alibaba,項目名稱:canal,代碼行數:13,代碼來源:MemoryEventStoreBase.java

示例6: buildPosition

import com.alibaba.otter.canal.protocol.position.LogIdentity; //導入依賴的package包/類
protected LogPosition buildPosition(int number) {
    LogPosition position = new LogPosition();
    position.setIdentity(new LogIdentity(new InetSocketAddress(MYSQL_ADDRESS, 3306), 1234L));
    position.setPostion(new EntryPosition("mysql-bin.000000" + number, 106L, new Date().getTime()));
    return position;
}
 
開發者ID:alibaba,項目名稱:canal,代碼行數:7,代碼來源:AbstractLogPositionManagerTest.java

示例7: Event

import com.alibaba.otter.canal.protocol.position.LogIdentity; //導入依賴的package包/類
public Event(LogIdentity logIdentity, CanalEntry.Entry entry){
    this.logIdentity = logIdentity;
    this.entry = entry;
}
 
開發者ID:alibaba,項目名稱:canal,代碼行數:5,代碼來源:Event.java

示例8: getLogIdentity

import com.alibaba.otter.canal.protocol.position.LogIdentity; //導入依賴的package包/類
public LogIdentity getLogIdentity() {
    return logIdentity;
}
 
開發者ID:alibaba,項目名稱:canal,代碼行數:4,代碼來源:Event.java

示例9: setLogIdentity

import com.alibaba.otter.canal.protocol.position.LogIdentity; //導入依賴的package包/類
public void setLogIdentity(LogIdentity logIdentity) {
    this.logIdentity = logIdentity;
}
 
開發者ID:alibaba,項目名稱:canal,代碼行數:4,代碼來源:Event.java


注:本文中的com.alibaba.otter.canal.protocol.position.LogIdentity類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。