use of com.alibaba.otter.shared.arbitrate.demo.servcie.TerminProcessDemo in project otter by alibaba.
the class ArbitrateAllTest method setUp.
@BeforeMethod
public void setUp() {
// 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(local));
pipeline.setExtractNodes(Arrays.asList(local));
pipeline.setLoadNodes(Arrays.asList(local));
pipeline.getParameters().setArbitrateMode(arbitrateMode);
channel.setPipelines(Arrays.asList(pipeline));
return channel;
}
@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));
pipeline.getParameters().setArbitrateMode(arbitrateMode);
return pipeline;
}
@Mock
public Long getCurrentNid() {
return nid;
}
@Mock
public int getParallelism(Long pipelineId) {
// 并行度
return 3;
}
@Mock
public Pipeline getOppositePipeline(Long pipelineId) {
return null;
}
@Mock
public Channel getChannel(Long pipelineId) {
Channel channel = new Channel();
channel.setId(channelId);
Pipeline pipeline = new Pipeline();
pipeline.setId(pipelineId);
pipeline.getParameters().setArbitrateMode(arbitrateMode);
channel.setPipelines(Arrays.asList(pipeline));
return channel;
}
});
Mockit.setUpMock(ArbitrateCommmunicationClient.class, new Object() {
@Mock
public Object callManager(final Event event) {
// do nothing
return null;
}
});
zookeeper = getZookeeper();
local.setId(nid);
nodeEvent = new NodeArbitrateEvent();
channelEvent = new ChannelArbitrateEvent();
pipelineEvent = new PipelineArbitrateEvent();
// 创建node节点
nodeEvent.init(local.getId());
// 创建pipeline节点
channelEvent.init(channelId);
pipelineEvent.init(channelId, pipelineId);
arbitrateEventService = (ArbitrateEventService) getBeanFactory().getBean("arbitrateEventService");
mainStem = new MainStemServiceDemo();
autowire(mainStem);
select = new SelectServiceDemo();
autowire(select);
extract = new ExtractServiceDemo();
autowire(extract);
transform = new TransformServiceDemo();
autowire(transform);
load = new LoadServiceDemo();
autowire(load);
view = new ProcessViewDemo();
autowire(view);
termin = new TerminProcessDemo();
autowire(termin);
}
use of com.alibaba.otter.shared.arbitrate.demo.servcie.TerminProcessDemo in project otter by alibaba.
the class ArbitrateForwardIntegration method setUp.
@BeforeMethod
public void setUp() {
// 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;
}
});
Mockit.setUpMock(ArbitrateCommmunicationClient.class, new Object() {
@Mock
public Object callManager(final Event event) {
// do nothing
return null;
}
});
zookeeper = getZookeeper();
one.setId(oneNid);
two.setId(twoNid);
nodeEvent = new NodeArbitrateEvent();
// 创建channel
channelEvent = new ChannelArbitrateEvent();
pipelineEvent = new PipelineArbitrateEvent();
// 创建node节点
nodeEvent.init(oneNid);
// 创建pipeline节点
try {
channelEvent.init(channelId);
} catch (Exception e) {
// ignore
}
try {
pipelineEvent.init(channelId, pipelineId);
} catch (Exception e) {
// ignore
}
arbitrateEventService = (ArbitrateEventService) getBeanFactory().getBean("arbitrateEventService");
mainStem = new MainStemServiceDemo();
autowire(mainStem);
select = new SelectServiceDemo();
autowire(select);
extract = new ExtractServiceDemo();
autowire(extract);
transform = new TransformServiceDemo();
autowire(transform);
load = new LoadServiceDemo();
autowire(load);
view = new ProcessViewDemo();
autowire(view);
termin = new TerminProcessDemo();
autowire(termin);
}
use of com.alibaba.otter.shared.arbitrate.demo.servcie.TerminProcessDemo in project otter by alibaba.
the class ArbitrateOppositeIntegration method setUp.
@BeforeMethod
public void setUp() {
// 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;
}
});
Mockit.setUpMock(ArbitrateCommmunicationClient.class, new Object() {
@Mock
public Object callManager(final Event event) {
// do nothing
return null;
}
});
zookeeper = getZookeeper();
one.setId(oneNid);
two.setId(twoNid);
nodeEvent = new NodeArbitrateEvent();
// 创建channel
channelEvent = new ChannelArbitrateEvent();
pipelineEvent = new PipelineArbitrateEvent();
// 创建node节点
nodeEvent.init(one.getId());
// 创建pipeline节点
try {
channelEvent.init(channelId);
} catch (Exception e) {
// ignore
}
try {
pipelineEvent.init(channelId, pipelineId);
} catch (Exception e) {
// ignore
}
arbitrateEventService = (ArbitrateEventService) getBeanFactory().getBean("arbitrateEventService");
mainStem = new MainStemServiceDemo();
autowire(mainStem);
select = new SelectServiceDemo();
autowire(select);
extract = new ExtractServiceDemo();
autowire(extract);
transform = new TransformServiceDemo();
autowire(transform);
load = new LoadServiceDemo();
autowire(load);
view = new ProcessViewDemo();
autowire(view);
termin = new TerminProcessDemo();
autowire(termin);
}
Aggregations