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

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


            bytes = zookeeper.readData(path);
        } catch (ZkNoNodeException e) {
            return false;// 说明节点已经被删除了,直接忽略
        }

        ProcessNodeEventData nodeData = JsonUtils.unmarshalFromByte(bytes, ProcessNodeEventData.class);
        if (nodeData.getStatus().isUsed()) {// 如果已使用在标记为true,需要创建termin节点
            // 只删除已经被使用了的节点

            if (noStage && nodeData.getMode().isZookeeper()) {// 针对rpc mode就是没有stage,不需要进行sleep
                // 处理一种case:
                // 针对两个并发操作,一个已经完成了s/e/t/l模块的所有delete,另一个刚好进来发现没有可delete的
                // 这时两个线程就一起进入createTermin操作,存在一些并发问题,针对这种case,需要错开一下
                // 不过这种情况可能会有误判,针对s模块没有处理完成,发起了一次rollback/shutdown操作就会碰上,概率比较小,忽略这种误判吧
                processDeleteFailed();
View Full Code Here


                    byte[] bytes = orginZk.getData(processPath, false, zkProcessStat);
                    if (bytes == null || bytes.length == 0) {
                        continue; // 直接认为未使用,忽略之
                    }

                    ProcessNodeEventData nodeData = JsonUtils.unmarshalFromByte(bytes, ProcessNodeEventData.class);
                    if (nodeData.getStatus().isUnUsed()) {// process未使用,直接忽略
                        continue; // 跳过该process
                    } else {
                        currentStageStat.setStage(StageType.SELECT);// select操作
                        currentStageStat.setStartTime(zkProcessStat.getMtime());
                    }
View Full Code Here

                synchronized (this) {
                    // 重新再取一次, dobble-check
                    List<String> currentProcesses = zookeeper.getChildren(path);
                    size = ArbitrateConfigUtils.getParallelism(getPipelineId()) - currentProcesses.size();
                    if (size > 0) {// 创建一个节点
                        ProcessNodeEventData nodeData = new ProcessNodeEventData();
                        nodeData.setStatus(ProcessNodeEventData.Status.UNUSED);// 标记为未使用
                        nodeData.setNid(ArbitrateConfigUtils.getCurrentNid());
                        byte[] nodeBytes = JsonUtils.marshalToByte(nodeData);
                        String processPath = zookeeper.create(path + "/", nodeBytes, CreateMode.PERSISTENT_SEQUENTIAL);
                        // 创建为顺序的节点
                        String processNode = StringUtils.substringAfterLast(processPath, "/");
                        Long processId = StagePathUtils.getProcessId(processNode);// 添加到当前的process列表
View Full Code Here

        List<Long> currentProcessIds = stageMonitor.getCurrentProcessIds(false);
        for (Long processId : currentProcessIds) {
            String path = StagePathUtils.getProcess(pipelineId, processId);
            try {
                byte[] bytes = zookeeper.readData(path);
                ProcessNodeEventData nodeData = JsonUtils.unmarshalFromByte(bytes, ProcessNodeEventData.class);
                if (nodeData.getStatus().isUnUsed()) {// 加入未使用的processId
                    addReply(processId);
                }
            } catch (ZkException e) {
                logger.error("SelectStageListener", e);
            }
View Full Code Here

                    byte[] bytes = orginZk.getData(processPath, false, zkProcessStat);
                    if (bytes == null || bytes.length == 0) {
                        continue; // 直接认为未使用,忽略之
                    }

                    ProcessNodeEventData nodeData = JsonUtils.unmarshalFromByte(bytes, ProcessNodeEventData.class);
                    if (nodeData.getStatus().isUnUsed()) {// process未使用,直接忽略
                        continue; // 跳过该process
                    } else {
                        currentStageStat.setStage(StageType.SELECT);// select操作
                        currentStageStat.setStartTime(zkProcessStat.getMtime());
                    }
View Full Code Here

                    byte[] bytes = orginZk.getData(processPath, false, zkProcessStat);
                    if (bytes == null || bytes.length == 0) {
                        continue; // 直接认为未使用,忽略之
                    }

                    ProcessNodeEventData nodeData = JsonUtils.unmarshalFromByte(bytes, ProcessNodeEventData.class);
                    if (nodeData.getStatus().isUnUsed()) {// process未使用,直接忽略
                        continue; // 跳过该process
                    } else {
                        currentStageStat.setStage(StageType.SELECT);// select操作
                        currentStageStat.setStartTime(zkProcessStat.getMtime());
                    }
View Full Code Here

     * 标记一下当前process为已使用
     */
    private void markUsed(EtlEventData data) throws ZkNoNodeException, ZkException {
        String path = StagePathUtils.getProcess(data.getPipelineId(), data.getProcessId());
        // 序列化
        ProcessNodeEventData eventData = new ProcessNodeEventData();
        Long nid = ArbitrateConfigUtils.getCurrentNid();
        eventData.setNid(nid);
        eventData.setStatus(ProcessNodeEventData.Status.USED);// 标记为已使用
        eventData.setMode(ArbitrateMode.RPC);// 直接声明为rpc模式
        byte[] bytes = JsonUtils.marshalToByte(eventData);
        zookeeper.writeData(path, bytes);
    }
View Full Code Here

     * 标记一下当前process为已使用
     */
    private void markUsed(EtlEventData data) throws ZkNoNodeException, ZkException {
        String path = StagePathUtils.getProcess(data.getPipelineId(), data.getProcessId());
        // 序列化
        ProcessNodeEventData eventData = new ProcessNodeEventData();
        Long nid = ArbitrateConfigUtils.getCurrentNid();
        eventData.setNid(nid);
        eventData.setStatus(ProcessNodeEventData.Status.USED);// 标记为已使用
        eventData.setMode(ArbitrateMode.ZOOKEEPER);// 直接声明为zookeeper模式
        byte[] bytes = JsonUtils.marshalToByte(eventData);
        zookeeper.writeData(path, bytes);
    }
View Full Code Here

                synchronized (this) {
                    // 重新再取一次, dobble-check
                    List<String> currentProcesses = zookeeper.getChildren(path);
                    size = ArbitrateConfigUtils.getParallelism(getPipelineId()) - currentProcesses.size();
                    if (size > 0) {// 创建一个节点
                        ProcessNodeEventData nodeData = new ProcessNodeEventData();
                        nodeData.setStatus(ProcessNodeEventData.Status.UNUSED);// 标记为未使用
                        nodeData.setMode(ArbitrateMode.RPC);
                        nodeData.setNid(ArbitrateConfigUtils.getCurrentNid());
                        byte[] nodeBytes = JsonUtils.marshalToByte(nodeData);
                        String processPath = zookeeper.create(path + "/", nodeBytes, CreateMode.PERSISTENT_SEQUENTIAL);
                        // 创建为顺序的节点
                        String processNode = StringUtils.substringAfterLast(processPath, "/");
                        Long processId = StagePathUtils.getProcessId(processNode);// 添加到当前的process列表
View Full Code Here

        List<Long> currentProcessIds = processMonitor.getCurrentProcessIds(false);
        for (Long processId : currentProcessIds) {
            String path = StagePathUtils.getProcess(pipelineId, processId);
            try {
                byte[] bytes = zookeeper.readData(path);
                ProcessNodeEventData nodeData = JsonUtils.unmarshalFromByte(bytes, ProcessNodeEventData.class);
                if (nodeData.getStatus().isUnUsed()) {// 加入未使用的processId
                    addReply(processId);
                }
            } catch (ZkException e) {
                logger.error("recovery error!", e);
            }
View Full Code Here

TOP

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

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.