use of com.alibaba.otter.manager.biz.common.exceptions.RepeatConfigureException 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.RepeatConfigureException 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.RepeatConfigureException in project otter by alibaba.
the class PipelineServiceImpl method modify.
/**
* 修改
*/
public void modify(Pipeline pipeline) {
Assert.assertNotNull(pipeline);
try {
PipelineDO pipelineDo = modelToDo(pipeline);
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);
}
pipelineNodeRelationDao.deleteByPipelineId(pipelineDo.getId());
pipelineDao.update(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);
} catch (Exception e) {
logger.error("ERROR ## modify the pipeline(" + pipeline.getId() + ") has an exception!");
throw new ManagerException(e);
}
}
use of com.alibaba.otter.manager.biz.common.exceptions.RepeatConfigureException in project otter by alibaba.
the class AlarmRuleAction method doAdd.
public void doAdd(@FormGroup("alarmRuleInfo") Group alarmRuleInfo, @FormField(name = "formAlarmRuleError", group = "alarmRuleInfo") CustomErrors err, Navigator nav) throws Exception {
AlarmRule alarmRule = new AlarmRule();
alarmRuleInfo.setProperties(alarmRule);
try {
alarmRuleService.create(alarmRule);
} catch (RepeatConfigureException rce) {
err.setMessage("invalidAlarmRule");
return;
}
nav.redirectToLocation("alarmRuleList.htm?pipelineId=" + alarmRule.getPipelineId());
}
use of com.alibaba.otter.manager.biz.common.exceptions.RepeatConfigureException in project otter by alibaba.
the class ChannelAction method doAdd.
/**
* 添加Channel
*
* @param channelInfo
* @param channelParameterInfo
* @throws Exception
*/
public void doAdd(@FormGroup("channelInfo") Group channelInfo, @FormGroup("channelParameterInfo") Group channelParameterInfo, @FormField(name = "formChannelError", group = "channelInfo") CustomErrors err, Navigator nav) throws Exception {
Channel channel = new Channel();
ChannelParameter parameter = new ChannelParameter();
channelInfo.setProperties(channel);
channelParameterInfo.setProperties(parameter);
// 新建Channel默认关闭该状态
channel.setStatus(ChannelStatus.STOP);
channel.setParameters(parameter);
try {
channelService.create(channel);
} catch (RepeatConfigureException rce) {
err.setMessage("invalidChannelName");
return;
}
nav.redirectTo(WebConstant.CHANNEL_LIST_LINK);
}
Aggregations