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


Java Output类代码示例

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


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

示例1: addOutputPort

import org.opendaylight.controller.sal.action.Output; //导入依赖的package包/类
@Override
public void addOutputPort(Node node, String flowName, List<NodeConnector> portList) {

    for (FlowEntryInstall flow : this.nodeFlows.get(node)) {
        if (flow.getFlowName().equals(flowName)) {
            FlowEntry currentFlowEntry = flow.getOriginal();
            FlowEntry newFlowEntry = currentFlowEntry.clone();
            for (NodeConnector dstPort : portList) {
                newFlowEntry.getFlow().addAction(new Output(dstPort));
            }
            Status error = modifyEntry(currentFlowEntry, newFlowEntry, false);
            if (error.isSuccess()) {
                log.info("Ports {} added to FlowEntry {}", portList, flowName);
            } else {
                log.warn("Failed to add ports {} to Flow entry {}. The failure is: {}", portList,
                        currentFlowEntry.toString(), error.getDescription());
            }
            return;
        }
    }
    log.warn("Failed to add ports to Flow {} on Node {}: Entry Not Found", flowName, node);
}
 
开发者ID:lbchen,项目名称:ODL,代码行数:23,代码来源:ForwardingRulesManager.java

示例2: removeOutputPort

import org.opendaylight.controller.sal.action.Output; //导入依赖的package包/类
@Override
public void removeOutputPort(Node node, String flowName, List<NodeConnector> portList) {
    for (FlowEntryInstall index : this.nodeFlows.get(node)) {
        FlowEntryInstall flow = this.installedSwView.get(index);
        if (flow.getFlowName().equals(flowName)) {
            FlowEntry currentFlowEntry = flow.getOriginal();
            FlowEntry newFlowEntry = currentFlowEntry.clone();
            for (NodeConnector dstPort : portList) {
                Action action = new Output(dstPort);
                newFlowEntry.getFlow().removeAction(action);
            }
            Status status = modifyEntry(currentFlowEntry, newFlowEntry, false);
            if (status.isSuccess()) {
                log.info("Ports {} removed from FlowEntry {}", portList, flowName);
            } else {
                log.warn("Failed to remove ports {} from Flow entry {}. The failure is: {}", portList,
                        currentFlowEntry.toString(), status.getDescription());
            }
            return;
        }
    }
    log.warn("Failed to remove ports from Flow {} on Node {}: Entry Not Found", flowName, node);
}
 
开发者ID:lbchen,项目名称:ODL,代码行数:24,代码来源:ForwardingRulesManager.java

示例3: flowPortsBelongToContainer

import org.opendaylight.controller.sal.action.Output; //导入依赖的package包/类
/**
 * Check whether the ports in the flow match and flow actions for
 * the specified node belong to the container
 *
 * @param container
 * @param node
 * @param flow
 * @return
 */
private boolean flowPortsBelongToContainer(String container, Node node,
        Flow flow) {
    Match m = flow.getMatch();
    if (m.isPresent(MatchType.IN_PORT)) {
        NodeConnector inPort = (NodeConnector) m.getField(MatchType.IN_PORT).getValue();
        // If the incoming port is specified, check if it belongs to
        if (!containerOwnsNodeConnector(container, inPort)) {
            return false;
        }
    }

    // If an outgoing port is specified, it must belong to this container
    for (Action action : flow.getActions()) {
        if (action.getType() == ActionType.OUTPUT) {
            NodeConnector outPort = ((Output) action).getPort();
            if (!containerOwnsNodeConnector(container, outPort)) {
                return false;
            }
        }
    }
    return true;
}
 
开发者ID:lbchen,项目名称:ODL,代码行数:32,代码来源:ReadServiceFilter.java

示例4: getOutputPort

import org.opendaylight.controller.sal.action.Output; //导入依赖的package包/类
@Override
public NodeConnector getOutputPort(Node node, String flowName) {
    for (FlowEntryInstall index : this.nodeFlows.get(node)) {
        FlowEntryInstall flow = this.installedSwView.get(index);
        if (flow.getFlowName().equals(flowName)) {
            for (Action action : flow.getOriginal().getFlow().getActions()) {
                if (action.getType() == ActionType.OUTPUT) {
                    return ((Output) action).getPort();
                }
            }
        }
    }
    return null;
}
 
