From ed60afc13f73925d3a2b82336952da90731e9f60 Mon Sep 17 00:00:00 2001 From: "Destiny.Lin" Date: Wed, 11 Sep 2024 10:44:42 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-133424=20=E3=80=90fr-fbp=E5=9B=9E?= =?UTF-8?q?=E5=BD=92=E3=80=91=E6=89=93=E5=BC=80=E6=A8=A1=E6=9D=BFA?= =?UTF-8?q?=EF=BC=8C=E5=88=87=E6=8D=A2=E7=8E=AF=E5=A2=83=EF=BC=8C=E6=A8=A1?= =?UTF-8?q?=E6=9D=BFA=E7=9A=84=E9=94=81=E5=AE=9A=E7=8A=B6=E6=80=81?= =?UTF-8?q?=E4=B8=8D=E4=BC=9A=E8=A7=A3=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/backup/EnvBackupHelper.java | 26 ++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/designer-base/src/main/java/com/fr/design/backup/EnvBackupHelper.java b/designer-base/src/main/java/com/fr/design/backup/EnvBackupHelper.java index bb9575ea19..73d0cbc1b1 100644 --- a/designer-base/src/main/java/com/fr/design/backup/EnvBackupHelper.java +++ b/designer-base/src/main/java/com/fr/design/backup/EnvBackupHelper.java @@ -4,11 +4,13 @@ import com.fanruan.carina.Carina; import com.fanruan.config.realm.ConfigRepositoryFactory; import com.fanruan.config.realm.local.LocalConfigRepositoryBuilder; import com.fr.design.ConfigHelper; +import com.fr.design.env.RemoteWorkspace; import com.fr.design.mem.MemConfigBackupManager; import com.fr.design.mem.MemConfigRepositoryBuilder; import com.fr.log.FineLoggerFactory; import com.fr.workspace.WorkContext; import com.fr.workspace.Workspace; +import com.fr.workspace.server.repository.connect.FineWorkspaceHttpClient; import java.util.Properties; @@ -42,11 +44,13 @@ public class EnvBackupHelper { FineLoggerFactory.getLogger().info("[EnvBackup] 1.back start..."); this.swtiching = true; local = WorkContext.getCurrent().isLocal(); + origin = WorkContext.getCurrent(); if (local) { properties = ConfigHelper.getEnvProperties(); path = ConfigHelper.getEnvPropertiesPath(); + } else { + closeEnv(); } - origin = WorkContext.getCurrent(); } /** @@ -107,10 +111,30 @@ public class EnvBackupHelper { } else { // 如果是远程,则新环境的配置全部弃用,直接走老的 MemConfigBackupManager.getInstance().failed(); + rollbackEnv(); } } + /** + * 关闭环境 + */ + public void closeEnv() { + // 如果原来是远程,要先发请求告诉原来的环境我这边要断开 + if (origin instanceof RemoteWorkspace) { + origin.close(); + } + } + + /** + * 重新进入老环境 + */ + public void rollbackEnv() { + if (origin instanceof RemoteWorkspace && ((RemoteWorkspace) origin).getClient() instanceof FineWorkspaceHttpClient) { + ((FineWorkspaceHttpClient) ((RemoteWorkspace) origin).getClient()).startHeartBeat(); + } + } + public boolean isSwtiching() { return swtiching; }