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

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


        // mock 配置信息数据
        Mockit.setUpMock(ArbitrateConfigUtils.class, new Object() {

            @Mock
            public Channel getChannelByChannelId(Long channelId) {
                Channel channel = new Channel();
                channel.setId(channelId);
                Pipeline pipeline = new Pipeline();
                pipeline.setId(pipelineId);
                pipeline.setSelectNodes(Arrays.asList(one));
                pipeline.setExtractNodes(Arrays.asList(one));
                pipeline.setLoadNodes(Arrays.asList(two));
                channel.setPipelines(Arrays.asList(pipeline));
                return channel;
            }

            @Mock
            public Pipeline getPipeline(Long pipelineId) {
                Pipeline pipeline = new Pipeline();
                pipeline.setId(pipelineId);
                pipeline.setSelectNodes(Arrays.asList(one));
                pipeline.setExtractNodes(Arrays.asList(one));
                pipeline.setLoadNodes(Arrays.asList(two));
                return pipeline;
            }

            @Mock
            public Long getCurrentNid() {
                return oneNid;
            }

            @Mock
            public int getParallelism(Long pipelineId) {
                return 3;// 并行度
            }

            @Mock
            public Pipeline getOppositePipeline(Long pipelineId) {
                Pipeline pipeline = new Pipeline();
                pipeline.setId(oppositePipelineId);
                pipeline.setSelectNodes(Arrays.asList(two));
                pipeline.setExtractNodes(Arrays.asList(two));
                pipeline.setLoadNodes(Arrays.asList(one));
                return pipeline;
            }

            @Mock
            public Channel getChannel(Long pipelineId) {
                Channel channel = new Channel();
                channel.setId(channelId);

                Pipeline pipeline = new Pipeline();
                pipeline.setId(pipelineId);

                Pipeline oppositePipeline = new Pipeline();
                oppositePipeline.setId(oppositePipelineId);
                channel.setPipelines(Arrays.asList(pipeline, oppositePipeline));
                return channel;
            }

        });
