Search in sources :

Example 46 with Channel

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 + "]");
}
Also used : Channel(com.alibaba.otter.shared.common.model.config.channel.Channel) ConfigException(com.alibaba.otter.shared.common.model.config.ConfigException) Pipeline(com.alibaba.otter.shared.common.model.config.pipeline.Pipeline)

Example 47 with Channel

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;
}
Also used : Channel(com.alibaba.otter.shared.common.model.config.channel.Channel) ArrayList(java.util.ArrayList) ChannelDO(com.alibaba.otter.manager.biz.config.channel.dal.dataobject.ChannelDO) ManagerException(com.alibaba.otter.manager.biz.common.exceptions.ManagerException) InvalidConfigureException(com.alibaba.otter.manager.biz.common.exceptions.InvalidConfigureException) RepeatConfigureException(com.alibaba.otter.manager.biz.common.exceptions.RepeatConfigureException) ManagerException(com.alibaba.otter.manager.biz.common.exceptions.ManagerException)

Example 48 with Channel

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;
}
Also used : Channel(com.alibaba.otter.shared.common.model.config.channel.Channel) ArrayList(java.util.ArrayList) ChannelStatus(com.alibaba.otter.shared.common.model.config.channel.ChannelStatus) InvalidConfigureException(com.alibaba.otter.manager.biz.common.exceptions.InvalidConfigureException) RepeatConfigureException(com.alibaba.otter.manager.biz.common.exceptions.RepeatConfigureException) ManagerException(com.alibaba.otter.manager.biz.common.exceptions.ManagerException) Pipeline(com.alibaba.otter.shared.common.model.config.pipeline.Pipeline) SystemParameter(com.alibaba.otter.shared.common.model.config.parameter.SystemParameter) ChannelDO(com.alibaba.otter.manager.biz.config.channel.dal.dataobject.ChannelDO) PipelineParameter(com.alibaba.otter.shared.common.model.config.pipeline.PipelineParameter) ManagerException(com.alibaba.otter.manager.biz.common.exceptions.ManagerException)

Example 49 with Channel

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;
}
Also used : Channel(com.alibaba.otter.shared.common.model.config.channel.Channel) ArrayList(java.util.ArrayList) ManagerException(com.alibaba.otter.manager.biz.common.exceptions.ManagerException) InvalidConfigureException(com.alibaba.otter.manager.biz.common.exceptions.InvalidConfigureException) RepeatConfigureException(com.alibaba.otter.manager.biz.common.exceptions.RepeatConfigureException) ManagerException(com.alibaba.otter.manager.biz.common.exceptions.ManagerException) Pipeline(com.alibaba.otter.shared.common.model.config.pipeline.Pipeline)

Example 50 with Channel

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;
}
Also used : Channel(com.alibaba.otter.shared.common.model.config.channel.Channel)

Aggregations

Channel (com.alibaba.otter.shared.common.model.config.channel.Channel)77 Pipeline (com.alibaba.otter.shared.common.model.config.pipeline.Pipeline)38 Mock (mockit.Mock)16 ArrayList (java.util.ArrayList)13 ManagerException (com.alibaba.otter.manager.biz.common.exceptions.ManagerException)10 RepeatConfigureException (com.alibaba.otter.manager.biz.common.exceptions.RepeatConfigureException)10 ChannelArbitrateEvent (com.alibaba.otter.shared.arbitrate.impl.manage.ChannelArbitrateEvent)10 BeforeClass (org.testng.annotations.BeforeClass)10 PipelineArbitrateEvent (com.alibaba.otter.shared.arbitrate.impl.manage.PipelineArbitrateEvent)9 InvalidConfigureException (com.alibaba.otter.manager.biz.common.exceptions.InvalidConfigureException)8 NodeArbitrateEvent (com.alibaba.otter.shared.arbitrate.impl.manage.NodeArbitrateEvent)8 Node (com.alibaba.otter.shared.common.model.config.node.Node)7 Event (com.alibaba.otter.shared.communication.core.model.Event)7 Test (org.testng.annotations.Test)7 ChannelStatus (com.alibaba.otter.shared.common.model.config.channel.ChannelStatus)6 DataMediaPair (com.alibaba.otter.shared.common.model.config.data.DataMediaPair)6 HashMap (java.util.HashMap)6 ChannelDO (com.alibaba.otter.manager.biz.config.channel.dal.dataobject.ChannelDO)5 SystemParameter (com.alibaba.otter.shared.common.model.config.parameter.SystemParameter)5 Identity (com.alibaba.otter.shared.etl.model.Identity)5