@Test public void onDataChangeTestCreatedDataSubmit() { doReturn(DataObjectModification.ModificationType.WRITE).when(mockModification).getModificationType(); doReturn(entryValue).when(mockModification).getDataAfter(); listener.onDataTreeChanged(changeEvent); verify(rwTx).submit(); }
@Override public void onDataTreeChanged(Collection<DataTreeModification<FlowCapableNodeConnector>> changes) { ReadWriteTransaction rwTx = dataProvider.newReadWriteTransaction(); Map<Name, Endpoint> epWithOfOverlayAugByPortName = readEpsWithOfOverlayAugByPortName(rwTx); Map<Name, EndpointL3> l3EpWithOfOverlayAugByPortName = readL3EpsWithOfOverlayAugByPortName(rwTx); boolean isDataPutToTx = false; for (DataTreeModification<FlowCapableNodeConnector> change: changes) { DataObjectModification<FlowCapableNodeConnector> rootNode = change.getRootNode(); InstanceIdentifier<NodeConnector> ncIid = change.getRootPath().getRootIdentifier() .firstIdentifierOf(NodeConnector.class); final FlowCapableNodeConnector originalFcnc = rootNode.getDataBefore(); boolean updated; boolean l3Updated; switch (rootNode.getModificationType()) { case SUBTREE_MODIFIED: case WRITE: FlowCapableNodeConnector fcnc = rootNode.getDataAfter(); LOG.trace( "FlowCapableNodeConnector updated: NodeId: {} NodeConnectorId: {} FlowCapableNodeConnector: {}", ncIid.firstKeyOf(Node.class, NodeKey.class).getId().getValue(), ncIid.firstKeyOf(NodeConnector.class, NodeConnectorKey.class).getId().getValue(), fcnc); switchManager.updateSwitchNodeConnectorConfig(ncIid, fcnc); Name portName = getPortName(fcnc); updated = updateEpWithNodeConnectorInfo(epWithOfOverlayAugByPortName.get(portName), ncIid, rwTx); l3Updated = updateL3EpWithNodeConnectorInfo(l3EpWithOfOverlayAugByPortName.get(portName), ncIid, rwTx); if (updated || l3Updated) { isDataPutToTx = true; } if (originalFcnc != null) { Name portNameFromOriginalFcnc = getPortName(originalFcnc); if (portNameFromOriginalFcnc != null && !Objects.equal(portNameFromOriginalFcnc, portName)) { updated = updateEpWithNodeConnectorInfo(epWithOfOverlayAugByPortName .get(portNameFromOriginalFcnc), null, rwTx); l3Updated = updateL3EpWithNodeConnectorInfo(l3EpWithOfOverlayAugByPortName .get(portNameFromOriginalFcnc), null, rwTx); if (updated || l3Updated) { isDataPutToTx = true; } } } break; case DELETE: LOG.trace("FlowCapableNodeConnector removed: NodeId: {} NodeConnectorId: {}", ncIid.firstKeyOf(Node.class, NodeKey.class).getId().getValue(), ncIid.firstKeyOf(NodeConnector.class, NodeConnectorKey.class).getId().getValue()); switchManager.updateSwitchNodeConnectorConfig(ncIid, null); Name portNameFromOriginalFcnc = getPortName(originalFcnc); updated = updateEpWithNodeConnectorInfo(epWithOfOverlayAugByPortName.get(portNameFromOriginalFcnc), null, rwTx); l3Updated = updateL3EpWithNodeConnectorInfo(l3EpWithOfOverlayAugByPortName.get(portNameFromOriginalFcnc), null, rwTx); if (updated || l3Updated) { isDataPutToTx = true; } break; default: break; } } if (isDataPutToTx) { rwTx.submit(); } else { rwTx.cancel(); } }
FlowCapableNodeConnectorListener implements DataTreeChangeListener<FlowCapableNodeConnector>,
        AutoCloseable { @Override public void onDataTreeChanged(Collection<DataTreeModification<FlowCapableNodeConnector>> changes) { ReadWriteTransaction rwTx = dataProvider.newReadWriteTransaction(); Map<Name, Endpoint> epWithOfOverlayAugByPortName = readEpsWithOfOverlayAugByPortName(rwTx); Map<Name, EndpointL3> l3EpWithOfOverlayAugByPortName = readL3EpsWithOfOverlayAugByPortName(rwTx); boolean isDataPutToTx = false; for (DataTreeModification<FlowCapableNodeConnector> change: changes) { DataObjectModification<FlowCapableNodeConnector> rootNode = change.getRootNode(); InstanceIdentifier<NodeConnector> ncIid = change.getRootPath().getRootIdentifier() .firstIdentifierOf(NodeConnector.class); final FlowCapableNodeConnector originalFcnc = rootNode.getDataBefore(); boolean updated; boolean l3Updated; switch (rootNode.getModificationType()) { case SUBTREE_MODIFIED: case WRITE: FlowCapableNodeConnector fcnc = rootNode.getDataAfter(); LOG.trace( "FlowCapableNodeConnector updated: NodeId: {} NodeConnectorId: {} FlowCapableNodeConnector: {}", ncIid.firstKeyOf(Node.class, NodeKey.class).getId().getValue(), ncIid.firstKeyOf(NodeConnector.class, NodeConnectorKey.class).getId().getValue(), fcnc); switchManager.updateSwitchNodeConnectorConfig(ncIid, fcnc); Name portName = getPortName(fcnc); updated = updateEpWithNodeConnectorInfo(epWithOfOverlayAugByPortName.get(portName), ncIid, rwTx); l3Updated = updateL3EpWithNodeConnectorInfo(l3EpWithOfOverlayAugByPortName.get(portName), ncIid, rwTx); if (updated || l3Updated) { isDataPutToTx = true; } if (originalFcnc != null) { Name portNameFromOriginalFcnc = getPortName(originalFcnc); if (portNameFromOriginalFcnc != null && !Objects.equal(portNameFromOriginalFcnc, portName)) { updated = updateEpWithNodeConnectorInfo(epWithOfOverlayAugByPortName .get(portNameFromOriginalFcnc), null, rwTx); l3Updated = updateL3EpWithNodeConnectorInfo(l3EpWithOfOverlayAugByPortName .get(portNameFromOriginalFcnc), null, rwTx); if (updated || l3Updated) { isDataPutToTx = true; } } } break; case DELETE: LOG.trace("FlowCapableNodeConnector removed: NodeId: {} NodeConnectorId: {}", ncIid.firstKeyOf(Node.class, NodeKey.class).getId().getValue(), ncIid.firstKeyOf(NodeConnector.class, NodeConnectorKey.class).getId().getValue()); switchManager.updateSwitchNodeConnectorConfig(ncIid, null); Name portNameFromOriginalFcnc = getPortName(originalFcnc); updated = updateEpWithNodeConnectorInfo(epWithOfOverlayAugByPortName.get(portNameFromOriginalFcnc), null, rwTx); l3Updated = updateL3EpWithNodeConnectorInfo(l3EpWithOfOverlayAugByPortName.get(portNameFromOriginalFcnc), null, rwTx); if (updated || l3Updated) { isDataPutToTx = true; } break; default: break; } } if (isDataPutToTx) { rwTx.submit(); } else { rwTx.cancel(); } } }
