Search in sources :

Example 16 with Pipeline

use of com.alibaba.otter.shared.common.model.config.pipeline.Pipeline in project otter by alibaba.

the class ChannelServiceImpl method listByNodeId.

/**
 * 根据NodeId和Channel状态找到对应的Channel列表。
 */
public List<Channel> listByNodeId(Long nodeId, ChannelStatus... statuses) {
    List<Channel> channels = new ArrayList<Channel>();
    List<Channel> results = new ArrayList<Channel>();
    try {
        List<Pipeline> pipelines = pipelineService.listByNodeId(nodeId);
        List<Long> pipelineIds = new ArrayList<Long>();
        for (Pipeline pipeline : pipelines) {
            pipelineIds.add(pipeline.getId());
        }
        if (pipelineIds.isEmpty()) {
            // 没有关联任务直接返回
            return channels;
        }
        // 反查对应的channel
        channels = listByPipelineIds(pipelineIds.toArray(new Long[pipelineIds.size()]));
        if (null == statuses || statuses.length == 0) {
            return channels;
        }
        for (Channel channel : channels) {
            for (ChannelStatus status : statuses) {
                if (channel.getStatus().equals(status)) {
                    results.add(channel);
                }
            }
        }
    } catch (Exception e) {
        logger.error("ERROR ## list query channel by nodeId:" + nodeId + " has an exception!");
        throw new ManagerException(e);
    }
    return results;
}
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) 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 17 with Pipeline

use of com.alibaba.otter.shared.common.model.config.pipeline.Pipeline in project otter by alibaba.

the class ChannelServiceImpl method doToModel.

/**
 * <pre>
 * 用于DO对象转化为Model对象
 * 现阶段优化:
 *      需要五次SQL交互:pipeline\node\dataMediaPair\dataMedia\dataMediaSource(五个层面)
 *      目前优化方案为单层只执行一次SQL,避免重复循环造成IO及数据库查询开销
 * 长期优化:
 *      对SQL进行改造,尽量减小SQL调用次数
 * </pre>
 *
 * @param channelDO
 * @return Channel
 */
private Channel doToModel(ChannelDO channelDo) {
    Channel channel = new Channel();
    try {
        channel.setId(channelDo.getId());
        channel.setName(channelDo.getName());
        channel.setDescription(channelDo.getDescription());
        channel.setStatus(arbitrateManageService.channelEvent().status(channelDo.getId()));
        channel.setParameters(channelDo.getParameters());
        channel.setGmtCreate(channelDo.getGmtCreate());
        channel.setGmtModified(channelDo.getGmtModified());
        List<Pipeline> pipelines = pipelineService.listByChannelIds(channelDo.getId());
        // 合并PipelineParameter和ChannelParameter
        SystemParameter systemParameter = systemParameterService.find();
        for (Pipeline pipeline : pipelines) {
            PipelineParameter parameter = new PipelineParameter();
            parameter.merge(systemParameter);
            parameter.merge(channel.getParameters());
            // 最后复制pipelineId参数
            parameter.merge(pipeline.getParameters());
            pipeline.setParameters(parameter);
        // pipeline.getParameters().merge(channel.getParameters());
        }
        channel.setPipelines(pipelines);
    } catch (Exception e) {
        logger.error("ERROR ## change the channel DO to Model has an exception");
        throw new ManagerException(e);
    }
    return channel;
}
Also used : Channel(com.alibaba.otter.shared.common.model.config.channel.Channel) SystemParameter(com.alibaba.otter.shared.common.model.config.parameter.SystemParameter) PipelineParameter(com.alibaba.otter.shared.common.model.config.pipeline.PipelineParameter) 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 18 with Pipeline

use of com.alibaba.otter.shared.common.model.config.pipeline.Pipeline in project otter by alibaba.

the class ChannelServiceImpl method findByPipelineId.

/*--------------------外部关联查询Channel-----------------------*/
/**
 * <pre>
 * 根据PipelineID找到对应的Channel
 * 优化设想:
 *    应该通过变长参数达到后期扩展的方便性
 * </pre>
 */
public Channel findByPipelineId(Long pipelineId) {
    Pipeline pipeline = pipelineService.findById(pipelineId);
    Channel channel = findById(pipeline.getChannelId());
    return channel;
}
Also used : Channel(com.alibaba.otter.shared.common.model.config.channel.Channel) Pipeline(com.alibaba.otter.shared.common.model.config.pipeline.Pipeline)

Example 19 with Pipeline

use of com.alibaba.otter.shared.common.model.config.pipeline.Pipeline in project otter by alibaba.

the class CanalInfo method execute.

