Search in sources :

Example 81 with ManagerException

use of com.alibaba.otter.manager.biz.common.exceptions.ManagerException 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)

Example 82 with ManagerException

use of com.alibaba.otter.manager.biz.common.exceptions.ManagerException in project otter by alibaba.

the class DataMediaPairServiceImpl method modify.

/**
     * 修改
     */
public void modify(DataMediaPair dataMediaPair) {
    Assert.assertNotNull(dataMediaPair);
    try {
        DataMediaPairDO dataMediaPairDo = modelToDo(dataMediaPair);
        if (dataMediaPairDao.checkUnique(dataMediaPairDo)) {
            dataMediaPairDao.update(dataMediaPairDo);
        } else {
            String exceptionCause = "exist the same pair in the database.";
            logger.warn("WARN ## " + exceptionCause);
            throw new RepeatConfigureException(exceptionCause);
        }
    } catch (RepeatConfigureException rce) {
        throw rce;
    } catch (Exception e) {
        logger.error("ERROR ## modify dataMediaPair has an exception!", e);
        throw new ManagerException(e);
    }
}
Also used : RepeatConfigureException(com.alibaba.otter.manager.biz.common.exceptions.RepeatConfigureException) 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 83 with ManagerException

use of com.alibaba.otter.manager.biz.common.exceptions.ManagerException in project otter by alibaba.

the class DataMediaSourceServiceImpl method doToModel.

/**
     * 类型:数据库类型 Mysql和Oracle 用于DO对象转化为Model对象
     * 
     * @param dataMediaSourceDo
     * @return DataMediaSource
     */
private DataMediaSource doToModel(DataMediaSourceDO dataMediaSourceDo) {
    DataMediaSource dataMediaSource = new DbMediaSource();
    try {
        if (dataMediaSourceDo.getType().isMysql() || dataMediaSourceDo.getType().isOracle()) {
            dataMediaSource = JsonUtils.unmarshalFromString(dataMediaSourceDo.getProperties(), DbMediaSource.class);
        } else if (dataMediaSourceDo.getType().isNapoli() || dataMediaSourceDo.getType().isMq()) {
            dataMediaSource = JsonUtils.unmarshalFromString(dataMediaSourceDo.getProperties(), MqMediaSource.class);
        }
        dataMediaSource.setId(dataMediaSourceDo.getId());
        dataMediaSource.setGmtCreate(dataMediaSourceDo.getGmtCreate());
        dataMediaSource.setGmtModified(dataMediaSourceDo.getGmtModified());
    } catch (Exception e) {
        logger.error("ERROR ## change the dataMediaSource Do to Model has an exception");
        throw new ManagerException(e);
    }
    return dataMediaSource;
}
Also used : DataMediaSource(com.alibaba.otter.shared.common.model.config.data.DataMediaSource) DbMediaSource(com.alibaba.otter.shared.common.model.config.data.db.DbMediaSource) 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 84 with ManagerException

use of com.alibaba.otter.manager.biz.common.exceptions.ManagerException in project otter by alibaba.

the class DataMediaSourceServiceImpl method modelToDo.

/**
     * 类型:数据库类型 Mysql和Oracle 用于Model对象转化为DO对象
     * 
     * @param dataMediaSource
     * @return DataMediaSourceDO
     */
private DataMediaSourceDO modelToDo(DataMediaSource dataMediaSource) {
    DataMediaSourceDO dataMediaSourceDo = new DataMediaSourceDO();
    try {
        dataMediaSourceDo.setId(dataMediaSource.getId());
        dataMediaSourceDo.setName(dataMediaSource.getName());
        dataMediaSourceDo.setType(dataMediaSource.getType());
        if (dataMediaSource instanceof DbMediaSource) {
            dataMediaSourceDo.setProperties(JsonUtils.marshalToString((DbMediaSource) dataMediaSource));
        } else if (dataMediaSource instanceof MqMediaSource) {
            dataMediaSourceDo.setProperties(JsonUtils.marshalToString((MqMediaSource) dataMediaSource));
        }
        dataMediaSourceDo.setGmtCreate(dataMediaSource.getGmtCreate());
        dataMediaSourceDo.setGmtModified(dataMediaSource.getGmtModified());
    } catch (Exception e) {
        logger.error("ERROR ## change the dataMediaSource Model to Do has an exception");
        throw new ManagerException(e);
    }
    return dataMediaSourceDo;
}
Also used : MqMediaSource(com.alibaba.otter.shared.common.model.config.data.mq.MqMediaSource) DbMediaSource(com.alibaba.otter.shared.common.model.config.data.db.DbMediaSource) DataMediaSourceDO(com.alibaba.otter.manager.biz.config.datamediasource.dal.dataobject.DataMediaSourceDO) 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 85 with ManagerException

