From d761b74dc8ac7c96b280ff7d1a59081a9fef4834 Mon Sep 17 00:00:00 2001 From: "Destiny.Lin" Date: Tue, 16 Jul 2024 10:19:36 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-114392-=E8=BF=9C=E7=A8=8B=E8=AE=BE?= =?UTF-8?q?=E8=AE=A1fbp=E8=83=BD=E5=A4=9F=E6=AD=A3=E5=B8=B8=E4=BD=BF?= =?UTF-8?q?=E7=94=A8=20=E5=AE=8C=E5=96=84=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../boot/env/DesignEnvChooseComponent.java | 6 +- .../fanruan/boot/env/DesignEnvComponent.java | 58 ++++++++++--------- .../boot/init/DesignWorkContextComponent.java | 2 + 3 files changed, 35 insertions(+), 31 deletions(-) diff --git a/designer-realize/src/main/java/com/fanruan/boot/env/DesignEnvChooseComponent.java b/designer-realize/src/main/java/com/fanruan/boot/env/DesignEnvChooseComponent.java index 3a0b195b03..35bbba6819 100644 --- a/designer-realize/src/main/java/com/fanruan/boot/env/DesignEnvChooseComponent.java +++ b/designer-realize/src/main/java/com/fanruan/boot/env/DesignEnvChooseComponent.java @@ -104,7 +104,7 @@ import org.jetbrains.annotations.NotNull; */ @FineComponent(name = "design_env_choose") public class DesignEnvChooseComponent extends ResourceAffiliate { - private Listener beforeSwitch4Min = new Listener(Integer.MIN_VALUE) { + private Listener afterSwitch4Max = new Listener(Integer.MAX_VALUE) { @Override public void on(Event event, Workspace current) { @@ -147,8 +147,8 @@ public class DesignEnvChooseComponent extends ResourceAffiliate { @Start public void start() { - registerEnvListener(); startEnvChoose(); + registerEnvListener(); afterAllStart(); } @@ -217,7 +217,7 @@ public class DesignEnvChooseComponent extends ResourceAffiliate { private void registerEnvListener() { /*切换环境前,重启所有相关模块,最后执行*/ - listenEvent(WorkspaceEvent.BeforeSwitch, beforeSwitch4Min); + listenEvent(WorkspaceEvent.AfterSwitch, afterSwitch4Max); /*切换环境前,存储一下打开的所有文件对象,要先于 关闭相关模块部分 被触发*/ listenEvent(WorkspaceEvent.BeforeSwitch, beforeSwitch4Max); diff --git a/designer-realize/src/main/java/com/fanruan/boot/env/DesignEnvComponent.java b/designer-realize/src/main/java/com/fanruan/boot/env/DesignEnvComponent.java index b4a1e91e85..0621a6a7ae 100644 --- a/designer-realize/src/main/java/com/fanruan/boot/env/DesignEnvComponent.java +++ b/designer-realize/src/main/java/com/fanruan/boot/env/DesignEnvComponent.java @@ -169,36 +169,38 @@ public class DesignEnvComponent { } private void startScheduler() { - TenantContext.doIsolatedWork(() -> { - ClusterLock lock = ClusterBridge.getLockFactory().get(SchedulerCoreComponent.class); - // 多节点同时启动quartz模块可能会产生脏数据,导致报错,使用集群锁控制一下 - DBSession dbSession = null; - try { - lock.lock(); - final DBContextProvider context = BaseDBEnv.getDBContext(); - if (context == null) { - throw new IllegalArgumentException("ConfigDBActivator must start before SchedulerActivator"); - } - dbSession = context.openSession(); - dbSession.doWork(new AbstractWork() { - - @Override - public void execute(Connection connection) throws SQLException { - //quartz需要的数据库方言 - Properties properties = context.getDBProperties(); - QuartzContext.getInstance().initScheduler(properties); + if (WorkContext.getCurrent().isLocal()) { + TenantContext.doIsolatedWork(() -> { + ClusterLock lock = ClusterBridge.getLockFactory().get(SchedulerCoreComponent.class); + // 多节点同时启动quartz模块可能会产生脏数据,导致报错,使用集群锁控制一下 + DBSession dbSession = null; + try { + lock.lock(); + final DBContextProvider context = BaseDBEnv.getDBContext(); + if (context == null) { + throw new IllegalArgumentException("ConfigDBActivator must start before SchedulerActivator"); + } + dbSession = context.openSession(); + dbSession.doWork(new AbstractWork() { + + @Override + public void execute(Connection connection) throws SQLException { + //quartz需要的数据库方言 + Properties properties = context.getDBProperties(); + QuartzContext.getInstance().initScheduler(properties); + } + }); + EventDispatcher.fire(SchedulerEvent.START); + } catch (Exception e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); + } finally { + if (dbSession != null) { + dbSession.closeSession(); } - }); - EventDispatcher.fire(SchedulerEvent.START); - } catch (Exception e) { - FineLoggerFactory.getLogger().error(e.getMessage(), e); - } finally { - if (dbSession != null) { - dbSession.closeSession(); + lock.unlock(); } - lock.unlock(); - } - }, "default"); + }, "default"); + } } diff --git a/designer-realize/src/main/java/com/fanruan/boot/init/DesignWorkContextComponent.java b/designer-realize/src/main/java/com/fanruan/boot/init/DesignWorkContextComponent.java index 8049690aec..2c01bcd005 100644 --- a/designer-realize/src/main/java/com/fanruan/boot/init/DesignWorkContextComponent.java +++ b/designer-realize/src/main/java/com/fanruan/boot/init/DesignWorkContextComponent.java @@ -50,6 +50,7 @@ import com.fr.workspace.server.repository.authority.RemoteAuthorityRepository; import com.fr.workspace.server.repository.compatible.CompatibleConnectionOperator; import com.fr.workspace.server.repository.compatible.register.CompatibleRegister; import com.fanruan.workplace.network.RemoteNetworkRepository; +import com.fr.workspace.server.repository.config.ConfigRepository; import com.fr.workspace.server.repository.connection.ConnectionRepository; import com.fr.workspace.server.repository.resource.PublicResourceRepository; import com.fr.workspace.server.repository.resource.WorkResourceRepository; @@ -98,6 +99,7 @@ public class DesignWorkContextComponent { RepositoryManager.getInstance().pureRegisterRepo4Start(ShareRepository.getInstance()); RepositoryManager.getInstance().pureRegisterRepo4Start(WorkResourceRepository.getInstance()); RepositoryManager.getInstance().pureRegisterRepo4Start(PublicResourceRepository.getInstance()); + RepositoryManager.getInstance().pureRegisterRepo4Start(ConfigRepository.getInstance()); RepositoryManager.getInstance().initLocalRepository(); CompatibleRegister.registerCompatibleEnv(); for (WorkRPCRegister workRPCRegister : ServiceContext.group(WorkspaceKey.class).getAll()) {