- // TODO direct registration/close seem to trigger a bug in singleton state transitions,
- // 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);
-
- }, 200, TimeUnit.MILLISECONDS);
+ LOG.debug("Running re-registration");
+ try {
+ registration = singletonServiceProvider.registerClusterSingletonService(this);
+ } catch (RuntimeException e) {
+ LOG.warn("There was a problem re-registering flapping singleton service.", e);
+ setInactive();
+
+ final long count = flapCount.get();
+ flapCount.compareAndSet(count, -count - 1);
+ }