本文整理匯總了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;
}
示例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);
}
示例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;
}
}
示例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;
}
示例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);
}
示例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;
}
示例7: Event
import com.alibaba.otter.canal.protocol.position.LogIdentity; //導入依賴的package包/類
public Event(LogIdentity logIdentity, CanalEntry.Entry entry){
this.logIdentity = logIdentity;
this.entry = entry;
}
示例8: getLogIdentity
import com.alibaba.otter.canal.protocol.position.LogIdentity; //導入依賴的package包/類
public LogIdentity getLogIdentity() {
return logIdentity;
}
示例9: setLogIdentity
import com.alibaba.otter.canal.protocol.position.LogIdentity; //導入依賴的package包/類
public void setLogIdentity(LogIdentity logIdentity) {
this.logIdentity = logIdentity;
}