开发者ID:lbchen,项目名称:ODL,代码行数:15,代码来源:ForwardingRulesManager.java

示例5: testFlowOnNodeMethods

import org.opendaylight.controller.sal.action.Output; //导入依赖的package包/类
@Test
        public void testFlowOnNodeMethods () {
        Match match = new Match();
        NodeConnector inNC = NodeConnectorCreator.createNodeConnector((short)10, NodeCreator.createOFNode((long)10));
        NodeConnector outNC = NodeConnectorCreator.createNodeConnector((short)20, NodeCreator.createOFNode((long)20));

        match.setField(MatchType.DL_TYPE, EtherTypes.IPv4.shortValue());
        match.setField(MatchType.IN_PORT, inNC);

        Output output = new Output(outNC);
        ArrayList<Action> action = new ArrayList<Action>();
        action.add(output);

        Flow flow = new Flow (match, action);

        FlowOnNode flowOnNode = new FlowOnNode (flow);

        Assert.assertTrue(flowOnNode.getFlow().equals(flow));

        flowOnNode.setPacketCount((long)100);
        flowOnNode.setByteCount((long)800);
        flowOnNode.setTableId((byte)0x55);
        flowOnNode.setDurationNanoseconds(40);
        flowOnNode.setDurationSeconds(45);

        Assert.assertTrue(flowOnNode.getPacketCount() == 100);
        Assert.assertTrue(flowOnNode.getByteCount() == 800);
        Assert.assertTrue(flowOnNode.getDurationNanoseconds() == 40);
        Assert.assertTrue(flowOnNode.getDurationSeconds() == 45);
        Assert.assertTrue(flowOnNode.getTableId() == (byte)0x55);
}
 
开发者ID:lbchen,项目名称:ODL,代码行数:32,代码来源:FlowOnNodeTest.java

示例6: getSampleFlowV6

import org.opendaylight.controller.sal.action.Output; //导入依赖的package包/类
private Flow getSampleFlowV6(Node node) throws UnknownHostException {
    NodeConnector port = NodeConnectorCreator.createOFNodeConnector((short) 24, node);
    NodeConnector oport = NodeConnectorCreator.createOFNodeConnector((short) 30, node);
    byte srcMac[] = { (byte) 0x12, (byte) 0x34, (byte) 0x56, (byte) 0x78, (byte) 0x9a, (byte) 0xbc };
    byte dstMac[] = { (byte) 0x1a, (byte) 0x2b, (byte) 0x3c, (byte) 0x4d, (byte) 0x5e, (byte) 0x6f };
    byte newMac[] = { (byte) 0x11, (byte) 0xaa, (byte) 0xbb, (byte) 0x34, (byte) 0x9a, (byte) 0xee };
    InetAddress srcIP = InetAddress.getByName("2001:420:281:1004:407a:57f4:4d15:c355");
    InetAddress dstIP = InetAddress.getByName("2001:420:281:1004:e123:e688:d655:a1b0");
    InetAddress ipMask = InetAddress.getByName("ffff:ffff:ffff:ffff:0:0:0:0");
    InetAddress ipMask2 = InetAddress.getByName("ffff:ffff:ffff:ffff:ffff:ffff:ffff:0");
    InetAddress newIP = InetAddress.getByName("2056:650::a1b0");
    short ethertype = EtherTypes.IPv6.shortValue();
    short vlan = (short) 27;
    byte vlanPr = (byte) 3;
    Byte tos = 4;
    byte proto = IPProtocols.UDP.byteValue();
    short src = (short) 5500;
    short dst = 80;

    /*
     * Create a SAL Flow aFlow
     */
    Match match = new Match();
    match.setField(MatchType.IN_PORT, port);
    match.setField(MatchType.DL_SRC, srcMac);
    match.setField(MatchType.DL_DST, dstMac);
    match.setField(MatchType.DL_TYPE, ethertype);
    match.setField(MatchType.DL_VLAN, vlan);
    match.setField(MatchType.DL_VLAN_PR, vlanPr);
    match.setField(MatchType.NW_SRC, srcIP, ipMask);
    match.setField(MatchType.NW_DST, dstIP, ipMask2);
    match.setField(MatchType.NW_TOS, tos);
    match.setField(MatchType.NW_PROTO, proto);
    match.setField(MatchType.TP_SRC, src);
    match.setField(MatchType.TP_DST, dst);

    List<Action> actions = new ArrayList<Action>();
    actions.add(new Controller());
    actions.add(new SetVlanId(5));
    actions.add(new SetDlDst(newMac));
    actions.add(new SetNwDst(newIP));
    actions.add(new Output(oport));
    actions.add(new PopVlan());
    actions.add(new Flood());

    Flow flow = new Flow(match, actions);
    flow.setPriority((short) 300);
    flow.setHardTimeout((short) 240);

    return flow;
}
 