View Full Code Here


        // 初始化节点
        Mockit.setUpMock(ArbitrateConfigUtils.class, new Object() {

            @Mock
            public Channel getChannel(Long pipelineId) {
                Channel channel = new Channel();
                channel.setId(channelId);
                return channel;
            }

            @Mock
            public Pipeline getOppositePipeline(Long pipelineId) {
View Full Code Here

        // mock 配置信息数据
        Mockit.setUpMock(ArbitrateConfigUtils.class, new Object() {

            @Mock
            public Channel getChannel(Long pipelineId) {
                Channel channel = new Channel();
                channel.setId(channelId);
                return channel;
            }

            @Mock
            public Pipeline getOppositePipeline(Long pipelineId) {
View Full Code Here

    @Test
    public void test_pipeline() {
        Long channelId = 100L;
        Long pipelineId = 100L;
        Long oppositePipelineId = 101L;
        final Channel channel = new Channel();
        channel.setId(channelId);
        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));

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

            @Mock
            public Object callManager(final Event event) {
                return channel;
            }
        });

        Pipeline pipeline = configClientService.findPipeline(pipelineId);
        want.bool(pipeline.getId() == pipelineId);

        pipeline = configClientService.findOppositePipeline(pipelineId);
        want.bool(pipeline.getId() == oppositePipelineId);

        Channel channel1 = configClientService.findChannel(channelId);
        want.bool(channel1.getId() == channelId);

        channel1 = configClientService.findChannelByPipelineId(pipelineId);
        want.bool(channel1.getId() == channelId);
    }
View Full Code Here

    }

    @Test
    public void test_pipeline() {
        Long channelId = 11L;
        Channel channel = configClientService.findChannel(channelId);
        System.out.println(channel);
        want.number(channel.getId()).isEqualTo(channelId);
    }
View Full Code Here

     */
    public void doAdd(@FormGroup("channelInfo") Group channelInfo,
                      @FormGroup("channelParameterInfo") Group channelParameterInfo,
                      @FormField(name = "formChannelError", group = "channelInfo") CustomErrors err, Navigator nav)
                                                                                                                   throws Exception {
        Channel channel = new Channel();
        ChannelParameter parameter = new ChannelParameter();
        channelInfo.setProperties(channel);
        channelParameterInfo.setProperties(parameter);
        // 新建Channel默认关闭该状态
        channel.setStatus(ChannelStatus.STOP);
        channel.setParameters(parameter);
        try {
            channelService.create(channel);
        } catch (RepeatConfigureException rce) {
            err.setMessage("invalidChannelName");
            return;
View Full Code Here

    public void doEdit(@FormGroup("channelInfo") Group channelInfo, @Param("pageIndex") int pageIndex,
                       @Param("searchKey") String searchKey,
                       @FormGroup("channelParameterInfo") Group channelParameterInfo,
                       @FormField(name = "formChannelError", group = "channelInfo") CustomErrors err, Navigator nav)
                                                                                                                    throws Exception {
        Channel channel = new Channel();
        ChannelParameter parameter = new ChannelParameter();
        channelInfo.setProperties(channel);
        channelParameterInfo.setProperties(parameter);
        channel.setStatus(channelService.findById(channel.getId()).getStatus());
        parameter.setChannelId(channel.getId());
        channel.setParameters(parameter);
        try {
            channelService.modify(channel);
        } catch (RepeatConfigureException rce) {
            err.setMessage("invalidChannelName");
            return;
View Full Code Here

    }

    private DbLoadContext buildContext(Identity identity) {
        DbLoadContext context = new DbLoadContext();
        context.setIdentity(identity);
        Channel channel = configClientService.findChannel(identity.getChannelId());
        Pipeline pipeline = configClientService.findPipeline(identity.getPipelineId());
        context.setChannel(channel);
        context.setPipeline(pipeline);
        return context;
    }
View Full Code Here

    /**
     * 更新一下事务标记
     */
    private void updateMark(DbLoadContext context, DbDialect dialect, int threadId, String sql, boolean needInfo) {
        Identity identity = context.getIdentity();
        Channel channel = context.getChannel();
        // 获取dbDialect
        String markTableName = context.getPipeline().getParameters().getSystemSchema() + "."
                               + context.getPipeline().getParameters().getSystemMarkTable();
        String markTableColumn = context.getPipeline().getParameters().getSystemMarkTableColumn();
        synchronized (dialect.getJdbcTemplate()) {
            if (tableCheckStatus.contains(dialect.getJdbcTemplate()) == false) {
                init(dialect.getJdbcTemplate(), markTableName, markTableColumn);
                tableCheckStatus.add(dialect.getJdbcTemplate());
            }
        }

        int affectedCount = 0;
        if (needInfo) {
            String infoColumn = context.getPipeline().getParameters().getSystemMarkTableInfo();
            String info = context.getPipeline().getParameters().getChannelInfo();// 记录一下channelInfo
            affectedCount = dialect.getJdbcTemplate().update(MessageFormat.format(sql, new Object[] { markTableName,
                                                                     markTableColumn, infoColumn }),
                                                             new Object[] { threadId, channel.getId(), info });
        } else {
            affectedCount = dialect.getJdbcTemplate().update(MessageFormat.format(sql, new Object[] { markTableName,
                                                                     markTableColumn }),
                                                             new Object[] { threadId, channel.getId() });
        }

        if (affectedCount <= 0) {
            logger.warn("## update {} failed by [{}]", markTableName, threadId);
        } else {
View Full Code Here

                            long startTime = etlEventData.getStartTime();
                            if (!CollectionUtils.isEmpty(eventData)) {
                                startTime = eventData.get(0).getExecuteTime();
                            }

                            Channel channel = configClientService.findChannelByPipelineId(pipelineId);
                            RowBatch rowBatch = new RowBatch();
                            // 构造唯一标识
                            Identity identity = new Identity();
                            identity.setChannelId(channel.getId());
                            identity.setPipelineId(pipelineId);
                            identity.setProcessId(etlEventData.getProcessId());
                            rowBatch.setIdentity(identity);
                            // 进行数据合并
                            for (EventData data : eventData) {
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.