Search in sources :

Example 26 with ManagerException

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

the class DataColumnPairGroupServiceImpl method listByDataMediaPairIds.

@Override
public Map<Long, List<ColumnGroup>> listByDataMediaPairIds(Long... dataMediaPairIds) {
    Assert.assertNotNull(dataMediaPairIds);
    Map<Long, List<ColumnGroup>> dataColumnGroups = new HashMap<Long, List<ColumnGroup>>();
    try {
        List<DataColumnPairGroupDO> dataColumnPairGroupDos = dataColumnPairGroupDao.ListByDataMediaPairIds(dataMediaPairIds);
        if (CollectionUtils.isEmpty(dataColumnPairGroupDos)) {
            logger.debug("DEBUG ## couldn't query any dataColumnPairGroup, maybe hasn't create any dataColumnPairGroup.");
            return dataColumnGroups;
        }
        for (DataColumnPairGroupDO dataColumnPairGroupDo : dataColumnPairGroupDos) {
            List<ColumnGroup> columnGroups = dataColumnGroups.get(dataColumnPairGroupDo.getDataMediaPairId());
            if (columnGroups != null) {
                if (!columnGroups.contains(doToModel(dataColumnPairGroupDo))) {
                    columnGroups.add(doToModel(dataColumnPairGroupDo));
                }
            } else {
                columnGroups = new ArrayList<ColumnGroup>();
                columnGroups.add(doToModel(dataColumnPairGroupDo));
                dataColumnGroups.put(dataColumnPairGroupDo.getDataMediaPairId(), columnGroups);
            }
        }
    } catch (Exception e) {
        logger.error("ERROR ## query dataColumnPairGroup by dataMediaId:" + dataMediaPairIds + " has an exception!");
        throw new ManagerException(e);
    }
    return dataColumnGroups;
}
Also used : HashMap(java.util.HashMap) DataColumnPairGroupDO(com.alibaba.otter.manager.biz.config.datacolumnpair.dal.dataobject.DataColumnPairGroupDO) ArrayList(java.util.ArrayList) List(java.util.List) ColumnGroup(com.alibaba.otter.shared.common.model.config.data.ColumnGroup) 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 ManagerException

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

the class DataMatrixServiceImpl method findByGroupKey.

public DataMatrix findByGroupKey(String groupKey) {
    Assert.assertNotNull(groupKey);
    DataMatrixDO matrixDo = dataMatrixDao.findByGroupKey(groupKey);
    if (matrixDo == null) {
        String exceptionCause = "query name:" + groupKey + " return null.";
        logger.error("ERROR ## " + exceptionCause);
        throw new ManagerException(exceptionCause);
    }
    return doToModel(matrixDo);
}
Also used : DataMatrixDO(com.alibaba.otter.manager.biz.config.datamatrix.dal.dataobject.DataMatrixDO) ManagerException(com.alibaba.otter.manager.biz.common.exceptions.ManagerException)

Example 28 with ManagerException

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

the class DataMatrixServiceImpl method doToModel.

/**
 * 用于DO对象转化为Model对象
 */
private DataMatrix doToModel(DataMatrixDO matrixDo) {
    DataMatrix matrix = new DataMatrix();
    try {
        matrix.setId(matrixDo.getId());
        matrix.setGroupKey(matrixDo.getGroupKey());
        matrix.setDescription(matrixDo.getDescription());
        matrix.setMaster(matrixDo.getMaster());
        matrix.setSlave(matrixDo.getSlave());
        matrix.setGmtCreate(matrixDo.getGmtCreate());
        matrix.setGmtModified(matrixDo.getGmtModified());
    } catch (Exception e) {
        logger.error("ERROR ## change the canal Do to Model has an exception");
        throw new ManagerException(e);
    }
    return matrix;
}
Also used : DataMatrix(com.alibaba.otter.shared.common.model.config.data.DataMatrix) 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 ManagerException

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

the class DataMatrixServiceImpl method listByIds.

public List<DataMatrix> listByIds(Long... identities) {
    List<DataMatrix> matrixs = new ArrayList<DataMatrix>();
    try {
        List<DataMatrixDO> matrixDos = null;
        if (identities.length < 1) {
            matrixDos = dataMatrixDao.listAll();
            if (matrixDos.isEmpty()) {
                logger.debug("DEBUG ## couldn't query any canal, maybe hasn't create any canal.");
                return matrixs;
            }
        } else {
            matrixDos = dataMatrixDao.listByMultiId(identities);
            if (matrixDos.isEmpty()) {
                String exceptionCause = "couldn't query any canal by matrixIds:" + Arrays.toString(identities);
                logger.error("ERROR ## " + exceptionCause);
                throw new ManagerException(exceptionCause);
            }
        }
        matrixs = doToModel(matrixDos);
    } catch (Exception e) {
        logger.error("ERROR ## query channels has an exception!");
        throw new ManagerException(e);
    }
    return matrixs;
}
Also used : ArrayList(java.util.ArrayList) DataMatrixDO(com.alibaba.otter.manager.biz.config.datamatrix.dal.dataobject.DataMatrixDO) DataMatrix(com.alibaba.otter.shared.common.model.config.data.DataMatrix) 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 ManagerException

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

the class DataMatrixServiceImpl method modify.

/**
 * 修改
 */
public void modify(final DataMatrix matrix) {
    Assert.assertNotNull(matrix);
    transactionTemplate.execute(new TransactionCallbackWithoutResult() {

        protected void doInTransactionWithoutResult(TransactionStatus status) {
            try {
                DataMatrixDO matrixDo = modelToDo(matrix);
                if (dataMatrixDao.checkUnique(matrixDo)) {
                    dataMatrixDao.update(matrixDo);
                } else {
                    String exceptionCause = "exist the same repeat matrix in the database.";
                    logger.warn("WARN ## " + exceptionCause);
                    throw new RepeatConfigureException(exceptionCause);
                }
            } catch (RepeatConfigureException rce) {
                throw rce;
            } catch (Exception e) {
                logger.error("ERROR ## modify canal(" + matrix.getId() + ") has an exception!");
                throw new ManagerException(e);
            }
        }
    });
}
Also used : RepeatConfigureException(com.alibaba.otter.manager.biz.common.exceptions.RepeatConfigureException) DataMatrixDO(com.alibaba.otter.manager.biz.config.datamatrix.dal.dataobject.DataMatrixDO) 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)

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