• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Bandwidth类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.opendaylight.controller.sal.core.Bandwidth的典型用法代码示例。如果您正苦于以下问题:Java Bandwidth类的具体用法?Java Bandwidth怎么用?Java Bandwidth使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Bandwidth类属于org.opendaylight.controller.sal.core包,在下文中一共展示了Bandwidth类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: EdgeBean

import org.opendaylight.controller.sal.core.Bandwidth; //导入依赖的package包/类
/**
 * EdgeBean object that includes complete node description
 *
 * @param link
 * @param bandwidth
 * @param headDescription
 * @param tailDescription
 */
public EdgeBean(Edge link, Bandwidth bandwidth, String headDescription,
        String tailDescription, String headPortDescription, String tailPortDescription) {
    this();
    this.source = link.getHeadNodeConnector();
    this.destination = link.getTailNodeConnector();

    // data
    data.put("$bandwidth", bandwidth.toString());
    data.put("$color", bandwidthColor(bandwidth));
    data.put("$nodeToPort", destination.getID().toString());
    data.put("$nodeFromPort", source.getID().toString());
    data.put("$descFrom", headDescription);
    data.put("$descTo", tailDescription);
    data.put("$nodeFromPortName", source.toString());
    data.put("$nodeToPortName", destination.toString());
    data.put("$nodeFromPortDescription", headPortDescription);
    data.put("$nodeToPortDescription", tailPortDescription);
}
 
开发者ID:lbchen,项目名称:ODL,代码行数:27,代码来源:Topology.java


示例2: bandwidthColor

import org.opendaylight.controller.sal.core.Bandwidth; //导入依赖的package包/类
private String bandwidthColor(Bandwidth bandwidth) {
        String color = null;
        long bandwidthValue = bandwidth.getValue();

        if (bandwidthValue == 0) {
        color = "#000";
    } else if (bandwidthValue < Bandwidth.BW1Kbps) {
        color = "#148AC6";
    } else if (bandwidthValue < Bandwidth.BW1Mbps) {
        color = "#2858A0";
    } else if (bandwidthValue < Bandwidth.BW1Gbps) {
        color = "#009393";
    } else if (bandwidthValue < Bandwidth.BW1Tbps) {
        color = "#C6C014";
    } else if (bandwidthValue < Bandwidth.BW1Pbps) {
        color = "#F9F464";
    }

        return color;
}
 
开发者ID:lbchen,项目名称:ODL,代码行数:21,代码来源:Topology.java


示例3: _pncs

import org.opendaylight.controller.sal.core.Bandwidth; //导入依赖的package包/类
public void _pncs(CommandInterpreter ci) {
    String st = ci.nextArgument();
    if (st == null) {
        ci.println("Please enter node id");
        return;
    }

    Node node = Node.fromString(st);
    if (node == null) {
        ci.println("Please enter node id");
        return;
    }

    ci.println("          NodeConnector               BandWidth(Gbps)     Admin     State");
    Set<NodeConnector> nodeConnectorSet = getNodeConnectors(node);
    if (nodeConnectorSet == null) {
        return;
    }
    for (NodeConnector nodeConnector : nodeConnectorSet) {
        if (nodeConnector == null) {
            continue;
        }
        Map<String, Property> propMap = getNodeConnectorProps(nodeConnector);
        Bandwidth bw = (Bandwidth) propMap.get(Bandwidth.BandwidthPropName);
        Config config = (Config) propMap.get(Config.ConfigPropName);
        State state = (State) propMap.get(State.StatePropName);
        String out = nodeConnector + "           ";
        out += (bw != null) ? bw.getValue() / Math.pow(10, 9) : "    ";
        out += "             ";
        out += (config != null) ? config.getValue() : " ";
        out += "          ";
        out += (state != null) ? state.getValue() : " ";
        ci.println(out);
    }
    ci.println("Total number of NodeConnectors: " + nodeConnectorSet.size());
}
 
开发者ID:lbchen,项目名称:ODL,代码行数:37,代码来源:SwitchManagerImpl.java


示例4: createProperty

import org.opendaylight.controller.sal.core.Bandwidth; //导入依赖的package包/类
/**
 * Creates a Name/Tier/Bandwidth Property object based on given property
 * name and value. Other property types are not supported yet.
 *
 * @param propName
 *            Name of the Property
 * @param propValue
 *            Value of the Property
 * @return {@link org.opendaylight.controller.sal.core.Property}
 */
