use of com.alibaba.otter.manager.biz.common.exceptions.ManagerException in project otter by alibaba.
the class ChannelServiceImpl method listByIds.
/*--------------------优化内容:listAll、listByIds、findById合并-------------------------------*/
public List<Channel> listByIds(Long... identities) {
List<Channel> channels = new ArrayList<Channel>();
try {
List<ChannelDO> channelDos = null;
if (identities.length < 1) {
channelDos = channelDao.listAll();
if (channelDos.isEmpty()) {
logger.debug("DEBUG ## couldn't query any channel, maybe hasn't create any channel.");
return channels;
}
} else {
channelDos = channelDao.listByMultiId(identities);
if (channelDos.isEmpty()) {
String exceptionCause = "couldn't query any channel by channelIds:" + Arrays.toString(identities);
logger.error("ERROR ## " + exceptionCause);
throw new ManagerException(exceptionCause);
}
}
channels = doToModel(channelDos);
} catch (Exception e) {
logger.error("ERROR ## query channels has an exception!");
throw new ManagerException(e);
}
return channels;
}
use of com.alibaba.otter.manager.biz.common.exceptions.ManagerException in project otter by alibaba.
the class ChannelServiceImpl method doToModel.
/**
* <pre>
* 用于DO对象转化为Model对象
* 现阶段优化:
* 需要五次SQL交互:pipeline\node\dataMediaPair\dataMedia\dataMediaSource(五个层面)
* 目前优化方案为单层只执行一次SQL,避免重复循环造成IO及数据库查询开销
* 长期优化:
* 对SQL进行改造,尽量减小SQL调用次数
* </pre>
*
* @param channelDO
* @return Channel
*/
private Channel doToModel(ChannelDO channelDo) {
Channel channel = new Channel();
try {
channel.setId(channelDo.getId());
channel.setName(channelDo.getName());
channel.setDescription(channelDo.getDescription());
channel.setStatus(arbitrateManageService.channelEvent().status(channelDo.getId()));
channel.setParameters(channelDo.getParameters());
channel.setGmtCreate(channelDo.getGmtCreate());
channel.setGmtModified(channelDo.getGmtModified());
List<Pipeline> pipelines = pipelineService.listByChannelIds(channelDo.getId());
// 合并PipelineParameter和ChannelParameter
SystemParameter systemParameter = systemParameterService.find();
for (Pipeline pipeline : pipelines) {
PipelineParameter parameter = new PipelineParameter();
parameter.merge(systemParameter);
parameter.merge(channel.getParameters());
// 最后复制pipelineId参数
parameter.merge(pipeline.getParameters());
pipeline.setParameters(parameter);
// pipeline.getParameters().merge(channel.getParameters());
}
channel.setPipelines(pipelines);
} catch (Exception e) {
logger.error("ERROR ## change the channel DO to Model has an exception");
throw new ManagerException(e);
}
return channel;
}
use of com.alibaba.otter.manager.biz.common.exceptions.ManagerException in project otter by alibaba.
the class CanalServiceImpl method listByIds.
public List<Canal> listByIds(Long... identities) {
List<Canal> canals = new ArrayList<Canal>();
try {
List<CanalDO> canalDos = null;
if (identities.length < 1) {
canalDos = canalDao.listAll();
if (canalDos.isEmpty()) {
logger.debug("DEBUG ## couldn't query any canal, maybe hasn't create any canal.");
return canals;
}
} else {
canalDos = canalDao.listByMultiId(identities);
if (canalDos.isEmpty()) {
String exceptionCause = "couldn't query any canal by canalIds:" + Arrays.toString(identities);
logger.error("ERROR ## " + exceptionCause);
throw new ManagerException(exceptionCause);
}
}
canals = doToModel(canalDos);
} catch (Exception e) {
logger.error("ERROR ## query channels has an exception!");
throw new ManagerException(e);
}
return canals;
}
use of com.alibaba.otter.manager.biz.common.exceptions.ManagerException in project otter by alibaba.
the class CanalServiceImpl method modelToDo.
/**
* 用于Model对象转化为DO对象
*
* @param canal
* @return CanalDO
*/
private CanalDO modelToDo(Canal canal) {
CanalDO canalDo = new CanalDO();
try {
canalDo.setId(canal.getId());
canalDo.setName(canal.getName());
canalDo.setStatus(canal.getStatus());
canalDo.setDescription(canal.getDesc());
canalDo.setParameters(canal.getCanalParameter());
canalDo.setGmtCreate(canal.getGmtCreate());
canalDo.setGmtModified(canal.getGmtModified());
} catch (Exception e) {
logger.error("ERROR ## change the canal Model to Do has an exception");
throw new ManagerException(e);
}
return canalDo;
}
use of com.alibaba.otter.manager.biz.common.exceptions.ManagerException in project otter by alibaba.
the class CanalServiceImpl method modify.
/**
* 修改
*/
public void modify(final Canal canal) {
Assert.assertNotNull(canal);
transactionTemplate.execute(new TransactionCallbackWithoutResult() {
protected void doInTransactionWithoutResult(TransactionStatus status) {
try {
CanalDO canalDo = modelToDo(canal);
if (canalDao.checkUnique(canalDo)) {
canalDao.update(canalDo);
} else {
String exceptionCause = "exist the same repeat canal in the database.";
logger.warn("WARN ## " + exceptionCause);
throw new RepeatConfigureException(exceptionCause);
}
} catch (RepeatConfigureException rce) {
throw rce;
} catch (Exception e) {
logger.error("ERROR ## modify canal(" + canal.getId() + ") has an exception!");
throw new ManagerException(e);
}
}
});
}
Aggregations