Fix RecoveryIntegrationSingleNodeTest failure
[controller.git] / opendaylight / md-sal / samples / clustering-test-app / provider / src / main / java / org / opendaylight / controller / clustering / it / provider / impl / ProduceTransactionsHandler.java
index 0d49a697d6d5b1227ee704bbb5099233b07cf05c..6af5beb0647cd267f3be70468d6e79b936091bef 100644 (file)
@@ -57,7 +57,7 @@ public class ProduceTransactionsHandler implements Runnable {
 
     static final QName ID_INTS =
             QName.create("tag:opendaylight.org,2017:controller:yang:lowlevel:target", "2017-02-15", "id-ints");
-    static final QName ID_INT =
+    public static final QName ID_INT =
             QName.create("tag:opendaylight.org,2017:controller:yang:lowlevel:target", "2017-02-15", "id-int");
     static final QName ID =
             QName.create("tag:opendaylight.org,2017:controller:yang:lowlevel:target", "2017-02-15", "id");
@@ -143,11 +143,17 @@ public class ProduceTransactionsHandler implements Runnable {
         cursor.close();
 
         try {
-            tx.submit().checkedGet();
-        } catch (final TransactionCommitFailedException e) {
+            tx.submit().checkedGet(125, TimeUnit.SECONDS);
+        } catch (final TransactionCommitFailedException | TimeoutException e) {
             LOG.warn("Unable to fill the initial item list.", e);
             settableFuture.set(RpcResultBuilder.<ProduceTransactionsOutput>failed()
                     .withError(RpcError.ErrorType.APPLICATION, "Unexpected-exception", e).build());
+
+            try {
+                itemProducer.close();
+            } catch (final DOMDataTreeProducerException exception) {
+                LOG.warn("Failure while closing producer.", exception);
+            }
             return false;
         }
 
@@ -192,7 +198,8 @@ public class ProduceTransactionsHandler implements Runnable {
             final ListenableFuture<List<Void>> allFutures = Futures.allAsList(futures);
 
             try {
-                allFutures.get(30, TimeUnit.SECONDS);
+                // Timeout from cds should be 2 minutes so leave some leeway.
+                allFutures.get(125, TimeUnit.SECONDS);
 
                 LOG.debug("All futures completed successfully.");