Search in sources :

Example 1 with TablestoreEtlService

use of com.alibaba.otter.canal.client.adapter.tablestore.service.TablestoreEtlService in project canal by alibaba.

the class TablestoreAdapter method etl.

@Override
public EtlResult etl(String task, List<String> params) {
    EtlResult etlResult = new EtlResult();
    MappingConfig config = tablestoreMapping.get(task);
    if (config == null) {
        etlResult.setErrorMessage("can not find config for " + task);
        etlResult.setSucceeded(false);
        return etlResult;
    }
    TableStoreWriter writer = null;
    try {
        writer = buildEtlWriter(configuration, config);
        TablestoreEtlService rdbEtlService = new TablestoreEtlService(writer, config);
        rdbEtlService.importData(params);
        etlResult.setSucceeded(true);
        return etlResult;
    } catch (Exception e) {
        logger.error("Error while etl for task " + task, e);
        etlResult.setSucceeded(false);
        etlResult.setErrorMessage(e.getMessage());
        return etlResult;
    } finally {
        if (writer != null) {
            writer.close();
        }
    }
}
Also used : DefaultTableStoreWriter(com.alicloud.openservices.tablestore.DefaultTableStoreWriter) TableStoreWriter(com.alicloud.openservices.tablestore.TableStoreWriter) MappingConfig(com.alibaba.otter.canal.client.adapter.tablestore.config.MappingConfig) EtlResult(com.alibaba.otter.canal.client.adapter.support.EtlResult) TablestoreEtlService(com.alibaba.otter.canal.client.adapter.tablestore.service.TablestoreEtlService)

Aggregations

EtlResult (com.alibaba.otter.canal.client.adapter.support.EtlResult)1 MappingConfig (com.alibaba.otter.canal.client.adapter.tablestore.config.MappingConfig)1 TablestoreEtlService (com.alibaba.otter.canal.client.adapter.tablestore.service.TablestoreEtlService)1 DefaultTableStoreWriter (com.alicloud.openservices.tablestore.DefaultTableStoreWriter)1 TableStoreWriter (com.alicloud.openservices.tablestore.TableStoreWriter)1