Search in sources :

Example 1 with TransformRoundRobinLoadBalance

use of com.alibaba.otter.shared.arbitrate.impl.setl.lb.TransformRoundRobinLoadBalance in project otter by alibaba.

the class RoundRobinBalanceTest method testTransform.

@Test
public void testTransform() {
    // 初始化节点
    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;
        }
    });
    TransformRoundRobinLoadBalance transform = new TransformRoundRobinLoadBalance(pipelineId);
    transform.setNodeMonitor(nodeMonitor);
    try {
        Node n1 = transform.next();
        Node n2 = transform.next();
        Node n3 = transform.next();
        Node n4 = transform.next();
        System.out.printf("n1[%s] n2[%s] n3[%s] n4[%s]", n1.getId(), n2.getId(), n3.getId(), n4.getId());
        want.bool(targetList.contains(n1)).is(true);
        want.bool(targetList.contains(n2)).is(true);
        want.bool(targetList.contains(n3)).is(true);
        want.bool(targetList.contains(n4)).is(true);
    } catch (InterruptedException e) {
        want.fail();
    }
}
Also used : Node(com.alibaba.otter.shared.common.model.config.node.Node) TransformRoundRobinLoadBalance(com.alibaba.otter.shared.arbitrate.impl.setl.lb.TransformRoundRobinLoadBalance) Mock(mockit.Mock) Pipeline(com.alibaba.otter.shared.common.model.config.pipeline.Pipeline) Test(org.testng.annotations.Test)

Aggregations

TransformRoundRobinLoadBalance (com.alibaba.otter.shared.arbitrate.impl.setl.lb.TransformRoundRobinLoadBalance)1 Node (com.alibaba.otter.shared.common.model.config.node.Node)1 Pipeline (com.alibaba.otter.shared.common.model.config.pipeline.Pipeline)1 Mock (mockit.Mock)1 Test (org.testng.annotations.Test)1