开发者ID:lbchen,项目名称:ODL,代码行数:52,代码来源:frmTest.java

示例7: replaceOutputPort

import org.opendaylight.controller.sal.action.Output; //导入依赖的package包/类
@Override
public void replaceOutputPort(Node node, String flowName, NodeConnector outPort) {
    FlowEntry currentFlowEntry = null;
    FlowEntry newFlowEntry = null;

    // Find the flow
    for (FlowEntryInstall index : this.nodeFlows.get(node)) {
        FlowEntryInstall flow = this.installedSwView.get(index);
        if (flow.getFlowName().equals(flowName)) {
            currentFlowEntry = flow.getOriginal();
            break;
        }
    }
    if (currentFlowEntry == null) {
        log.warn("Failed to replace output port for flow {} on node {}: Entry Not Found", flowName, node);
        return;
    }

    // Create a flow copy with the new output port
    newFlowEntry = currentFlowEntry.clone();
    Action target = null;
    for (Action action : newFlowEntry.getFlow().getActions()) {
        if (action.getType() == ActionType.OUTPUT) {
            target = action;
            break;
        }
    }
    newFlowEntry.getFlow().removeAction(target);
    newFlowEntry.getFlow().addAction(new Output(outPort));

    // Modify on network node
    Status status = modifyEntry(currentFlowEntry, newFlowEntry, false);

    if (status.isSuccess()) {
        log.info("Output port replaced with {} for flow {} on node {}", outPort, flowName, node);
    } else {
        log.warn("Failed to replace output port for flow {} on node {}. The failure is: {}", flowName, node,
                status.getDescription());
    }
    return;
}
 
开发者ID:lbchen,项目名称:ODL,代码行数:42,代码来源:ForwardingRulesManager.java

示例8: getSampleFlow

import org.opendaylight.controller.sal.action.Output; //导入依赖的package包/类
private Flow getSampleFlow(Node node) throws UnknownHostException {
    NodeConnector port = NodeConnectorCreator.createOFNodeConnector((short) 24, node);
    NodeConnector oport = NodeConnectorCreator.createOFNodeConnector((short) 30, node);
    byte srcMac[] = { (byte) 0x12, (byte) 0x34, (byte) 0x56, (byte) 0x78, (byte) 0x9a, (byte) 0xbc };
    byte dstMac[] = { (byte) 0x1a, (byte) 0x2b, (byte) 0x3c, (byte) 0x4d, (byte) 0x5e, (byte) 0x6f };
    InetAddress srcIP = InetAddress.getByName("172.28.30.50");
    InetAddress dstIP = InetAddress.getByName("171.71.9.52");
    InetAddress ipMask = InetAddress.getByName("255.255.255.0");
    InetAddress ipMask2 = InetAddress.getByName("255.0.0.0");
    short ethertype = EtherTypes.IPv4.shortValue();
    short vlan = (short) 27;
    byte vlanPr = 3;
    Byte tos = 4;
    byte proto = IPProtocols.TCP.byteValue();
    short src = (short) 55000;
    short dst = 80;

    /*
     * Create a SAL Flow aFlow
     */
    Match match = new Match();
    match.setField(MatchType.IN_PORT, port);
    match.setField(MatchType.DL_SRC, srcMac);
    match.setField(MatchType.DL_DST, dstMac);
    match.setField(MatchType.DL_TYPE, ethertype);
    match.setField(MatchType.DL_VLAN, vlan);
    match.setField(MatchType.DL_VLAN_PR, vlanPr);
    match.setField(MatchType.NW_SRC, srcIP, ipMask);
    match.setField(MatchType.NW_DST, dstIP, ipMask2);
    match.setField(MatchType.NW_TOS, tos);
    match.setField(MatchType.NW_PROTO, proto);
    match.setField(MatchType.TP_SRC, src);
    match.setField(MatchType.TP_DST, dst);

    List<Action> actions = new ArrayList<Action>();
    actions.add(new Output(oport));
    actions.add(new PopVlan());
    actions.add(new Flood());
    actions.add(new Controller());
    return new Flow(match, actions);
}
 
