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

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


        TerminEventData shutdown = new TerminEventData();
        shutdown.setPipelineId(pipelineId);
        shutdown.setType(TerminType.SHUTDOWN);
        terminEvent.single(shutdown);

        PermitMonitor monitor = ArbitrateFactory.getInstance(pipelineId, PermitMonitor.class);
        want.bool(monitor.getChannelPermit(true).isStop()).is(true);

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


        rollback.setPipelineId(pipelineId);
        rollback.setType(TerminType.RESTART);
        terminEvent.single(rollback);

        sleep(4000L);
        PermitMonitor monitor = ArbitrateFactory.getInstance(pipelineId, PermitMonitor.class);
        want.bool(monitor.getChannelPermit(true).isStart()).is(true);
        sleep(4000L);

        // 发送shutdown信号
        TerminEventData shutdown = new TerminEventData();
        shutdown.setPipelineId(pipelineId);
        shutdown.setType(TerminType.SHUTDOWN);
        terminEvent.single(shutdown);

        want.bool(monitor.getChannelPermit(true).isStop()).is(true);

        // 删除对应的错误节点
        destoryTermin();
        ArbitrateFactory.destory(pipelineId);
    }
View Full Code Here

        TerminEventData rollback = new TerminEventData();
        rollback.setPipelineId(pipelineId);
        rollback.setType(TerminType.ROLLBACK);
        terminEvent.single(rollback);

        PermitMonitor monitor = ArbitrateFactory.getInstance(pipelineId, PermitMonitor.class);
        want.bool(monitor.getChannelPermit().isPause()).is(true);

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

        TerminEventData shutdown = new TerminEventData();
        shutdown.setPipelineId(pipelineId);
        shutdown.setType(TerminType.SHUTDOWN);
        terminEvent.single(shutdown);

        PermitMonitor monitor = ArbitrateFactory.getInstance(pipelineId, PermitMonitor.class);
        want.bool(monitor.getChannelPermit().isStop()).is(true);

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

        TerminEventData rollback = new TerminEventData();
        rollback.setPipelineId(pipelineId);
        rollback.setType(TerminType.RESTART);
        terminEvent.single(rollback);

        PermitMonitor monitor = ArbitrateFactory.getInstance(pipelineId, PermitMonitor.class);
        sleep(4000L);
        want.bool(monitor.getChannelPermit().isStart()).is(true);

        // 发送shutdown信号
        TerminEventData shutdown = new TerminEventData();
        shutdown.setPipelineId(pipelineId);
        shutdown.setType(TerminType.SHUTDOWN);
        terminEvent.single(shutdown);

        want.bool(monitor.getChannelPermit().isStop()).is(true);

        // 删除对应的错误节点
        destoryTermin();
        ArbitrateFactory.destory(pipelineId);
    }
View Full Code Here

     * @throws InterruptedException
     */
    public void waitForPermit(Long pipelineId) throws InterruptedException {
        Assert.notNull(pipelineId);

        PermitMonitor permitMonitor = ArbitrateFactory.getInstance(pipelineId, PermitMonitor.class);
        permitMonitor.waitForPermit();// 阻塞等待授权
    }
View Full Code Here

    private static final Logger logger = LoggerFactory.getLogger(SelectMemoryArbitrateEvent.class);

    public EtlEventData await(Long pipelineId) throws InterruptedException {
        Assert.notNull(pipelineId);

        PermitMonitor permitMonitor = ArbitrateFactory.getInstance(pipelineId, PermitMonitor.class);
        permitMonitor.waitForPermit();// 阻塞等待授权

        MemoryStageController stageController = ArbitrateFactory.getInstance(pipelineId, MemoryStageController.class);
        Long processId = stageController.waitForProcess(StageType.SELECT); // 符合条件的processId

        ChannelStatus status = permitMonitor.getChannelPermit();
        if (status.isStart()) {// 即时查询一下当前的状态,状态随时可能会变
            EtlEventData eventData = new EtlEventData();
            eventData.setPipelineId(pipelineId);
            eventData.setProcessId(processId);
            eventData.setStartTime(new Date().getTime());// 返回当前时间
View Full Code Here

     * 4. 获取Select传递的EventData数据,添加next node信息后直接返回
     * </pre>
     */
    public EtlEventData await(Long pipelineId) throws InterruptedException {
        Assert.notNull(pipelineId);
        PermitMonitor permitMonitor = ArbitrateFactory.getInstance(pipelineId, PermitMonitor.class);
        permitMonitor.waitForPermit();// 阻塞等待授权

        LoadStageListener loadStageListener = ArbitrateFactory.getInstance(pipelineId, LoadStageListener.class);
        Long processId = loadStageListener.waitForProcess(); // 符合条件的processId

        // DistributedLock lock = getLock(pipelineId);
        try {
            // 使用锁的理由:
            // 1. 针对双向同步时,其中一个方向出现了异常,需要发起另一端的关闭,此时对方正好在执行某个process的load
            // 2. 单向同步时,如果出现node节点异常,此时正常的节点正在执行某个process的load
            // 为避免因load无法中端引起的数据重复录入,所以针对load阶段添加分布式锁。在有process load过程中不允许进行pipeline关闭操作
            // lock.lock();

            ChannelStatus status = permitMonitor.getChannelPermit();
            if (status.isStart()) {// 即时查询一下当前的状态,状态随时可能会变
                // 根据pipelineId+processId构造对应的path
                String path = StagePathUtils.getTransformStage(pipelineId, processId);
                try {
                    byte[] data = zookeeper.readData(path);
View Full Code Here

        try {
            String path = StagePathUtils.getProcessRoot(getPipelineId());
            // 根据并行度创建任务
            int size = ArbitrateConfigUtils.getParallelism(getPipelineId()) - processIds.size();
            if (size > 0) {// 创建一个节点
                PermitMonitor permit = ArbitrateFactory.getInstance(getPipelineId(), PermitMonitor.class);
                if (permit.isPermit() == false) { // 如果非授权,则不做任何处理
                    return;
                }

                String mainStemPath = StagePathUtils.getMainStem(getPipelineId());
                byte[] bytes = zookeeper.readData(mainStemPath, true);
View Full Code Here

     *  b. 如果创建失败,则关注该节点的exist信号. 继续执行步骤2
     * </pre>
     */
    public void await(Long pipelineId) throws InterruptedException {
        Assert.notNull(pipelineId);
        PermitMonitor permitMonitor = ArbitrateFactory.getInstance(pipelineId, PermitMonitor.class);
        ChannelStatus status = permitMonitor.getChannelPermit(true);
        boolean isRuning = check(pipelineId);
        if (!status.isStart() && isRuning) {
            // 当前状态不为启动,强制设置为taking,下次授权启动后重新追数据
            MainStemEventData data = new MainStemEventData();
            data.setPipelineId(pipelineId);
            data.setStatus(MainStemEventData.Status.TAKEING);
            single(data);
            permitMonitor.waitForChannelPermit(); // 阻塞等待挂起
            return;
        } else if (status.isStart() && isRuning) {// 正常状态
            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 {
                logger.info("pipelineId[{}] mainstem ignore by status[{}]", new Object[] { pipelineId, status });
                await(pipelineId);// 重新进行check一次
View Full Code Here

TOP

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

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.