本文整理汇总了Java中org.opendaylight.controller.sal.utils.NodeConnectorCreator类的典型用法代码示例。如果您正苦于以下问题:Java NodeConnectorCreator类的具体用法?Java NodeConnectorCreator怎么用?Java NodeConnectorCreator使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
NodeConnectorCreator类属于org.opendaylight.controller.sal.utils包,在下文中一共展示了NodeConnectorCreator类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getNodeConnectorsFromString
import org.opendaylight.controller.sal.utils.NodeConnectorCreator; //导入依赖的package包/类
private void getNodeConnectorsFromString(String codedNodeConnectors,
Set<NodeConnector> sp) {
if (codedNodeConnectors == null) {
return;
}
if (sp == null) {
return;
}
// codedNodeConnectors = xx:xx:xx:xx:xx:xx:xx:xx/a,b,c-m,r-t,y
String pieces[] = codedNodeConnectors.split("/");
for (Short port : getPortList(pieces[1])) {
Node n = Node.fromString(pieces[0]);
if (n == null) {
continue;
}
NodeConnector p = NodeConnectorCreator.createOFNodeConnector(port,
n);
if (p == null) {
continue;
}
sp.add(p);
}
}
示例2: testNodeConnectorProperties
import org.opendaylight.controller.sal.utils.NodeConnectorCreator; //导入依赖的package包/类
@Test
public void testNodeConnectorProperties() {
Node node = NodeCreator.createOFNode(1L);
NodeConnector port = NodeConnectorCreator.createOFNodeConnector(
(short) 24, node);
NodeConnectorProperties ncp= new NodeConnectorProperties(port, null);
Assert.assertTrue(ncp.getProperties() == null);
Assert.assertTrue(ncp.getNodeConnector().equals(port));
NodeConnector port2 = NodeConnectorCreator.createOFNodeConnector(
(short) 33, node);
ncp.setNodeConnector(port2);
Assert.assertTrue(ncp.getNodeConnector().equals(port2));
Set<Property> props = new HashSet<Property>();
ncp.setProperties(props);
Assert.assertTrue(ncp.getProperties().equals(props));
}
示例3: filterPortListPerContainer
import org.opendaylight.controller.sal.utils.NodeConnectorCreator; //导入依赖的package包/类
/**
* Filters a list of OFStatistics elements based on the container
*
* @param container
* @param nodeId
* @param list
* @return
*/
public List<OFStatistics> filterPortListPerContainer(String container, long switchId, List<OFStatistics> list) {
if (list == null) {
return null;
}
// Create new filtered list of flows
List<OFStatistics> newList = new ArrayList<OFStatistics>();
for (OFStatistics stat : list) {
OFPortStatisticsReply target = (OFPortStatisticsReply) stat;
NodeConnector nc = NodeConnectorCreator.createOFNodeConnector(
target.getPortNumber(), NodeCreator.createOFNode(switchId));
if (containerOwnsNodeConnector(container, nc)) {
newList.add(target);
}
}
return newList;
}
示例4: 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);
}
示例5: StaticRoute
import org.opendaylight.controller.sal.utils.NodeConnectorCreator; //导入依赖的package包/类
/**
* Create a static route object from the StaticRouteConfig.
* @param: config: StaticRouteConfig
*/
public StaticRoute(StaticRouteConfig config) {
networkAddress = config.getStaticRouteIP();
mask = StaticRoute.getV4AddressMaskFromDecimal(config
.getStaticRouteMask());
type = NextHopType.fromString(config.getNextHopType());
nextHopAddress = config.getNextHopIP();
Map<Long, Short> switchPort = config.getNextHopSwitchPorts();
if ((switchPort != null) && (switchPort.size() == 1)) {
node = NodeCreator.createOFNode((Long) switchPort.keySet()
.toArray()[0]);
port = NodeConnectorCreator.createOFNodeConnector(
(Short) switchPort.values().toArray()[0], node);
}
}
示例6: testSwitchAddRemovePort
import org.opendaylight.controller.sal.utils.NodeConnectorCreator; //导入依赖的package包/类
@Test
public void testSwitchAddRemovePort() {
Node node = NodeCreator.createOFNode(((long) 10));
NodeConnector nc0 = NodeConnectorCreator.createOFNodeConnector(
(short) 20, node);
NodeConnector nc1 = NodeConnectorCreator.createOFNodeConnector(
(short) 30, node);
NodeConnector nc4 = NodeConnectorCreator.createOFNodeConnector(
(short) 60, node);
NodeConnector nc5 = NodeConnectorCreator.createOFNodeConnector(
(short) 70, node);
ArrayList<NodeConnector> portList = new ArrayList<NodeConnector>();
portList.add(nc4);
portList.add(nc5);
Set<NodeConnector> ncSet = new HashSet<NodeConnector>();
ncSet.add(nc0);
ncSet.add(nc1);
Switch sw = new Switch(node);
sw.setNodeConnectors(ncSet);
sw.removeNodeConnector(nc0);
Assert.assertFalse(ncSet.contains(nc0));
sw.removeSpanPorts(portList);
Assert.assertTrue(sw.getSpanPorts().isEmpty());
}
示例7: testMatchSetGet
import org.opendaylight.controller.sal.utils.NodeConnectorCreator; //导入依赖的package包/类
@Test
public void testMatchSetGet() {
Match x = new Match();
short val = 2346;
NodeConnector inPort = NodeConnectorCreator.createOFNodeConnector(val, NodeCreator.createOFNode(1l));
x.setField(MatchType.IN_PORT, inPort);
Assert.assertTrue(((NodeConnector) x.getField(MatchType.IN_PORT).getValue()).equals(inPort));
Assert.assertTrue((Short) ((NodeConnector) x.getField(MatchType.IN_PORT).getValue()).getID() == val);
}
示例8: testMatchMask
import org.opendaylight.controller.sal.utils.NodeConnectorCreator; //导入依赖的package包/类
@Test
public void testMatchMask() {
Match x = new Match();
NodeConnector inPort = NodeConnectorCreator.createOFNodeConnector((short) 6, NodeCreator.createOFNode(3l));
x.setField(MatchType.IN_PORT, inPort);
x.setField(MatchType.DL_VLAN, (short) 28, (short) 0xfff);
Assert.assertFalse(x.getMatches() == 0);
Assert.assertTrue(x.getMatches() == (MatchType.IN_PORT.getIndex() | MatchType.DL_VLAN.getIndex()));
}
示例9: 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));
}
示例10: 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);
}
示例11: _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");
}
}
示例12: testHostFind
import org.opendaylight.controller.sal.utils.NodeConnectorCreator; //导入依赖的package包/类
@Test
public void testHostFind() throws UnknownHostException {
assertNotNull(this.invtoryListener);
// create one node and two node connectors
Node node1 = NodeCreator.createOFNode(1L);
NodeConnector nc1_1 = NodeConnectorCreator.createOFNodeConnector(
(short) 1, node1);
NodeConnector nc1_2 = NodeConnectorCreator.createOFNodeConnector(
(short) 2, node1);
// test addStaticHost(), put into inactive host DB if not verifiable
Status st = this.hosttracker.addStaticHost("192.168.0.8",
"11:22:33:44:55:66", nc1_1, "0");
st = this.hosttracker.addStaticHost("192.168.0.13",
"11:22:33:44:55:77", nc1_2, "0");
HostNodeConnector hnc_1 = this.hosttracker.hostFind(InetAddress
.getByName("192.168.0.8"));
assertNull(hnc_1);
this.invtoryListener.notifyNodeConnector(nc1_1, UpdateType.ADDED, null);
hnc_1 = this.hosttracker.hostFind(InetAddress.getByName("192.168.0.8"));
assertNotNull(hnc_1);
}
示例13: addDiscovery
import org.opendaylight.controller.sal.utils.NodeConnectorCreator; //导入依赖的package包/类
private void addDiscovery(Node node) {
Map<Long, ISwitch> switches = controller.getSwitches();
ISwitch sw = switches.get(node.getID());
List<OFPhysicalPort> ports = sw.getEnabledPorts();
if (ports == null) {
return;
}
for (OFPhysicalPort port : ports) {
NodeConnector nodeConnector = NodeConnectorCreator.createOFNodeConnector(port.getPortNumber(), node);
if (!readyListHi.contains(nodeConnector)) {
readyListHi.add(nodeConnector);
}
}
}
示例14: testSwitchCreation
import org.opendaylight.controller.sal.utils.NodeConnectorCreator; //导入依赖的package包/类
@Test
public void testSwitchCreation() {
Node node = NodeCreator.createOFNode(((long) 10));
Node node2 = NodeCreator.createOFNode(((long) 11));
NodeConnector nc0 = NodeConnectorCreator.createOFNodeConnector(
(short) 20, node);
NodeConnector nc1 = NodeConnectorCreator.createOFNodeConnector(
(short) 30, node);
NodeConnector nc2 = NodeConnectorCreator.createOFNodeConnector(
(short) 40, node);
NodeConnector nc3 = NodeConnectorCreator.createOFNodeConnector(
(short) 50, node);
NodeConnector nc4 = NodeConnectorCreator.createOFNodeConnector(
(short) 60, node);
NodeConnector nc5 = NodeConnectorCreator.createOFNodeConnector(
(short) 70, node);
Set<NodeConnector> ncSet = new HashSet<NodeConnector>();
ArrayList<NodeConnector> portList = new ArrayList<NodeConnector>();
Switch sw = new Switch(node);
Switch sw2 = new Switch(node);
Assert.assertTrue(sw.equals(sw2));
sw2.setNode(node2);
Assert.assertTrue(sw2.getNode().equals(node2));
Assert.assertFalse(sw.equals(sw2));
ncSet.add(nc0);
ncSet.add(nc1);
ncSet.add(nc2);
sw.addNodeConnector(nc3);
try {
sw.addNodeConnector(nc3);
} catch (Exception e) {
fail("Attempted to add duplicate NodeConnector to set");
}
portList.add(nc4);
portList.add(nc5);
sw.setNodeConnectors(ncSet);
sw.addSpanPorts(portList);
sw.setDataLayerAddress(null);
Assert.assertNull(sw.getDataLayerAddress());
byte[] dlAddress = { (byte) 0x01, (byte) 0x02, (byte) 0x03,
(byte) 0x04, (byte) 0x05, (byte) 0x06 };
sw.setDataLayerAddress(dlAddress);
Node resultNode = sw.getNode();
Set<NodeConnector> resultncSet = sw.getNodeConnectors();
byte[] resultdlAddress = sw.getDataLayerAddress();
ArrayList<NodeConnector> resultSpanPort = (ArrayList<NodeConnector>) sw
.getSpanPorts();
Assert.assertEquals(node, resultNode);
for (int i = 0; i < dlAddress.length; i++)
Assert.assertEquals(dlAddress[i], resultdlAddress[i]);
Assert.assertTrue(ncSet.equals(resultncSet));
for (int i = 0; i < portList.size(); i++)
Assert.assertEquals(portList.get(i), resultSpanPort.get(i));
}
示例15: testSubnet
import org.opendaylight.controller.sal.utils.NodeConnectorCreator; //导入依赖的package包/类
@Test
public void testSubnet() throws Exception {
InetAddress ipaddr = InetAddress.getByName("100.0.0.1");
Subnet subnet = new Subnet(ipaddr, (short) 24, (short) 5);
Assert.assertTrue(subnet.equals(subnet));
Assert.assertFalse(subnet.equals(null));
Assert.assertFalse(subnet.equals(ipaddr));
Subnet subnet2 = new Subnet(ipaddr, (short) 24, (short) 5);
Inet6Address ipv6 = (Inet6Address) Inet6Address
.getByName("1111::2222:3333:4444:5555:6666");
Subnet subnet3 = new Subnet(ipv6, (short) 24, (short) 5);
Assert.assertTrue(subnet.equals(subnet2));
Assert.assertFalse(subnet.isMutualExclusive(subnet2));
Assert.assertTrue(subnet.isMutualExclusive(subnet3));
InetAddress subnetAddr = InetAddress.getByName("200.0.0.100");
Assert.assertTrue(subnet.isFlatLayer2() == true);
Set<NodeConnector> ncSet = new HashSet<NodeConnector>();
Node node = NodeCreator.createOFNode(((long) 10));
NodeConnector nc0 = NodeConnectorCreator.createOFNodeConnector(
(short) 20, node);
NodeConnector nc1 = NodeConnectorCreator.createOFNodeConnector(
(short) 30, node);
NodeConnector nc2 = NodeConnectorCreator.createOFNodeConnector(
(short) 40, node);
ncSet.add(nc0);
ncSet.add(nc1);
ncSet.add(nc2);
Assert.assertTrue(subnet.hasNodeConnector(nc0));
Assert.assertFalse(subnet.hasNodeConnector(null));
subnet.addNodeConnectors(ncSet);
Assert.assertTrue(subnet.hasNodeConnector(nc0));
Set<NodeConnector> resultncSet = subnet.getNodeConnectors();
Assert.assertEquals(resultncSet, ncSet);
subnet.addNodeConnectors(null);
Assert.assertEquals(subnet.getNodeConnectors(), ncSet);
subnet.deleteNodeConnectors(null);
Assert.assertEquals(subnet.getNodeConnectors(), ncSet);
Set<NodeConnector> ncSet2 = new HashSet<NodeConnector>();
ncSet2.add(nc0);
subnet.deleteNodeConnectors(ncSet2);
Assert.assertFalse(subnet.getNodeConnectors().contains(nc0));
Assert.assertFalse(subnet.hasNodeConnector(nc0));
Assert.assertTrue(subnet.getNodeConnectors().contains(nc1));
Assert.assertTrue(subnet.getNodeConnectors().contains(nc2));
subnet.deleteNodeConnectors(ncSet2);
subnet.setNetworkAddress(subnetAddr);
Assert.assertTrue(subnet.isMutualExclusive(subnet2));
Assert.assertTrue(subnet.getNetworkAddress().equals(subnetAddr));
subnet.setSubnetMaskLength((short) 16);
Assert.assertTrue(subnet.getSubnetMaskLength() == 16);
subnet.setVlan((short) 100);
Assert.assertTrue(subnet.getVlan() == 100);
Assert.assertTrue(subnet.isFlatLayer2() == false);
}