当前位置: 首页>>代码示例>>Java>>正文


Java Tier类代码示例

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


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

示例1: testSwitchConfig

import org.opendaylight.controller.sal.core.Tier; //导入依赖的package包/类
@Test
public void testSwitchConfig(){
    Map<String, Property> prop = new HashMap<String, Property>();
    Property desc = new Description("swicth1");
    prop.put(desc.getName(), desc);
    Property tier = new Tier(1);
    prop.put(tier.getName(), tier);
    SwitchConfig sc1 = new SwitchConfig("123", prop);
    SwitchConfig sc2 = new SwitchConfig("123", prop);
    Property mode = new ForwardingMode(1);
    prop.put(mode.getName(), mode);
    SwitchConfig sc3 = new SwitchConfig("123", prop);
    Assert.assertTrue(sc1.equals(sc2));
    Assert.assertEquals(tier, sc1.getProperty(Tier.TierPropName));
    Assert.assertFalse(sc1.equals(sc3));
    Assert.assertTrue(sc1.hashCode() == sc2.hashCode());
    Assert.assertTrue(sc1.getNodeProperties().equals(sc2.getNodeProperties()));
}
 
开发者ID:lbchen,项目名称:ODL,代码行数:19,代码来源:SwitchTest.java

示例2: _snt

import org.opendaylight.controller.sal.core.Tier; //导入依赖的package包/类
public void _snt(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;
    }

    st = ci.nextArgument();
    if (st == null) {
        ci.println("Please enter tier number");
        return;
    }
    Integer tid = Integer.decode(st);
    Tier tier = new Tier(tid);
    setNodeProp(node, tier);
}
 
开发者ID:lbchen,项目名称:ODL,代码行数:23,代码来源:SwitchManagerImpl.java

示例3: switchNeedsTieringUpdate

import org.opendaylight.controller.sal.core.Tier; //导入依赖的package包/类
/**
 * Internal convenience routine to check the eligibility of a Switch for a
 * Tier update. Any Node with Tier=0 or a Tier value that is greater than
 * the new Tier Value is eligible for the update.
 *
 * @param n
 *            Node for which the Tier update eligibility is checked
 * @param tier
 *            new Tier Value
 * @return <code>true</code> if the Node is eligible for Tier Update
 *         <code>false</code> otherwise
 */

private boolean switchNeedsTieringUpdate(Node n, int tier) {
    if (n == null) {
        logger.error("switchNeedsTieringUpdate(): Null node for tier: {}", tier);
        return false;
    }
    /*
     * Node could have gone down
     */
    if (!switchManager.getNodes().contains(n)) {
        return false;
    }
    // This is the case where Tier was never set for this node
    Tier t = (Tier) switchManager.getNodeProp(n, Tier.TierPropName);
    if (t == null)
        return true;
    if (t.getValue() == 0)
        return true;
    else if (t.getValue() > tier)
        return true;
    return false;
}
 
开发者ID:lbchen,项目名称:ODL,代码行数:35,代码来源:HostTracker.java

示例4: SwitchConfig

import org.opendaylight.controller.sal.core.Tier; //导入依赖的package包/类
@Deprecated
public SwitchConfig(String nodeId, String description, String tier, String mode) {
    this.nodeId = nodeId;
    this.nodeProperties = new HashMap<String, Property>();
    Property desc = new Description(description);
    this.nodeProperties.put(desc.getName(), desc);
    Property nodeTier = new Tier(Integer.valueOf(tier));
    this.nodeProperties.put(nodeTier.getName(), nodeTier);
    Property forwardingMode = new ForwardingMode(Integer.valueOf(mode));
    this.nodeProperties.put(forwardingMode.getName(), forwardingMode);
}
 
开发者ID:lbchen,项目名称:ODL,代码行数:12,代码来源:SwitchConfig.java

示例5: createProperty

import org.opendaylight.controller.sal.core.Tier; //导入依赖的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

示例6: updateSwitchTiers

import org.opendaylight.controller.sal.core.Tier; //导入依赖的package包/类
/**
 * When a new Host is learnt by the hosttracker module, it places the
 * directly connected Node in Tier-1 & using this function, updates the Tier
 * value for all other Nodes in the network hierarchy.
 *
 * This is a recursive function and it takes care of updating the Tier value
 * for all the connected and eligible Nodes.
 *
 * @param n
 *            Node that represents one of the Vertex in the Topology Graph.
 * @param currentTier
 *            The Tier on which n belongs
 */
