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 + "]");
}
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);
}
}
}
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;
}
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);
}
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();
}
}
Aggregations