From 542cc671163e58cf681612b5d762ab47eeb71e13 Mon Sep 17 00:00:00 2001 From: Vratko Polak Date: Thu, 9 Mar 2017 11:57:26 +0100 Subject: [PATCH] Bug 7799: Set inactive on any flapping service error Also updated the Yang model to a corresponding description. Change-Id: Ia1d4a815ad3e03b35f4daa9a57ddb8ba610d4003 Signed-off-by: Vratko Polak --- .../src/main/yang/odl-mdsal-lowlevel-control.yang | 4 ++-- .../it/provider/impl/FlappingSingletonService.java | 13 ++++++++++--- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/opendaylight/md-sal/samples/clustering-test-app/model/src/main/yang/odl-mdsal-lowlevel-control.yang b/opendaylight/md-sal/samples/clustering-test-app/model/src/main/yang/odl-mdsal-lowlevel-control.yang index 4c0871551c..5a7f2e12e7 100644 --- a/opendaylight/md-sal/samples/clustering-test-app/model/src/main/yang/odl-mdsal-lowlevel-control.yang +++ b/opendaylight/md-sal/samples/clustering-test-app/model/src/main/yang/odl-mdsal-lowlevel-control.yang @@ -102,8 +102,8 @@ module odl-mdsal-lowlevel-control { If the application is instantiated, it immediatelly un-registers itself. When the application instance is closed, it increments flap-count and if active flag is set, re-registers the application implementation as a singleton. - If either un-registration or re-registration fails, flap-count is set - to negative of its previous value (minus one in case of un-registration) + If either un-registration or re-registration fails, 'active' flag is unset, + flap-count is set to negative of its previous value (minus one in case of un-registration) to signal a failure has happened."; // No input. // No output. diff --git a/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/impl/FlappingSingletonService.java b/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/impl/FlappingSingletonService.java index 21e6acf1c7..5ca33ad51d 100644 --- a/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/impl/FlappingSingletonService.java +++ b/opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/impl/FlappingSingletonService.java @@ -56,6 +56,7 @@ public class FlappingSingletonService implements ClusterSingletonService { registration = null; } catch (final Exception e) { LOG.warn("There was a problem closing flapping singleton service.", e); + setInactive(); flapCount = -flapCount; } }); @@ -71,9 +72,15 @@ public class FlappingSingletonService implements ClusterSingletonService { // remove whole executor shenanigans after it's fixed. // Needs to be delayed slightly otherwise it's triggered as well. EXECUTOR.schedule(() -> { - LOG.debug("Running registration"); - registration = - singletonServiceProvider.registerClusterSingletonService(this); + LOG.debug("Running re-registration"); + try { + registration = + singletonServiceProvider.registerClusterSingletonService(this); + } catch (final Exception e) { + LOG.warn("There was a problem re-registering flapping singleton service.", e); + setInactive(); + flapCount = -flapCount - 1; + } }, 200, TimeUnit.MILLISECONDS); } -- 2.36.6