private void updateSwitchTiers(Node n, int currentTier) {
    Map<Node, Set<Edge>> ndlinks = topologyManager.getNodeEdges();
    if (ndlinks == null) {
        logger.debug("updateSwitchTiers(): ndlinks null for Node: {}, Tier:{}", n, currentTier);
        return;
    }
    Set<Edge> links = ndlinks.get(n);
    if (links == null) {
        logger.debug("updateSwitchTiers(): links null for ndlinks:{}", ndlinks);
        return;
    }
    ArrayList<Node> needsVisiting = new ArrayList<Node>();
    for (Edge lt : links) {
        if (!lt.getHeadNodeConnector().getType().equals(NodeConnector.NodeConnectorIDType.OPENFLOW)) {
            // We don't want to work on Node that are not openflow
            // for now
            continue;
        }
        Node dstNode = lt.getHeadNodeConnector().getNode();
        if (switchNeedsTieringUpdate(dstNode, currentTier + 1)) {
            Tier t = new Tier(currentTier + 1);
            switchManager.setNodeProp(dstNode, t);
            needsVisiting.add(dstNode);
        }
    }

    /*
     * Due to the nature of the problem, having a separate loop for nodes
     * that needs visiting provides a decent walk optimization.
     */
    for (Node node : needsVisiting) {
        updateSwitchTiers(node, currentTier + 1);
    }
}
 
开发者ID:lbchen,项目名称:ODL,代码行数:48,代码来源:HostTracker.java

示例7: clearTiers

import org.opendaylight.controller.sal.core.Tier; //导入依赖的package包/类
/**
 * Internal convenience routine to clear all the Tier values to 0. This
 * cleanup is performed during cases such as Topology Change where the
 * existing Tier values might become incorrect
 */
private void clearTiers() {
    Set<Node> nodes = null;
    if (switchManager == null) {
        logger.error("clearTiers(): Null switchManager");
        return;
    }
    nodes = switchManager.getNodes();

    for (Node n : nodes) {
        Tier t = new Tier(0);
        switchManager.setNodeProp(n, t);
    }
}
 
开发者ID:lbchen,项目名称:ODL,代码行数:19,代码来源:HostTracker.java

示例8: updateLearntNode

import org.opendaylight.controller.sal.core.Tier; //导入依赖的package包/类
@RequestMapping(value = "/nodesLearnt/update", method = RequestMethod.GET)
@ResponseBody
public StatusJsonBean updateLearntNode(
        @RequestParam("nodeName") String nodeName,
        @RequestParam("nodeId") String nodeId,
        @RequestParam("tier") String tier,
        @RequestParam("operationMode") String operationMode,
        HttpServletRequest request,
        @RequestParam(required = false) String container) {
    String containerName = (container == null) ? GlobalConstants.DEFAULT
            .toString() : container;

    // Authorization check
    String userName = request.getUserPrincipal().getName();
    if (DaylightWebUtil
            .getContainerPrivilege(userName, containerName, this) != Privilege.WRITE) {
        return unauthorizedMessage();
    }

    StatusJsonBean resultBean = new StatusJsonBean();
    try {
        ISwitchManager switchManager = (ISwitchManager) ServiceHelper
                .getInstance(ISwitchManager.class, containerName, this);
        Map<String, Property> nodeProperties = new HashMap<String, Property>();
        Property desc = new Description(nodeName);
        nodeProperties.put(desc.getName(), desc);
        Property nodeTier = new Tier(Integer.parseInt(tier));
        nodeProperties.put(nodeTier.getName(), nodeTier);
        Property mode = new ForwardingMode(Integer.parseInt(operationMode));
        nodeProperties.put(mode.getName(), mode);
        SwitchConfig cfg = new SwitchConfig(nodeId, nodeProperties);
        Status result = switchManager.updateNodeConfig(cfg);
        if (!result.isSuccess()) {
            resultBean.setStatus(false);
            resultBean.setMessage(result.getDescription());
        } else {
            resultBean.setStatus(true);
            resultBean.setMessage("Updated node information successfully");
        }
    } catch (Exception e) {
        resultBean.setStatus(false);
        resultBean.setMessage("Error updating node information. "
                + e.getMessage());
    }
    return resultBean;
}
 
开发者ID:lbchen,项目名称:ODL,代码行数:47,代码来源:Devices.java

示例9: updateSwitchConfig