@Override
public Property createProperty(String propName, String propValue) {
    if (propName == null) {
        log.debug("propName is null");
        return null;
    }
    if (propValue == null) {
        log.debug("propValue is null");
        return null;
    }

    try {
        if (propName.equalsIgnoreCase(Description.propertyName)) {
            return new Description(propValue);
        } else if (propName.equalsIgnoreCase(Tier.TierPropName)) {
            int tier = Integer.parseInt(propValue);
            return new Tier(tier);
        } else if (propName.equalsIgnoreCase(Bandwidth.BandwidthPropName)) {
            long bw = Long.parseLong(propValue);
            return new Bandwidth(bw);
        } else if (propName.equalsIgnoreCase(ForwardingMode.name)) {
            int mode = Integer.parseInt(propValue);
            return new ForwardingMode(mode);
        } else {
            log.debug("Not able to create {} property", propName);
        }
    } catch (Exception e) {
        log.debug("createProperty caught exception {}", e.getMessage());
    }

    return null;
}
 
开发者ID:lbchen,项目名称:ODL,代码行数:43,代码来源:SwitchManagerImpl.java


示例5: OFPortToProps

import org.opendaylight.controller.sal.core.Bandwidth; //导入依赖的package包/类
public static Set<Property> OFPortToProps(OFPhysicalPort port) {
    Set<Property> props = new HashSet<Property>();
    Bandwidth bw = InventoryServiceHelper.OFPortToBandWidth(port
            .getCurrentFeatures());
    if (bw != null) {
        props.add(bw);
    }

    Bandwidth abw = InventoryServiceHelper.OFPortToBandWidth(port.getAdvertisedFeatures());
    if (abw != null) {
            AdvertisedBandwidth a = new AdvertisedBandwidth(abw.getValue());
            if (a != null) {
                    props.add(a);
            }
    }
    Bandwidth sbw = InventoryServiceHelper.OFPortToBandWidth(port.getSupportedFeatures());
    if (sbw != null) {
            SupportedBandwidth s = new SupportedBandwidth(sbw.getValue());
            if (s != null) {
                    props.add(s);
            }
    }
    Bandwidth pbw = InventoryServiceHelper.OFPortToBandWidth(port.getPeerFeatures());
    if (pbw != null) {
            PeerBandwidth p = new PeerBandwidth(pbw.getValue());
            if (p != null) {
                    props.add(p);
            }
    }
    props.add(new Name(port.getName()));
    props.add(InventoryServiceHelper.OFPortToConfig(port.getConfig()));
    props.add(InventoryServiceHelper.OFPortToState(port.getState()));
    return props;
}
 
开发者ID:lbchen,项目名称:ODL,代码行数:35,代码来源:InventoryServiceHelper.java


示例6: _pem

import org.opendaylight.controller.sal.core.Bandwidth; //导入依赖的package包/类
public void _pem(CommandInterpreter ci) {
    String container = ci.nextArgument();
    if (container == null) {
        container = GlobalConstants.DEFAULT.toString();
    }

    ci.println("Container: " + container);
    ci.println("                             Edge                                          Bandwidth");

    Map<NodeConnector, Pair<Edge, Set<Property>>> edgePropsMap = edgeMap
            .get(container);
    if (edgePropsMap == null) {
        return;
    }
    int count = 0;
    for (Pair<Edge, Set<Property>> edgeProps : edgePropsMap.values()) {
        if (edgeProps == null) {
            continue;
        }

        long bw = 0;
        Set<Property> props = edgeProps.getRight();
        if (props != null) {
            for (Property prop : props) {
                if (prop.getName().equals(Bandwidth.BandwidthPropName)) {
                    bw = ((Bandwidth) prop).getValue();
                }
            }
        }
        count++;
        ci.println(edgeProps.getLeft() + "          " + bw);
    }
    ci.println("Total number of Edges: " + count);
}
 
开发者ID:lbchen,项目名称:ODL,代码行数:35,代码来源:TopologyServiceShim.java


示例7: initMaxThroughput

