Examples of MainStemEventData


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

                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

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

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

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

        }

        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

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

    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
TOP
Copyright © 2018 www.massapi.com. 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.