Search in sources :

Example 61 with ManagerException

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

the class DataMediaServiceImpl method listByIds.

@Override
public List<DataMedia> listByIds(Long... identities) {
    List<DataMedia> dataMedias = new ArrayList<DataMedia>();
    try {
        List<DataMediaDO> dataMediaDos = null;
        if (identities.length < 1) {
            dataMediaDos = dataMediaDao.listAll();
            if (dataMediaDos.isEmpty()) {
                logger.debug("DEBUG ## couldn't query any dataMedia, maybe hasn't create any dataMedia.");
                return dataMedias;
            }
        } else {
            dataMediaDos = dataMediaDao.listByMultiId(identities);
            if (dataMediaDos.isEmpty()) {
                String exceptionCause = "couldn't query any dataMedia by dataMediaIds:" + Arrays.toString(identities);
                logger.error("ERROR ## " + exceptionCause);
                throw new ManagerException(exceptionCause);
            }
        }
        dataMedias = doToModel(dataMediaDos);
    } catch (Exception e) {
        logger.error("ERROR ## query dataMedias has an exception!");
        throw new ManagerException(e);
    }
    return dataMedias;
}
Also used : DataMediaDO(com.alibaba.otter.manager.biz.config.datamedia.dal.dataobject.DataMediaDO) ArrayList(java.util.ArrayList) ManagerException(com.alibaba.otter.manager.biz.common.exceptions.ManagerException) MqDataMedia(com.alibaba.otter.shared.common.model.config.data.mq.MqDataMedia) DataMedia(com.alibaba.otter.shared.common.model.config.data.DataMedia) DbDataMedia(com.alibaba.otter.shared.common.model.config.data.db.DbDataMedia) ManagerException(com.alibaba.otter.manager.biz.common.exceptions.ManagerException) RepeatConfigureException(com.alibaba.otter.manager.biz.common.exceptions.RepeatConfigureException)

Example 62 with ManagerException

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

the class DataMediaServiceImpl method create.

/**
     * 添加
     */
@Override
public void create(DataMedia dataMedia) {
    Assert.assertNotNull(dataMedia);
    try {
        DataMediaDO dataMediaDo = modelToDo(dataMedia);
        dataMediaDo.setId(0L);
        if (!dataMediaDao.checkUnique(dataMediaDo)) {
            String exceptionCause = "exist the same name dataMedia in the database.";
            logger.warn("WARN ## " + exceptionCause);
            throw new RepeatConfigureException(exceptionCause);
        }
        dataMediaDao.insert(dataMediaDo);
    } catch (RepeatConfigureException rce) {
        throw rce;
    } catch (Exception e) {
        logger.error("ERROR ## create dataMedia has an exception!");
        throw new ManagerException(e);
    }
}
Also used : RepeatConfigureException(com.alibaba.otter.manager.biz.common.exceptions.RepeatConfigureException) DataMediaDO(com.alibaba.otter.manager.biz.config.datamedia.dal.dataobject.DataMediaDO) 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 63 with ManagerException

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

the class DataMediaServiceImpl method modelToDo.

/**
     * 用于Model对象转化为DO对象
     * 
     * @param dataMedia
     * @return DataMediaDO
     */
private DataMediaDO modelToDo(DataMedia dataMedia) {
    DataMediaDO dataMediaDo = new DataMediaDO();
    try {
        dataMediaDo.setId(dataMedia.getId());
        dataMediaDo.setName(dataMedia.getName());
        dataMediaDo.setNamespace(dataMedia.getNamespace());
        dataMediaDo.setDataMediaSourceId(dataMedia.getSource().getId());
        // if (dataMedia instanceof DbDataMedia) {
        // dataMediaDo.setProperties(JsonUtils.marshalToString((DbDataMedia) dataMedia));
        // }
        dataMediaDo.setProperties(JsonUtils.marshalToString(dataMedia));
        dataMediaDo.setGmtCreate(dataMedia.getGmtCreate());
        dataMediaDo.setGmtModified(dataMedia.getGmtModified());
    } catch (Exception e) {
        logger.error("ERROR ## change the dataMedia Model to Do has an exception");
        throw new ManagerException(e);
    }
    return dataMediaDo;
}
Also used : DataMediaDO(com.alibaba.otter.manager.biz.config.datamedia.dal.dataobject.DataMediaDO) 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 64 with ManagerException

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

the class NodeServiceImpl method create.

/**
     * 添加
     */
public void create(final Node node) {
    Assert.assertNotNull(node);
    transactionTemplate.execute(new TransactionCallbackWithoutResult() {

        protected void doInTransactionWithoutResult(TransactionStatus status) {
            try {
                NodeDO nodeDo = modelToDo(node);
                nodeDo.setId(0L);
                if (!nodeDao.checkUnique(nodeDo)) {
                    String exceptionCause = "exist the same repeat node in the database.";
                    logger.warn("WARN ## " + exceptionCause);
                    throw new RepeatConfigureException(exceptionCause);
                }
                nodeDao.insert(nodeDo);
            } catch (RepeatConfigureException rce) {
                throw rce;
            } catch (Exception e) {
                logger.error("ERROR ## create node has an exception!");
                throw new ManagerException(e);
            }
        }
    });
}
Also used : RepeatConfigureException(com.alibaba.otter.manager.biz.common.exceptions.RepeatConfigureException) NodeDO(com.alibaba.otter.manager.biz.config.node.dal.dataobject.NodeDO) TransactionStatus(org.springframework.transaction.TransactionStatus) ManagerException(com.alibaba.otter.manager.biz.common.exceptions.ManagerException) TransactionCallbackWithoutResult(org.springframework.transaction.support.TransactionCallbackWithoutResult) ManagerException(com.alibaba.otter.manager.biz.common.exceptions.ManagerException) RepeatConfigureException(com.alibaba.otter.manager.biz.common.exceptions.RepeatConfigureException)

Example 65 with ManagerException

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

the class NodeServiceImpl method listByIds.

public List<Node> listByIds(Long... identities) {
    List<Node> nodes = new ArrayList<Node>();
    try {
        List<NodeDO> nodeDos = null;
        if (identities.length < 1) {
            nodeDos = nodeDao.listAll();
            if (nodeDos.isEmpty()) {
                logger.debug("DEBUG ## couldn't query any node, maybe hasn't create any channel.");
                return nodes;
            }
        } else {
            nodeDos = nodeDao.listByMultiId(identities);
            if (nodeDos.isEmpty()) {
                String exceptionCause = "couldn't query any node by nodeIds:" + Arrays.toString(identities);
                logger.error("ERROR ## " + exceptionCause);
                throw new ManagerException(exceptionCause);
            }
        }
        // 验证zk的node信息
        List<Long> nodeIds = arbitrateManageService.nodeEvent().liveNodes();
        for (NodeDO nodeDo : nodeDos) {
            if (nodeIds.contains(nodeDo.getId())) {
                nodeDo.setStatus(NodeStatus.START);
            } else {
                nodeDo.setStatus(NodeStatus.STOP);
            }
        }
        nodes = doToModel(nodeDos);
    } catch (Exception e) {
        logger.error("ERROR ## query nodes has an exception!");
        throw new ManagerException(e);
    }
    return nodes;
}
Also used : Node(com.alibaba.otter.shared.common.model.config.node.Node) ArrayList(java.util.ArrayList) NodeDO(com.alibaba.otter.manager.biz.config.node.dal.dataobject.NodeDO) 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