import org.opendaylight.controller.sal.core.Bandwidth; //导入依赖的package包/类
@Override
public synchronized void initMaxThroughput(
        final Map<Edge, Number> EdgeWeightMap) {
    if (mtp != null) {
        log.error("Max Throughput Dijkstra is already enabled!");
        return;
    }
    Transformer<Edge, ? extends Number> mtTransformer = null;
    if (EdgeWeightMap == null) {
        mtTransformer = new Transformer<Edge, Double>() {
            public Double transform(Edge e) {
                if (switchManager == null) {
                    log.error("switchManager is null");
                    return (double) -1;
                }
                NodeConnector srcNC = e.getTailNodeConnector();
                NodeConnector dstNC = e.getHeadNodeConnector();
                if ((srcNC == null) || (dstNC == null)) {
                    log.error("srcNC:{} or dstNC:{} is null", srcNC, dstNC);
                    return (double) -1;
                }
                Bandwidth bwSrc = (Bandwidth) switchManager
                        .getNodeConnectorProp(srcNC,
                                Bandwidth.BandwidthPropName);
                Bandwidth bwDst = (Bandwidth) switchManager
                        .getNodeConnectorProp(dstNC,
                                Bandwidth.BandwidthPropName);

                long srcLinkSpeed = 0, dstLinkSpeed = 0;
                if ((bwSrc == null)
                        || ((srcLinkSpeed = bwSrc.getValue()) == 0)) {
                    log.debug(
                            "srcNC: {} - Setting srcLinkSpeed to Default!",
                            srcNC);
                    srcLinkSpeed = DEFAULT_LINK_SPEED;
                }

                if ((bwDst == null)
                        || ((dstLinkSpeed = bwDst.getValue()) == 0)) {
                    log.debug(
                            "dstNC: {} - Setting dstLinkSpeed to Default!",
                            dstNC);
                    dstLinkSpeed = DEFAULT_LINK_SPEED;
                }

                long avlSrcThruPut = srcLinkSpeed
                        - readService.getTransmitRate(srcNC);
                long avlDstThruPut = dstLinkSpeed
                        - readService.getTransmitRate(dstNC);

                // Use lower of the 2 available thruput as the available
                // thruput
                long avlThruPut = avlSrcThruPut < avlDstThruPut ? avlSrcThruPut
                        : avlDstThruPut;

                if (avlThruPut <= 0) {
                    log.debug("Edge {}: Available Throughput {} <= 0!", e,
                            avlThruPut);
                    return (double) -1;
                }
                return (double) (Bandwidth.BW1Pbps / avlThruPut);
            }
        };
    } else {
        mtTransformer = new Transformer<Edge, Number>() {
            public Number transform(Edge e) {
                return EdgeWeightMap.get(e);
            }
        };
    }
    Short baseBW = Short.valueOf((short) 0);
    // Initialize mtp also using the default topo
    Graph<Node, Edge> g = this.topologyBWAware.get(baseBW);
    if (g == null) {
        log.error("Default Topology Graph is null");
        return;
    }
    mtp = new DijkstraShortestPath<Node, Edge>(g, mtTransformer);
}
 
开发者ID:lbchen,项目名称:ODL,代码行数:80,代码来源:DijkstraImplementation.java


示例8: edgeUpdate

import org.opendaylight.controller.sal.core.Bandwidth; //导入依赖的package包/类
private boolean edgeUpdate(Edge e, UpdateType type, Set<Property> props) {
    String srcType = null;
    String dstType = null;

    if (e == null || type == null) {
        log.error("Edge or Update type are null!");
        return false;
    } else {
        srcType = e.getTailNodeConnector().getType();
        dstType = e.getHeadNodeConnector().getType();

        if (srcType.equals(NodeConnector.NodeConnectorIDType.PRODUCTION)) {
            log.debug("Skip updates for {}", e);
            return false;
        }

        if (dstType.equals(NodeConnector.NodeConnectorIDType.PRODUCTION)) {
            log.debug("Skip updates for {}", e);
            return false;
        }
    }

    Bandwidth bw = new Bandwidth(0);
    boolean newEdge = false;
    if (props != null)
        props.remove(bw);

    if (log.isDebugEnabled()) {
      log.debug("edgeUpdate: {} bw: {}", e, bw.getValue());
    }

    Short baseBW = Short.valueOf((short) 0);
    boolean add = (type == UpdateType.ADDED) ? true : false;
    // Update base topo
    newEdge = !updateTopo(e, baseBW, add);
    if (newEdge == true) {
        if (bw.getValue() != baseBW) {
            // Update BW topo
            updateTopo(e, (short) bw.getValue(), add);
        }
    }
    return newEdge;
}
 
开发者ID:lbchen,项目名称:ODL,代码行数:44,代码来源:DijkstraImplementation.java


示例9: testGetEdges