FlowCapableNodeConnectorListener implements DataTreeChangeListener<FlowCapableNodeConnector>,
        AutoCloseable { @Override public void onDataTreeChanged(Collection<DataTreeModification<FlowCapableNodeConnector>> changes) { ReadWriteTransaction rwTx = dataProvider.newReadWriteTransaction(); Map<Name, Endpoint> epWithOfOverlayAugByPortName = readEpsWithOfOverlayAugByPortName(rwTx); Map<Name, EndpointL3> l3EpWithOfOverlayAugByPortName = readL3EpsWithOfOverlayAugByPortName(rwTx); boolean isDataPutToTx = false; for (DataTreeModification<FlowCapableNodeConnector> change: changes) { DataObjectModification<FlowCapableNodeConnector> rootNode = change.getRootNode(); InstanceIdentifier<NodeConnector> ncIid = change.getRootPath().getRootIdentifier() .firstIdentifierOf(NodeConnector.class); final FlowCapableNodeConnector originalFcnc = rootNode.getDataBefore(); boolean updated; boolean l3Updated; switch (rootNode.getModificationType()) { case SUBTREE_MODIFIED: case WRITE: FlowCapableNodeConnector fcnc = rootNode.getDataAfter(); LOG.trace( "FlowCapableNodeConnector updated: NodeId: {} NodeConnectorId: {} FlowCapableNodeConnector: {}", ncIid.firstKeyOf(Node.class, NodeKey.class).getId().getValue(), ncIid.firstKeyOf(NodeConnector.class, NodeConnectorKey.class).getId().getValue(), fcnc); switchManager.updateSwitchNodeConnectorConfig(ncIid, fcnc); Name portName = getPortName(fcnc); updated = updateEpWithNodeConnectorInfo(epWithOfOverlayAugByPortName.get(portName), ncIid, rwTx); l3Updated = updateL3EpWithNodeConnectorInfo(l3EpWithOfOverlayAugByPortName.get(portName), ncIid, rwTx); if (updated || l3Updated) { isDataPutToTx = true; } if (originalFcnc != null) { Name portNameFromOriginalFcnc = getPortName(originalFcnc); if (portNameFromOriginalFcnc != null && !Objects.equal(portNameFromOriginalFcnc, portName)) { updated = updateEpWithNodeConnectorInfo(epWithOfOverlayAugByPortName .get(portNameFromOriginalFcnc), null, rwTx); l3Updated = updateL3EpWithNodeConnectorInfo(l3EpWithOfOverlayAugByPortName .get(portNameFromOriginalFcnc), null, rwTx); if (updated || l3Updated) { isDataPutToTx = true; } } } break; case DELETE: LOG.trace("FlowCapableNodeConnector removed: NodeId: {} NodeConnectorId: {}", ncIid.firstKeyOf(Node.class, NodeKey.class).getId().getValue(), ncIid.firstKeyOf(NodeConnector.class, NodeConnectorKey.class).getId().getValue()); switchManager.updateSwitchNodeConnectorConfig(ncIid, null); Name portNameFromOriginalFcnc = getPortName(originalFcnc); updated = updateEpWithNodeConnectorInfo(epWithOfOverlayAugByPortName.get(portNameFromOriginalFcnc), null, rwTx); l3Updated = updateL3EpWithNodeConnectorInfo(l3EpWithOfOverlayAugByPortName.get(portNameFromOriginalFcnc), null, rwTx); if (updated || l3Updated) { isDataPutToTx = true; } break; default: break; } } if (isDataPutToTx) { rwTx.submit(); } else { rwTx.cancel(); } } FlowCapableNodeConnectorListener(DataBroker dataProvider, SwitchManager switchManager); }