开发者ID:lbchen,项目名称:ODL,代码行数:42,代码来源:ForwardingRulesManager.java

示例9: getSampleFlow

import org.opendaylight.controller.sal.action.Output; //导入依赖的package包/类
private Flow getSampleFlow(Node node) throws UnknownHostException {
    NodeConnector port = NodeConnectorCreator.createOFNodeConnector(
            (short) 24, node);
    NodeConnector oport = NodeConnectorCreator.createOFNodeConnector(
            (short) 30, node);
    byte srcMac[] = { (byte) 0x12, (byte) 0x34, (byte) 0x56, (byte) 0x78,
            (byte) 0x9a, (byte) 0xbc };
    byte dstMac[] = { (byte) 0x1a, (byte) 0x2b, (byte) 0x3c, (byte) 0x4d,
            (byte) 0x5e, (byte) 0x6f };
    InetAddress srcIP = InetAddress.getByName("172.28.30.50");
    InetAddress dstIP = InetAddress.getByName("171.71.9.52");
    InetAddress newIP = InetAddress.getByName("200.200.100.1");
    InetAddress ipMask = InetAddress.getByName("255.255.255.0");
    InetAddress ipMask2 = InetAddress.getByName("255.240.0.0");
    short ethertype = EtherTypes.IPv4.shortValue();
    short vlan = (short) 27;
    byte vlanPr = 3;
    Byte tos = 4;
    byte proto = IPProtocols.TCP.byteValue();
    short src = (short) 55000;
    short dst = 80;

    /*
     * Create a SAL Flow aFlow
     */
    Match match = new Match();
    match.setField(MatchType.IN_PORT, port);
    match.setField(MatchType.DL_SRC, srcMac);
    match.setField(MatchType.DL_DST, dstMac);
    match.setField(MatchType.DL_TYPE, ethertype);
    match.setField(MatchType.DL_VLAN, vlan);
    match.setField(MatchType.DL_VLAN_PR, vlanPr);
    match.setField(MatchType.NW_SRC, srcIP, ipMask);
    match.setField(MatchType.NW_DST, dstIP, ipMask2);
    match.setField(MatchType.NW_TOS, tos);
    match.setField(MatchType.NW_PROTO, proto);
    match.setField(MatchType.TP_SRC, src);
    match.setField(MatchType.TP_DST, dst);

    List<Action> actions = new ArrayList<Action>();
    actions.add(new SetNwDst(newIP));
    actions.add(new Output(oport));
    actions.add(new PopVlan());
    actions.add(new Flood());
    actions.add(new Controller());

    Flow flow = new Flow(match, actions);
    flow.setPriority((short) 100);
    flow.setHardTimeout((short) 360);

    return flow;
}
 
开发者ID:lbchen,项目名称:ODL,代码行数:53,代码来源:FlowTest.java

示例10: getSampleFlowV6