import org.opendaylight.controller.sal.core.Bandwidth; //导入依赖的package包/类
@Test
public void testGetEdges() throws ConstructionException {
    TopologyManagerImpl topoManagerImpl = new TopologyManagerImpl();
    setNodeEdges(topoManagerImpl);

    Map<Edge, Set<Property>> edgeProperty = topoManagerImpl.getEdges();

    for (Iterator<Map.Entry<Edge, Set<Property>>> i = edgeProperty
            .entrySet().iterator(); i.hasNext();) {
        Map.Entry<Edge, Set<Property>> entry = i.next();
        Edge e = entry.getKey();
        NodeConnector headnc = e.getHeadNodeConnector();
        NodeConnector tailnc = e.getTailNodeConnector();

        Long headNodeId = (Long) headnc.getNode().getID();

        Long headNcId = ((Short) headnc.getID()).longValue();
        Long tailNcId = ((Short) tailnc.getID()).longValue();

        if (headNodeId == 1 || headNodeId == 3 || headNodeId == 5) {
            Assert.assertTrue((headNcId.equals(headNodeId) && tailNcId
                    .equals(headNodeId + 10))
                    || (headNcId.equals(headNodeId + 10) && tailNcId
                            .equals(headNodeId))
                            || (headNcId.equals(headNodeId + 1) && tailNcId
                                    .equals(headNodeId + 11))
                                    || (headNcId.equals(headNodeId + 11) && tailNcId
                                            .equals(headNodeId + 1)));
        } else if (headNodeId == 11 || headNodeId == 13 || headNodeId == 15) {
            Assert.assertTrue((headNcId.equals(headNodeId) && tailNcId
                    .equals(headNodeId - 10))
                    || (headNcId.equals(headNodeId) && tailNcId
                            .equals(headNodeId - 10))
                            || (headNcId.equals(headNodeId - 9) && tailNcId
                                    .equals(headNodeId + 1))
                                    || (headNcId.equals(headNodeId + 1) && tailNcId
                                            .equals(headNodeId - 9)));
        }

        Set<Property> prop = entry.getValue();
        for (Property p : prop) {
            String pName;
            long pValue;
            if (p instanceof Bandwidth) {
                Bandwidth b = (Bandwidth) p;
                pName = Bandwidth.BandwidthPropName;
                pValue = b.getValue();
                Assert.assertTrue(pName.equals(p.getName())
                        && pValue == Bandwidth.BW100Gbps);
                continue;
            }
            if (p instanceof Latency) {
                Latency l = (Latency) p;
                pName = Latency.LatencyPropName;
                pValue = l.getValue();
                Assert.assertTrue(pName.equals(p.getName())
                        && pValue == Latency.LATENCY100ns);
                continue;
            }
            if (p instanceof State) {
                State state = (State) p;
                pName = State.StatePropName;
                pValue = state.getValue();
                Assert.assertTrue(pName.equals(p.getName())
                        && pValue == State.EDGE_UP);
                continue;
            }
        }
        i.remove();
    }
    Assert.assertTrue(edgeProperty.isEmpty());
}
 
开发者ID:lbchen,项目名称:ODL,代码行数:73,代码来源:TopologyManagerImplTest.java


示例10: pollTxBitRates

import org.opendaylight.controller.sal.core.Bandwidth; //导入依赖的package包/类
/**
 * Continuously polls the transmit bit rate for all the node connectors from
 * statistics manager and trigger the warning notification upward when the
 * transmit rate is above a threshold which is a percentage of the edge
 * bandwidth
 */
protected void pollTxBitRates() {
    Map<NodeConnector, Pair<Edge, Set<Property>>> globalContainerEdges = edgeMap
            .get(GlobalConstants.DEFAULT.toString());
    if (globalContainerEdges == null) {
        return;
    }

    for (NodeConnector connector : globalContainerEdges.keySet()) {
        // Skip if node connector belongs to production switch
        if (connector.getType().equals(
                NodeConnector.NodeConnectorIDType.PRODUCTION)) {
            continue;
        }

        // Get edge for which this node connector is head
        Pair<Edge, Set<Property>> props = this.edgeMap.get(
                GlobalConstants.DEFAULT.toString()).get(connector);
        // On switch mgr restart the props get reset
        if (props == null) {
            continue;
        }
        Set<Property> propSet = props.getRight();
        if (propSet == null) {
            continue;
        }

        float bw = 0;
        for (Property prop : propSet) {
            if (prop instanceof Bandwidth) {
                bw = ((Bandwidth) prop).getValue();
                break;
            }
        }

        // Skip if agent did not provide a bandwidth info for the edge
        if (bw == 0) {
            continue;
        }

        // Compare bandwidth usage
        Long switchId = (Long) connector.getNode().getID();
        Short port = (Short) connector.getID();
        float rate = statsMgr.getTransmitRate(switchId, port);
        if (rate > bwThresholdFactor * bw) {
            if (!connectorsOverUtilized.contains(connector)) {
                connectorsOverUtilized.add(connector);
                this.bwUtilNotifyQ.add(new UtilizationUpdate(connector,
                        UpdateType.ADDED));
            }
        } else {
            if (connectorsOverUtilized.contains(connector)) {
                connectorsOverUtilized.remove(connector);
                this.bwUtilNotifyQ.add(new UtilizationUpdate(connector,
                        UpdateType.REMOVED));
            }
        }
    }

}
 
开发者ID:lbchen,项目名称:ODL,代码行数:66,代码来源:TopologyServiceShim.java



注:本文中的org.opendaylight.controller.sal.core.Bandwidth类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java StateContext类代码示例发布时间:2022-05-16
下一篇:
Java NodeVisitorFactory类代码示例发布时间:2022-05-16
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap