Search in sources :

Example 21 with ManagerException

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

the class DataMediaPairServiceImpl method listByIds.

/*-----------------------------------查询方法,整合-----------------------------------------*/
public List<DataMediaPair> listByIds(Long... identities) {
    List<DataMediaPair> dataMediaPairs = new ArrayList<DataMediaPair>();
    try {
        List<DataMediaPairDO> dataMediaPairDos = null;
        if (identities.length < 1) {
            dataMediaPairDos = dataMediaPairDao.listAll();
            if (dataMediaPairDos.isEmpty()) {
                logger.debug("DEBUG ## couldn't query any dataMediaPair, maybe hasn't create any dataMediaPair.");
                return dataMediaPairs;
            }
        } else {
            dataMediaPairDos = dataMediaPairDao.listByMultiId(identities);
            if (dataMediaPairDos.isEmpty()) {
                String exceptionCause = "couldn't query any dataMediaPair by dataMediaPairIds:" + Arrays.toString(identities);
                logger.error("ERROR ## " + exceptionCause);
                throw new ManagerException(exceptionCause);
            }
        }
        dataMediaPairs = doToModel(dataMediaPairDos);
    } catch (Exception e) {
        logger.error("ERROR ## query dataMediaPairs 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 22 with ManagerException

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

the class DataMediaPairServiceImpl method modelToDo.

/**
 * 用于Model对象转化为DO对象
 *
 * @param dataMediaPair
 * @return DataMediaPairDO
 */
private DataMediaPairDO modelToDo(DataMediaPair dataMediaPair) {
    DataMediaPairDO dataMediaPairDo = new DataMediaPairDO();
    try {
        dataMediaPairDo.setId(dataMediaPair.getId());
        dataMediaPairDo.setPipelineId(dataMediaPair.getPipelineId());
        dataMediaPairDo.setSourceDataMediaId(dataMediaPair.getSource().getId());
        dataMediaPairDo.setTargetDataMediaId(dataMediaPair.getTarget().getId());
        dataMediaPairDo.setFilter(JsonUtils.marshalToString(dataMediaPair.getFilterData()));
        dataMediaPairDo.setResolver(JsonUtils.marshalToString(dataMediaPair.getResolverData()));
        dataMediaPairDo.setPullWeight(dataMediaPair.getPullWeight());
        dataMediaPairDo.setPushWeight(dataMediaPair.getPushWeight());
        dataMediaPairDo.setColumnPairMode(dataMediaPair.getColumnPairMode());
        dataMediaPairDo.setGmtCreate(dataMediaPair.getGmtCreate());
        dataMediaPairDo.setGmtModified(dataMediaPair.getGmtModified());
    } catch (Exception e) {
        logger.error("ERROR ## change the dataMediaPair Model to Do has an exception", e);
        throw new ManagerException(e);
    }
    return dataMediaPairDo;
}
Also used : 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 23 with ManagerException

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

the class DataMediaPairServiceImpl method listByCondition.

@Override
public List<DataMediaPair> listByCondition(Map condition) {
    List<DataMediaPair> dataMediaPairs = new ArrayList<DataMediaPair>();
    try {
        List<DataMediaPairDO> dataMediaPairDos = dataMediaPairDao.listByCondition(condition);
        if (dataMediaPairDos.isEmpty()) {
            logger.debug("DEBUG ## couldn't query any DataMediaPairs by the condition:" + JsonUtils.marshalToString(condition));
            return dataMediaPairs;
        }
        dataMediaPairs = doToModel(dataMediaPairDos);
    } catch (Exception e) {
        logger.error("ERROR ## query dataMediaPairs by condition 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 24 with ManagerException

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

the class LogRecordServiceImpl method modelToDo.

/*----------------------DO <-> MODEL 组装方法--------------------------*/
/**
 * <pre>
 * 用于Model对象转化为DO对象
 * 优化:
 *      无SQL交互,只是简单进行字段组装,暂时无须优化
 * </pre>
 *
 * @param channel
 * @return ChannelDO
 */
private LogRecordDO modelToDo(LogRecord entityObj) {
    LogRecordDO logRecordDo = new LogRecordDO();
    try {
        if (entityObj.getPipeline() != null && entityObj.getPipeline().getId() > 0) {
            Channel channel = channelService.findByPipelineId(entityObj.getPipeline().getId());
            logRecordDo.setChannelId(channel.getId());
            logRecordDo.setPipelineId(entityObj.getPipeline().getId());
        } else {
            logRecordDo.setChannelId(-1l);
            logRecordDo.setPipelineId(-1l);
        }
        logRecordDo.setNid(entityObj.getNid());
        logRecordDo.setTitle(entityObj.getTitle());
        String message = entityObj.getMessage();
        if (message != null && message.length() > 65535 / 3) {
            message = message.substring(0, 65535 / 3);
        }
        logRecordDo.setMessage(message);
        logRecordDo.setGmtCreate(entityObj.getGmtCreate());
        logRecordDo.setGmtModified(entityObj.getGmtModified());
    } catch (Exception e) {
        logger.error("ERROR ## has an error where write log to db");
        throw new ManagerException(e);
    }
    return logRecordDo;
}
Also used : Channel(com.alibaba.otter.shared.common.model.config.channel.Channel) LogRecordDO(com.alibaba.otter.manager.biz.config.record.dal.dataobject.LogRecordDO) ManagerException(com.alibaba.otter.manager.biz.common.exceptions.ManagerException) ManagerException(com.alibaba.otter.manager.biz.common.exceptions.ManagerException)

Example 25 with ManagerException

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

the class LogRecordServiceImpl method doToModel.

/**
 * <pre>
 * 用于DO对象转化为Model对象
 * </pre>
 *
 * @param channelDO
 * @return Channel
 */
private LogRecord doToModel(LogRecordDO logRecordDo) {
    LogRecord logRecord = new LogRecord();
    try {
        logRecord.setId(logRecordDo.getId());
        if (logRecordDo.getPipelineId() > 0 && logRecordDo.getChannelId() > 0) {
            try {
                Channel channel = channelService.findByPipelineId(logRecordDo.getPipelineId());
                logRecord.setChannel(channel);
                for (Pipeline pipeline : channel.getPipelines()) {
                    if (pipeline.getId().equals(logRecordDo.getPipelineId())) {
                        logRecord.setPipeline(pipeline);
                    }
                }
            } catch (Exception e) {
                // 可能历史的log记录对应的channel/pipeline已经被删除了,直接忽略吧
                Channel channel = new Channel();
                channel.setId(0l);
                logRecord.setChannel(channel);
                Pipeline pipeline = new Pipeline();
                pipeline.setId(0l);
                logRecord.setPipeline(pipeline);
            }
        } else {
            Channel channel = new Channel();
            channel.setId(-1l);
            logRecord.setChannel(channel);
            Pipeline pipeline = new Pipeline();
            pipeline.setId(-1l);
            logRecord.setPipeline(pipeline);
        }
        logRecord.setTitle(logRecordDo.getTitle());
        logRecord.setNid(logRecordDo.getNid());
        logRecord.setMessage(logRecordDo.getMessage());
        logRecord.setGmtCreate(logRecordDo.getGmtCreate());
        logRecord.setGmtModified(logRecordDo.getGmtModified());
    } catch (Exception e) {
        logger.error("ERROR ## ");
        throw new ManagerException(e);
    }
    return logRecord;
}
Also used : LogRecord(com.alibaba.otter.shared.common.model.config.record.LogRecord) Channel(com.alibaba.otter.shared.common.model.config.channel.Channel) ManagerException(com.alibaba.otter.manager.biz.common.exceptions.ManagerException) ManagerException(com.alibaba.otter.manager.biz.common.exceptions.ManagerException) Pipeline(com.alibaba.otter.shared.common.model.config.pipeline.Pipeline)

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