import org.opendaylight.controller.sal.action.Output; //导入依赖的package包/类
private Flow getSampleFlowV6(Node node) throws UnknownHostException {
    NodeConnector port = NodeConnectorCreator.createOFNodeConnector(
            (short) 24, node);
    NodeConnector oport = NodeConnectorCreator.createOFNodeConnector(
            (short) 30, node);
    byte srcMac[] = { (byte) 0x12, (byte) 0x34, (byte) 0x56, (byte) 0x78,
            (byte) 0x9a, (byte) 0xbc };
    byte dstMac[] = { (byte) 0x1a, (byte) 0x2b, (byte) 0x3c, (byte) 0x4d,
            (byte) 0x5e, (byte) 0x6f };
    byte newMac[] = { (byte) 0x11, (byte) 0xaa, (byte) 0xbb, (byte) 0x34,
            (byte) 0x9a, (byte) 0xee };
    InetAddress srcIP = InetAddress
            .getByName("2001:420:281:1004:407a:57f4:4d15:c355");
    InetAddress dstIP = InetAddress
            .getByName("2001:420:281:1004:e123:e688:d655:a1b0");
    InetAddress ipMask = InetAddress
            .getByName("ffff:ffff:ffff:ffff:0:0:0:0");
    InetAddress ipMask2 = InetAddress
            .getByName("ffff:ffff:ffff:ffff:ffff:ffff:ffff:0");
    InetAddress newIP = InetAddress.getByName("2056:650::a1b0");
    short ethertype = EtherTypes.IPv6.shortValue();
    short vlan = (short) 27;
    byte vlanPr = (byte) 3;
    Byte tos = 4;
    byte proto = IPProtocols.UDP.byteValue();
    short src = (short) 5500;
    short dst = 80;

    /*
     * Create a SAL Flow aFlow
     */
    Match match = new Match();
    match.setField(MatchType.IN_PORT, port);
    match.setField(MatchType.DL_SRC, srcMac);
    match.setField(MatchType.DL_DST, dstMac);
    match.setField(MatchType.DL_TYPE, ethertype);
    match.setField(MatchType.DL_VLAN, vlan);
    match.setField(MatchType.DL_VLAN_PR, vlanPr);
    match.setField(MatchType.NW_SRC, srcIP, ipMask);
    match.setField(MatchType.NW_DST, dstIP, ipMask2);
    match.setField(MatchType.NW_TOS, tos);
    match.setField(MatchType.NW_PROTO, proto);
    match.setField(MatchType.TP_SRC, src);
    match.setField(MatchType.TP_DST, dst);

    List<Action> actions = new ArrayList<Action>();
    actions.add(new Controller());
    actions.add(new SetVlanId(5));
    actions.add(new SetDlDst(newMac));
    actions.add(new SetNwDst(newIP));
    actions.add(new Output(oport));
    actions.add(new PopVlan());
    actions.add(new Flood());

    actions.add(new Controller());

    Flow flow = new Flow(match, actions);
    flow.setPriority((short) 300);
    flow.setHardTimeout((short) 240);

    return flow;
}
 
开发者ID:lbchen,项目名称:ODL,代码行数:63,代码来源:FlowTest.java

示例11: getSampleFlow

