use of com.alibaba.otter.manager.biz.common.exceptions.ManagerException 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);
}
}
});
}
use of com.alibaba.otter.manager.biz.common.exceptions.ManagerException in project otter by alibaba.
the class PipelineServiceImpl method listByDestinationWithoutOther.
public List<Pipeline> listByDestinationWithoutOther(String destination) {
Assert.assertNotNull(destination);
List<Pipeline> pipelines = new ArrayList<Pipeline>();
try {
List<PipelineDO> pipelineDos = pipelineDao.listByDestinationCondition(destination);
if (pipelineDos.isEmpty()) {
logger.debug("DEBUG ## query pipeline by destination:" + destination + " return null.");
return pipelines;
}
pipelines = doToModelWithoutOther(pipelineDos);
} catch (Exception e) {
logger.error("ERROR ## query pipelines by destination:" + destination + " has an exception!");
throw new ManagerException(e);
}
return pipelines;
}
use of com.alibaba.otter.manager.biz.common.exceptions.ManagerException in project otter by alibaba.
the class PipelineServiceImpl method remove.
/**
* 删除
*/
public void remove(final Long pipelineId) {
Assert.assertNotNull(pipelineId);
transactionTemplate.execute(new TransactionCallbackWithoutResult() {
@Override
protected void doInTransactionWithoutResult(TransactionStatus status) {
try {
PipelineDO pipelineDO = pipelineDao.findById(pipelineId);
if (pipelineDO != null) {
pipelineDao.delete(pipelineId);
pipelineNodeRelationDao.deleteByPipelineId(pipelineId);
// 删除历史cursor
String destination = pipelineDO.getParameters().getDestinationName();
short clientId = pipelineDO.getId().shortValue();
arbitrateViewService.removeCanal(destination, clientId);
arbitrateManageService.pipelineEvent().destory(pipelineDO.getChannelId(), pipelineId);
}
} catch (Exception e) {
logger.error("ERROR ## remove the pipeline(" + pipelineId + ") has an exception!");
throw new ManagerException(e);
}
}
});
}
use of com.alibaba.otter.manager.biz.common.exceptions.ManagerException in project otter by alibaba.
the class PipelineServiceImpl method create.
/**
* 添加
*/
public void create(final Pipeline pipeline) {
Assert.assertNotNull(pipeline);
transactionTemplate.execute(new TransactionCallbackWithoutResult() {
@Override
protected void doInTransactionWithoutResult(TransactionStatus status) {
try {
PipelineDO pipelineDo = modelToDo(pipeline);
pipelineDo.setId(0L);
if (!pipelineDao.checkUnique(pipelineDo)) {
String exceptionCause = "exist the same name pipeline under the channel(" + pipelineDo.getChannelId() + ") in the database.";
logger.warn("WARN ## " + exceptionCause);
throw new RepeatConfigureException(exceptionCause);
}
pipelineDao.insert(pipelineDo);
List<PipelineNodeRelationDO> pipelineNodeRelationDos = new ArrayList<PipelineNodeRelationDO>();
for (Node node : pipeline.getSelectNodes()) {
PipelineNodeRelationDO pipelineNodeRelationDo = new PipelineNodeRelationDO();
pipelineNodeRelationDo.setPipelineId(pipelineDo.getId());
pipelineNodeRelationDo.setNodeId(node.getId());
pipelineNodeRelationDo.setLocation(Location.SELECT);
pipelineNodeRelationDos.add(pipelineNodeRelationDo);
}
for (Node node : pipeline.getExtractNodes()) {
PipelineNodeRelationDO pipelineNodeRelationDo = new PipelineNodeRelationDO();
pipelineNodeRelationDo.setPipelineId(pipelineDo.getId());
pipelineNodeRelationDo.setNodeId(node.getId());
pipelineNodeRelationDo.setLocation(Location.EXTRACT);
pipelineNodeRelationDos.add(pipelineNodeRelationDo);
}
for (Node node : pipeline.getLoadNodes()) {
PipelineNodeRelationDO pipelineNodeRelationDo = new PipelineNodeRelationDO();
pipelineNodeRelationDo.setPipelineId(pipelineDo.getId());
pipelineNodeRelationDo.setNodeId(node.getId());
pipelineNodeRelationDo.setLocation(Location.LOAD);
pipelineNodeRelationDos.add(pipelineNodeRelationDo);
}
pipelineNodeRelationDao.insertBatch(pipelineNodeRelationDos);
arbitrateManageService.pipelineEvent().init(pipelineDo.getChannelId(), pipelineDo.getId());
} catch (RepeatConfigureException rce) {
throw rce;
} catch (Exception e) {
logger.error("ERROR ## create pipeline has an exception!");
throw new ManagerException(e);
}
}
});
}
use of com.alibaba.otter.manager.biz.common.exceptions.ManagerException in project otter by alibaba.
the class PipelineServiceImpl method modelToDo.
/**
* 用于Model对象转化为DO对象
*
* @param pipeline
* @return PipelineDO
*/
private PipelineDO modelToDo(Pipeline pipeline) {
PipelineDO pipelineDO = new PipelineDO();
try {
pipelineDO.setId(pipeline.getId());
pipelineDO.setName(pipeline.getName());
pipelineDO.setParameters(pipeline.getParameters());
pipelineDO.setDescription(pipeline.getDescription());
pipelineDO.setChannelId(pipeline.getChannelId());
pipelineDO.setGmtCreate(pipeline.getGmtCreate());
pipelineDO.setGmtModified(pipeline.getGmtModified());
} catch (Exception e) {
logger.error("ERROR ## change the pipeline Model to Do has an exception");
throw new ManagerException(e);
}
return pipelineDO;
}
Aggregations