Search in sources :

Example 26 with DataMediaPair

use of com.alibaba.otter.shared.common.model.config.data.DataMediaPair in project otter by alibaba.

the class DataMediaPairServiceImpl method listByDataMediaId.

@Override
public List<DataMediaPair> listByDataMediaId(Long dataMediaId) {
    Assert.assertNotNull(dataMediaId);
    List<DataMediaPair> dataMediaPairs = new ArrayList<DataMediaPair>();
    try {
        List<DataMediaPairDO> dataMediaPairDos = dataMediaPairDao.listByDataMediaId(dataMediaId);
        if (dataMediaPairDos.isEmpty()) {
            logger.debug("DEBUG ## couldn't query any dataMediaPair, maybe hasn't create any dataMediaPair.");
            return dataMediaPairs;
        }
        dataMediaPairs = doToModel(dataMediaPairDos);
    } catch (Exception e) {
        logger.error("ERROR ## query dataMediaPairs by dataMediaId:" + dataMediaId + " has an exception!", e);
        throw new ManagerException(e);
    }
    return dataMediaPairs;
}
Also used : DataMediaPair(com.alibaba.otter.shared.common.model.config.data.DataMediaPair) ArrayList(java.util.ArrayList) DataMediaPairDO(com.alibaba.otter.manager.biz.config.datamediapair.dal.dataobject.DataMediaPairDO) ManagerException(com.alibaba.otter.manager.biz.common.exceptions.ManagerException) ManagerException(com.alibaba.otter.manager.biz.common.exceptions.ManagerException) RepeatConfigureException(com.alibaba.otter.manager.biz.common.exceptions.RepeatConfigureException)

Example 27 with DataMediaPair

use of com.alibaba.otter.shared.common.model.config.data.DataMediaPair in project otter by alibaba.

the class DataMediaPairServiceImpl method doToModel.

private List<DataMediaPair> doToModel(List<DataMediaPairDO> dataMediaPairDos) {
    List<Long> dataMediaPairIds = new ArrayList<Long>();
    for (DataMediaPairDO dataMediaPairDo : dataMediaPairDos) {
        dataMediaPairIds.add(dataMediaPairDo.getId());
    }
    Map<Long, List<ColumnPair>> columnPairMap = dataColumnPairService.listByDataMediaPairIds(dataMediaPairIds.toArray(new Long[dataMediaPairIds.size()]));
    Map<Long, List<ColumnGroup>> columnPairGroupMap = dataColumnPairGroupService.listByDataMediaPairIds(dataMediaPairIds.toArray(new Long[dataMediaPairIds.size()]));
    List<DataMediaPair> dataMediaPairs = new ArrayList<DataMediaPair>();
    for (DataMediaPairDO dataMediaPairDo : dataMediaPairDos) {
        List<ColumnPair> columnPairs = columnPairMap.get(dataMediaPairDo.getId()) == null ? new ArrayList<ColumnPair>() : columnPairMap.get(dataMediaPairDo.getId());
        List<ColumnGroup> columnGroups = columnPairGroupMap.get(dataMediaPairDo.getId()) == null ? new ArrayList<ColumnGroup>() : columnPairGroupMap.get(dataMediaPairDo.getId());
        dataMediaPairs.add(doToModel(dataMediaPairDo, columnPairs, columnGroups));
    }
    return dataMediaPairs;
}
Also used : ColumnPair(com.alibaba.otter.shared.common.model.config.data.ColumnPair) DataMediaPair(com.alibaba.otter.shared.common.model.config.data.DataMediaPair) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) ColumnGroup(com.alibaba.otter.shared.common.model.config.data.ColumnGroup) DataMediaPairDO(com.alibaba.otter.manager.biz.config.datamediapair.dal.dataobject.DataMediaPairDO)

Example 28 with DataMediaPair

use of com.alibaba.otter.shared.common.model.config.data.DataMediaPair in project otter by alibaba.

the class DataMediaPairServiceImpl method listByPipelineId.