import org.opendaylight.controller.sal.action.Output; //导入依赖的package包/类
private Flow getSampleFlow(Node node) throws UnknownHostException {
    NodeConnector port = NodeConnectorCreator.createOFNodeConnector(
            (short) 24, node);
    NodeConnector oport = NodeConnectorCreator.createOFNodeConnector(
            (short) 30, node);
    byte srcMac[] = { (byte) 0x12, (byte) 0x34, (byte) 0x56, (byte) 0x78,
            (byte) 0x9a, (byte) 0xbc };
    byte dstMac[] = { (byte) 0x1a, (byte) 0x2b, (byte) 0x3c, (byte) 0x4d,
            (byte) 0x5e, (byte) 0x6f };
    InetAddress srcIP = InetAddress.getByName("172.28.30.50");
    InetAddress dstIP = InetAddress.getByName("171.71.9.52");
    InetAddress ipMask = InetAddress.getByName("255.255.255.0");
    InetAddress ipMask2 = InetAddress.getByName("255.0.0.0");
    short ethertype = EtherTypes.IPv4.shortValue();
    short vlan = (short) 27;
    byte vlanPr = 3;
    Byte tos = 4;
    byte proto = IPProtocols.TCP.byteValue();
    short src = (short) 55000;
    short dst = 80;

    /*
     * Create a SAL Flow aFlow
     */
    Match match = new Match();
    match.setField(MatchType.IN_PORT, port);
    match.setField(MatchType.DL_SRC, srcMac);
    match.setField(MatchType.DL_DST, dstMac);
    match.setField(MatchType.DL_TYPE, ethertype);
    match.setField(MatchType.DL_VLAN, vlan);
    match.setField(MatchType.DL_VLAN_PR, vlanPr);
    match.setField(MatchType.NW_SRC, srcIP, ipMask);
    match.setField(MatchType.NW_DST, dstIP, ipMask2);
    match.setField(MatchType.NW_TOS, tos);
    match.setField(MatchType.NW_PROTO, proto);
    match.setField(MatchType.TP_SRC, src);
    match.setField(MatchType.TP_DST, dst);

    List<Action> actions = new ArrayList<Action>();
    actions.add(new Output(oport));
    actions.add(new PopVlan());
    actions.add(new Flood());
    actions.add(new Controller());
    return new Flow(match, actions);
}
 
开发者ID:lbchen,项目名称:ODL,代码行数:46,代码来源:ReadService.java

示例12: getSampleFlowV6

import org.opendaylight.controller.sal.action.Output; //导入依赖的package包/类
private Flow getSampleFlowV6(Node node) throws UnknownHostException {
    NodeConnector port = NodeConnectorCreator.createOFNodeConnector(
            (short) 24, node);
    NodeConnector oport = NodeConnectorCreator.createOFNodeConnector(
            (short) 30, node);
    byte srcMac[] = { (byte) 0x12, (byte) 0x34, (byte) 0x56, (byte) 0x78,
            (byte) 0x9a, (byte) 0xbc };
    byte dstMac[] = { (byte) 0x1a, (byte) 0x2b, (byte) 0x3c, (byte) 0x4d,
            (byte) 0x5e, (byte) 0x6f };
    InetAddress srcIP = InetAddress
            .getByName("2001:420:281:1004:407a:57f4:4d15:c355");
    InetAddress dstIP = InetAddress
            .getByName("2001:420:281:1004:e123:e688:d655:a1b0");
    InetAddress ipMask = null; // InetAddress.getByName("ffff:ffff:ffff:ffff:0:0:0:0");
                               // V6Match implementation assumes no mask is
                               // specified
    InetAddress ipMask2 = null; // InetAddress.getByName("ffff:ffff:ffff:ffff:ffff:ffff:ffff:0");
    short ethertype = EtherTypes.IPv6.shortValue();
    short vlan = (short) 27;
    byte vlanPr = (byte) 3;
    Byte tos = 4;
    byte proto = IPProtocols.UDP.byteValue();
    short src = (short) 5500;
    // short dst = 80;

    /*
     * Create a SAL Flow aFlow
     */
    Match match = new Match();
    match.setField(MatchType.IN_PORT, port);
    match.setField(MatchType.DL_SRC, srcMac);
    match.setField(MatchType.DL_DST, dstMac);
    match.setField(MatchType.DL_TYPE, ethertype);
    match.setField(MatchType.DL_VLAN, vlan);
    match.setField(MatchType.DL_VLAN_PR, vlanPr); // V6Match does not handle
                                                  // this properly...
    match.setField(MatchType.NW_SRC, srcIP, ipMask);
    match.setField(MatchType.NW_DST, dstIP, ipMask2);
    match.setField(MatchType.NW_TOS, tos);
    match.setField(MatchType.NW_PROTO, proto);
    match.setField(MatchType.TP_SRC, src); // V6Match does not handle this
                                           // properly...
    // match.setField(MatchType.TP_DST, dst); V6Match does not handle this
    // properly...

    List<Action> actions = new ArrayList<Action>();
    actions.add(new Output(oport));
    actions.add(new PopVlan());
    actions.add(new Flood());

    Flow flow = new Flow(match, actions);
    flow.setPriority((short) 300);
    flow.setHardTimeout((short) 240);

    return flow;
}
 
