public synchronized boolean commitTransaction() throws DocumentedException { if (!getCandidateTransaction().isPresent()) { throw new DocumentedException( NO_TRANSACTION_FOUND_FOR_SESSION + netconfSessionIdForReporting, ErrorType.application, ErrorTag.operation_failed, ErrorSeverity.error); } CheckedFuture<Void, TransactionCommitFailedException> future = candidateTransaction.submit(); try { future.checkedGet(); } catch (TransactionCommitFailedException e) { LOG.debug("Transaction {} failed on", candidateTransaction, e); throw new DocumentedException( "Transaction commit failed on " + e.getMessage() + " " + netconfSessionIdForReporting, ErrorType.application, ErrorTag.operation_failed, ErrorSeverity.error); } allOpenReadWriteTransactions.remove(candidateTransaction); candidateTransaction = null; return true; }
public synchronized boolean commitRunningTransaction(DOMDataReadWriteTransaction tx) throws DocumentedException { allOpenReadWriteTransactions.remove(tx); CheckedFuture<Void, TransactionCommitFailedException> future = tx.submit(); try { future.checkedGet(); } catch (TransactionCommitFailedException e) { LOG.debug("Transaction {} failed on", tx, e); throw new DocumentedException( "Transaction commit failed on " + e.getMessage() + " " + netconfSessionIdForReporting, ErrorType.application, ErrorTag.operation_failed, ErrorSeverity.error); } return true; }
/** * This method stores the pushUpdate Notification data to MD-SAL * * @param sub_id * @param timeofeventupdate * @param domSource * @param data */ private void storeToMdSal( String sub_id, String timeofeventupdate, DOMSource domSource, String data) { NodeIdentifier subscriptionid = NodeIdentifier.create(QName.create(PushUpdates.QNAME, "subscription-id")); NodeIdentifier timeofupdate = NodeIdentifier.create(QName.create(PushUpdates.QNAME, "time-of-update")); NodeIdentifier datanode = NodeIdentifier.create(QName.create(PushUpdates.QNAME, "data")); YangInstanceIdentifier pid = YangInstanceIdentifier.builder() .node(PushUpdates.QNAME) .node( org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.yangpush.rev150105 .push.updates.PushUpdate.QNAME) .build(); NodeIdentifierWithPredicates p = new NodeIdentifierWithPredicates( QName.create(PushUpdates.QNAME, "push-update"), QName.create(PushUpdates.QNAME, "subscription-id"), sub_id); MapEntryNode men = ImmutableNodes.mapEntryBuilder() .withNodeIdentifier(p) .withChild(ImmutableNodes.leafNode(subscriptionid, sub_id)) .withChild(ImmutableNodes.leafNode(timeofupdate, timeofeventupdate)) .withChild(ImmutableNodes.leafNode(datanode, data)) .build(); DOMDataWriteTransaction tx = this.globalDomDataBroker.newWriteOnlyTransaction(); YangInstanceIdentifier yid = pid.node( new NodeIdentifierWithPredicates( org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.yangpush.rev150105 .push.updates.PushUpdate.QNAME, men.getIdentifier().getKeyValues())); tx.merge(LogicalDatastoreType.CONFIGURATION, yid, men); LOG.info("--DATA PATh: {}\n--DATA\n{}", yid, men); try { tx.submit().checkedGet(); } catch (TransactionCommitFailedException e) { e.printStackTrace(); } }