Search in sources :

Example 6 with TerminMonitor

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

the class TerminMonitorTest method test_dynamic.

@Test
public void test_dynamic() {
    initTermin(1L);
    initTermin(2L);
    try {
        terminMonitor = new TerminMonitor(pipelineId);
        // 开始变化
        destoryTermin(1L);
        initTermin(3L);
        initTermin(1L);
        sleep();
        Long p1 = terminMonitor.waitForProcess();
        terminMonitor.ack(p1);
        Long p2 = terminMonitor.waitForProcess();
        terminMonitor.ack(p2);
        Long p3 = terminMonitor.waitForProcess();
        terminMonitor.ack(p3);
        // 一定是按顺序输出
        want.bool(p1.equals(1L)).is(true);
        want.bool(p2.equals(2L)).is(true);
        want.bool(p3.equals(3L)).is(true);
        terminMonitor.destory();
    } catch (InterruptedException e) {
        want.fail();
    } finally {
        destoryTermin(1L);
        destoryTermin(2L);
        destoryTermin(3L);
    }
}
Also used : TerminMonitor(com.alibaba.otter.shared.arbitrate.impl.setl.monitor.TerminMonitor) Test(org.testng.annotations.Test) BaseEventTest(com.alibaba.otter.shared.arbitrate.BaseEventTest)

Aggregations

TerminMonitor (com.alibaba.otter.shared.arbitrate.impl.setl.monitor.TerminMonitor)6 ArbitrateException (com.alibaba.otter.shared.arbitrate.exception.ArbitrateException)3 BaseEventTest (com.alibaba.otter.shared.arbitrate.BaseEventTest)2 ZkException (org.I0Itec.zkclient.exception.ZkException)2 ZkNoNodeException (org.I0Itec.zkclient.exception.ZkNoNodeException)2 Test (org.testng.annotations.Test)2 TerminEventData (com.alibaba.otter.shared.arbitrate.model.TerminEventData)1