Search in sources :

Example 1 with MainStemArbitrateEvent

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

the class MainStemArbitrateEventTest method test_mainStem.

@Test
public void test_mainStem() {
    // 启动
    channelEvent.start(channelId);
    mainStemEvent = new MainStemArbitrateEvent();
    try {
        mainStemEvent.await(pipelineId);
        MainStemEventData eventData = new MainStemEventData();
        eventData.setPipelineId(pipelineId);
        eventData.setStatus(MainStemEventData.Status.OVERTAKE);
        mainStemEvent.single(eventData);
        PermitMonitor permit = ArbitrateFactory.getInstance(pipelineId, PermitMonitor.class);
        // 阻塞等待授权
        permit.waitForPermit();
    } catch (InterruptedException e) {
        want.fail();
    }
    boolean check = mainStemEvent.check(pipelineId);
    want.bool(check).is(true);
    // 删除mainStem节点
    mainStemEvent.release(pipelineId);
}
Also used : PermitMonitor(com.alibaba.otter.shared.arbitrate.impl.setl.monitor.PermitMonitor) MainStemEventData(com.alibaba.otter.shared.arbitrate.model.MainStemEventData) MainStemArbitrateEvent(com.alibaba.otter.shared.arbitrate.impl.setl.MainStemArbitrateEvent) Test(org.testng.annotations.Test) BaseEventTest(com.alibaba.otter.shared.arbitrate.BaseEventTest)

Aggregations

BaseEventTest (com.alibaba.otter.shared.arbitrate.BaseEventTest)1 MainStemArbitrateEvent (com.alibaba.otter.shared.arbitrate.impl.setl.MainStemArbitrateEvent)1 PermitMonitor (com.alibaba.otter.shared.arbitrate.impl.setl.monitor.PermitMonitor)1 MainStemEventData (com.alibaba.otter.shared.arbitrate.model.MainStemEventData)1 Test (org.testng.annotations.Test)1