开发者ID:lbchen,项目名称:ODL,代码行数:57,代码来源:FlowProgrammerService.java

示例13: installLoadBalancerFlow

import org.opendaylight.controller.sal.action.Output; //导入依赖的package包/类
private boolean installLoadBalancerFlow(Client source,
                                        VIP dest,
                                        Node sourceSwitch,
                                        String destMachineIp,
                                        byte[] destMachineMac,
                                        NodeConnector outport,
                                        int flowDirection) throws UnknownHostException{

    Match match = new Match();
    List<Action> actions = new ArrayList<Action>();

    if(flowDirection == LBConst.FORWARD_DIRECTION_LB_FLOW){
        match.setField(MatchType.DL_TYPE, EtherTypes.IPv4.shortValue());
        match.setField(MatchType.NW_SRC, InetAddress.getByName(source.getIp()));
        match.setField(MatchType.NW_DST, InetAddress.getByName(dest.getIp()));
        match.setField(MatchType.NW_PROTO, IPProtocols.getProtocolNumberByte(dest.getProtocol()));
        match.setField(MatchType.TP_SRC, source.getPort());
        match.setField(MatchType.TP_DST, dest.getPort());

        actions.add(new SetNwDst(InetAddress.getByName(destMachineIp)));
        actions.add(new SetDlDst(destMachineMac));
    }

    if(flowDirection == LBConst.REVERSE_DIRECTION_LB_FLOW){
        match.setField(MatchType.DL_TYPE, EtherTypes.IPv4.shortValue());
        match.setField(MatchType.NW_SRC, InetAddress.getByName(destMachineIp));
        match.setField(MatchType.NW_DST, InetAddress.getByName(source.getIp()));
        match.setField(MatchType.NW_PROTO, IPProtocols.getProtocolNumberByte(source.getProtocol()));
        match.setField(MatchType.TP_SRC, dest.getPort());
        match.setField(MatchType.TP_DST,source.getPort());

        actions.add(new SetNwSrc(InetAddress.getByName(dest.getIp())));
        actions.add(new SetDlSrc(destMachineMac));
    }

    actions.add(new Output(outport));

    // Make sure the priority for IP switch entries is
    // set to a level just above default drop entries

    Flow flow = new Flow(match, actions);
    flow.setIdleTimeout((short) 5);
    flow.setHardTimeout((short) 0);
    flow.setPriority(LB_IPSWITCH_PRIORITY);

    String policyName = source.getIp()+":"+source.getProtocol()+":"+source.getPort();
    String flowName =null;

    if(flowDirection == LBConst.FORWARD_DIRECTION_LB_FLOW){
        flowName = "["+policyName+":"+source.getIp() + ":"+dest.getIp()+"]";
    }

    if(flowDirection == LBConst.REVERSE_DIRECTION_LB_FLOW){

        flowName = "["+policyName+":"+dest.getIp() + ":"+source.getIp()+"]";
    }

    FlowEntry fEntry = new FlowEntry(policyName, flowName, flow, sourceSwitch);

    lbsLogger.info("Install flow entry {} on node {}",fEntry.toString(),sourceSwitch.toString());

    if(!this.ruleManager.checkFlowEntryConflict(fEntry)){
        if(this.ruleManager.installFlowEntry(fEntry).isSuccess()){
            return true;
        }else{
            lbsLogger.error("Error in installing flow entry to node : {}",sourceSwitch);
        }
    }else{
        lbsLogger.error("Conflicting flow entry exists : {}",fEntry.toString());
    }
    return false;
}
 
开发者ID:lbchen,项目名称:ODL,代码行数:73,代码来源:LoadBalancerService.java


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