BUG-4569: Data-change-counter reconfiguration failure 54/30254/1
authorClaudio D. Gasparini <cgaspari@cisco.com>
Thu, 26 Nov 2015 15:23:31 +0000 (16:23 +0100)
committerClaudio D. Gasparini <cgaspari@cisco.com>
Thu, 26 Nov 2015 15:23:31 +0000 (16:23 +0100)
Data-change-counter reconfiguration fails because of
race condition. Last task which removes model from
DS is not executed before new data-change-counter is
created and insert his own model on DS.
Fix by wait until last task is executed when close module.

Change-Id: Ic9349bf99d6a96fd44babdb874158138d7eaf6e8
Signed-off-by: Claudio D. Gasparini <cgaspari@cisco.com>
data-change-counter/src/main/java/org/opendaylight/protocol/data/change/counter/TopologyDataChangeCounter.java

index afbf20013e02c0c7ad85e05dfca3221658ba28ba..a324c055c5923ac918eff69a69d74e5dbfecd597 100644 (file)
@@ -18,6 +18,7 @@ import org.opendaylight.controller.md.sal.common.api.data.AsyncTransaction;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.controller.md.sal.common.api.data.TransactionChain;
 import org.opendaylight.controller.md.sal.common.api.data.TransactionChainListener;
+import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.data.change.counter.rev140815.DataChangeCounter;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.data.change.counter.rev140815.DataChangeCounterBuilder;
 import org.opendaylight.yangtools.yang.binding.DataObject;
@@ -53,7 +54,11 @@ public class TopologyDataChangeCounter implements DataChangeListener, Transactio
     public void close() {
         final WriteTransaction wTx = this.dataBroker.newWriteOnlyTransaction();
         wTx.delete(LogicalDatastoreType.OPERATIONAL, IID);
-        wTx.submit();
+        try {
+            wTx.submit().checkedGet();
+        } catch (TransactionCommitFailedException except) {
+            LOG.warn("Error on remove  data change counter{}", IID.toString(), except);
+        }
         this.chain.close();
         LOG.debug("Data change counter removed");
     }