當前位置: 首頁>>代碼示例>>Java>>正文


Java Switch.getNodeConnectors方法代碼示例

本文整理匯總了Java中org.opendaylight.controller.switchmanager.Switch.getNodeConnectors方法的典型用法代碼示例。如果您正苦於以下問題:Java Switch.getNodeConnectors方法的具體用法?Java Switch.getNodeConnectors怎麽用?Java Switch.getNodeConnectors使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.opendaylight.controller.switchmanager.Switch的用法示例。


在下文中一共展示了Switch.getNodeConnectors方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: isPortValid

import org.opendaylight.controller.switchmanager.Switch; //導入方法依賴的package包/類
public boolean isPortValid(Switch sw, Short port) {
    if (port < 1) {
        log.debug("port {} is not valid", port);
        return false;
    }

    if (sw == null) {
        log.debug("switch info is not available. Skip checking if port is part of a switch or not.");
        return true;
    }

    Set<NodeConnector> nodeConnectorSet = sw.getNodeConnectors();
    for (NodeConnector nodeConnector : nodeConnectorSet) {
        if (((Short) nodeConnector.getID()).equals(port)) {
            return true;
        }
    }
    log.debug("port {} is not a valid port of node {}", port, sw.getNode());
    return false;
}
 
開發者ID:lbchen,項目名稱:ODL,代碼行數:21,代碼來源:FlowConfig.java

示例2: getNodePorts

import org.opendaylight.controller.switchmanager.Switch; //導入方法依賴的package包/類
@RequestMapping(value = "/node-ports")
@ResponseBody
public Map<String, Object> getNodePorts(HttpServletRequest request, @RequestParam(required = false) String container) {
    String containerName = (container == null) ? GlobalConstants.DEFAULT.toString() : container;

    // Derive the privilege this user has on the current container
    String userName = request.getUserPrincipal().getName();
    if (DaylightWebUtil.getContainerPrivilege(userName, containerName, this) == Privilege.NONE) {
        return null;
    }

    ISwitchManager switchManager = (ISwitchManager) ServiceHelper
            .getInstance(ISwitchManager.class, containerName, this);
    if (switchManager == null) {
        return null;
    }

    Map<String, Object> nodes = new HashMap<String, Object>();
    Map<Short, String> port;

    for (Switch node : switchManager.getNetworkDevices()) {
        port = new HashMap<Short, String>(); // new port
        Set<NodeConnector> nodeConnectorSet = node.getNodeConnectors();

        if (nodeConnectorSet != null) {
            for (NodeConnector nodeConnector : nodeConnectorSet) {
                String nodeConnectorName = ((Name) switchManager
                        .getNodeConnectorProp(nodeConnector,
                                Name.NamePropName)).getValue();
                port.put((Short) nodeConnector.getID(), nodeConnectorName
                        + "(" + nodeConnector.getNodeConnectorIDString()
                        + ")");
            }
        }

        // add ports
        Map<String, Object> entry = new HashMap<String, Object>();
        entry.put("ports", port);

        // add name
        entry.put("name", getNodeDesc(node.getNode(), switchManager));

        // add to the node
        nodes.put(node.getNode().toString(), entry);
    }

    return nodes;
}
 
開發者ID:lbchen,項目名稱:ODL,代碼行數:49,代碼來源:Flows.java

示例3: getNodePorts

import org.opendaylight.controller.switchmanager.Switch; //導入方法依賴的package包/類
@RequestMapping(value = "/nodeports")
@ResponseBody
public Map<String, Object> getNodePorts(HttpServletRequest request,
        @RequestParam(required = false) String container) {
    String containerName = (container == null) ? GlobalConstants.DEFAULT
            .toString() : container;

    // Derive the privilege this user has on the current container
    String userName = request.getUserPrincipal().getName();
    if (DaylightWebUtil.getContainerPrivilege(userName, containerName, this) == Privilege.NONE) {
        return null;
    }


    ISwitchManager switchManager = (ISwitchManager) ServiceHelper
            .getInstance(ISwitchManager.class, containerName, this);
    if (switchManager == null) {
        return null;
    }

    Map<String, Object> nodes = new HashMap<String, Object>();
    Map<Short, String> port;

    for (Switch node : switchManager.getNetworkDevices()) {
        port = new HashMap<Short, String>(); // new port
        Set<NodeConnector> nodeConnectorSet = node.getNodeConnectors();

        if (nodeConnectorSet != null) {
            for (NodeConnector nodeConnector : nodeConnectorSet) {
                String nodeConnectorName = ((Name) switchManager
                        .getNodeConnectorProp(nodeConnector,
                                Name.NamePropName)).getValue();
                port.put((Short) nodeConnector.getID(), nodeConnectorName
                        + "(" + nodeConnector.getID() + ")");
            }
        }

        nodes.put(node.getNode().toString(), port);
    }

    return nodes;
}
 
開發者ID:lbchen,項目名稱:ODL,代碼行數:43,代碼來源:Devices.java

示例4: _pdm

import org.opendaylight.controller.switchmanager.Switch; //導入方法依賴的package包/類
public void _pdm(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;
    }

    Switch sw = getSwitchByNode(node);

    ci.println("          NodeConnector                        Name");
    if (sw == null) {
        return;
    }
    Set<NodeConnector> nodeConnectorSet = sw.getNodeConnectors();
    String nodeConnectorName;
    if (nodeConnectorSet != null && nodeConnectorSet.size() > 0) {
        for (NodeConnector nodeConnector : nodeConnectorSet) {
            Map<String, Property> propMap = getNodeConnectorProps(nodeConnector);
            nodeConnectorName = (propMap == null) ? null : ((Name) propMap
                    .get(Name.NamePropName)).getValue();
            if (nodeConnectorName != null) {
                Node nd = nodeConnector.getNode();
                if (!nd.equals(node)) {
                    log.debug("node not match {} {}", nd, node);
                }
                Map<String, NodeConnector> map = nodeConnectorNames
                        .get(node);
                if (map != null) {
                    NodeConnector nc = map.get(nodeConnectorName);
                    if (nc == null) {
                        log.debug("no nodeConnector named {}",
                                nodeConnectorName);
                    } else if (!nc.equals(nodeConnector)) {
                        log.debug("nodeConnector not match {} {}", nc,
                                nodeConnector);
                    }
                }
            }

            ci.println(nodeConnector
                    + "            "
                    + ((nodeConnectorName == null) ? "" : nodeConnectorName)
                    + "(" + nodeConnector.getID() + ")");
        }
        ci.println("Total number of NodeConnectors: "
                + nodeConnectorSet.size());
    }
}
 
開發者ID:lbchen,項目名稱:ODL,代碼行數:55,代碼來源:SwitchManagerImpl.java


注:本文中的org.opendaylight.controller.switchmanager.Switch.getNodeConnectors方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。