Search in sources :

Example 76 with Pipeline

use of com.alibaba.otter.shared.common.model.config.pipeline.Pipeline 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 77 with Pipeline

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

the class ArbitrateConfigImpl method updateMapping.

private void updateMapping(Channel channel, Long excludeId) {
    Long channelId = channel.getId();
    List<Pipeline> pipelines = channel.getPipelines();
    for (Pipeline pipeline : pipelines) {
        if (excludeId == null || !pipeline.getId().equals(excludeId)) {
            channelMapping.put(pipeline.getId(), channelId);
        }
    }
}
Also used : Pipeline(com.alibaba.otter.shared.common.model.config.pipeline.Pipeline)

Example 78 with Pipeline

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

the class ArbitrateConfigImpl method findOppositePipeline.

public Pipeline findOppositePipeline(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) == false) {
            // 这里假定pipeline只有两个
            return pipeline;
        }
    }
    return null;
}
Also used : Channel(com.alibaba.otter.shared.common.model.config.channel.Channel) Pipeline(com.alibaba.otter.shared.common.model.config.pipeline.Pipeline)

Example 79 with Pipeline

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

the class MainStemArbitrateEventTest method init.

@BeforeClass
public void init() {
    // 初始化节点
    // 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) {
            // 没有反向同步
            return null;
        }

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

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

        @Mock
        public Long getCurrentNid() {
            return nid;
        }
    });
    getZookeeper();
    local.setId(nid);
    nodeEvent = new NodeArbitrateEvent();
    channelEvent = new ChannelArbitrateEvent();
    pipelineEvent = new PipelineArbitrateEvent();
    nodeEvent.init(nid);
    channelEvent.init(channelId);
    pipelineEvent.init(channelId, pipelineId);
    channelEvent.start(channelId);
}
Also used : Channel(com.alibaba.otter.shared.common.model.config.channel.Channel) ChannelArbitrateEvent(com.alibaba.otter.shared.arbitrate.impl.manage.ChannelArbitrateEvent) PipelineArbitrateEvent(com.alibaba.otter.shared.arbitrate.impl.manage.PipelineArbitrateEvent) Mock(mockit.Mock) Pipeline(com.alibaba.otter.shared.common.model.config.pipeline.Pipeline) NodeArbitrateEvent(com.alibaba.otter.shared.arbitrate.impl.manage.NodeArbitrateEvent) BeforeClass(org.testng.annotations.BeforeClass)

Example 80 with Pipeline

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

the class RandomLoadBalanceTest method testExtract.

@Test
public void testExtract() {
    // 初始化节点
    Mockit.setUpMock(ArbitrateConfigUtils.class, new Object() {

        @Mock
        public Pipeline getPipeline(Long pipelineId) {
            Pipeline pipeline = new Pipeline();
            pipeline.setId(pipelineId);
            pipeline.setSelectNodes(sourceList);
            pipeline.setExtractNodes(sourceList);
            pipeline.setLoadNodes(targetList);
            return pipeline;
        }
    });
    ExtractRandomLoadBanlance extract = new ExtractRandomLoadBanlance(pipelineId);
    extract.setNodeMonitor(nodeMonitor);
    sleep(500L);
    try {
        Node n1 = extract.next();
        Node n2 = extract.next();
        Node n3 = extract.next();
        Node n4 = extract.next();
        System.out.printf("n1[%s] n2[%s] n3[%s] n4[%s]", n1.getId(), n2.getId(), n3.getId(), n4.getId());
        want.bool(sourceList.contains(n1)).is(true);
        want.bool(sourceList.contains(n2)).is(true);
        want.bool(sourceList.contains(n3)).is(true);
        want.bool(sourceList.contains(n4)).is(true);
    } catch (InterruptedException e) {
        want.fail();
    }
}
Also used : Node(com.alibaba.otter.shared.common.model.config.node.Node) Mock(mockit.Mock) ExtractRandomLoadBanlance(com.alibaba.otter.shared.arbitrate.impl.setl.lb.ExtractRandomLoadBanlance) Pipeline(com.alibaba.otter.shared.common.model.config.pipeline.Pipeline) Test(org.testng.annotations.Test)

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