Search in sources :

Example 1 with HbaseEtlService

use of com.alibaba.otter.canal.client.adapter.hbase.service.HbaseEtlService in project canal by alibaba.

the class HbaseAdapter method etl.

@Override
public EtlResult etl(String task, List<String> params) {
    EtlResult etlResult = new EtlResult();
    MappingConfig config = hbaseMapping.get(task);
    HbaseEtlService hbaseEtlService = new HbaseEtlService(hbaseTemplate, config);
    if (config != null) {
        return hbaseEtlService.importData(params);
    } else {
        StringBuilder resultMsg = new StringBuilder();
        boolean resSucc = true;
        for (MappingConfig configTmp : hbaseMapping.values()) {
            // 取所有的destination为task的配置
            if (configTmp.getDestination().equals(task)) {
                EtlResult etlRes = hbaseEtlService.importData(params);
                if (!etlRes.getSucceeded()) {
                    resSucc = false;
                    resultMsg.append(etlRes.getErrorMessage()).append("\n");
                } else {
                    resultMsg.append(etlRes.getResultMessage()).append("\n");
                }
            }
        }
        if (resultMsg.length() > 0) {
            etlResult.setSucceeded(resSucc);
            if (resSucc) {
                etlResult.setResultMessage(resultMsg.toString());
            } else {
                etlResult.setErrorMessage(resultMsg.toString());
            }
            return etlResult;
        }
    }
    etlResult.setSucceeded(false);
    etlResult.setErrorMessage("Task not found");
    return etlResult;
}
Also used : MappingConfig(com.alibaba.otter.canal.client.adapter.hbase.config.MappingConfig) HbaseEtlService(com.alibaba.otter.canal.client.adapter.hbase.service.HbaseEtlService) EtlResult(com.alibaba.otter.canal.client.adapter.support.EtlResult)

Aggregations

MappingConfig (com.alibaba.otter.canal.client.adapter.hbase.config.MappingConfig)1 HbaseEtlService (com.alibaba.otter.canal.client.adapter.hbase.service.HbaseEtlService)1 EtlResult (com.alibaba.otter.canal.client.adapter.support.EtlResult)1