/**
     * 根据PipelineId找到该枝干下的所有DataMediaPairs
     */
public List<DataMediaPair> listByPipelineId(Long pipelineId) {
    Assert.assertNotNull(pipelineId);
    List<DataMediaPair> dataMediaPairs = new ArrayList<DataMediaPair>();
    try {
        List<DataMediaPairDO> dataMediaPairDos = dataMediaPairDao.listByPipelineId(pipelineId);
        if (dataMediaPairDos.isEmpty()) {
            logger.debug("DEBUG ## couldn't query any dataMediaPair, maybe hasn't create any dataMediaPair.");
            return dataMediaPairs;
        }
        dataMediaPairs = doToModel(dataMediaPairDos);
    } catch (Exception e) {
        logger.error("ERROR ## query dataMediaPairs by pipelineId:" + pipelineId + " has an exception!", e);
        throw new ManagerException(e);
    }
    return dataMediaPairs;
}
Also used : DataMediaPair(com.alibaba.otter.shared.common.model.config.data.DataMediaPair) ArrayList(java.util.ArrayList) DataMediaPairDO(com.alibaba.otter.manager.biz.config.datamediapair.dal.dataobject.DataMediaPairDO) ManagerException(com.alibaba.otter.manager.biz.common.exceptions.ManagerException) ManagerException(com.alibaba.otter.manager.biz.common.exceptions.ManagerException) RepeatConfigureException(com.alibaba.otter.manager.biz.common.exceptions.RepeatConfigureException)

Example 29 with DataMediaPair

use of com.alibaba.otter.shared.common.model.config.data.DataMediaPair in project otter by alibaba.

the class DataMediaPairServiceImpl method listByPipelineIdWithoutColumn.

@Override
public List<DataMediaPair> listByPipelineIdWithoutColumn(Long pipelineId) {
    Assert.assertNotNull(pipelineId);
    List<DataMediaPair> dataMediaPairs = new ArrayList<DataMediaPair>();
    try {
        List<DataMediaPairDO> dataMediaPairDos = dataMediaPairDao.listByPipelineId(pipelineId);
        if (dataMediaPairDos.isEmpty()) {
            logger.debug("DEBUG ## couldn't query any dataMediaPair, maybe hasn't create any dataMediaPair.");
            return dataMediaPairs;
        }
        dataMediaPairs = doToModelWithoutOther(dataMediaPairDos);
    } catch (Exception e) {
        logger.error("ERROR ## query dataMediaPairs by pipelineId:" + pipelineId + " has an exception!", e);
        throw new ManagerException(e);
    }
    return dataMediaPairs;
}
Also used : DataMediaPair(com.alibaba.otter.shared.common.model.config.data.DataMediaPair) ArrayList(java.util.ArrayList) DataMediaPairDO(com.alibaba.otter.manager.biz.config.datamediapair.dal.dataobject.DataMediaPairDO) ManagerException(com.alibaba.otter.manager.biz.common.exceptions.ManagerException) ManagerException(com.alibaba.otter.manager.biz.common.exceptions.ManagerException) RepeatConfigureException(com.alibaba.otter.manager.biz.common.exceptions.RepeatConfigureException)

Example 30 with DataMediaPair

use of com.alibaba.otter.shared.common.model.config.data.DataMediaPair in project otter by alibaba.

the class DataMediaPairServiceImpl method doToModel.

