本文整理汇总了Java中org.opendaylight.controller.sal.utils.NodeCreator.createOFNode方法的典型用法代码示例。如果您正苦于以下问题:Java NodeCreator.createOFNode方法的具体用法?Java NodeCreator.createOFNode怎么用?Java NodeCreator.createOFNode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.opendaylight.controller.sal.utils.NodeCreator
的用法示例。
在下文中一共展示了NodeCreator.createOFNode方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: handlePortStatusMessage
import org.opendaylight.controller.sal.utils.NodeCreator; //导入方法依赖的package包/类
protected void handlePortStatusMessage(ISwitch sw, OFPortStatus m) {
Node node = NodeCreator.createOFNode(sw.getId());
NodeConnector nodeConnector = PortConverter.toNodeConnector(
m.getDesc().getPortNumber(), node);
// get node connector properties
Set<Property> props = InventoryServiceHelper.OFPortToProps(m.getDesc());
UpdateType type = null;
if (m.getReason() == (byte) OFPortReason.OFPPR_ADD.ordinal()) {
type = UpdateType.ADDED;
nodeConnectorProps.put(nodeConnector, props);
} else if (m.getReason() == (byte) OFPortReason.OFPPR_DELETE.ordinal()) {
type = UpdateType.REMOVED;
nodeConnectorProps.remove(nodeConnector);
} else if (m.getReason() == (byte) OFPortReason.OFPPR_MODIFY.ordinal()) {
type = UpdateType.CHANGED;
nodeConnectorProps.put(nodeConnector, props);
}
logger.trace("handlePortStatusMessage {} type {}", nodeConnector, type);
if (type != null) {
notifyInventoryShimListener(nodeConnector, type, props);
}
}
示例2: testNodeTableOpenFlowOfWrongType
import org.opendaylight.controller.sal.utils.NodeCreator; //导入方法依赖的package包/类
@Test
public void testNodeTableOpenFlowOfWrongType() {
try {
Node node = NodeCreator.createOFNode((long) 20);
NodeTable of1 = new NodeTable(NodeTable.NodeTableIDType.OPENFLOW, "name", node);
// If we reach this point the exception was not raised
// which should have been the case
Assert.assertTrue(false);
} catch (ConstructionException e) {
// If we reach this point the exception has been raised
// and so test passed
System.out.println("Got exception as expected!:" + e);
Assert.assertTrue(true);
}
}
示例3: portStatisticsRefreshed
import org.opendaylight.controller.sal.utils.NodeCreator; //导入方法依赖的package包/类
@Override
public void portStatisticsRefreshed(Long switchId, List<OFStatistics> ports) {
String container;
IReadFilterInternalListener listener;
Node node = NodeCreator.createOFNode(switchId);
for (Map.Entry<String, IReadFilterInternalListener> l : readFilterInternalListeners.entrySet()) {
container = l.getKey();
listener = l.getValue();
// Convert and filter the statistics per container
List<OFStatistics> filteredPorts = filterPortListPerContainer(container, switchId, ports);
List<NodeConnectorStatistics> ncStatsList = new PortStatisticsConverter(switchId, filteredPorts)
.getNodeConnectorStatsList();
// notify listeners
listener.nodeConnectorStatisticsUpdated(node, ncStatsList);
}
}
示例4: descriptionStatisticsRefreshed
import org.opendaylight.controller.sal.utils.NodeCreator; //导入方法依赖的package包/类
@Override
public void descriptionStatisticsRefreshed(Long switchId, List<OFStatistics> descriptionStats) {
Node node = NodeCreator.createOFNode(switchId);
Set<Property> properties = new HashSet<Property>(1);
OFDescriptionStatistics ofDesc = (OFDescriptionStatistics) descriptionStats.get(0);
Description desc = new Description(ofDesc.getDatapathDescription());
properties.add(desc);
// Notify all internal and external listeners
notifyInventoryShimListener(node, UpdateType.CHANGED, properties);
}
示例5: StaticRoute
import org.opendaylight.controller.sal.utils.NodeCreator; //导入方法依赖的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: testFlowCloning
import org.opendaylight.controller.sal.utils.NodeCreator; //导入方法依赖的package包/类
@Test
public void testFlowCloning() throws UnknownHostException {
Node node = NodeCreator.createOFNode(55l);
Flow flow1 = getSampleFlowV6(node);
Flow flow2 = flow1.clone();
Assert.assertTrue(flow1.equals(flow2));
Assert.assertTrue(flow1.getMatch().equals(flow2.getMatch()));
Assert.assertTrue(flow1.getActions() != flow2.getActions());
Assert.assertTrue(flow1.getActions().equals(flow2.getActions()));
}
示例7: testSwitchAddRemovePort
import org.opendaylight.controller.sal.utils.NodeCreator; //导入方法依赖的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());
}
示例8: testFlowEntrySetGet
import org.opendaylight.controller.sal.utils.NodeCreator; //导入方法依赖的package包/类
@Test
public void testFlowEntrySetGet() throws UnknownHostException {
Node node = NodeCreator.createOFNode(1L);
Node node2 = NodeCreator.createOFNode(2L);
FlowEntry pol = new FlowEntry("polTest", null, getSampleFlowV6(node), node);
pol.setGroupName("polTest2");
pol.setFlowName("flowName");
Assert.assertTrue(pol.getFlowName().equals("flowName"));
Assert.assertTrue(pol.getGroupName().equals("polTest2"));
pol.setNode(node2);
Assert.assertTrue(pol.getNode().equals(node2));
Assert.assertTrue(pol.equalsByNodeAndName(node2, "flowName"));
}
示例9: testFlowEntryEquality
import org.opendaylight.controller.sal.utils.NodeCreator; //导入方法依赖的package包/类
@Test
public void testFlowEntryEquality() throws UnknownHostException {
Node node = NodeCreator.createOFNode(1L);
Node node2 = NodeCreator.createOFNode(1L);
FlowEntry pol = new FlowEntry("polTest", null, getSampleFlowV6(node), node);
FlowEntry pol2 = new FlowEntry("polTest", null, getSampleFlowV6(node), node2);
Assert.assertTrue(pol.equals(pol2));
}
示例10: testNodeProperties
import org.opendaylight.controller.sal.utils.NodeCreator; //导入方法依赖的package包/类
@Test
public void testNodeProperties() {
Node node = NodeCreator.createOFNode(1L);
NodeProperties np= new NodeProperties(node, null);
Assert.assertTrue(np.getNode().equals(node));
Assert.assertTrue(np.getProperties() == null);
Node node2 = NodeCreator.createOFNode(2L);
np.setNode(node2);
Assert.assertTrue(np.getNode().equals(node2));
Set<Property> props = new HashSet<Property>();
np.setProperties(props);
Assert.assertTrue(np.getProperties().equals(props));
}
示例11: testFlowEntryCloning
import org.opendaylight.controller.sal.utils.NodeCreator; //导入方法依赖的package包/类
@Test
public void testFlowEntryCloning() throws UnknownHostException {
Node node = NodeCreator.createOFNode(1L);
FlowEntry pol = new FlowEntry("polTest", null, getSampleFlowV6(node), node);
FlowEntry pol2 = pol.clone();
Assert.assertTrue(pol.equals(pol2));
}
示例12: _addsw
import org.opendaylight.controller.sal.utils.NodeCreator; //导入方法依赖的package包/类
public void _addsw(CommandInterpreter ci) {
String val = ci.nextArgument();
Long sid;
try {
sid = Long.parseLong(val);
Node node = NodeCreator.createOFNode(sid);
addDiscovery(node);
} catch (Exception e) {
ci.println("Please enter a valid number");
}
return;
}
示例13: addNode
import org.opendaylight.controller.sal.utils.NodeCreator; //导入方法依赖的package包/类
private void addNode(ISwitch sw) {
Node node = NodeCreator.createOFNode(sw.getId());
UpdateType type = UpdateType.ADDED;
Set<Property> props = new HashSet<Property>();
Long sid = (Long) node.getID();
Date connectedSince = controller.getSwitches().get(sid)
.getConnectedDate();
Long connectedSinceTime = (connectedSince == null) ? 0 : connectedSince
.getTime();
props.add(new TimeStamp(connectedSinceTime, "connectedSince"));
props.add(new MacAddress(deriveMacAddress(sid)));
byte tables = sw.getTables();
Tables t = new Tables(tables);
if (t != null) {
props.add(t);
}
int cap = sw.getCapabilities();
Capabilities c = new Capabilities(cap);
if (c != null) {
props.add(c);
}
int act = sw.getActions();
Actions a = new Actions(act);
if (a != null) {
props.add(a);
}
int buffers = sw.getBuffers();
Buffers b = new Buffers(buffers);
if (b != null) {
props.add(b);
}
nodeProps.put(node, props);
// Notify all internal and external listeners
notifyInventoryShimListener(node, type, props);
}
示例14: testHostFind
import org.opendaylight.controller.sal.utils.NodeCreator; //导入方法依赖的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);
}
示例15: testFlowEquality
import org.opendaylight.controller.sal.utils.NodeCreator; //导入方法依赖的package包/类
@Test
public void testFlowEquality() throws Exception {
Node node = NodeCreator.createOFNode(1055l);
Flow flow1 = getSampleFlowV6(node);
Flow flow2 = getSampleFlowV6(node);
Flow flow3 = getSampleFlow(node);
// Check Match equality
Assert.assertTrue(flow1.getMatch().equals(flow2.getMatch()));
// Check Actions equality
for (int i = 0; i < flow1.getActions().size(); i++) {
Action a = flow1.getActions().get(i);
Action b = flow2.getActions().get(i);
Assert.assertTrue(a != b);
Assert.assertTrue(a.equals(b));
}
Assert.assertTrue(flow1.equals(flow2));
Assert.assertFalse(flow2.equals(flow3));
// Check Flow equality where Flow has null action list (pure match)
List<Action> emptyList = new ArrayList<Action>(1);
Flow x = flow1.clone();
x.setActions(emptyList);
Assert.assertFalse(flow1.equals(x));
flow1.setActions(emptyList);
Assert.assertTrue(flow1.equals(x));
}