use of com.alibaba.otter.manager.biz.config.channel.dal.dataobject.ChannelDO in project otter by alibaba.
the class ChannelServiceImpl method listOnlyChannels.
public List<Channel> listOnlyChannels(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 = doToModelOnlyChannels(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.config.channel.dal.dataobject.ChannelDO in project otter by alibaba.
the class ChannelServiceImpl method doToModelWithColumn.
private List<Channel> doToModelWithColumn(List<ChannelDO> channelDos) {
List<Channel> channels = new ArrayList<Channel>();
try {
// 1.将ChannelID单独拿出来
List<Long> channelIds = new ArrayList<Long>();
for (ChannelDO channelDo : channelDos) {
channelIds.add(channelDo.getId());
}
Long[] idArray = new Long[channelIds.size()];
// 拿到所有的Pipeline进行ChannelID过滤,避免重复查询。
List<Pipeline> pipelines = pipelineService.listByChannelIdsWithoutColumn(channelIds.toArray(idArray));
SystemParameter systemParameter = systemParameterService.find();
for (ChannelDO channelDo : channelDos) {
Channel channel = new Channel();
channel.setId(channelDo.getId());
channel.setName(channelDo.getName());
channel.setDescription(channelDo.getDescription());
ChannelStatus channelStatus = arbitrateManageService.channelEvent().status(channelDo.getId());
channel.setStatus(null == channelStatus ? ChannelStatus.STOP : channelStatus);
channel.setParameters(channelDo.getParameters());
channel.setGmtCreate(channelDo.getGmtCreate());
channel.setGmtModified(channelDo.getGmtModified());
// 遍历,将该Channel节点下的Pipeline提取出来。
List<Pipeline> subPipelines = new ArrayList<Pipeline>();
for (Pipeline pipeline : pipelines) {
if (pipeline.getChannelId().equals(channelDo.getId())) {
// 合并PipelineParameter和ChannelParameter
PipelineParameter parameter = new PipelineParameter();
parameter.merge(systemParameter);
parameter.merge(channel.getParameters());
// 最后复制pipelineId参数
parameter.merge(pipeline.getParameters());
pipeline.setParameters(parameter);
subPipelines.add(pipeline);
}
}
channel.setPipelines(subPipelines);
channels.add(channel);
}
} catch (Exception e) {
logger.error("ERROR ## change the channels DO to Model has an exception");
throw new ManagerException(e);
}
return channels;
}
use of com.alibaba.otter.manager.biz.config.channel.dal.dataobject.ChannelDO in project otter by alibaba.
the class ChannelServiceImpl method listAllChannelId.
public List<Long> listAllChannelId() {
List<ChannelDO> channelDos = channelDao.listChannelPks();
List<Long> channelPks = new ArrayList<Long>();
if (channelDos.isEmpty()) {
logger.debug("DEBUG ## couldn't query any channel");
}
for (ChannelDO channelDo : channelDos) {
channelPks.add(channelDo.getId());
}
return channelPks;
}
use of com.alibaba.otter.manager.biz.config.channel.dal.dataobject.ChannelDO 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