/*-------------------------------------------------------------*/
private DataMediaPair doToModel(DataMediaPairDO dataMediaPairDo, List<ColumnPair> columnPairs, List<ColumnGroup> columnGroups) {
    DataMediaPair dataMediaPair = new DataMediaPair();
    try {
        dataMediaPair.setId(dataMediaPairDo.getId());
        dataMediaPair.setPipelineId(dataMediaPairDo.getPipelineId());
        dataMediaPair.setPullWeight(dataMediaPairDo.getPullWeight());
        dataMediaPair.setPushWeight(dataMediaPairDo.getPushWeight());
        if (StringUtils.isNotBlank(dataMediaPairDo.getFilter())) {
            dataMediaPair.setFilterData(JsonUtils.unmarshalFromString(dataMediaPairDo.getFilter(), ExtensionData.class));
        }
        if (StringUtils.isNotBlank(dataMediaPairDo.getResolver())) {
            dataMediaPair.setResolverData(JsonUtils.unmarshalFromString(dataMediaPairDo.getResolver(), ExtensionData.class));
        }
        dataMediaPair.setColumnPairs(columnPairs);
        dataMediaPair.setColumnGroups(columnGroups);
        dataMediaPair.setColumnPairMode(dataMediaPairDo.getColumnPairMode());
        dataMediaPair.setGmtCreate(dataMediaPairDo.getGmtCreate());
        dataMediaPair.setGmtModified(dataMediaPairDo.getGmtModified());
        // 组装DataMedia
        List<DataMedia> dataMedias = dataMediaService.listByIds(dataMediaPairDo.getSourceDataMediaId(), dataMediaPairDo.getTargetDataMediaId());
        if (null == dataMedias || dataMedias.size() != 2) {
            // 抛出异常
            return dataMediaPair;
        }
        for (DataMedia dataMedia : dataMedias) {
            if (dataMedia.getId().equals(dataMediaPairDo.getSourceDataMediaId())) {
                dataMediaPair.setSource(dataMedia);
            } else if (dataMedia.getId().equals(dataMediaPairDo.getTargetDataMediaId())) {
                dataMediaPair.setTarget(dataMedia);
            }
        }
    } catch (Exception e) {
        logger.error("ERROR ## change the dataMediaPair Do to Model has an exception", e);
        throw new ManagerException(e);
    }
    return dataMediaPair;
}
Also used : DataMediaPair(com.alibaba.otter.shared.common.model.config.data.DataMediaPair) ManagerException(com.alibaba.otter.manager.biz.common.exceptions.ManagerException) DataMedia(com.alibaba.otter.shared.common.model.config.data.DataMedia) ManagerException(com.alibaba.otter.manager.biz.common.exceptions.ManagerException) RepeatConfigureException(com.alibaba.otter.manager.biz.common.exceptions.RepeatConfigureException) ExtensionData(com.alibaba.otter.shared.common.model.config.data.ExtensionData)

Aggregations

DataMediaPair (com.alibaba.otter.shared.common.model.config.data.DataMediaPair)51 ArrayList (java.util.ArrayList)26 Pipeline (com.alibaba.otter.shared.common.model.config.pipeline.Pipeline)19 EventData (com.alibaba.otter.shared.etl.model.EventData)16 RepeatConfigureException (com.alibaba.otter.manager.biz.common.exceptions.RepeatConfigureException)12 DataMedia (com.alibaba.otter.shared.common.model.config.data.DataMedia)11 DbDataMedia (com.alibaba.otter.shared.common.model.config.data.db.DbDataMedia)10 ManagerException (com.alibaba.otter.manager.biz.common.exceptions.ManagerException)9 BaseDbTest (com.alibaba.otter.node.etl.BaseDbTest)9 RowBatch (com.alibaba.otter.shared.etl.model.RowBatch)9 Test (org.testng.annotations.Test)9 Identity (com.alibaba.otter.shared.etl.model.Identity)8 DataMediaPairDO (com.alibaba.otter.manager.biz.config.datamediapair.dal.dataobject.DataMediaPairDO)6 Channel (com.alibaba.otter.shared.common.model.config.channel.Channel)6 HashMap (java.util.HashMap)6 ColumnPair (com.alibaba.otter.shared.common.model.config.data.ColumnPair)5 BatchObject (com.alibaba.otter.shared.etl.model.BatchObject)5 ColumnGroup (com.alibaba.otter.shared.common.model.config.data.ColumnGroup)4 Node (com.alibaba.otter.shared.common.model.config.node.Node)4 DbBatch (com.alibaba.otter.shared.etl.model.DbBatch)4