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.
registration = null;
} catch (final Exception e) {
LOG.warn("There was a problem closing flapping singleton service.", e);
+ setInactive();
flapCount = -flapCount;
}
});
// 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);
}