FlowCapableNodeConnectorListener implements DataTreeChangeListener<FlowCapableNodeConnector>,
        AutoCloseable { @Override public void onDataTreeChanged(Collection<DataTreeModification<FlowCapableNodeConnector>> changes) { ReadWriteTransaction rwTx = dataProvider.newReadWriteTransaction(); Map<Name, Endpoint> epWithOfOverlayAugByPortName = readEpsWithOfOverlayAugByPortName(rwTx); Map<Name, EndpointL3> l3EpWithOfOverlayAugByPortName = readL3EpsWithOfOverlayAugByPortName(rwTx); boolean isDataPutToTx = false; for (DataTreeModification<FlowCapableNodeConnector> change: changes) { DataObjectModification<FlowCapableNodeConnector> rootNode = change.getRootNode(); InstanceIdentifier<NodeConnector> ncIid = change.getRootPath().getRootIdentifier() .firstIdentifierOf(NodeConnector.class); final FlowCapableNodeConnector originalFcnc = rootNode.getDataBefore(); boolean updated; boolean l3Updated; switch (rootNode.getModificationType()) { case SUBTREE_MODIFIED: case WRITE: FlowCapableNodeConnector fcnc = rootNode.getDataAfter(); LOG.trace( "FlowCapableNodeConnector updated: NodeId: {} NodeConnectorId: {} FlowCapableNodeConnector: {}", ncIid.firstKeyOf(Node.class, NodeKey.class).getId().getValue(), ncIid.firstKeyOf(NodeConnector.class, NodeConnectorKey.class).getId().getValue(), fcnc); switchManager.updateSwitchNodeConnectorConfig(ncIid, fcnc); Name portName = getPortName(fcnc); updated = updateEpWithNodeConnectorInfo(epWithOfOverlayAugByPortName.get(portName), ncIid, rwTx); l3Updated = updateL3EpWithNodeConnectorInfo(l3EpWithOfOverlayAugByPortName.get(portName), ncIid, rwTx); if (updated || l3Updated) { isDataPutToTx = true; } if (originalFcnc != null) { Name portNameFromOriginalFcnc = getPortName(originalFcnc); if (portNameFromOriginalFcnc != null && !Objects.equal(portNameFromOriginalFcnc, portName)) { updated = updateEpWithNodeConnectorInfo(epWithOfOverlayAugByPortName .get(portNameFromOriginalFcnc), null, rwTx); l3Updated = updateL3EpWithNodeConnectorInfo(l3EpWithOfOverlayAugByPortName .get(portNameFromOriginalFcnc), null, rwTx); if (updated || l3Updated) { isDataPutToTx = true; } } } break; case DELETE: LOG.trace("FlowCapableNodeConnector removed: NodeId: {} NodeConnectorId: {}", ncIid.firstKeyOf(Node.class, NodeKey.class).getId().getValue(), ncIid.firstKeyOf(NodeConnector.class, NodeConnectorKey.class).getId().getValue()); switchManager.updateSwitchNodeConnectorConfig(ncIid, null); Name portNameFromOriginalFcnc = getPortName(originalFcnc); updated = updateEpWithNodeConnectorInfo(epWithOfOverlayAugByPortName.get(portNameFromOriginalFcnc), null, rwTx); l3Updated = updateL3EpWithNodeConnectorInfo(l3EpWithOfOverlayAugByPortName.get(portNameFromOriginalFcnc), null, rwTx); if (updated || l3Updated) { isDataPutToTx = true; } break; default: break; } } if (isDataPutToTx) { rwTx.submit(); } else { rwTx.cancel(); } } FlowCapableNodeConnectorListener(DataBroker dataProvider, SwitchManager switchManager); @Override void onDataTreeChanged(Collection<DataTreeModification<FlowCapableNodeConnector>> changes); @Override void close(); }