import org.opendaylight.controller.sal.core.Tier; //导入依赖的package包/类
@Override
public void updateSwitchConfig(SwitchConfig cfgObject) {
    // update default container only
    if (!isDefaultContainer) {
        return;
    }

    SwitchConfig sc = nodeConfigList.get(cfgObject.getNodeId());
    if (sc == null) {
        if (nodeConfigList.putIfAbsent(cfgObject.getNodeId(), cfgObject) != null) {
            return;
        }
    } else {
        if (!nodeConfigList.replace(cfgObject.getNodeId(), sc, cfgObject)) {
            return;
        }
    }

    boolean modeChange = false;

    if ((sc == null) || !cfgObject.getMode().equals(sc.getMode())) {
        modeChange = true;
    }

    String nodeId = cfgObject.getNodeId();
    Node node = Node.fromString(nodeId);
    Map<String, Property> propMapCurr = nodeProps.get(node);
    if (propMapCurr == null) {
        return;
    }
    Map<String, Property> propMap = new HashMap<String, Property>(propMapCurr);
    Property desc = new Description(cfgObject.getNodeDescription());
    propMap.put(desc.getName(), desc);
    Property tier = new Tier(Integer.parseInt(cfgObject.getTier()));
    propMap.put(tier.getName(), tier);

    if (!nodeProps.replace(node, propMapCurr, propMap)) {
        // TODO rollback using Transactionality
        return;
    }

    log.info("Set Node {}'s Mode to {}", nodeId, cfgObject.getMode());

    if (modeChange) {
        notifyModeChange(node, cfgObject.isProactive());
    }
}
 
开发者ID:lbchen,项目名称:ODL,代码行数:48,代码来源:SwitchManagerImpl.java

示例10: updateCurrentHierarchy

import org.opendaylight.controller.sal.core.Tier; //导入依赖的package包/类
/**
 * A convenient recursive routine to obtain the Hierarchy of Switches.
 *
 * @param node
 *            Current Node in the Recursive routine.
 * @param currHierarchy
 *            Array of Nodes that make this hierarchy on which the Current
 *            Switch belong
 * @param fullHierarchy
 *            Array of multiple Hierarchies that represent a given host.
 */
@SuppressWarnings("unchecked")
private void updateCurrentHierarchy(Node node, ArrayList<String> currHierarchy, List<List<String>> fullHierarchy) {
    // currHierarchy.add(String.format("%x", currSw.getId()));
    currHierarchy.add(dpidToHostNameHack((Long) node.getID()));
    ArrayList<String> currHierarchyClone = (ArrayList<String>) currHierarchy.clone(); // Shallow
                                                                                      // copy
                                                                                      // as
                                                                                      // required

    Map<Node, Set<Edge>> ndlinks = topologyManager.getNodeEdges();
    if (ndlinks == null) {
        logger.debug("updateCurrentHierarchy(): topologyManager returned null ndlinks for node: {}", node);
        return;
    }
    Node n = NodeCreator.createOFNode((Long) node.getID());
    Set<Edge> links = ndlinks.get(n);
    if (links == null) {
        logger.debug("updateCurrentHierarchy(): Null links for ndlinks");
        return;
    }
    for (Edge lt : links) {
        if (!lt.getHeadNodeConnector().getType().equals(NodeConnector.NodeConnectorIDType.OPENFLOW)) {
            // We don't want to work on Node that are not openflow
            // for now
            continue;
        }
        Node dstNode = lt.getHeadNodeConnector().getNode();

        Tier nodeTier = (Tier) switchManager.getNodeProp(node, Tier.TierPropName);
        Tier dstNodeTier = (Tier) switchManager.getNodeProp(dstNode, Tier.TierPropName);
        if (dstNodeTier.getValue() > nodeTier.getValue()) {
            ArrayList<String> buildHierarchy = currHierarchy;
            if (currHierarchy.size() > currHierarchyClone.size()) {
                buildHierarchy = (ArrayList<String>) currHierarchyClone.clone(); // Shallow
                                                                                 // copy
                                                                                 // as
                                                                                 // required
                fullHierarchy.add(buildHierarchy);
            }
            updateCurrentHierarchy(dstNode, buildHierarchy, fullHierarchy);
        }
    }
}
 
开发者ID:lbchen,项目名称:ODL,代码行数:55,代码来源:HostTracker.java

示例11: getTier

import org.opendaylight.controller.sal.core.Tier; //导入依赖的package包/类
/**
 * This method returns the configured Tier of a node
 *
 * @return Configured tier
 *
 * @deprecated replaced by getProperty(Tier.TierPropName)
 */
@Deprecated
public String getTier() {
    Tier tier = (Tier) getProperty(Tier.TierPropName);
    return (tier == null) ? null : String.valueOf(tier.getValue());
}
 
开发者ID:lbchen,项目名称:ODL,代码行数:13,代码来源:SwitchConfig.java


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