Refactoring the code for updating the reconciliation state 35/76435/2
authoreeiillu <suja.t@ericsson.com>
Tue, 25 Sep 2018 08:56:04 +0000 (14:26 +0530)
committerSuja T <suja.t@ericsson.com>
Thu, 27 Sep 2018 09:15:54 +0000 (09:15 +0000)
in the datastore during all scenarios.

Change-Id: Ia25d98053f9157101cf6684371a36696cd01d4d9
Signed-off-by: eeiillu <suja.t@ericsson.com>
applications/southbound-cli/src/main/java/org/opendaylight/openflowplugin/applications/southboundcli/ReconciliationServiceImpl.java

index 33249f958a99253438a449169416edd3351c0f6a..cab6b27b8c0896ecfc0da06e53004b2f9f4b9a4d 100644 (file)
@@ -198,9 +198,9 @@ public class ReconciliationServiceImpl implements ReconciliationService, AutoClo
                 }
             } catch (ExecutionException | InterruptedException e) {
                 increaseReconcileCount(false);
+                updateReconciliationState(FAILED);
                 LOG.error("Error occurred while invoking reconcile RPC for node {}", this.nodeId, e);
-            }
-            finally {
+            } finally {
                 alarmAgent.clearNodeReconciliationAlarm(nodeId.longValue());
             }
         }
@@ -259,8 +259,12 @@ public class ReconciliationServiceImpl implements ReconciliationService, AutoClo
             ReconciliationStateListBuilder stateBuilder = new ReconciliationStateListBuilder()
                     .withKey(new ReconciliationStateListKey(nodeId))
                     .setState(state);
-            tx.merge(LogicalDatastoreType.OPERATIONAL, instanceIdentifier, stateBuilder.build(), true);
-            tx.submit();
+            try {
+                tx.merge(LogicalDatastoreType.OPERATIONAL, instanceIdentifier, stateBuilder.build(), true);
+                tx.submit().get();
+            } catch (InterruptedException | ExecutionException e) {
+                LOG.error("Exception while updating reconciliation state: {}", nodeId, e);
+            }
         }
     }
 }