use of com.alibaba.otter.shared.common.model.config.channel.Channel in project otter by alibaba.
the class ArbitrateConfigImpl method findPipeline.
public Pipeline findPipeline(Long pipelineId) {
Long channelId = channelMapping.get(pipelineId);
Channel channel = channelCache.get(channelId);
List<Pipeline> pipelines = channel.getPipelines();
for (Pipeline pipeline : pipelines) {
if (pipeline.getId().equals(pipelineId)) {
return pipeline;
}
}
throw new ConfigException("no pipeline for pipelineId[" + pipelineId + "]");
}
use of com.alibaba.otter.shared.common.model.config.channel.Channel 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.shared.common.model.config.channel.Channel 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.shared.common.model.config.channel.Channel in project otter by alibaba.
the class ChannelServiceImpl method listByPipelineIds.
/**
* <pre>
* 根据PipelineID找到对应的Channel
* 优化设想:
* 应该通过变长参数达到后期扩展的方便性
* </pre>
*/
public List<Channel> listByPipelineIds(Long... pipelineIds) {
List<Channel> channels = new ArrayList<Channel>();
try {
List<Pipeline> pipelines = pipelineService.listByIds(pipelineIds);
List<Long> channelIds = new ArrayList<Long>();
for (Pipeline pipeline : pipelines) {
if (!channelIds.contains(pipeline.getChannelId())) {
channelIds.add(pipeline.getChannelId());
}
}
channels = listByIds(channelIds.toArray(new Long[channelIds.size()]));
} catch (Exception e) {
logger.error("ERROR ## list query channel by pipelineIds:" + pipelineIds.toString() + " has an exception!");
throw new ManagerException(e);
}
return channels;
}
use of com.alibaba.otter.shared.common.model.config.channel.Channel in project otter by alibaba.
the class ConfigRemoteServiceImpl method onFindChannel.
/**
* 根据对应的工作节点机器id,获取相关的channel任务
*/
public Channel onFindChannel(FindChannelEvent event) {
Assert.notNull(event);
Long channelId = event.getChannelId();
Long pipelineId = event.getPipelineId();
Channel channel = null;
if (channelId != null) {
channel = channelService.findById(channelId);
} else {
Assert.notNull(pipelineId);
channel = channelService.findByPipelineId(pipelineId);
}
return channel;
}
Aggregations