[NETVIRT-1075] NeutronvpnUtils: handle transactions with jobCoordinator to avoid blocking Created: 01/Feb/18  Updated: 25/Nov/19  Resolved: 25/Nov/19

Status: Resolved
Project: netvirt
Component/s: None
Affects Version/s: None
Fix Version/s: Magnesium

Type: Improvement Priority: Medium
Reporter: Valentina Krasnobaeva Assignee: Valentina Krasnobaeva
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

Now we are using  in NeutronvpnUtils: updateVpnInstanceOpWithType  blocking transaction:

VpnInstanceOpDataEntryBuilder builder = new VpnInstanceOpDataEntryBuilder(vpnInstanceOpDataEntry);
builder.setBgpvpnType(choice);
WriteTransaction writeTxn = dataBroker.newWriteOnlyTransaction();
writeTxn.merge(LogicalDatastoreType.OPERATIONAL, id, builder.build(), false);
LOG.debug("updateVpnInstanceOpWithType: sent merge to operDS BgpvpnType {} for {}", choice, vpn.getValue());
try {
     writeTxn.submit().get();

....

And the same in some other methods.

It will be better to refactor NeutronvpnUtils, and to use async transactions handeled by jobCoordinator as much as possible, to avoid blocking

https://git.opendaylight.org/gerrit/#/c/57411/153/vpnservice/neutronvpn/neutronvpn-impl/src/main/java/org/opendaylight/netvirt/neutronvpn/NeutronvpnUtils.java@1627

 



 Comments   
Comment by Philippe Guibert [ 02/Feb/18 ]

as illustration, the following code extract shows how to go from sync mode to async mode:

  • by removing the try catch block and replacing with following code as illustration.
  • The error message will be displayed at some point, if there is a failure to do this.
    import org.opendaylight.infrautils.utils.concurrent.ListenableFutures;
    
    WriteTransaction writeConfigTxn = dataBroker.newWriteOnlyTransaction();
    ListenableFuture<Void> futures = writeConfigTxn.submit();
    
    String errorText = "addVpnInterfaceCall: Exception encountered while submitting writeConfigTxn"
                                 + " for interface " + vpnInterface.getName() + " on vpn " + vpnName;
                            ListenableFutures.addErrorLogging(futures, LOG, errorText);
    
Generated at Wed Feb 07 20:23:10 UTC 2024 using Jira 8.20.10#820010-sha1:ace47f9899e9ee25d7157d59aa17ab06aee30d3d.