Sfoglia il codice sorgente

Fix restoring related flags in config response (#26)

Merge branch 'master' of git.bubblev.org:bubblev/bubble into kris/fix_restore

Rename restoreInProgress

Merge branch 'master' into kris/fix_restore

# Conflicts:
#	bubble-server/src/main/java/bubble/server/BubbleConfiguration.java
#	bubble-web

Fix resotring related flags in config response

Co-authored-by: Jonathan Cobb <jonathan@kyuss.org>
Co-authored-by: Kristijan Mitrovic <kmitrovic@itekako.com>
Reviewed-on: #26
tags/v0.14.0
Kristijan Mitrovic 4 anni fa
committed by jonathan
parent
commit
2339b60ef2
2 ha cambiato i file con 16 aggiunte e 9 eliminazioni
  1. +13
    -6
      bubble-server/src/main/java/bubble/server/BubbleConfiguration.java
  2. +3
    -3
      bubble-server/src/main/java/bubble/service/backup/RestoreService.java

+ 13
- 6
bubble-server/src/main/java/bubble/server/BubbleConfiguration.java Vedi File

@@ -91,6 +91,7 @@ public class BubbleConfiguration extends PgRestServerConfiguration
public static final String TAG_SUPPORT = "support";
public static final String TAG_SECURITY_LEVELS = "securityLevels";
public static final String TAG_RESTORE_MODE = "awaitingRestore";
public static final String TAG_RESTORING_IN_PROGRESS = "restoreInProgress";
public static final String TAG_JAR_VERSION = "jarVersion";
public static final String TAG_JAR_UPGRADE_AVAILABLE = "jarUpgradeAvailable";

@@ -309,13 +310,14 @@ public class BubbleConfiguration extends PgRestServerConfiguration

private final AtomicReference<Map<String, Object>> publicSystemConfigs = new AtomicReference<>();
public Map<String, Object> getPublicSystemConfigs () {
final var thisNetwork = getThisNetwork();
final var awaitingRestore = thisNetwork != null && thisNetwork.getState() == BubbleNetworkState.restoring;

synchronized (publicSystemConfigs) {
if (publicSystemConfigs.get() == null) {
final BubbleNetwork thisNetwork = getThisNetwork();
final AccountDAO accountDAO = getBean(AccountDAO.class);
final CloudServiceDAO cloudDAO = getBean(CloudServiceDAO.class);
final ActivationService activationService = getBean(ActivationService.class);
final RestoreService restoreService = getBean(RestoreService.class);

publicSystemConfigs.set(MapBuilder.build(new Object[][]{
{TAG_ALLOW_REGISTRATION, thisNetwork == null ? null : thisNetwork.getBooleanTag(TAG_ALLOW_REGISTRATION, false)},
@@ -330,16 +332,21 @@ public class BubbleConfiguration extends PgRestServerConfiguration
{TAG_CLOUD_CONFIGS, accountDAO.activated() ? null : activationService.getCloudDefaults()},
{TAG_LOCKED, accountDAO.locked()},
{TAG_LAUNCH_LOCK, isSageLauncher() || thisNetwork == null ? null : thisNetwork.launchLock()},
{TAG_RESTORE_MODE, thisNetwork == null
? false
: thisNetwork.getState() == BubbleNetworkState.restoring
&& !restoreService.isRestoreStarted(thisNetwork.getUuid())},
{TAG_RESTORE_MODE, awaitingRestore},
{TAG_RESTORING_IN_PROGRESS, awaitingRestore
&& getBean(RestoreService.class).isSelfRestoreStarted()},
{TAG_SSL_PORT, getDefaultSslPort()},
{TAG_SUPPORT, getSupport()},
{TAG_SECURITY_LEVELS, DeviceSecurityLevel.values()},
{TAG_JAR_VERSION, getVersion()},
{TAG_JAR_UPGRADE_AVAILABLE, getJarUpgradeAvailable() ? getSageVersionInfo() : null}
}));
} else {
// some things has to be refreshed all the time in some cases:
if (awaitingRestore) {
publicSystemConfigs.get().put(TAG_RESTORING_IN_PROGRESS,
getBean(RestoreService.class).isSelfRestoreStarted());
}
}
return publicSystemConfigs.get();
}


+ 3
- 3
bubble-server/src/main/java/bubble/service/backup/RestoreService.java Vedi File

@@ -35,7 +35,6 @@ import static org.cobbzilla.util.io.FileUtil.*;
import static org.cobbzilla.util.json.JsonUtil.json;
import static org.cobbzilla.util.security.CryptStream.BUFFER_SIZE;
import static org.cobbzilla.wizard.cache.redis.RedisService.EX;
import static org.cobbzilla.wizard.cache.redis.RedisService.LOCK_SUFFIX;

@Service @Slf4j
public class RestoreService {
@@ -66,8 +65,9 @@ public class RestoreService {

public boolean isValidRestoreKey(String restoreKey) { return getRestoreKeys().exists(restoreKey); }

public boolean isRestoreStarted(String networkUuid) {
return getRestoreKeys().exists(networkUuid + LOCK_SUFFIX) || RESTORE_MARKER_FILE.exists();
public boolean isSelfRestoreStarted() {
// only one restore may be started, hence
return getRestoreKeys().keys("*").size() > 0 || RESTORE_MARKER_FILE.exists();
}

public boolean restore(String restoreKey, BubbleBackup backup) {


Caricamento…
Annulla
Salva