Search in sources :

Example 6 with NodeDO

use of com.alibaba.otter.manager.biz.config.node.dal.dataobject.NodeDO in project otter by alibaba.

the class NodeServiceImpl method modify.

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

        protected void doInTransactionWithoutResult(TransactionStatus status) {
            try {
                NodeDO nodeDo = modelToDo(node);
                if (nodeDao.checkUnique(nodeDo)) {
                    nodeDao.update(nodeDo);
                } else {
                    String exceptionCause = "exist the same repeat node in the database.";
                    logger.warn("WARN ## " + exceptionCause);
                    throw new RepeatConfigureException(exceptionCause);
                }
            } catch (RepeatConfigureException rce) {
                throw rce;
            } catch (Exception e) {
                logger.error("ERROR ## modify node(" + node.getId() + ") 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)

Aggregations

NodeDO (com.alibaba.otter.manager.biz.config.node.dal.dataobject.NodeDO)6 ManagerException (com.alibaba.otter.manager.biz.common.exceptions.ManagerException)4 RepeatConfigureException (com.alibaba.otter.manager.biz.common.exceptions.RepeatConfigureException)4 ArrayList (java.util.ArrayList)3 TransactionStatus (org.springframework.transaction.TransactionStatus)2 TransactionCallbackWithoutResult (org.springframework.transaction.support.TransactionCallbackWithoutResult)2 BaseOtterTest (com.alibaba.otter.manager.biz.BaseOtterTest)1 NodeArbitrateEvent (com.alibaba.otter.shared.arbitrate.impl.manage.NodeArbitrateEvent)1 Node (com.alibaba.otter.shared.common.model.config.node.Node)1 List (java.util.List)1 Test (org.testng.annotations.Test)1