Search in sources :

Example 1 with DataMatrixDO

use of com.alibaba.otter.manager.biz.config.datamatrix.dal.dataobject.DataMatrixDO 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)

Example 2 with DataMatrixDO

use of com.alibaba.otter.manager.biz.config.datamatrix.dal.dataobject.DataMatrixDO in project otter by alibaba.

the class DataMatrixServiceImpl method modelToDo.

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

use of com.alibaba.otter.manager.biz.config.datamatrix.dal.dataobject.DataMatrixDO 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 4 with DataMatrixDO

use of com.alibaba.otter.manager.biz.config.datamatrix.dal.dataobject.DataMatrixDO 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 5 with DataMatrixDO

use of com.alibaba.otter.manager.biz.config.datamatrix.dal.dataobject.DataMatrixDO in project otter by alibaba.

the class DataMatrixServiceImpl method create.

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

        protected void doInTransactionWithoutResult(TransactionStatus status) {
            try {
                DataMatrixDO matrixlDO = modelToDo(matrix);
                matrixlDO.setId(0L);
                if (!dataMatrixDao.checkUnique(matrixlDO)) {
                    String exceptionCause = "exist the same repeat canal in the database.";
                    logger.warn("WARN ## " + exceptionCause);
                    throw new RepeatConfigureException(exceptionCause);
                }
                dataMatrixDao.insert(matrixlDO);
            } catch (RepeatConfigureException rce) {
                throw rce;
            } catch (Exception e) {
                logger.error("ERROR ## create canal 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)5 DataMatrixDO (com.alibaba.otter.manager.biz.config.datamatrix.dal.dataobject.DataMatrixDO)5 RepeatConfigureException (com.alibaba.otter.manager.biz.common.exceptions.RepeatConfigureException)4 TransactionStatus (org.springframework.transaction.TransactionStatus)2 TransactionCallbackWithoutResult (org.springframework.transaction.support.TransactionCallbackWithoutResult)2 DataMatrix (com.alibaba.otter.shared.common.model.config.data.DataMatrix)1 ArrayList (java.util.ArrayList)1