本文整理汇总了Java中org.opendaylight.controller.sal.utils.NodeConnectorCreator.createNodeConnector方法的典型用法代码示例。如果您正苦于以下问题:Java NodeConnectorCreator.createNodeConnector方法的具体用法?Java NodeConnectorCreator.createNodeConnector怎么用?Java NodeConnectorCreator.createNodeConnector使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.opendaylight.controller.sal.utils.NodeConnectorCreator
的用法示例。
在下文中一共展示了NodeConnectorCreator.createNodeConnector方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: toNodeConnector
import org.opendaylight.controller.sal.utils.NodeConnectorCreator; //导入方法依赖的package包/类
/**
* Converts the Openflow port number to the equivalent NodeConnector.
*/
public static NodeConnector toNodeConnector(short ofPort, Node node) {
// Restore original OF unsigned 16 bits value for the comparison
int unsignedOFPort = NetUtils.getUnsignedShort(ofPort);
log.trace("Openflow port number signed: {} unsigned: {}", ofPort,
unsignedOFPort);
if (unsignedOFPort > maxOFPhysicalPort) {
if (ofPort == OFPort.OFPP_LOCAL.getValue()) {
return NodeConnectorCreator.createNodeConnector(
NodeConnectorIDType.SWSTACK,
NodeConnector.SPECIALNODECONNECTORID, node);
} else if (ofPort == OFPort.OFPP_NORMAL.getValue()) {
return NodeConnectorCreator.createNodeConnector(
NodeConnectorIDType.HWPATH,
NodeConnector.SPECIALNODECONNECTORID, node);
} else if (ofPort == OFPort.OFPP_CONTROLLER.getValue()) {
return NodeConnectorCreator.createNodeConnector(
NodeConnectorIDType.CONTROLLER,
NodeConnector.SPECIALNODECONNECTORID, node);
}
}
return NodeConnectorCreator.createNodeConnector(ofPort, node);
}
示例2: testNodeConnectorStatisticsMethods
import org.opendaylight.controller.sal.utils.NodeConnectorCreator; //导入方法依赖的package包/类
@Test
public void testNodeConnectorStatisticsMethods() {
NodeConnector nc = NodeConnectorCreator.createNodeConnector((short)20, NodeCreator.createOFNode((long)20));
NodeConnectorStatistics ncStats = new NodeConnectorStatistics();
ncStats.setNodeConnector(nc);
ncStats.setReceiveByteCount(800);
ncStats.setReceiveCRCErrorCount(10);
ncStats.setReceiveDropCount(5);
ncStats.setReceiveErrorCount(20);
ncStats.setReceiveFrameErrorCount(25);
ncStats.setReceiveOverRunErrorCount(30);
ncStats.setReceivePacketCount(100);
ncStats.setTransmitByteCount(400);
ncStats.setTransmitDropCount(15);
ncStats.setTransmitErrorCount(18);
ncStats.setTransmitPacketCount(50);
ncStats.setCollisionCount(2);
Assert.assertTrue(ncStats.getCollisionCount() == 2);
Assert.assertTrue(ncStats.getTransmitPacketCount() == 50);
Assert.assertTrue(ncStats.getTransmitErrorCount() == 18);
Assert.assertTrue(ncStats.getTransmitDropCount() == 15);
Assert.assertTrue(ncStats.getReceivePacketCount() == 100);
Assert.assertTrue(ncStats.getReceiveOverRunErrorCount() == 30);
Assert.assertTrue(ncStats.getReceiveFrameErrorCount() == 25);
Assert.assertTrue(ncStats.getReceiveDropCount() == 5);
Assert.assertTrue(ncStats.getReceiveCRCErrorCount() == 10);
Assert.assertTrue(ncStats.getReceiveByteCount() == 800);
Assert.assertTrue(ncStats.getNodeConnector().equals(nc));
}
示例3: testFlowOnNodeMethods
import org.opendaylight.controller.sal.utils.NodeConnectorCreator; //导入方法依赖的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);
}
示例4: _readport
import org.opendaylight.controller.sal.utils.NodeConnectorCreator; //导入方法依赖的package包/类
public void _readport(CommandInterpreter ci) {
String nodeId = ci.nextArgument();
String portId = ci.nextArgument();
String cacheReq = ci.nextArgument();
boolean cached;
if (nodeId == null) {
ci.print("Node id not specified");
return;
}
if (portId == null) {
ci.print("Port id not specified");
return;
}
cached = (cacheReq == null) ? true : cacheReq.equals("true");
NodeConnector nodeConnector = null;
Node node = NodeCreator.createOFNode(Long.parseLong(nodeId));
nodeConnector = NodeConnectorCreator.createNodeConnector(Short
.valueOf(portId), node);
NodeConnectorStatistics stats = (cached) ? this
.readNodeConnector(nodeConnector) : this
.nonCachedReadNodeConnector(nodeConnector);
if (stats != null) {
ci.println(stats.toString());
} else {
ci.println("null");
}
}
示例5: testV6MatchToSALMatchToV6MatchConversion
import org.opendaylight.controller.sal.utils.NodeConnectorCreator; //导入方法依赖的package包/类
@Test
public void testV6MatchToSALMatchToV6MatchConversion()
throws UnknownHostException {
NodeConnector port = NodeConnectorCreator.createNodeConnector(
(short) 24, NodeCreator.createOFNode(6l));
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");
short ethertype = EtherTypes.IPv6.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 aMatch = new Match();
aMatch.setField(MatchType.IN_PORT, port);
aMatch.setField(MatchType.DL_SRC, srcMac);
aMatch.setField(MatchType.DL_DST, dstMac);
aMatch.setField(MatchType.DL_TYPE, ethertype);
aMatch.setField(MatchType.DL_VLAN, vlan);
aMatch.setField(MatchType.DL_VLAN_PR, vlanPr);
aMatch.setField(MatchType.NW_SRC, srcIP, ipMask);
aMatch.setField(MatchType.NW_DST, dstIP, ipMask);
aMatch.setField(MatchType.NW_TOS, tos);
aMatch.setField(MatchType.NW_PROTO, proto);
aMatch.setField(MatchType.TP_SRC, src);
aMatch.setField(MatchType.TP_DST, dst);
Assert.assertTrue(aMatch.isIPv6());
}