From 225b5a041e37cb25e041979d09d4cdaed754c402 Mon Sep 17 00:00:00 2001 From: Jonathan Cobb Date: Sun, 19 Jan 2020 13:14:44 -0500 Subject: [PATCH] better handling of special networks in network monitor --- .../service/cloud/NetworkMonitorService.java | 17 ++++++++++++++--- bubble-web | 2 +- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/bubble-server/src/main/java/bubble/service/cloud/NetworkMonitorService.java b/bubble-server/src/main/java/bubble/service/cloud/NetworkMonitorService.java index 1b76e689..64daecb0 100644 --- a/bubble-server/src/main/java/bubble/service/cloud/NetworkMonitorService.java +++ b/bubble-server/src/main/java/bubble/service/cloud/NetworkMonitorService.java @@ -3,12 +3,13 @@ package bubble.service.cloud; import bubble.dao.cloud.BubbleNetworkDAO; import bubble.model.cloud.BubbleNetwork; import bubble.model.cloud.BubbleNetworkState; -import bubble.server.BubbleConfiguration; +import bubble.service.boot.StandardSelfNodeService; import lombok.extern.slf4j.Slf4j; import org.cobbzilla.util.daemon.SimpleDaemon; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import static bubble.ApiConstants.ROOT_NETWORK_UUID; import static java.util.concurrent.TimeUnit.MINUTES; import static org.cobbzilla.util.daemon.ZillaRuntime.shortError; import static org.cobbzilla.wizard.server.RestServerBase.reportError; @@ -24,15 +25,25 @@ public class NetworkMonitorService extends SimpleDaemon { @Autowired private BubbleNetworkDAO networkDAO; @Autowired private StandardNetworkService networkService; - @Autowired private BubbleConfiguration configuration; + @Autowired private StandardSelfNodeService selfNodeService; @Override protected void process() { - final BubbleNetwork thisNetwork = configuration.getThisNetwork(); + final BubbleNetwork thisNetwork = selfNodeService.getThisNetwork(); try { for (BubbleNetwork network : networkDAO.findAll()) { + + // never update the root network + if (network.getUuid().equals(ROOT_NETWORK_UUID)) continue; + + // if we are looking at ourselves, obviously we are running if (thisNetwork != null && network.getUuid().equals(thisNetwork.getUuid())) { + if (network.getState() != BubbleNetworkState.running) { + networkDAO.update(network.setState(BubbleNetworkState.running)); + selfNodeService.refreshThisNetwork(); + } continue; } + if (networkService.anyNodesRunning(network)) { switch (network.getState()) { case running: case restoring: continue; diff --git a/bubble-web b/bubble-web index 58dc73fc..85ab827c 160000 --- a/bubble-web +++ b/bubble-web @@ -1 +1 @@ -Subproject commit 58dc73fc5736385096e6ceaf0fce27102b278085 +Subproject commit 85ab827c5acaa73818496e10b250d87333f24df4