FlowCapableNodeConnectorListener implements DataTreeChangeListener<FlowCapableNodeConnector>,
        AutoCloseable { @Override public void onDataTreeChanged(Collection<DataTreeModification<FlowCapableNodeConnector>> changes) { ReadWriteTransaction rwTx = dataProvider.newReadWriteTransaction(); Map<Name, Endpoint> epWithOfOverlayAugByPortName = readEpsWithOfOverlayAugByPortName(rwTx); Map<Name, EndpointL3> l3EpWithOfOverlayAugByPortName = readL3EpsWithOfOverlayAugByPortName(rwTx); boolean isDataPutToTx = false; for (DataTreeModification<FlowCapableNodeConnector> change: changes) { DataObjectModification<FlowCapableNodeConnector> rootNode = change.getRootNode(); InstanceIdentifier<NodeConnector> ncIid = change.getRootPath().getRootIdentifier() .firstIdentifierOf(NodeConnector.class); final FlowCapableNodeConnector originalFcnc = rootNode.getDataBefore(); boolean updated; boolean l3Updated; switch (rootNode.getModificationType()) { case SUBTREE_MODIFIED: case WRITE: FlowCapableNodeConnector fcnc = rootNode.getDataAfter(); LOG.trace( "FlowCapableNodeConnector updated: NodeId: {} NodeConnectorId: {} FlowCapableNodeConnector: {}", ncIid.firstKeyOf(Node.class, NodeKey.class).getId().getValue(), ncIid.firstKeyOf(NodeConnector.class, NodeConnectorKey.class).getId().getValue(), fcnc); switchManager.updateSwitchNodeConnectorConfig(ncIid, fcnc); Name portName = getPortName(fcnc); updated = updateEpWithNodeConnectorInfo(epWithOfOverlayAugByPortName.get(portName), ncIid, rwTx); l3Updated = updateL3EpWithNodeConnectorInfo(l3EpWithOfOverlayAugByPortName.get(portName), ncIid, rwTx); if (updated || l3Updated) { isDataPutToTx = true; } if (originalFcnc != null) { Name portNameFromOriginalFcnc = getPortName(originalFcnc); if (portNameFromOriginalFcnc != null && !Objects.equal(portNameFromOriginalFcnc, portName)) { updated = updateEpWithNodeConnectorInfo(epWithOfOverlayAugByPortName .get(portNameFromOriginalFcnc), null, rwTx); l3Updated = updateL3EpWithNodeConnectorInfo(l3EpWithOfOverlayAugByPortName .get(portNameFromOriginalFcnc), null, rwTx); if (updated || l3Updated) { isDataPutToTx = true; } } } break; case DELETE: LOG.trace("FlowCapableNodeConnector removed: NodeId: {} NodeConnectorId: {}", ncIid.firstKeyOf(Node.class, NodeKey.class).getId().getValue(), ncIid.firstKeyOf(NodeConnector.class, NodeConnectorKey.class).getId().getValue()); switchManager.updateSwitchNodeConnectorConfig(ncIid, null); Name portNameFromOriginalFcnc = getPortName(originalFcnc); updated = updateEpWithNodeConnectorInfo(epWithOfOverlayAugByPortName.get(portNameFromOriginalFcnc), null, rwTx); l3Updated = updateL3EpWithNodeConnectorInfo(l3EpWithOfOverlayAugByPortName.get(portNameFromOriginalFcnc), null, rwTx); if (updated || l3Updated) { isDataPutToTx = true; } break; default: break; } } if (isDataPutToTx) { rwTx.submit(); } else { rwTx.cancel(); } } FlowCapableNodeConnectorListener(DataBroker dataProvider, SwitchManager switchManager); @Override void onDataTreeChanged(Collection<DataTreeModification<FlowCapableNodeConnector>> changes); @Override void close();  }