Search in sources :

Example 1 with KuduEtlService

use of com.alibaba.otter.canal.client.adapter.kudu.service.KuduEtlService in project canal by alibaba.

the class KuduAdapter method etl.

@Override
public EtlResult etl(String task, List<String> params) {
    EtlResult etlResult = new EtlResult();
    KuduMappingConfig config = kuduMapping.get(task);
    KuduEtlService hbaseEtlService = new KuduEtlService(kuduTemplate, config);
    if (config != null) {
        return hbaseEtlService.importData(params);
    } else {
        StringBuilder resultMsg = new StringBuilder();
        boolean resSucc = true;
        for (KuduMappingConfig configTmp : kuduMapping.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;
        }
    }
    return null;
}
Also used : EtlResult(com.alibaba.otter.canal.client.adapter.support.EtlResult) KuduMappingConfig(com.alibaba.otter.canal.client.adapter.kudu.config.KuduMappingConfig) KuduEtlService(com.alibaba.otter.canal.client.adapter.kudu.service.KuduEtlService)

Aggregations

KuduMappingConfig (com.alibaba.otter.canal.client.adapter.kudu.config.KuduMappingConfig)1 KuduEtlService (com.alibaba.otter.canal.client.adapter.kudu.service.KuduEtlService)1 EtlResult (com.alibaba.otter.canal.client.adapter.support.EtlResult)1