Package com.alibaba.otter.shared.common.model.config.channel

Examples of com.alibaba.otter.shared.common.model.config.channel.Channel


        try {

            logRecord.setId(logRecordDo.getId());
            if (logRecordDo.getPipelineId() > 0 && logRecordDo.getChannelId() > 0) {
                try {
                    Channel channel = channelService.findByPipelineId(logRecordDo.getPipelineId());
                    logRecord.setChannel(channel);
                    for (Pipeline pipeline : channel.getPipelines()) {
                        if (pipeline.getId().equals(logRecordDo.getPipelineId())) {
                            logRecord.setPipeline(pipeline);
                        }
                    }
                } catch (Exception e) {
                    // 可能历史的log记录对应的channel/pipeline已经被删除了,直接忽略吧
                    Channel channel = new Channel();
                    channel.setId(0l);
                    logRecord.setChannel(channel);
                    Pipeline pipeline = new Pipeline();
                    pipeline.setId(0l);
                    logRecord.setPipeline(pipeline);
                }
            } else {
                Channel channel = new Channel();
                channel.setId(-1l);
                logRecord.setChannel(channel);
                Pipeline pipeline = new Pipeline();
                pipeline.setId(-1l);
                logRecord.setPipeline(pipeline);
            }
View Full Code Here


            // 拿到所有的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);
View Full Code Here

            for (ChannelDO channelDo : channelDos) {
                channelIds.add(channelDo.getId());
            }

            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>();
                channel.setPipelines(subPipelines);
                channels.add(channel);
            }
        } catch (Exception e) {
            logger.error("ERROR ## change the channels doToModelOnlyChannels has an exception");
            throw new ManagerException(e);
View Full Code Here

     */
    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);
