瀏覽代碼

checks to see if we should run upgrade service

tags/v1.2.3
Jonathan Cobb 4 年之前
父節點
當前提交
8a07bb931c
共有 3 個檔案被更改,包括 29 行新增4 行删除
  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 查看文件

@@ -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();


+ 1
- 1
bubble-server/src/main/java/bubble/server/listener/BubbleFirstTimeListener.java 查看文件

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

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 () {
final RedisService r = redis.get();
return r == null ? null : r.get(UNLOCK_KEY);


+ 27
- 2
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<BubbleNode> nodes = nodeDAO.findRunningByNetwork(thisNetwork.getUuid()).stream()


Loading…
取消
儲存