Browse Source

checks to see if we should run upgrade service

tags/v1.2.3
Jonathan Cobb 4 years ago
parent
commit
8a07bb931c
3 changed files with 29 additions and 4 deletions
  1. +1
    -1
      bubble-server/src/main/java/bubble/notify/NotificationHandler_hello_from_sage.java
  2. +1
    -1
      bubble-server/src/main/java/bubble/server/listener/BubbleFirstTimeListener.java
  3. +27
    -2
      bubble-server/src/main/java/bubble/service/upgrade/AppUpgradeService.java

+ 1
- 1
bubble-server/src/main/java/bubble/notify/NotificationHandler_hello_from_sage.java View File

@@ -47,7 +47,7 @@ public class NotificationHandler_hello_from_sage extends ReceivedNotificationHan
configuration.setSageVersion(payloadNode.getSageVersion()); configuration.setSageVersion(payloadNode.getSageVersion());


// start the app upgrade service, if not running // 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(); final BubbleNode thisNode = configuration.getThisNode();


+ 1
- 1
bubble-server/src/main/java/bubble/server/listener/BubbleFirstTimeListener.java View File

@@ -43,7 +43,7 @@ public class BubbleFirstTimeListener extends RestServerLifecycleListenerBase<Bub


private static final FirstTimeType FIRST_TIME_TYPE_DEFAULT = FirstTimeType.install; private static final FirstTimeType FIRST_TIME_TYPE_DEFAULT = FirstTimeType.install;


private static AtomicReference<RedisService> redis = new AtomicReference<>();
private static final AtomicReference<RedisService> redis = new AtomicReference<>();
public static String getUnlockKey () { public static String getUnlockKey () {
final RedisService r = redis.get(); final RedisService r = redis.get();
return r == null ? null : r.get(UNLOCK_KEY); return r == null ? null : r.get(UNLOCK_KEY);


+ 27
- 2
bubble-server/src/main/java/bubble/service/upgrade/AppUpgradeService.java View File

@@ -50,24 +50,49 @@ public class AppUpgradeService extends SimpleDaemon {
@Autowired private RuleDriverDAO driverDAO; @Autowired private RuleDriverDAO driverDAO;
@Autowired private StandardRuleEngineService ruleEngine; @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() { @Override protected void process() {
final BubbleNetwork thisNetwork = configuration.getThisNetwork(); final BubbleNetwork thisNetwork = configuration.getThisNetwork();
if (thisNetwork == null) { if (thisNetwork == null) {
log.warn("process: thisNetwork is null, not running"); log.warn("process: thisNetwork is null, not running");
return; return;
} }

final BubbleNode thisNode = configuration.getThisNode(); final BubbleNode thisNode = configuration.getThisNode();
if (thisNode == null) { if (thisNode == null) {
log.warn("process: thisNode is null, not running"); log.warn("process: thisNode is null, not running");
return; return;
} }

final BubbleNode sageNode = configuration.getSageNode(); final BubbleNode sageNode = configuration.getSageNode();
if (sageNode == null) { if (sageNode == null) {
log.warn("process: sageNode is null, not running"); log.warn("process: sageNode is null, not running");
return; return;
} }
if (sageNode.getUuid().equals(thisNode.getUuid())) {
log.warn("process: sageNode is thisNode, not running");
return;
}


// excluding sage, are we the oldest running node? // excluding sage, are we the oldest running node?
final List<BubbleNode> nodes = nodeDAO.findRunningByNetwork(thisNetwork.getUuid()).stream() final List<BubbleNode> nodes = nodeDAO.findRunningByNetwork(thisNetwork.getUuid()).stream()


Loading…
Cancel
Save