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

Examples of com.alibaba.otter.shared.common.model.config.node.Node


                EtlEventData eventData = new EtlEventData();
                eventData.setPipelineId(pipelineId);
                eventData.setProcessId(processId);
                eventData.setStartTime(new Date().getTime());// 返回当前时间

                Node node = LoadBalanceFactory.getNextExtractNode(pipelineId);// 获取下一个处理节点信息
                if (node == null) {// 没有后端节点
                    // TerminEventData termin = new TerminEventData();
                    // termin.setPipelineId(pipelineId);
                    // termin.setType(TerminType.ROLLBACK);
                    // termin.setCode("no_node");
                    // termin.setDesc(MessageFormat.format("pipeline[{}] extract stage has no node!", pipelineId));
                    // terminEvent.single(termin);
                    throw new ArbitrateException("Select_single", "no next node");
                } else {
                    eventData.setNextNid(node.getId());
                    markUsed(eventData); // 标记为已使用
                    return eventData;// 只有这一条路返回
                }
            } catch (ZkNoNodeException e) {
                logger.error("pipeline[{}] processId[{}] is invalid , retry again", pipelineId, processId);
View Full Code Here


        if (nodes == null || nodes.size() == 0) {
            return null;
        }

        Long nid = ArbitrateConfigUtils.getCurrentNid();
        Node current = new Node();
        current.setId(nid);

        // 判断一下是否优先返回local
        boolean existLocal = nodes.remove(current);
        if (existLocal && nodes.size() == 0) {// 如果只有它自己
            return current;
        } else if (existLocal && RandomUtils.nextInt(100) <= stickPercent) {// 计算一下百分比
            return current;
        } else {
            for (Node node : nodes) {
                if (node.getId().equals(lastNid) && RandomUtils.nextInt(100) <= stickPercent) {
                    lastNid = node.getId();
                    long count = stickCount.incrementAndGet();
                    if (count > randomThresold) {
                        lastNid = -1; // 进入下一轮的重新选择,避免挂死一个节点
                        stickCount.set(0);
                    }
                    return node;
                }
            }

            // 如果没找到对应lastNid对应的信息,可能节点挂了,则随机选一个
            int index = RandomUtils.nextInt(nodes.size());
            Node node = nodes.get(index);
            lastNid = node.getId();
            return node;
        }

    }
View Full Code Here

        Long processId = stageController.waitForProcess(StageType.EXTRACT); // 符合条件的processId

        ChannelStatus status = permitMonitor.getChannelPermit();
        if (status.isStart() || status.isPause()) {// pause状态也让其处理,避免误删除pause状态的processId,导致通道挂起
            EtlEventData eventData = stageController.getLastData(processId);
            Node node = LoadBalanceFactory.getNextTransformNode(pipelineId);// 获取下一个处理节点信息
            if (node == null) {// 没有后端节点
                throw new ArbitrateException("Extract_single", "no next node");
            } else {
                eventData.setNextNid(node.getId());
                return eventData;// 只有这一条路返回
            }
        } else {
            logger.warn("pipelineId[{}] extract ignore processId[{}] by status[{}]", new Object[] { pipelineId,
                    processId, status });
View Full Code Here

TOP

Related Classes of com.alibaba.otter.shared.common.model.config.node.Node

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.