当前位置: 首页>>代码示例>>Java>>正文


Java CanalEntry.Column方法代码示例

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


在下文中一共展示了CanalEntry.Column方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: insert

import com.alibaba.otter.canal.protocol.CanalEntry; //导入方法依赖的package包/类
public void insert(List<CanalEntry.Column> data, String schemaName, String tableName) {
    DBObject obj = DBConvertUtil.columnToJson(data);
    logger.debug("insert :{}", obj.toString());
    //订单库单独处理
    if (schemaName.equals("order")) {
        //保存原始数据
        if (tableName.startsWith("order_base_info")) {
            tableName = "order_base_info";
        } else if (tableName.startsWith("order_detail_info")) {
            tableName = "order_detail_info";
        } else {
            logger.info("unknown data :{}.{}:{}", schemaName, tableName, obj);
            return;
        }
        insertData(schemaName, tableName, obj, obj);
    } else {
        DBObject newObj = (DBObject) ObjectUtils.clone(obj);
        if (newObj.containsField("id")) {
            newObj.put("_id", newObj.get("id"));
            newObj.removeField("id");
        }
        insertData(schemaName, tableName, newObj, obj);
    }
}
 
开发者ID:zhangtr,项目名称:canal-mongo,代码行数:25,代码来源:DataService.java

示例2: update

import com.alibaba.otter.canal.protocol.CanalEntry; //导入方法依赖的package包/类
public void update(List<CanalEntry.Column> data, String schemaName, String tableName) {
    DBObject obj = DBConvertUtil.columnToJson(data);
    logger.debug("update:{}", obj.toString());
    //订单库单独处理
    if (schemaName.equals("order")) {
        if (tableName.startsWith("order_base_info")) {
            tableName = "order_base_info";
        } else if (tableName.startsWith("order_detail_info")) {
            tableName = "order_detail_info";
        } else {
            logger.info("unknown data:{}.{}:{}", schemaName, tableName, obj);
        }
        updateData(schemaName, tableName, new BasicDBObject("orderId", obj.get("orderId")), obj);
    } else {
        if (obj.containsField("id")) {
            updateData(schemaName, tableName, new BasicDBObject("_id", obj.get("id")), obj);
        } else {
            logger.info("unknown data structure");
        }
    }
}
 
开发者ID:zhangtr,项目名称:canal-mongo,代码行数:22,代码来源:DataService.java

示例3: encapsulationColumn

import com.alibaba.otter.canal.protocol.CanalEntry; //导入方法依赖的package包/类
private void encapsulationColumn(CangoMsgDto msgDto, List<CanalEntry.Column> columns, List<ColumnDto> columnDtos, boolean isNewData) {
    for (CanalEntry.Column column : columns) {
        if (column.getIsKey()) {
            msgDto.setPkName(column.getName()).setPkValue(convertValue(column.getValue(), column.getSqlType()));
        }

        ColumnDto columnDto = getColumnDto(columnDtos, column.getName());
        columnDto.setJdbcType(column.getSqlType());

        if (isNewData) {
            columnDto.setStrValue(column.getValue());
            columnDto.setValue(convertValue(column.getValue(), column.getSqlType()));
        } else {
            columnDto.setOldStrValue(column.getValue());
            columnDto.setOldValue(convertValue(column.getValue(), column.getSqlType()));
        }
    }
}
 
开发者ID:kevinKaiF,项目名称:cango,代码行数:19,代码来源:KafkaMysqlStore.java

示例4: delete

import com.alibaba.otter.canal.protocol.CanalEntry; //导入方法依赖的package包/类
public void delete(List<CanalEntry.Column> data, String schemaName, String tableName) {
    DBObject obj = DBConvertUtil.columnToJson(data);
    logger.debug("delete:{}", obj.toString());
    if (schemaName.equals("order")) {
        logger.info("not support delete:{}.{}:{}", schemaName, tableName, obj);
    } else {
        deleteData(schemaName, tableName, obj);
    }
}
 
开发者ID:zhangtr,项目名称:canal-mongo,代码行数:10,代码来源:DataService.java

示例5: columnToJson

import com.alibaba.otter.canal.protocol.CanalEntry; //导入方法依赖的package包/类
/**
 * binlog行数据列转换成DBObject
 *
 * @param columns
 * @return
 */
public static BasicDBObject columnToJson(List<CanalEntry.Column> columns) {
    BasicDBObject obj = new BasicDBObject();
    for (CanalEntry.Column column : columns) {
        Object value = dataTypeConvert(column.getMysqlType(), column.getValue());
        obj.put(column.getName(), value);
    }
    return obj;
}
 
开发者ID:zhangtr,项目名称:canal-mongo,代码行数:15,代码来源:DBConvertUtil.java

示例6: 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;

}
 
开发者ID:zhongchengxcr,项目名称:canal-elasticsearch,代码行数:14,代码来源:SimpleEsAdapter.java

示例7: 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;
    }
 
开发者ID:zhongchengxcr,项目名称:canal-elasticsearch,代码行数:33,代码来源:TotoroTransForm.java

示例8: printColumn

import com.alibaba.otter.canal.protocol.CanalEntry; //导入方法依赖的package包/类
protected void printColumn(List<CanalEntry.Column> columns) {
    for (CanalEntry.Column column : columns) {
        StringBuilder builder = new StringBuilder();
        builder.append(column.getName() + " : " + column.getValue());
        builder.append("    type=" + column.getMysqlType());
        if (column.getUpdated()) {
            builder.append("    update=" + column.getUpdated());
        }
        builder.append(SEP);
        logger.info(builder.toString());
    }
}
 
开发者ID:zhongchengxcr,项目名称:canal-elasticsearch,代码行数:13,代码来源:SelectorTask.java

示例9: 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;
}
 
开发者ID:BriData,项目名称:DBus,代码行数:51,代码来源:MysqlMessageProcessor.java

示例10: 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;
}
 
开发者ID:BriData,项目名称:DBus,代码行数:62,代码来源:MysqlMessageProcessor.java

示例11: getColumnList

import com.alibaba.otter.canal.protocol.CanalEntry; //导入方法依赖的package包/类
List<CanalEntry.Column> getColumnList(int esEventType, CanalEntry.RowData rowData); 
开发者ID:zhongchengxcr,项目名称:canal-elasticsearch,代码行数:2,代码来源:EsAdapter.java


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