use of Nodes.Node in project openflowplugin by opendaylight.
the class NodeChangeListenerImpl method processRemovedNode.
private void processRemovedNode(final DataTreeModification<FlowCapableNode> modification) {
final InstanceIdentifier<FlowCapableNode> iiToNodeInInventory = modification.getRootPath().getRootIdentifier();
final NodeId nodeId = provideTopologyNodeId(iiToNodeInInventory);
final InstanceIdentifier<org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node> iiToTopologyRemovedNode = provideIIToTopologyNode(nodeId);
if (iiToTopologyRemovedNode != null) {
operationProcessor.enqueueOperation(manager -> {
manager.addDeleteOperationToTxChain(LogicalDatastoreType.OPERATIONAL, iiToTopologyRemovedNode);
TopologyManagerUtil.removeAffectedLinks(nodeId, manager, II_TO_TOPOLOGY);
});
} else {
LOG.debug("Instance identifier to inventory wasn't translated to topology while deleting node.");
}
}
use of Nodes.Node in project openflowplugin by opendaylight.
the class TerminationPointChangeListenerImpl method processRemovedTerminationPoints.
private void processRemovedTerminationPoints(final DataTreeModification<FlowCapableNodeConnector> modification) {
final InstanceIdentifier<FlowCapableNodeConnector> removedNode = modification.getRootPath().getRootIdentifier();
final TpId terminationPointId = provideTopologyTerminationPointId(removedNode);
final InstanceIdentifier<TerminationPoint> iiToTopologyTerminationPoint = provideIIToTopologyTerminationPoint(terminationPointId, removedNode);
if (iiToTopologyTerminationPoint != null) {
final InstanceIdentifier<org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node> node = iiToTopologyTerminationPoint.firstIdentifierOf(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node.class);
operationProcessor.enqueueOperation(manager -> {
Optional<org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node> nodeOptional = Optional.empty();
try {
nodeOptional = Optional.ofNullable(manager.readFromTransaction(LogicalDatastoreType.OPERATIONAL, node).checkedGet().orNull());
} catch (ReadFailedException e) {
LOG.warn("Error occurred when trying to read NodeConnector: {}", e.getMessage());
LOG.debug("Error occurred when trying to read NodeConnector.. ", e);
}
if (nodeOptional.isPresent()) {
TopologyManagerUtil.removeAffectedLinks(terminationPointId, manager, II_TO_TOPOLOGY);
manager.addDeleteOperationToTxChain(LogicalDatastoreType.OPERATIONAL, iiToTopologyTerminationPoint);
}
});
} else {
LOG.debug("Instance identifier to inventory wasn't translated to topology while deleting termination point.");
}
}
use of Nodes.Node in project openflowplugin by opendaylight.
the class DeviceMastershipManager method registerNodeListener.
@SuppressWarnings("IllegalCatch")
private void registerNodeListener() {
final InstanceIdentifier<FlowCapableNode> flowNodeWildCardIdentifier = InstanceIdentifier.create(Nodes.class).child(Node.class).augmentation(FlowCapableNode.class);
final DataTreeIdentifier<FlowCapableNode> treeId = new DataTreeIdentifier<>(LogicalDatastoreType.OPERATIONAL, flowNodeWildCardIdentifier);
try {
SimpleTaskRetryLooper looper = new SimpleTaskRetryLooper(ForwardingRulesManagerImpl.STARTUP_LOOP_TICK, ForwardingRulesManagerImpl.STARTUP_LOOP_MAX_RETRIES);
listenerRegistration = looper.loopUntilNoException(() -> dataBroker.registerDataTreeChangeListener(treeId, DeviceMastershipManager.this));
} catch (Exception e) {
LOG.warn("Data listener registration failed: {}", e.getMessage());
LOG.debug("Data listener registration failed ", e);
throw new IllegalStateException("Node listener registration failed!", e);
}
}
use of Nodes.Node in project openflowplugin by opendaylight.
the class SalBulkFlowServiceImplTest method testAddRemoveFlowsRpc.
@Test
public void testAddRemoveFlowsRpc() throws Exception {
Mockito.when(mockSalFlowService.addFlow(Matchers.<AddFlowInput>any())).thenReturn(RpcResultBuilder.success(new AddFlowOutputBuilder().build()).buildFuture());
Mockito.when(mockSalFlowService.removeFlow(Matchers.<RemoveFlowInput>any())).thenReturn(RpcResultBuilder.success(new RemoveFlowOutputBuilder().build()).buildFuture());
final BulkFlowItemBuilder bulkFlowItemBuilder = new BulkFlowItemBuilder();
final InstanceIdentifier<Node> nodeId = BulkOMaticUtils.getFlowCapableNodeId("1");
bulkFlowItemBuilder.setNode(new NodeRef(nodeId));
final BulkFlowItem bulkFlowItem = bulkFlowItemBuilder.build();
final List<BulkFlowItem> bulkFlowItems = new ArrayList<>();
bulkFlowItems.add(bulkFlowItem);
final AddFlowsRpcInputBuilder addFlowsRpcInputBuilder = new AddFlowsRpcInputBuilder();
addFlowsRpcInputBuilder.setBulkFlowItem(bulkFlowItems);
final AddFlowsRpcInput addFlowsRpcInput = addFlowsRpcInputBuilder.build();
salBulkFlowService.addFlowsRpc(addFlowsRpcInput);
verify(mockSalFlowService).addFlow(Matchers.<AddFlowInput>any());
final RemoveFlowsRpcInputBuilder removeFlowsRpcInputBuilder = new RemoveFlowsRpcInputBuilder();
removeFlowsRpcInputBuilder.setBulkFlowItem(bulkFlowItems);
final RemoveFlowsRpcInput removeFlowsRpcInput = removeFlowsRpcInputBuilder.build();
salBulkFlowService.removeFlowsRpc(removeFlowsRpcInput);
verify(mockSalFlowService).removeFlow(Matchers.<RemoveFlowInput>any());
}
use of Nodes.Node in project openflowplugin by opendaylight.
the class SalBulkFlowServiceImplTest method testAddRemoveFlowsDs.
@Test
public void testAddRemoveFlowsDs() throws Exception {
Mockito.when(writeTransaction.submit()).thenReturn(Futures.immediateCheckedFuture(null));
final BulkFlowDsItemBuilder bulkFlowDsItemBuilder = new BulkFlowDsItemBuilder().setFlowId(new FlowId("1")).setTableId((short) 2);
final InstanceIdentifier<Node> nodeId = BulkOMaticUtils.getFlowCapableNodeId("1");
bulkFlowDsItemBuilder.setNode(new NodeRef(nodeId));
final BulkFlowDsItem bulkFlowDsItem = bulkFlowDsItemBuilder.build();
final List<BulkFlowDsItem> bulkFlowDsItems = new ArrayList<>();
bulkFlowDsItems.add(bulkFlowDsItem);
final AddFlowsDsInputBuilder addFlowsDsInputBuilder = new AddFlowsDsInputBuilder();
addFlowsDsInputBuilder.setBulkFlowDsItem(bulkFlowDsItems);
final AddFlowsDsInput addFlowsDsInput = addFlowsDsInputBuilder.build();
salBulkFlowService.addFlowsDs(addFlowsDsInput);
verify(writeTransaction).submit();
verify(writeTransaction).put(Matchers.<LogicalDatastoreType>any(), Matchers.<InstanceIdentifier<Flow>>any(), flowArgumentCaptor.capture(), Mockito.anyBoolean());
Flow flow = flowArgumentCaptor.getValue();
Assert.assertEquals("1", flow.getId().getValue());
Assert.assertEquals((short) 2, flow.getTableId().shortValue());
final RemoveFlowsDsInputBuilder removeFlowsDsInputBuilder = new RemoveFlowsDsInputBuilder();
removeFlowsDsInputBuilder.setBulkFlowDsItem(bulkFlowDsItems);
final RemoveFlowsDsInput removeFlowsDsInput = removeFlowsDsInputBuilder.build();
salBulkFlowService.removeFlowsDs(removeFlowsDsInput);
verify(writeTransaction).delete(Matchers.<LogicalDatastoreType>any(), Matchers.<InstanceIdentifier<Flow>>any());
verify(writeTransaction, times(2)).submit();
}
Aggregations