View Full Code Here

            Assert.notNull(data.getProcessId());
            normalTerminProcess.process(data); // 单独处理
        } else if (type.isWarning()) {
            warningTerminProcess.process(data); // warn单独处理,不需要关闭相关的pipeline
        } else {
            Channel channel = ArbitrateConfigUtils.getChannel(data.getPipelineId());

            if (data.getType().isRollback()) {
                boolean paused = channelEvent.pause(channel.getId());
                if (paused) {// 如果pause成功,则发送报警信息
                    warningTerminProcess.process(data);
                }
            } else if (data.getType().isShutdown()) {
                boolean shutdowned = channelEvent.stop(channel.getId());
                // 发送报警信息
                if (shutdowned) {
                    warningTerminProcess.process(data);
                }
                // 发送关闭命令给manager
                StopChannelEvent event = new StopChannelEvent();
                event.setChannelId(channel.getId());
                arbitrateCommmunicationClient.callManager(event);
            } else if (data.getType().isRestart()) {
                boolean restarted = channelEvent.restart(channel.getId());
                // 发送报警信息
                if (restarted) {
                    warningTerminProcess.process(data);
                }
            }
View Full Code Here

        // 以及 dataMediaPair 的 pushWeight
        final int fileDataStartIndex = 0;
        final int fileDataCount = 50;
        final Pipeline pipeline = buildPipeline(fileDataStartIndex, fileDataCount);

        final Channel channel = new Channel();

        new NonStrictExpectations() {

            {
                configClientService.findChannel(anyLong);
View Full Code Here

    @Test
    public void test_db_load_oracle() {
        ArbitrateConfigRegistry.regist(configClientService);
        dbLoadAction = (DbLoadAction) TestedObject.getSpringBeanFactory().getBean("dbLoadAction");

        final Channel channel = new Channel();
        channel.setId(1L);

        final Pipeline pipeline = new Pipeline();
        pipeline.setId(100L);
        List<DataMediaPair> pairs = generatorDataMediaPairForOracle(20);
        pipeline.setPairs(pairs);
        pipeline.getParameters().merge(new SystemParameter());
        pipeline.getParameters().merge(new ChannelParameter());

        // final Pipeline oppositePipeline = new Pipeline();
        // oppositePipeline.setId(101L);
        channel.setPipelines(Arrays.asList(pipeline));

        final Node currentNode = new Node();
        currentNode.setId(1L);
        new NonStrictExpectations() {
View Full Code Here

    @Test
    public void test_db_load_mysql() {
        ArbitrateConfigRegistry.regist(configClientService);
        dbLoadAction = (DbLoadAction) TestedObject.getSpringBeanFactory().getBean("dbLoadAction");

        final Channel channel = new Channel();
        channel.setId(1L);

        final Pipeline pipeline = new Pipeline();
        pipeline.setId(100L);
        List<DataMediaPair> pairs = generatorDataMediaPairForMysql(20);
        pipeline.setPairs(pairs);
        pipeline.getParameters().merge(new SystemParameter());
        pipeline.getParameters().merge(new ChannelParameter());
        // pipeline.getParameters().setChannelInfo("LJH_DEMO");

        // final Pipeline oppositePipeline = new Pipeline();
        // oppositePipeline.setId(101L);
        channel.setPipelines(Arrays.asList(pipeline));

        final Node currentNode = new Node();
        currentNode.setId(1L);
        new NonStrictExpectations() {
View Full Code Here

    @Test
    public void test_b_channel() {
        Long channelId = 100L;
        Long pipelineId = 101L;
        Long oppositePipelineId = 102L; // 先加一个pipeline的同步任务
        final Channel channel = new Channel();
        channel.setId(channelId);
        channel.setStatus(ChannelStatus.START);
        Pipeline pipeline1 = new Pipeline();
        pipeline1.setChannelId(channelId);
        pipeline1.setId(pipelineId);

        Pipeline pipeline2 = new Pipeline();
        pipeline2.setChannelId(channelId);
        pipeline2.setId(oppositePipelineId);
        channel.setPipelines(Arrays.asList(pipeline1, pipeline2));

        Node node1 = new Node();
        node1.setId(1L);

        Node node2 = new Node();
View Full Code Here

    @Test
    public void test_a_reload() throws Exception {
        Long channelId = 100L;
        Long pipelineId = 100L;
        Long oppositePipelineId = 101L;
        final Channel channel = new Channel();
        channel.setId(channelId);
        channel.setStatus(ChannelStatus.START);
        Pipeline pipeline1 = new Pipeline();
        pipeline1.setChannelId(channelId);
        pipeline1.setId(pipelineId);

        Pipeline pipeline2 = new Pipeline();
        pipeline2.setChannelId(channelId);
        pipeline2.setId(oppositePipelineId);
        channel.setPipelines(Arrays.asList(pipeline1, pipeline2));

        Node node1 = new Node();
        node1.setId(1L);

        Node node2 = new Node();
        node2.setId(2L);

        pipeline1.setSelectNodes(Arrays.asList(node1, node2));
        pipeline1.setExtractNodes(Arrays.asList(node1, node2));
        pipeline1.setLoadNodes(Arrays.asList(node1));

        pipeline2.setSelectNodes(Arrays.asList(node2));
        pipeline2.setExtractNodes(Arrays.asList(node2));
        pipeline2.setLoadNodes(Arrays.asList(node1, node2));

        Mockit.setUpMock(NodeCommmunicationClient.class, new Object() {

            @Mock
            public Object callManager(final Event event) {
                if (event instanceof FindNodeEvent) {
                    Node node = new Node();
                    Long nid = ((FindNodeEvent) event).getNid();
                    node.setId(nid);
                    return node;
                } else {
                    return Arrays.asList(channel);
                }
            }
        });
        List<NodeTask> tasks = null;
        NodeTaskServiceImpl nodeTaskSerivce = (NodeTaskServiceImpl) spring.getBean("nodeTaskService");
        reflector.invoke(nodeTaskSerivce, "initNodeTask");
        tasks = reflector.invoke(nodeTaskSerivce, "mergeIncNodeTasks");
        want.number(tasks.size()).isEqualTo(2);

        reflector.invoke(nodeTaskSerivce, "initNodeTask");
        tasks = reflector.invoke(nodeTaskSerivce, "mergeIncNodeTasks");
        want.bool(tasks.size() == 0).is(true);

        channel.setStatus(ChannelStatus.STOP);
        reflector.invoke(nodeTaskSerivce, "initNodeTask");
        tasks = reflector.invoke(nodeTaskSerivce, "mergeIncNodeTasks");
        want.bool(tasks.size() == 2).is(true);
        tasks = nodeTaskSerivce.listAllNodeTasks();
        want.bool(tasks.size() == 2).is(true);

        // 清理内存
        TestUtils.setField(nodeTaskSerivce, "allTasks", Lists.newArrayList());
        TestUtils.setField(nodeTaskSerivce, "incTasks", Lists.newArrayList());
        // 删除某个pipeline的node
        channel.setStatus(ChannelStatus.START);
        reflector.invoke(nodeTaskSerivce, "initNodeTask");
        tasks = reflector.invoke(nodeTaskSerivce, "mergeIncNodeTasks");
        want.number(tasks.size()).isEqualTo(2);

        pipeline1.setSelectNodes(Arrays.asList(node2));
        pipeline1.setExtractNodes(Arrays.asList(node2));
        pipeline1.setLoadNodes(Arrays.asList(node2));
        channel.setStatus(ChannelStatus.START);
        reflector.invoke(nodeTaskSerivce, "initNodeTask");
        tasks = reflector.invoke(nodeTaskSerivce, "mergeIncNodeTasks");
        want.bool(tasks.size() == 1).is(true);

        // 清理内存
        TestUtils.setField(nodeTaskSerivce, "allTasks", Lists.newArrayList());
        TestUtils.setField(nodeTaskSerivce, "incTasks", Lists.newArrayList());
        channel.setStatus(ChannelStatus.START);
        reflector.invoke(nodeTaskSerivce, "initNodeTask");
        tasks = reflector.invoke(nodeTaskSerivce, "mergeIncNodeTasks");
        want.number(tasks.size()).isEqualTo(1);
        // 删除某个pipeline
        channel.setPipelines(Arrays.asList(pipeline1));
        reflector.invoke(nodeTaskSerivce, "initNodeTask");
        tasks = reflector.invoke(nodeTaskSerivce, "mergeIncNodeTasks");
        want.number(tasks.size()).isEqualTo(1);
    }
View Full Code Here

TOP

Related Classes of com.alibaba.otter.shared.common.model.config.channel.Channel

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.