Package com.alibaba.otter.shared.common.model.config.channel

Examples of com.alibaba.otter.shared.common.model.config.channel.ChannelStatus


     * </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


            logger.error(path, e);
        }
    }

    private void initChannelStatus(byte[] bytes) {
        ChannelStatus newChannelStatus = JsonUtils.unmarshalFromByte(bytes, ChannelStatus.class);

        if (logger.isDebugEnabled()) {
            logger.debug("pipeline[{}] newChannelStatus is [{}]", getPipelineId(), newChannelStatus);
        }

        synchronized (this) {
            // 发生变化,才触发权限检查
            if (!newChannelStatus.equals(channelStatus)) {
                channelStatus = newChannelStatus;
                permitSem();
            }
        }
    }
View Full Code Here

        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());// 返回当前时间
            Long nid = ArbitrateConfigUtils.getCurrentNid();
View Full Code Here

        if (isStop()) {
            return;
        }

        PermitMonitor permitMonitor = ArbitrateFactory.getInstance(getPipelineId(), PermitMonitor.class);
        ChannelStatus status = permitMonitor.getChannelPermit(true);
        if (status.isStop()) {
            return; // 如果已经关闭则退出
        }

        Long nid = ArbitrateConfigUtils.getCurrentNid();
        String path = StagePathUtils.getMainStem(getPipelineId());
View Full Code Here

            // 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);
                    return JsonUtils.unmarshalFromByte(data, EtlEventData.class);// 反序列化并返回
View Full Code Here

        MainStemEventData mainstemData = arbitrateViewService.mainstemData(pipeline.getChannelId(), pipelineId);

        PositionEventData positionData = arbitrateViewService.getCanalCursor(pipeline.getParameters().getDestinationName(),
                                                                             pipeline.getParameters().getMainstemClientId());

        ChannelStatus status = channelArbitrateEvent.status(pipeline.getChannelId());

        context.put("pipeline", pipeline);
        context.put("pipelineId", pipelineId);
        context.put("processStats", processStats);
        context.put("offset", offset);
View Full Code Here

        List<Long> theStatusPks = new ArrayList<Long>();
        if (null != status) {
            List<Long> allChannelPks = channelService.listAllChannelId();

            for (Long channelPk : allChannelPks) {
                ChannelStatus channelStatus = arbitrateManageService.channelEvent().status(channelPk);
                if (channelStatus.equals(ChannelStatus.valueOf(status))) {
                    theStatusPks.add(channelPk);
                }
            }
        }
View Full Code Here

            return;
        }

        AlarmRule rule = rules.get(0);
        Pipeline pipeline = pipelineService.findById(rule.getPipelineId());
        ChannelStatus status = arbitrateManageService.channelEvent().status(pipeline.getChannelId());
        if (status.isPause() && rule.getAutoRecovery()) {
            // 出现问题直接恢复
            restartAlarmRecovery.recovery(rule);
        }
    }
View Full Code Here

        Long pipelineId = rules.get(0).getPipelineId();
        Pipeline pipeline = pipelineService.findById(pipelineId);
        PositionEventData data = arbitrateViewService.getCanalCursor(pipeline.getParameters().getDestinationName(),
                                                                     pipeline.getParameters().getMainstemClientId());
        // 如果处于stop状态,则忽略报警
        ChannelStatus status = arbitrateManageService.channelEvent().status(pipeline.getChannelId());
        if (status == null || status.isStop()) {
            return;
        }

        long latestSyncTime = 0L;
        if (data != null && data.getModifiedTime() != null) {
View Full Code Here

                        String exceptionCause = "query channelId:" + channelId + " return null.";
                        logger.error("ERROR ## " + exceptionCause);
                        throw new ManagerException(exceptionCause);
                    }

                    ChannelStatus oldStatus = arbitrateManageService.channelEvent().status(channelDo.getId());
                    Channel channel = doToModel(channelDo);
                    channel.setStatus(oldStatus);
                    ChannelStatus newStatus = channelStatus;
                    if (newStatus != null) {
                        if (newStatus.equals(oldStatus)) {
                            // String exceptionCause = "switch the channel(" +
                            // channelId + ") status to " +
                            // channelStatus
                            // + " but it had the status:" + oldStatus;
                            // logger.error("ERROR ## " + exceptionCause);
                            // throw new ManagerException(exceptionCause);
                            // ignored
                            return;
                        } else {
                            channel.setStatus(newStatus);// 强制修改为当前变更状态
                        }
                    } else {
                        newStatus = oldStatus;
                    }

                    // 针对关闭操作,要优先更改对应的status,避免node工作线程继续往下跑
                    if (newStatus.isStop()) {
                        arbitrateManageService.channelEvent().stop(channelId);
                    } else if (newStatus.isPause()) {
                        arbitrateManageService.channelEvent().pause(channelId);
                    }

                    // 通知变更内容
                    boolean result = configRemoteService.notifyChannel(channel);// 客户端响应成功,才更改对应的状态

                    if (result) {
                        // 针对启动的话,需要先通知到客户端,客户端启动线程后,再更改channel状态
                        if (newStatus.isStart()) {
                            arbitrateManageService.channelEvent().start(channelId);
                        }
                    }

                } catch (Exception e) {
View Full Code Here

TOP

Related Classes of com.alibaba.otter.shared.common.model.config.channel.ChannelStatus

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.