Package com.alibaba.otter.shared.arbitrate.impl.setl.monitor

Examples of com.alibaba.otter.shared.arbitrate.impl.setl.monitor.MainstemMonitor


    }

    @Test
    public void testInit() {
        MainstemMonitor mainstemMonitor = ArbitrateFactory.getInstance(pipelineId, MainstemMonitor.class);
        boolean running = mainstemMonitor.check();
        want.bool(running).is(true);

        try {
            mainstemMonitor.waitForActive();
        } catch (InterruptedException e) {
            want.fail();
        }

        ArbitrateFactory.destory(pipelineId);
        mainstemMonitor.releaseMainstem();
    }
View Full Code Here


        mainstemMonitor.releaseMainstem();
    }

    @Test
    public void testRelease() {
        MainstemMonitor mainstemMonitor = ArbitrateFactory.getInstance(pipelineId, MainstemMonitor.class);
        boolean running = mainstemMonitor.check();
        want.bool(running).is(true);

        boolean release = mainstemMonitor.releaseMainstem();// 模拟一次断网,
        want.bool(release).is(true);

        long start = System.currentTimeMillis();
        try {
            mainstemMonitor.waitForActive();
        } catch (InterruptedException e) {
            want.fail();
        }
        want.number(System.currentTimeMillis() - start).isLe(1000L);
        ArbitrateFactory.destory(pipelineId);
        mainstemMonitor.releaseMainstem();
    }
View Full Code Here

        mainstemMonitor.releaseMainstem();
    }

    @Test
    public void testManualRelease() {
        MainstemMonitor mainstemMonitor = ArbitrateFactory.getInstance(pipelineId, MainstemMonitor.class);
        boolean running = mainstemMonitor.check();
        want.bool(running).is(true);
        mainstemMonitor.setDelayTime(5);

        switchWarmup(channelId, pipelineId);
        sleep(1000L); // 等manual release被响应

        long start = System.currentTimeMillis();
        try {
            mainstemMonitor.waitForActive();
        } catch (InterruptedException e) {
            want.fail();
        }
        want.number(System.currentTimeMillis() - start).isGe(4000L);
        ArbitrateFactory.destory(pipelineId);
        mainstemMonitor.releaseMainstem();
    }
View Full Code Here

            return;
        } else if (isRuning == false) {
            if (!status.isStart()) {
                permitMonitor.waitForChannelPermit(); // 阻塞等待挂起
            }
            MainstemMonitor mainstemMonitor = ArbitrateFactory.getInstance(pipelineId, MainstemMonitor.class);
            mainstemMonitor.waitForActive();// 等待自己成为active

            status = permitMonitor.getChannelPermit(false);
            if (status.isStart()) {
                return;
            } else {
View Full Code Here

    /**
     * 检查下当前的mainstem是否可以运行(在await获取成功后,每次执行业务之前进行check)
     */
    public boolean check(Long pipelineId) {
        MainstemMonitor mainstemMonitor = ArbitrateFactory.getInstance(pipelineId, MainstemMonitor.class);
        return mainstemMonitor.check();
    }
View Full Code Here

    /**
     * 更新mainStem的同步状态数据
     */
    public void single(MainStemEventData data) {
        MainstemMonitor mainstemMonitor = ArbitrateFactory.getInstance(data.getPipelineId(), MainstemMonitor.class);
        mainstemMonitor.single(data);
    }
View Full Code Here

    /**
     * 释放mainStem的节点,重新选择工作节点
     */
    public void release(Long pipelineId) {
        MainstemMonitor mainstemMonitor = ArbitrateFactory.getInstance(pipelineId, MainstemMonitor.class);
        mainstemMonitor.releaseMainstem();
    }
View Full Code Here

TOP

Related Classes of com.alibaba.otter.shared.arbitrate.impl.setl.monitor.MainstemMonitor

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.