From ce270209c52ec43df3e61b49244f8ddc796ecd0f Mon Sep 17 00:00:00 2001 From: Tomas Cere Date: Tue, 16 May 2017 12:40:35 +0200 Subject: [PATCH] BUG 8422: Change tx handlers hard timeout This makes write-transactions/produce-transactions return an RpcError upon reaching 2 minutes of waiting after the last transaction is submitted in case the transactions arent timed out from the frontend. Also close producer when the initial write into id-ints list fails. Change-Id: I20abbd02ed14e16d9e9a49f935113c0044e7c6d8 Signed-off-by: Tomas Cere --- .../provider/impl/ProduceTransactionsHandler.java | 13 ++++++++++--- .../it/provider/impl/WriteTransactionsHandler.java | 7 ++++--- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/impl/ProduceTransactionsHandler.java b/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/impl/ProduceTransactionsHandler.java index 0d49a697d6..21c82b7c90 100644 --- a/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/impl/ProduceTransactionsHandler.java +++ b/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/impl/ProduceTransactionsHandler.java @@ -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.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> 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."); diff --git a/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/impl/WriteTransactionsHandler.java b/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/impl/WriteTransactionsHandler.java index e4236abc7b..c4abb391e6 100644 --- a/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/impl/WriteTransactionsHandler.java +++ b/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/impl/WriteTransactionsHandler.java @@ -189,8 +189,8 @@ public class WriteTransactionsHandler implements Runnable { tx.put(LogicalDatastoreType.CONFIGURATION, itemListId, mapBuilder.build()); 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.failed() .withError(RpcError.ErrorType.APPLICATION, "Unexpected-exception", e).build()); @@ -234,7 +234,8 @@ public class WriteTransactionsHandler implements Runnable { final ListenableFuture> 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."); -- 2.36.6