public void execute(@Param("canalId") Long canalId, Context context) throws Exception {
    Canal canal = canalService.findById(canalId);
    AutoKeeperCluster zkCluster = autoKeeperClusterService.findAutoKeeperClusterById(canal.getCanalParameter().getZkClusterId());
    List<Pipeline> pipelines = pipelineService.listByDestinationWithoutOther(canal.getName());
    List<Long> channelIds = new ArrayList<Long>();
    for (Pipeline pipeline : pipelines) {
        channelIds.add(pipeline.getChannelId());
    }
    List<Channel> channels = channelService.listOnlyChannels(channelIds.toArray(new Long[channelIds.size()]));
    Map<Long, Channel> channelMap = new HashMap<Long, Channel>();
    for (Channel channel : channels) {
        channelMap.put(channel.getId(), channel);
    }
    context.put("canal", canal);
    context.put("pipelines", pipelines);
    context.put("channelMap", channelMap);
    context.put("zkCluster", zkCluster);
}
Also used : HashMap(java.util.HashMap) Canal(com.alibaba.otter.canal.instance.manager.model.Canal) Channel(com.alibaba.otter.shared.common.model.config.channel.Channel) ArrayList(java.util.ArrayList) AutoKeeperCluster(com.alibaba.otter.shared.common.model.autokeeper.AutoKeeperCluster) Pipeline(com.alibaba.otter.shared.common.model.config.pipeline.Pipeline)

Example 20 with Pipeline

use of com.alibaba.otter.shared.common.model.config.pipeline.Pipeline in project otter by alibaba.

the class CanalList method execute.

public void execute(@Param("pageIndex") int pageIndex, @Param("searchKey") String searchKey, Context context) throws Exception {
    @SuppressWarnings("unchecked") Map<String, Object> condition = new HashMap<String, Object>();
    if ("请输入关键字(目前支持Node的ID、名字搜索)".equals(searchKey)) {
        searchKey = "";
    }
    condition.put("searchKey", searchKey);
    int count = canalService.getCount(condition);
    Paginator paginator = new Paginator();
    paginator.setItems(count);
    paginator.setPage(pageIndex);
    condition.put("offset", paginator.getOffset());
    condition.put("length", paginator.getLength());
    List<Canal> canals = canalService.listByCondition(condition);
    List<SeniorCanal> seniorCanals = new ArrayList<SeniorCanal>();
    for (Canal canal : canals) {
        SeniorCanal seniorCanal = new SeniorCanal();
        seniorCanal.setId(canal.getId());
        seniorCanal.setName(canal.getName());
        seniorCanal.setStatus(canal.getStatus());
        seniorCanal.setDesc(canal.getDesc());
        seniorCanal.setCanalParameter(canal.getCanalParameter());
        seniorCanal.setGmtCreate(canal.getGmtCreate());
        seniorCanal.setGmtModified(canal.getGmtModified());
        List<Pipeline> pipelines = pipelineService.listByDestinationWithoutOther(canal.getName());
        seniorCanal.setPipelines(pipelines);
        seniorCanal.setUsed(!pipelines.isEmpty());
        seniorCanals.add(seniorCanal);
    }
    context.put("seniorCanals", seniorCanals);
    context.put("paginator", paginator);
    context.put("searchKey", searchKey);
}
Also used : HashMap(java.util.HashMap) Canal(com.alibaba.otter.canal.instance.manager.model.Canal) SeniorCanal(com.alibaba.otter.manager.web.common.model.SeniorCanal) ArrayList(java.util.ArrayList) Paginator(com.alibaba.citrus.util.Paginator) Pipeline(com.alibaba.otter.shared.common.model.config.pipeline.Pipeline) SeniorCanal(com.alibaba.otter.manager.web.common.model.SeniorCanal)

Aggregations

Pipeline (com.alibaba.otter.shared.common.model.config.pipeline.Pipeline)105 Channel (com.alibaba.otter.shared.common.model.config.channel.Channel)38 ArrayList (java.util.ArrayList)37 Node (com.alibaba.otter.shared.common.model.config.node.Node)22 Test (org.testng.annotations.Test)20 DataMediaPair (com.alibaba.otter.shared.common.model.config.data.DataMediaPair)19 EventData (com.alibaba.otter.shared.etl.model.EventData)19 Mock (mockit.Mock)19 ManagerException (com.alibaba.otter.manager.biz.common.exceptions.ManagerException)17 RepeatConfigureException (com.alibaba.otter.manager.biz.common.exceptions.RepeatConfigureException)17 Identity (com.alibaba.otter.shared.etl.model.Identity)12 RowBatch (com.alibaba.otter.shared.etl.model.RowBatch)12 BaseDbTest (com.alibaba.otter.node.etl.BaseDbTest)10 ChannelArbitrateEvent (com.alibaba.otter.shared.arbitrate.impl.manage.ChannelArbitrateEvent)10 PipelineArbitrateEvent (com.alibaba.otter.shared.arbitrate.impl.manage.PipelineArbitrateEvent)9 PipelineParameter (com.alibaba.otter.shared.common.model.config.pipeline.PipelineParameter)9 FileBatch (com.alibaba.otter.shared.etl.model.FileBatch)9 FileData (com.alibaba.otter.shared.etl.model.FileData)9 HashMap (java.util.HashMap)9 BeforeClass (org.testng.annotations.BeforeClass)9