use of com.alibaba.otter.manager.biz.common.exceptions.ManagerException in project otter by alibaba.
the class CanalServiceImpl method doToModel.
/**
* 用于DO对象转化为Model对象
*
* @param canalDo
* @return Canal
*/
private Canal doToModel(CanalDO canalDo) {
Canal canal = new Canal();
try {
canal.setId(canalDo.getId());
canal.setName(canalDo.getName());
canal.setStatus(canalDo.getStatus());
canal.setDesc(canalDo.getDescription());
CanalParameter parameter = canalDo.getParameters();
AutoKeeperCluster zkCluster = autoKeeperClusterService.findAutoKeeperClusterById(parameter.getZkClusterId());
if (zkCluster != null) {
parameter.setZkClusters(Arrays.asList(StringUtils.join(zkCluster.getServerList(), ',')));
}
canal.setCanalParameter(canalDo.getParameters());
canal.setGmtCreate(canalDo.getGmtCreate());
canal.setGmtModified(canalDo.getGmtModified());
} catch (Exception e) {
logger.error("ERROR ## change the canal Do to Model has an exception");
throw new ManagerException(e);
}
return canal;
}
use of com.alibaba.otter.manager.biz.common.exceptions.ManagerException in project otter by alibaba.
the class CanalServiceImpl method create.
/**
* 添加
*/
public void create(final Canal canal) {
Assert.assertNotNull(canal);
transactionTemplate.execute(new TransactionCallbackWithoutResult() {
protected void doInTransactionWithoutResult(TransactionStatus status) {
try {
CanalDO canalDO = modelToDo(canal);
canalDO.setId(0L);
if (!canalDao.checkUnique(canalDO)) {
String exceptionCause = "exist the same repeat canal in the database.";
logger.warn("WARN ## " + exceptionCause);
throw new RepeatConfigureException(exceptionCause);
}
canalDao.insert(canalDO);
canal.setId(canalDO.getId());
} catch (RepeatConfigureException rce) {
throw rce;
} catch (Exception e) {
logger.error("ERROR ## create canal has an exception!");
throw new ManagerException(e);
}
}
});
}
use of com.alibaba.otter.manager.biz.common.exceptions.ManagerException in project otter by alibaba.
the class CanalServiceImpl method remove.
/**
* 删除
*/
public void remove(final Long canalId) {
Assert.assertNotNull(canalId);
transactionTemplate.execute(new TransactionCallbackWithoutResult() {
protected void doInTransactionWithoutResult(TransactionStatus status) {
try {
Canal canal = findById(canalId);
canalDao.delete(canalId);
// 删除canal节点信息
arbitrateViewService.removeCanal(canal.getName());
} catch (Exception e) {
logger.error("ERROR ## remove canal(" + canalId + ") has an exception!");
throw new ManagerException(e);
}
}
});
}
use of com.alibaba.otter.manager.biz.common.exceptions.ManagerException in project otter by alibaba.
the class CanalServiceImpl method findByName.
public Canal findByName(String name) {
Assert.assertNotNull(name);
CanalDO canalDo = canalDao.findByName(name);
if (canalDo == null) {
String exceptionCause = "query name:" + name + " return null.";
logger.error("ERROR ## " + exceptionCause);
throw new ManagerException(exceptionCause);
}
return doToModel(canalDo);
}
use of com.alibaba.otter.manager.biz.common.exceptions.ManagerException in project otter by alibaba.
the class ChannelServiceImpl method modify.
/**
* 修改Channel
*/
public void modify(Channel channel) {
Assert.assertNotNull(channel);
try {
ChannelDO channelDo = modelToDo(channel);
if (channelDao.checkUnique(channelDo)) {
channelDao.update(channelDo);
} else {
String exceptionCause = "exist the same name channel in the database.";
logger.warn("WARN ## " + exceptionCause);
throw new RepeatConfigureException(exceptionCause);
}
} catch (RepeatConfigureException rce) {
throw rce;
} catch (Exception e) {
logger.error("ERROR ## modify channel has an exception ", e);
throw new ManagerException(e);
}
}
Aggregations