-
- @Override
- public void onNodeConnectorRemoved(NodeConnectorRemoved nodeConector) {
- }
-
- @Override
- public void onNodeConnectorUpdated(NodeConnectorUpdated nodeConnector) {
- }
-
- @Override
- public void onNodeRemoved(NodeRemoved node) {
- }
-
-
- @Override
- public void run() {
- try {
- for (; ; ) {
- String nodeId = queue.take();
- this.programDefaultPipelineRule(nodeId);
- }
- } catch (InterruptedException e) {
- logger.warn("Processing interrupted, terminating", e);
- }
-
- while (!queue.isEmpty()) {
- queue.poll();
- }
-
- }
-
- void enqueue(final String nodeId) {
- try {
- queue.put(nodeId);
- } catch (InterruptedException e) {
- logger.warn("Failed to enqueue operation {}", nodeId, e);
- }
- }
-
- /**
- * Process the Node update notification. Check for Openflow node and make sure if the bridge is part of the Pipeline before
- * programming the Pipeline specific flows.
- */
- @Override
- public void onNodeUpdated(NodeUpdated nodeUpdated) {
- NodeRef ref = nodeUpdated.getNodeRef();
- InstanceIdentifier<Node> identifier = (InstanceIdentifier<Node>) ref.getValue();
- logger.info("GOT NOTIFICATION FOR "+identifier.toString());
- final NodeKey key = identifier.firstKeyOf(Node.class, NodeKey.class);
- final String nodeId = key.getId().getValue();
- if (!this.isBridgeInPipeline(nodeId)) {
- logger.debug("Bridge {} is not in pipeline", nodeId);
- return;
- }
- if (key != null && key.getId().getValue().contains("openflow")) {
- InstanceIdentifierBuilder<Node> builder = ((InstanceIdentifier<Node>) ref.getValue()).builder();
- InstanceIdentifierBuilder<FlowCapableNode> augmentation = builder.augmentation(FlowCapableNode.class);
- final InstanceIdentifier<FlowCapableNode> path = augmentation.build();
- BindingTransactionChain txChain = mdsalConsumer.getDataBroker().createTransactionChain(this);
- CheckedFuture readFuture = txChain.newReadWriteTransaction().read(LogicalDatastoreType.OPERATIONAL, path);
- Futures.addCallback(readFuture, new FutureCallback<Optional<? extends DataObject>>() {
- @Override
- public void onSuccess(Optional<? extends DataObject> optional) {
- if (!optional.isPresent()) {
- enqueue(nodeId);
- }
- }
-
- @Override
- public void onFailure(Throwable throwable) {
- logger.debug(String.format("Can't retrieve node data for node %s. Writing node data with table0.", nodeId));
- enqueue(nodeId);
- }
- });
- }
- }
-
- @Override
- public void onTransactionChainFailed(final TransactionChain<?, ?> chain, final AsyncTransaction<?, ?> transaction,
- final Throwable cause) {
- logger.error("Failed to export Flow Capable Inventory, Transaction {} failed.",transaction.getIdentifier(),cause);
- }
-
- @Override
- public void onTransactionChainSuccessful(final TransactionChain<?, ?> chain) {
- }