Package com.alibaba.otter.shared.arbitrate.model

Examples of com.alibaba.otter.shared.arbitrate.model.MainStemEventData


            logger.error(path, e);
        }
    }

    private void initOppositeMainStemStatus(byte[] bytes) {
        MainStemEventData eventData = JsonUtils.unmarshalFromByte(bytes, MainStemEventData.class);
        MainStemEventData.Status newStatus = eventData.getStatus();

        if (logger.isDebugEnabled()) {
            logger.debug("pipeline[{}] new oppositeMainStemStatus is [{}]", getPipelineId(), newStatus);
        }
View Full Code Here


        // initMainstem();
        dataListener = new IZkDataListener() {

            public void handleDataChange(String dataPath, Object data) throws Exception {
                MDC.put(ArbitrateConstants.splitPipelineLogFileKey, String.valueOf(getPipelineId()));
                MainStemEventData mainStemData = JsonUtils.unmarshalFromByte((byte[]) data, MainStemEventData.class);
                if (!isMine(mainStemData.getNid())) {
                    mutex.set(false);
                }

                if (!mainStemData.isActive() && isMine(mainStemData.getNid())) { // 说明出现了主动释放的操作,并且本机之前是active
                    release = true;
                    releaseMainstem();// 彻底释放mainstem
                }

                activeData = (MainStemEventData) mainStemData;
View Full Code Here

        }

        Long nid = ArbitrateConfigUtils.getCurrentNid();
        String path = StagePathUtils.getMainStem(getPipelineId());

        MainStemEventData data = new MainStemEventData();
        data.setStatus(MainStemEventData.Status.TAKEING);
        data.setPipelineId(getPipelineId());
        data.setNid(nid);// 设置当前的nid
        // 序列化
        byte[] bytes = JsonUtils.marshalToByte(data);
        try {
            mutex.set(false);
            zookeeper.create(path, bytes, CreateMode.EPHEMERAL);
View Full Code Here

    public boolean check() {
        String path = StagePathUtils.getMainStem(getPipelineId());
        try {
            byte[] bytes = zookeeper.readData(path);
            Long nid = ArbitrateConfigUtils.getCurrentNid();
            MainStemEventData eventData = JsonUtils.unmarshalFromByte(bytes, MainStemEventData.class);
            activeData = eventData;// 更新下为最新值
            // 检查下nid是否为自己
            boolean result = nid.equals(eventData.getNid());
            if (!result) {
                logger.warn("mainstem is running in node[{}] , but not in node[{}]", eventData.getNid(), nid);
            }
            return result;
        } catch (ZkNoNodeException e) {
            logger.warn("mainstem is not run any in node");
            return false;
View Full Code Here

                byte[] bytes = zookeeper.readData(mainStemPath, true);
                if (bytes == null) {
                    return;
                }

                MainStemEventData eventData = JsonUtils.unmarshalFromByte(bytes, MainStemEventData.class);
                if (eventData.getNid().equals(ArbitrateConfigUtils.getCurrentNid()) == false) {
                    return;// 如果非自己设置的mainStem,则不做任何处理
                }

                // 目前select只会在一个节点上部署,只需要单机版锁即可,后续可采用分布式锁进行并发控制
                // DistributedLock lock = new DistributedLock(PathUtils.getSelectLock(getPipelineId()));
View Full Code Here

        return super.after(events);
    }

    private void startDetecting() {
        // 直接发送已追上的状态,保持和eromanga兼容处理
        MainStemEventData mainStemData = new MainStemEventData();
        mainStemData.setPipelineId(pipelineId);
        mainStemData.setStatus(MainStemEventData.Status.OVERTAKE);
        arbitrateEventService.mainStemEvent().single(mainStemData);

        // 启动异步线程定时监控,一定会有数据过来
        String schedulerName = String.format("pipelineId = %s , CanalDetecting", String.valueOf(pipelineId));
        scheduler = Executors.newScheduledThreadPool(1, new NamedThreadFactory(schedulerName));
View Full Code Here

        }

    }

    private void notifyMainstemStatus(MainStemEventData.Status status) {
        MainStemEventData mainStemData = new MainStemEventData();
        mainStemData.setPipelineId(pipelineId);
        mainStemData.setStatus(status);
        arbitrateEventService.mainStemEvent().single(mainStemData);
    }
View Full Code Here

        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;
View Full Code Here

            }
            processTime.put(processStat.getProcessId(), timeout);
        }

        // 获取下mainstem状态信息
        MainStemEventData mainstemData = arbitrateViewService.mainstemData(pipeline.getChannelId(), pipelineId);

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

        ChannelStatus status = channelArbitrateEvent.status(pipeline.getChannelId());
View Full Code Here

        String path = ManagePathUtils.getMainStem(channelId, pipelineId);
        try {
            while (true) {
                Stat stat = new Stat();
                byte[] bytes = zookeeper.readData(path, stat);
                MainStemEventData mainStemData = JsonUtils.unmarshalFromByte(bytes, MainStemEventData.class);
                mainStemData.setActive(false);
                try {
                    zookeeper.writeData(path, JsonUtils.marshalToByte(mainStemData), stat.getVersion());
                    logger.warn("relase channelId[{}],pipelineId[{}] mainstem successed! ", channelId, pipelineId);
                    break;
                } catch (ZkBadVersionException e) {
View Full Code Here

TOP

Related Classes of com.alibaba.otter.shared.arbitrate.model.MainStemEventData

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.