Bug 7728 - modules-state conflict kills rest-connector-default-impl 69/52169/1
authorIvan Hrasko <ivan.hrasko@pantheon.tech>
Thu, 16 Feb 2017 13:27:25 +0000 (14:27 +0100)
committerIvan Hrasko <ivan.hrasko@pantheon.tech>
Wed, 22 Feb 2017 12:53:41 +0000 (12:53 +0000)
- this is just Carbon workaround for bug
- ignore error when another node is already putting the same data

Change-Id: I091393c27cb4ab8d7db04257ffe0e922d6487843
Signed-off-by: Ivan Hrasko <ivan.hrasko@pantheon.tech>
(cherry picked from commit e95dcf13b6b1c442ef9a0fa69533cb2ee6eed38c)

restconf/sal-rest-connector/src/main/java/org/opendaylight/restconf/handlers/SchemaContextHandler.java

index b00d0cfabd1c589a478bc7885759a40a34c4583d..c5a62737ae61ac5c9d511c7bef9e9617c05fe7a1 100644 (file)
@@ -21,8 +21,11 @@ import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdent
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
 import org.opendaylight.yangtools.yang.data.api.schema.DataContainerChild;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
+import org.opendaylight.yangtools.yang.data.api.schema.tree.ConflictingModificationAppliedException;
 import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * Implementation of {@link SchemaContextHandler}
@@ -30,10 +33,12 @@ import org.opendaylight.yangtools.yang.model.api.SchemaContext;
  */
 public class SchemaContextHandler implements SchemaContextListenerHandler {
 
+    private static final Logger LOG = LoggerFactory.getLogger(SchemaContextHandler.class);
+
+    private final TransactionChainHandler transactionChainHandler;
     private SchemaContext context;
 
     private int moduleSetId;
-    private final TransactionChainHandler transactionChainHandler;
 
     /**
      * Set module-set-id on initial value - 0
@@ -77,7 +82,16 @@ public class SchemaContextHandler implements SchemaContextListenerHandler {
         try {
             wTx.submit().checkedGet();
         } catch (final TransactionCommitFailedException e) {
-            throw new RestconfDocumentedException("Problem occured while putting data to DS.", e);
+            if (e.getCause() instanceof ConflictingModificationAppliedException) {
+                /*
+                  Ignore error when another cluster node is already putting the same data to DS.
+                  This is workaround for bug:
+                  https://bugs.opendaylight.org/show_bug.cgi?id=7728
+                */
+                LOG.warn("Ignoring that another cluster node is already putting the same data to DS.", e);
+            } else {
+                throw new RestconfDocumentedException("Problem occurred while putting data to DS.", e);
+            }
         }
     }
 }