diff --git a/bubble-server/src/main/java/bubble/notify/NotificationHandler_hello_from_sage.java b/bubble-server/src/main/java/bubble/notify/NotificationHandler_hello_from_sage.java index b0733f07..a229d906 100644 --- a/bubble-server/src/main/java/bubble/notify/NotificationHandler_hello_from_sage.java +++ b/bubble-server/src/main/java/bubble/notify/NotificationHandler_hello_from_sage.java @@ -47,7 +47,7 @@ public class NotificationHandler_hello_from_sage extends ReceivedNotificationHan configuration.setSageVersion(payloadNode.getSageVersion()); // start the app upgrade service, if not running - if (!appUpgradeService.getIsAlive()) appUpgradeService.start(); + if (!appUpgradeService.getIsAlive() && appUpgradeService.shouldRun()) appUpgradeService.start(); } final BubbleNode thisNode = configuration.getThisNode(); diff --git a/bubble-server/src/main/java/bubble/server/listener/BubbleFirstTimeListener.java b/bubble-server/src/main/java/bubble/server/listener/BubbleFirstTimeListener.java index 3082c1f3..f6dfbbaa 100644 --- a/bubble-server/src/main/java/bubble/server/listener/BubbleFirstTimeListener.java +++ b/bubble-server/src/main/java/bubble/server/listener/BubbleFirstTimeListener.java @@ -43,7 +43,7 @@ public class BubbleFirstTimeListener extends RestServerLifecycleListenerBase redis = new AtomicReference<>(); + private static final AtomicReference redis = new AtomicReference<>(); public static String getUnlockKey () { final RedisService r = redis.get(); return r == null ? null : r.get(UNLOCK_KEY); diff --git a/bubble-server/src/main/java/bubble/service/upgrade/AppUpgradeService.java b/bubble-server/src/main/java/bubble/service/upgrade/AppUpgradeService.java index 33ba3d0c..f1bd15b6 100644 --- a/bubble-server/src/main/java/bubble/service/upgrade/AppUpgradeService.java +++ b/bubble-server/src/main/java/bubble/service/upgrade/AppUpgradeService.java @@ -50,24 +50,49 @@ public class AppUpgradeService extends SimpleDaemon { @Autowired private RuleDriverDAO driverDAO; @Autowired private StandardRuleEngineService ruleEngine; + public boolean shouldRun () { + final BubbleNetwork thisNetwork = configuration.getThisNetwork(); + if (thisNetwork == null) { + log.warn("shouldRun: thisNetwork is null, not running"); + return false; + } + final BubbleNode thisNode = configuration.getThisNode(); + if (thisNode == null) { + log.warn("shouldRun: thisNode is null, not running"); + return false; + } + final BubbleNode sageNode = configuration.getSageNode(); + if (sageNode == null) { + log.warn("shouldRun: sageNode is null, not running"); + return false; + } + if (sageNode.getUuid().equals(thisNode.getUuid())) { + log.warn("shouldRun: sageNode is thisNode, not running"); + return false; + } + return true; + } + @Override protected void process() { final BubbleNetwork thisNetwork = configuration.getThisNetwork(); if (thisNetwork == null) { log.warn("process: thisNetwork is null, not running"); return; } - final BubbleNode thisNode = configuration.getThisNode(); if (thisNode == null) { log.warn("process: thisNode is null, not running"); return; } - final BubbleNode sageNode = configuration.getSageNode(); if (sageNode == null) { log.warn("process: sageNode is null, not running"); return; } + if (sageNode.getUuid().equals(thisNode.getUuid())) { + log.warn("process: sageNode is thisNode, not running"); + return; + } // excluding sage, are we the oldest running node? final List nodes = nodeDAO.findRunningByNetwork(thisNetwork.getUuid()).stream()