use of com.alibaba.otter.manager.biz.common.exceptions.ManagerException in project otter by alibaba.
the class ChannelServiceImpl method create.
/**
* 添加Channel
*/
public void create(final Channel channel) {
Assert.assertNotNull(channel);
transactionTemplate.execute(new TransactionCallbackWithoutResult() {
@Override
protected void doInTransactionWithoutResult(TransactionStatus status) {
try {
ChannelDO channelDo = modelToDo(channel);
channelDo.setId(0L);
if (!channelDao.checkUnique(channelDo)) {
String exceptionCause = "exist the same name channel in the database.";
logger.warn("WARN ## " + exceptionCause);
throw new RepeatConfigureException(exceptionCause);
}
channelDao.insert(channelDo);
arbitrateManageService.channelEvent().init(channelDo.getId());
} catch (RepeatConfigureException rce) {
throw rce;
} catch (Exception e) {
logger.error("ERROR ## create channel has an exception ", e);
throw new ManagerException(e);
}
}
});
}
use of com.alibaba.otter.manager.biz.common.exceptions.ManagerException in project otter by alibaba.
the class ChannelServiceImpl method remove.
/**
* 删除Channel
*/
public void remove(final Long channelId) {
Assert.assertNotNull(channelId);
transactionTemplate.execute(new TransactionCallbackWithoutResult() {
@Override
protected void doInTransactionWithoutResult(TransactionStatus status) {
try {
arbitrateManageService.channelEvent().destory(channelId);
channelDao.delete(channelId);
} catch (Exception e) {
logger.error("ERROR ## remove channel has an exception ", e);
throw new ManagerException(e);
}
}
});
}
use of com.alibaba.otter.manager.biz.common.exceptions.ManagerException in project otter by alibaba.
the class ChannelServiceImpl method modelToDo.
/*----------------------DO <-> MODEL 组装方法--------------------------*/
/**
* <pre>
* 用于Model对象转化为DO对象
* 优化:
* 无SQL交互,只是简单进行字段组装,暂时无须优化
* </pre>
*
* @param channel
* @return ChannelDO
*/
private ChannelDO modelToDo(Channel channel) {
ChannelDO channelDO = new ChannelDO();
try {
channelDO.setId(channel.getId());
channelDO.setName(channel.getName());
channelDO.setDescription(channel.getDescription());
channelDO.setStatus(channel.getStatus());
channelDO.setParameters(channel.getParameters());
channelDO.setGmtCreate(channel.getGmtCreate());
channelDO.setGmtModified(channel.getGmtModified());
} catch (Exception e) {
logger.error("ERROR ## change the channel Model to Do has an exception");
throw new ManagerException(e);
}
return channelDO;
}
use of com.alibaba.otter.manager.biz.common.exceptions.ManagerException in project otter by alibaba.
the class DataColumnPairServiceImpl method listByDataMediaPairIds.
public Map<Long, List<ColumnPair>> listByDataMediaPairIds(Long... dataMediaPairIds) {
Assert.assertNotNull(dataMediaPairIds);
Map<Long, List<ColumnPair>> dataColumnPairs = new HashMap<Long, List<ColumnPair>>();
try {
List<DataColumnPairDO> dataColumnPairDos = dataColumnPairDao.listByDataMediaPairIds(dataMediaPairIds);
if (dataColumnPairDos.isEmpty()) {
logger.debug("DEBUG ## couldn't query any dataColumnPair, maybe hasn't create any dataColumnPair.");
return dataColumnPairs;
}
for (DataColumnPairDO dataColumnPairDo : dataColumnPairDos) {
List<ColumnPair> columnPairs = dataColumnPairs.get(dataColumnPairDo.getDataMediaPairId());
if (columnPairs != null) {
if (!columnPairs.contains(doToModel(dataColumnPairDo))) {
columnPairs.add(doToModel(dataColumnPairDo));
}
} else {
columnPairs = new ArrayList<ColumnPair>();
columnPairs.add(doToModel(dataColumnPairDo));
dataColumnPairs.put(dataColumnPairDo.getDataMediaPairId(), columnPairs);
}
}
} catch (Exception e) {
logger.error("ERROR ## query dataColumnPair by dataMediaId:" + dataMediaPairIds + " has an exception!");
throw new ManagerException(e);
}
return dataColumnPairs;
}
use of com.alibaba.otter.manager.biz.common.exceptions.ManagerException in project otter by alibaba.
the class DataColumnPairServiceImpl method create.
public void create(ColumnPair entityObj) {
Assert.assertNotNull(entityObj);
try {
DataColumnPairDO dataColumnPairDo = modelToDo(entityObj);
dataColumnPairDao.insert(dataColumnPairDo);
} catch (RepeatConfigureException rcf) {
throw rcf;
} catch (Exception e) {
logger.error("ERROR ## create dataColumnPair has an exception!");
throw new ManagerException(e);
}
}
Aggregations