use of com.alibaba.otter.manager.biz.common.exceptions.ManagerException in project otter by alibaba.

the class DataMediaSourceServiceImpl method listByCondition.

@Override
public List<DataMediaSource> listByCondition(Map condition) {
    List<DataMediaSource> dataMediaSources = new ArrayList<DataMediaSource>();
    try {
        List<DataMediaSourceDO> dataMediaSourceDos = dataMediaSourceDao.listByCondition(condition);
        if (dataMediaSourceDos.isEmpty()) {
            logger.debug("DEBUG ## couldn't query any DataMediaSources by the condition:" + JsonUtils.marshalToString(condition));
            return dataMediaSources;
        }
        dataMediaSources = doToModel(dataMediaSourceDos);
    } catch (Exception e) {
        logger.error("ERROR ## query DataMediaSources by condition has an exception!");
        throw new ManagerException(e);
    }
    return dataMediaSources;
}
Also used : ArrayList(java.util.ArrayList) DataMediaSource(com.alibaba.otter.shared.common.model.config.data.DataMediaSource) DataMediaSourceDO(com.alibaba.otter.manager.biz.config.datamediasource.dal.dataobject.DataMediaSourceDO) 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)

Aggregations

ManagerException (com.alibaba.otter.manager.biz.common.exceptions.ManagerException)85 RepeatConfigureException (com.alibaba.otter.manager.biz.common.exceptions.RepeatConfigureException)76 ArrayList (java.util.ArrayList)35 Pipeline (com.alibaba.otter.shared.common.model.config.pipeline.Pipeline)17 TransactionStatus (org.springframework.transaction.TransactionStatus)13 TransactionCallbackWithoutResult (org.springframework.transaction.support.TransactionCallbackWithoutResult)13 InvalidConfigureException (com.alibaba.otter.manager.biz.common.exceptions.InvalidConfigureException)12 PipelineDO (com.alibaba.otter.manager.biz.config.pipeline.dal.dataobject.PipelineDO)10 Channel (com.alibaba.otter.shared.common.model.config.channel.Channel)10 DataMediaPairDO (com.alibaba.otter.manager.biz.config.datamediapair.dal.dataobject.DataMediaPairDO)9 DataMediaPair (com.alibaba.otter.shared.common.model.config.data.DataMediaPair)9 ChannelDO (com.alibaba.otter.manager.biz.config.channel.dal.dataobject.ChannelDO)8 DataMediaDO (com.alibaba.otter.manager.biz.config.datamedia.dal.dataobject.DataMediaDO)7 Node (com.alibaba.otter.shared.common.model.config.node.Node)7 CanalDO (com.alibaba.otter.manager.biz.config.canal.dal.dataobject.CanalDO)5 DataColumnPairDO (com.alibaba.otter.manager.biz.config.datacolumnpair.dal.dataobject.DataColumnPairDO)5 DataMatrixDO (com.alibaba.otter.manager.biz.config.datamatrix.dal.dataobject.DataMatrixDO)5 PipelineNodeRelationDO (com.alibaba.otter.manager.biz.config.pipeline.dal.dataobject.PipelineNodeRelationDO)5 DataMedia (com.alibaba.otter.shared.common.model.config.data.DataMedia)5 DataMediaSourceDO (com.alibaba.otter.manager.biz.config.datamediasource.dal.dataobject.DataMediaSourceDO)4