本文整理汇总了Java中com.alibaba.otter.canal.protocol.CanalEntry.RowData方法的典型用法代码示例。如果您正苦于以下问题:Java CanalEntry.RowData方法的具体用法?Java CanalEntry.RowData怎么用?Java CanalEntry.RowData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.alibaba.otter.canal.protocol.CanalEntry
的用法示例。
在下文中一共展示了CanalEntry.RowData方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: put
import com.alibaba.otter.canal.protocol.CanalEntry; //导入方法依赖的package包/类
@Override
public void put(List<Event> list) throws InterruptedException, CanalStoreException {
if (CollectionUtils.isNotEmpty(list)) {
for (Event event : list) {
CanalEntry.Entry entry = event.getEntry();
try {
CanalEntry.RowChange rowChange = CanalEntry.RowChange.parseFrom(entry.getStoreValue());
CanalEntry.EventType eventType = rowChange.getEventType();
if (eventType == CanalEntry.EventType.INSERT || eventType == CanalEntry.EventType.UPDATE || eventType == CanalEntry.EventType.DELETE) {
List<CanalEntry.RowData> rowDatas = rowChange.getRowDatasList();
for (CanalEntry.RowData rowData : rowDatas) {
sendKafkaMsg(rowData, entry, eventType);
}
}
} catch (InvalidProtocolBufferException e) {
LOGGER.error(e.getMessage(), e);
}
}
}
}
示例2: getElasticsearchMetadata
import com.alibaba.otter.canal.protocol.CanalEntry; //导入方法依赖的package包/类
private ElasticsearchMetadata.EsEntry getElasticsearchMetadata(CanalEntry.Entry entry) throws InvalidProtocolBufferException {
final String database = entry.getHeader().getSchemaName(); // => index
final String table = entry.getHeader().getTableName();// => type
final CanalEntry.RowChange change = CanalEntry.RowChange.parseFrom(entry.getStoreValue());
final List<CanalEntry.RowData> rowDataList = change.getRowDatasList();
CanalEntry.EventType eventType = entry.getHeader().getEventType();
final int esEventType = esAdapter.getEsEventType(eventType);
EsRowDataArrayList esRowDataList = TotoroObjectPool.esRowDataArrayList();
for (CanalEntry.RowData rowData : rowDataList) {
List<CanalEntry.Column> columnList = esAdapter.getColumnList(esEventType, rowData);
ElasticsearchMetadata.EsRowData esRowData = TotoroObjectPool.esRowData();
EsColumnHashMap columnMap = TotoroObjectPool.esColumnHashMap();
columnList.forEach(column -> columnMap.put(column.getName(), column.getValue()));
esRowData.setRowData(columnMap);
esRowData.setIdColumn(esAdapter.getEsIdColumn(database, table));//获取es对应的id Column
esRowDataList.add(esRowData);
}
ElasticsearchMetadata.EsEntry esEntry = TotoroObjectPool.esEntry();
esEntry.setIndex(database)
.setType(table)
.setEsRowDatas(esRowDataList)
.setEventType(esEventType);
return esEntry;
}
示例3: processFullPullerMessage
import com.alibaba.otter.canal.protocol.CanalEntry; //导入方法依赖的package包/类
@Override
public int processFullPullerMessage(Map<String, List<IGenericMessage>> map, IGenericMessage obj) throws IOException {
MysqlGenericMessage message = (MysqlGenericMessage) obj;
CanalEntry.Entry entry = message.getEntry();
CanalEntry.EventType eventType = entry.getHeader().getEventType();
if(eventType != CanalEntry.EventType.INSERT) {
//skip it.
logger.info ("Skipped a FULL_PULL_REQUESTS message which is not INSERT Type! :" + eventType.toString());
return -1;
}
CanalEntry.RowChange rowChange = CanalEntry.RowChange.parseFrom(entry.getStoreValue());
List<CanalEntry.RowData> dataList = rowChange.getRowDatasList();
if (dataList.size() != 1) {
throw new RuntimeException(String.format("解压FULL_PULL_REQUESTS 发现 %d 条bach数据,应该只有一条", dataList.size()));
}
//为了向下兼容,使用PULL_REMARK 保存dsName
String dsName = null;
String schema = null;
String table = null;
List<CanalEntry.Column> columns = dataList.get(0).getAfterColumnsList();
for (CanalEntry.Column column : columns) {
if (column.getName().equalsIgnoreCase("PULL_REMARK")) {
dsName = column.getValue();
} else if (column.getName().equalsIgnoreCase("SCHEMA_NAME")) {
schema = column.getValue();
} else if (column.getName().equalsIgnoreCase("TABLE_NAME")) {
table = column.getValue();
}
}
if (dsName == null || schema == null || table == null) {
throw new RuntimeException("解压FULL_PULL_REQUESTS 发现 dsName 或 schema 或 table为空.");
}
if (!dsName.equalsIgnoreCase(dsInfo.getDbSourceName())) {
logger.info("Skipped other datasource FULL_PULL_REQUESTS! : {}.{}.{}" , dsName, schema, table);
return -1;
}
logger.info(String.format("Get FULL_PULL_REQUESTS message : %s.%s.%s", dsName, schema, table));
//单独发送一条 拉全量的消息
List<IGenericMessage> subList = new ArrayList<>();
subList.add(message);
map.put(schema, subList);
return 0;
}
示例4: getColumnList
import com.alibaba.otter.canal.protocol.CanalEntry; //导入方法依赖的package包/类
@Override
public List<CanalEntry.Column> getColumnList(int esEventType, CanalEntry.RowData rowData) {
List<CanalEntry.Column> columnList;
if (esEventType == ElasticsearchMetadata.DELETE) {
columnList = rowData.getBeforeColumnsList();
} else {
columnList = rowData.getAfterColumnsList();
}
return columnList;
}
示例5: processHeartBeatMessage
import com.alibaba.otter.canal.protocol.CanalEntry; //导入方法依赖的package包/类
@Override
public int processHeartBeatMessage(Map<String, List<IGenericMessage>> map, IGenericMessage obj) throws IOException {
MysqlGenericMessage message = (MysqlGenericMessage) obj;
CanalEntry.Entry entry = message.getEntry();
CanalEntry.EventType eventType = entry.getHeader().getEventType();
if(eventType != CanalEntry.EventType.INSERT) {
//skip it.
logger.info ("Skipped a DB_HEARTBEAT_MONITOR message which is not INSERT Type! :" + eventType.toString());
return -1;
}
CanalEntry.RowChange rowChange = CanalEntry.RowChange.parseFrom(entry.getStoreValue());
List<CanalEntry.RowData> dataList = rowChange.getRowDatasList();
if (dataList.size() != 1) {
throw new RuntimeException(String.format("DB_HEARTBEAT_MONITOR 发现 %d 条bach数据,应该只有一条", dataList.size()));
}
String dsName = null;
String schemaName = null;
String tableName = null;
String packetJson = null;
List<CanalEntry.Column> columns = dataList.get(0).getAfterColumnsList();
for (CanalEntry.Column column : columns) {
if (column.getName().equalsIgnoreCase("DS_NAME")) {
dsName = column.getValue();
} else if (column.getName().equalsIgnoreCase("SCHEMA_NAME")) {
schemaName = column.getValue();
} else if (column.getName().equalsIgnoreCase("TABLE_NAME")) {
tableName = column.getValue();
} else if (column.getName().equalsIgnoreCase("PACKET"))
packetJson = column.getValue();
}
if (dsName == null || schemaName == null || tableName == null || packetJson == null) {
throw new RuntimeException("DB_HEARTBEAT_MONITOR 发现 dsName 或 schema 或 table, 或 packetJson 为空.");
}
if (!dsName.equalsIgnoreCase(dsInfo.getDbSourceName())) {
logger.info("Skipped other datasource HeartBeat! : {}.{}.{}" , dsName, schemaName, tableName);
return -1;
}
//logger.info(String.format("Get DB_HEARTBEAT_MONITOR message : %s.%s", schemaName, tableName));
if (packetJson.indexOf("checkpoint") >= 0) {
HeartBeatPacket packet = HeartBeatPacket.parse(packetJson);
statMeter(schemaName, tableName, packet.getTime(), packet.getTxtime());
}
List<IGenericMessage> subList = map.get(schemaName);
if (subList != null) {
subList.add(message);
} else {
subList = new ArrayList<>();
subList.add(message);
map.put(schemaName, subList);
}
return 0;
}
示例6: getColumnList
import com.alibaba.otter.canal.protocol.CanalEntry; //导入方法依赖的package包/类
List<CanalEntry.Column> getColumnList(int esEventType, CanalEntry.RowData rowData);
示例7: onInsert
import com.alibaba.otter.canal.protocol.CanalEntry; //导入方法依赖的package包/类
public void onInsert(CanalEntry.RowData rowData);
示例8: onDelete
import com.alibaba.otter.canal.protocol.CanalEntry; //导入方法依赖的package包/类
public void onDelete(CanalEntry.RowData rowData);
示例9: onUpdate
import com.alibaba.otter.canal.protocol.CanalEntry; //导入方法依赖的package包/类
public void onUpdate(CanalEntry.RowData rowData);