From 94006395f5bc8571d0fa0a99eeda2216a8e79441 Mon Sep 17 00:00:00 2001 From: "Bruce.Deng" Date: Thu, 12 Sep 2024 22:08:43 +0800 Subject: [PATCH 1/4] =?UTF-8?q?REPORT-130080=20=E3=80=90FR-FBP=E3=80=91?= =?UTF-8?q?=E5=9F=8B=E7=82=B9=E6=96=B9=E6=A1=88=E6=A2=B3=E7=90=86=E4=B8=8E?= =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/fr/design/EnvChangeEntrance.java | 12 +- .../com/fr/design/EnvSwitcherSubmitTask.java | 214 ++++++++++++++++++ .../design/metric/AbstractDesignerMetric.java | 39 ++++ .../boot/env/DesignEnvChooseComponent.java | 19 +- .../java/com/fr/start/CarinaDesigner.java | 3 +- .../com/fr/start/DesignerStartupMetric.java | 94 ++++++++ 6 files changed, 369 insertions(+), 12 deletions(-) create mode 100644 designer-base/src/main/java/com/fr/design/EnvSwitcherSubmitTask.java create mode 100644 designer-base/src/main/java/com/fr/design/metric/AbstractDesignerMetric.java create mode 100644 designer-realize/src/main/java/com/fr/start/DesignerStartupMetric.java diff --git a/designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java b/designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java index e2a08bbbc3..33be0b7fc4 100644 --- a/designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java +++ b/designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java @@ -2,8 +2,6 @@ package com.fr.design; import com.fr.common.report.ReportState; import com.fr.design.backup.EnvBackupHelper; -import com.fr.design.mainframe.manager.clip.TemplateTreeClipboard; -import com.fr.design.plugin.remind.PluginErrorDesignReminder; import com.fr.design.data.DesignTableDataManager; import com.fr.design.dialog.BasicDialog; import com.fr.design.dialog.DialogActionAdapter; @@ -52,7 +50,6 @@ import com.fr.workspace.engine.base.FineObjectPool; import com.fr.workspace.engine.channel.http.FunctionalHttpRequest; import com.fr.workspace.engine.exception.WorkspaceConnectionException; import com.fr.workspace.engine.rpc.WorkspaceProxyPool; -import static javax.swing.JOptionPane.QUESTION_MESSAGE; import javax.swing.JOptionPane; import javax.swing.SwingUtilities; @@ -68,9 +65,10 @@ import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.Optional; -import java.util.Properties; import java.util.Set; +import static javax.swing.JOptionPane.QUESTION_MESSAGE; + public class EnvChangeEntrance { private static final String BRANCH_TAG = "#"; private static final String BRANCH_BEGIN = "-"; @@ -158,11 +156,11 @@ public class EnvChangeEntrance { } /** - * 由云端运维,触发切换埋点 - * 内部空实现 - * 见 实现 + * 异步提交埋点 + * */ private void triggerSwitchMetric() { + EnvSwitcherSubmitTask.asyncSubmit(); } /** diff --git a/designer-base/src/main/java/com/fr/design/EnvSwitcherSubmitTask.java b/designer-base/src/main/java/com/fr/design/EnvSwitcherSubmitTask.java new file mode 100644 index 0000000000..33edfc66cb --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/EnvSwitcherSubmitTask.java @@ -0,0 +1,214 @@ +package com.fr.design; + +import com.fr.concurrent.FineExecutors; +import com.fr.concurrent.NamedThreadFactory; +import com.fr.design.mainframe.SiteCenterToken; +import com.fr.design.metric.AbstractDesignerMetric; +import com.fr.general.CloudCenter; +import com.fr.general.http.HttpToolbox; +import com.fr.json.JSONArray; +import com.fr.json.JSONObject; +import com.fr.log.FineLoggerFactory; +import com.fr.stable.StringUtils; +import com.fr.workspace.Workspace; +import com.fr.workspace.WorkspaceSwitchProcess; +import com.fr.workspace.WorkspaceSwitchStatics; +import com.fr.workspace.switcher.WorkspaceSwitchHistory; +import org.jetbrains.annotations.NotNull; + +import java.util.Comparator; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; +import java.util.TreeSet; +import java.util.concurrent.ExecutorService; + +/** + * 设计器环境切换埋点提交 + * + * @author Bruce.Deng + * @since 11.0 + * Created on 2024/9/5 + */ +public class EnvSwitcherSubmitTask extends AbstractDesignerMetric { + + private static final String TAG_MODULE = "module"; + private static final String TAG_SELF_USED = "selfUsed"; + private static final String TAG_SUB = "sub"; + private static final String WORK_DIRECTORY_TYPE_BEFORE_SWITCHING = "workDirectoryTypeBeforeSwitching"; + private static final String WORK_DIRECTORY_TYPE_AFTER_SWITCHING = "workDirectoryTypeAfterSwitching"; + private static final String SWITCH_COMPLETED = "switchCompleted"; + private static final String EXCHANGE_TIME = "exchangeTime"; + private static final String START_SLOW_MODULE_NAME = "startSlowModuleName"; + private static final String STOP_SLOW_MODULE_NAME = "stopSlowModuleName"; + private static final int MIN_LIMIT = 100; + private static final String SWITCH_TABLE_SUFFIX = "record_of_fbp_remoteSwitch/single"; + private final ExecutorService service; + + private EnvSwitcherSubmitTask() { + service = FineExecutors.newSingleThreadExecutor(new NamedThreadFactory("DesignEnvSwitchMetricSubmit")); + } + + /** + * 异步提交环境切换的埋点 + */ + public static void asyncSubmit() { + new EnvSwitcherSubmitTask().run(); + } + + /** + * 执行任务 + */ + private void run() { + + WorkspaceSwitchHistory.consume(workspaceSwitchProcesses -> { + Iterator workspaceSwitchProcessIterator = workspaceSwitchProcesses.descendingIterator(); + while (workspaceSwitchProcessIterator.hasNext()) { + WorkspaceSwitchProcess next = workspaceSwitchProcessIterator.next(); + // 过滤掉 source 为空的启动过程 + if (next != null && next.getSource() != null) { + submitProcess(next); + } + // 提交之后要移除掉 + workspaceSwitchProcessIterator.remove(); + } + }); + } + + private void submitProcess(WorkspaceSwitchProcess process) { + service.submit(new Runnable() { + @Override + public void run() { + collectAndSubmit(process); + } + }); + } + + private void collectAndSubmit(WorkspaceSwitchProcess process) { + Map para = new HashMap<>(); + para.put("token", SiteCenterToken.generateToken()); + para.put("content", collect(process)); + try { + HttpToolbox.post(getUrl(), para); + FineLoggerFactory.getLogger().debug("[EnvSwitcher] submit env switcher metric to cloud."); + } catch (Throwable t) { + FineLoggerFactory.getLogger().debug(t,"[EnvSwitcher] failed to submit env switcher metric to cloud."); + } + } + + private JSONObject collect(WorkspaceSwitchProcess process) { + JSONObject info = new JSONObject(); + addDefaultMetric(info); + addMeta(info, process); + addStatics(info, process.getStatics()); + return info; + } + + private static void addMeta(JSONObject info, WorkspaceSwitchProcess process) { + Workspace source = process.getSource(); + info.put(WORK_DIRECTORY_TYPE_BEFORE_SWITCHING, workspaceType(source)); + Workspace target = process.getTarget(); + info.put(WORK_DIRECTORY_TYPE_AFTER_SWITCHING, workspaceType(target)); + info.put(SWITCH_COMPLETED, switchCompleted(process)); + } + + @NotNull + private static String switchCompleted(WorkspaceSwitchProcess process) { + + return process.isSwitchSuccess() ? "yes" : "no"; + } + + @NotNull + private static String workspaceType(Workspace workspace) { + + return workspace.isLocal() ? "local" : "remote"; + } + + private void addStatics(JSONObject info, WorkspaceSwitchStatics statics) { + info.put(EXCHANGE_TIME, statics.getElapsed()); + JSONObject startSlowModuleName = convert2CloudModel(statics.getStartModuleUsed()); + info.put(START_SLOW_MODULE_NAME, startSlowModuleName); + JSONObject stopSlowModuleName = convert2CloudModel(statics.getStopModuleUsed()); + info.put(STOP_SLOW_MODULE_NAME, stopSlowModuleName); + } + + /* convert */ + + @NotNull + private JSONObject convert2CloudModel(JSONObject moduleUsedJO) { + + TreeSet entries = convert2SortSet(moduleUsedJO); + return convert2JO(entries); + } + + @NotNull + private static JSONObject convert2JO(TreeSet startEntries) { + + JSONObject moduleNames = new JSONObject(); + startEntries.stream() + .filter((e) -> e.getSelfUsed() > MIN_LIMIT) + .forEach((e) -> moduleNames.put(e.getModuleName(), e.getSelfUsed())); + return moduleNames; + } + + @NotNull + private TreeSet convert2SortSet(JSONObject moduleUsedJO) { + + TreeSet entries = new TreeSet<>(Comparator.comparingInt(Entry::getSelfUsed)); + sortBySelfUsed(moduleUsedJO, entries); + return entries; + } + + /** + * 循环处理 JSON, 并降序排序 + * + * @param moduleUsed 模块用时 {@link com.fr.module.engine.FineModule} + * @param entries 降序排序的树集合 + */ + private void sortBySelfUsed(JSONObject moduleUsed, TreeSet entries) { + + if (moduleUsed == null || moduleUsed.isEmpty()) { + return; + } + + String moduleName = moduleUsed.optString(TAG_MODULE); + int selfUsed = moduleUsed.optInt(TAG_SELF_USED); + entries.add(new Entry(moduleName, selfUsed)); + + JSONArray subModules = moduleUsed.optJSONArray(TAG_SUB); + if (subModules != null) { + int length = subModules.length(); + for (int i = 0; i < length; i++) { + JSONObject subModuleUsed = subModules.optJSONObject(i); + sortBySelfUsed(subModuleUsed, entries); + } + } + } + + private String getUrl() { + String monitorEntry = CloudCenter.getInstance().acquireUrlByKind("cloud.monitor.api.entrypoint"); + String url = (StringUtils.isNotEmpty(monitorEntry) ? monitorEntry : DEFAULT_MONITOR_URL) + + SWITCH_TABLE_SUFFIX; + return url; + } + + private static class Entry { + + private final String moduleName; + + private final Integer selfUsed; + + public Entry(String moduleName, Integer selfUsed) { + this.moduleName = moduleName; + this.selfUsed = selfUsed; + } + + public String getModuleName() { + return moduleName; + } + + public Integer getSelfUsed() { + return selfUsed; + } + } +} diff --git a/designer-base/src/main/java/com/fr/design/metric/AbstractDesignerMetric.java b/designer-base/src/main/java/com/fr/design/metric/AbstractDesignerMetric.java new file mode 100644 index 0000000000..97c9cfac48 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/metric/AbstractDesignerMetric.java @@ -0,0 +1,39 @@ +package com.fr.design.metric; + +import com.fanruan.carina.Carina; +import com.fanruan.config.bbs.FineBBSConfigProvider; +import com.fr.config.MarketConfig; +import com.fr.design.DesignerEnvManager; +import com.fr.general.GeneralUtils; +import com.fr.json.JSONObject; +import org.jetbrains.annotations.NotNull; + +/** + * 设计器埋点抽象 + * + * @author Bruce.Deng + * @since 11.0 + * Created on 2024/9/10 + */ +public abstract class AbstractDesignerMetric { + + public static final String TIME = "time"; + + public static final String DESIGNER_ID = "designerId"; + + public static final String DESIGNER_VERSION = "designerVersion"; + + public static final String USERID = "userId"; + + public static final String APPID = "appId"; + + public static final String DEFAULT_MONITOR_URL = "https://cloud.fanruan.com/api/monitor/"; + + protected void addDefaultMetric(@NotNull JSONObject info) { + info.put(TIME, System.currentTimeMillis()); + info.put(DESIGNER_ID, DesignerEnvManager.getEnvManager().getUUID()); + info.put(DESIGNER_VERSION, GeneralUtils.getVersion()); + info.put(USERID, Carina.config(FineBBSConfigProvider.class).getBbsUid()); + info.put(APPID, MarketConfig.getInstance().getCloudOperationMaintenanceId()); + } +} 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 d655e511f1..cfc29edad3 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 @@ -1,8 +1,6 @@ package com.fanruan.boot.env; -import com.fr.design.ConfigHelper; import com.fanruan.boot.key.StartupArgsShell; -import com.fr.design.mem.MemConfigRepositoryBuilder; import com.fanruan.carina.Carina; import com.fanruan.carina.annotions.FineComponent; import com.fanruan.carina.annotions.Start; @@ -15,15 +13,18 @@ import com.fanruan.config.realm.local.LocalConfigRepositoryBuilder; import com.fr.base.operator.org.OrganizationOperator; import com.fr.base.rpc.encrypt.EncryptOperator; import com.fr.decision.service.context.ServiceContext; +import com.fr.design.ConfigHelper; import com.fr.design.DesignerEnvManager; import com.fr.design.EnvChangeEntrance; import com.fr.design.PluginClassRefreshManager; +import com.fr.design.backup.DesignContext; import com.fr.design.constants.DesignerLaunchStatus; import com.fr.design.editlock.ConnectionLockChangeChecker; import com.fr.design.editlock.ServerTableDataLockChangeChecker; import com.fr.design.env.DesignerWorkspaceGenerator; import com.fr.design.env.DesignerWorkspaceInfo; import com.fr.design.file.HistoryTemplateListCache; +import com.fr.design.mem.MemConfigRepositoryBuilder; import com.fr.design.plugin.remind.PluginErrorDesignReminder; import com.fr.env.utils.WorkspaceUtils; import com.fr.event.Event; @@ -36,12 +37,12 @@ import com.fr.report.lock.DefaultLockInfoOperator; import com.fr.report.lock.LocalLockInfoOperator; import com.fr.report.lock.LockInfoOperator; import com.fr.report.lock.ServerLockInfoOperator; -import com.fr.design.backup.DesignContext; import com.fr.start.module.StartupArgs; import com.fr.value.NotNullLazyValue; import com.fr.workspace.WorkContext; import com.fr.workspace.Workspace; import com.fr.workspace.WorkspaceEvent; +import com.fr.workspace.WorkspaceSwitchProcess; import com.fr.workspace.base.WorkspaceKey; import com.fr.workspace.pool.WorkRPCRegister; import com.fr.workspace.pool.WorkRPCType; @@ -101,6 +102,8 @@ import com.fr.workspace.server.vcs.v2.scheduler.VcsAutoCleanOperator; import com.fr.workspace.server.vcs.v2.scheduler.VcsAutoCleanService; import org.jetbrains.annotations.NotNull; +import java.util.Optional; + /** * 环境选择模块 * @@ -118,10 +121,20 @@ public class DesignEnvChooseComponent extends ResourceAffiliate { BootstrapFactory.get().reboot("design_env_prepare"); // 环境切换后,等到模块重启更新一下当前的系统信息 WorkplaceConstants.updateBean(); + recordModuleStartStop(); } catch (Exception e) { throw new RuntimeException(e); } } + + private void recordModuleStartStop() { + + WorkspaceSwitchProcess process = WorkContext.getSwitcher().getProcess(); + Optional.ofNullable(process) + .ifPresent((e) -> e.recordModuleStartUsed(() -> BootstrapFactory.get().profileStart("design_env_prepare"))); + Optional.ofNullable(process) + .ifPresent((e) -> e.recordModuleStopUsed(() -> BootstrapFactory.get().profileStop("design_env_prepare"))); + } }; private Listener beforeSwitch4Max = new Listener(Integer.MAX_VALUE) { diff --git a/designer-realize/src/main/java/com/fr/start/CarinaDesigner.java b/designer-realize/src/main/java/com/fr/start/CarinaDesigner.java index 5e44ed8425..775eaf06fa 100644 --- a/designer-realize/src/main/java/com/fr/start/CarinaDesigner.java +++ b/designer-realize/src/main/java/com/fr/start/CarinaDesigner.java @@ -10,11 +10,9 @@ import com.fanruan.gui.UiInspector; import com.fr.base.StateHubContext; import com.fr.design.backup.DesignContext; import com.fr.design.carton.SwitchForSwingChecker; - import com.fr.design.carton.latency.DesignerLatencyMetric; import com.fr.design.mainframe.DesignerUIModeConfig; import com.fr.log.FineLoggerFactory; - import com.fr.runtime.FineRuntime; import com.fr.start.common.DesignerStartupContext; import com.fr.start.module.StartupArgs; @@ -65,6 +63,7 @@ public class CarinaDesigner extends MainDesigner{ FineLoggerFactory.getLogger().info("Designer started.Time used {} ms", DesignerStartupContext.getRecorder().getTime(TimeUnit.MILLISECONDS)); DesignerStartupContext.getRecorder().stop(); + DesignerStartupMetric.getInstance().asyncSubmit(); SwitchForSwingChecker.initThreadMonitoring(); DesignerLatencyMetric.getInstance().start(); } diff --git a/designer-realize/src/main/java/com/fr/start/DesignerStartupMetric.java b/designer-realize/src/main/java/com/fr/start/DesignerStartupMetric.java new file mode 100644 index 0000000000..2dc2712799 --- /dev/null +++ b/designer-realize/src/main/java/com/fr/start/DesignerStartupMetric.java @@ -0,0 +1,94 @@ +package com.fr.start; + +import com.fr.concurrent.FineExecutors; +import com.fr.concurrent.NamedThreadFactory; +import com.fr.design.mainframe.SiteCenterToken; +import com.fr.design.metric.AbstractDesignerMetric; +import com.fr.general.CloudCenter; +import com.fr.general.http.HttpToolbox; +import com.fr.json.JSONObject; +import com.fr.json.revise.EmbedJson; +import com.fr.log.FineLoggerFactory; +import com.fr.stable.StringUtils; +import com.fr.start.common.DesignerStartupContext; +import com.fr.startup.metric.DesignerMetrics; +import com.fr.startup.metric.DesignerStartupModel; + +import java.util.HashMap; +import java.util.Map; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.TimeUnit; + +/** + * fbp设计器启动埋点提交 + * + * @author Bruce.Deng + * @since 11.0 + * Created on 2024/9/5 + */ +public class DesignerStartupMetric extends AbstractDesignerMetric { + + private static final String LANDING_TIME = "landingTime"; + private static final String STARTING_TIME = "startingTime"; + private static final String MODE = "mode"; + private static final String INFO = "info"; + private static volatile DesignerStartupMetric instance = new DesignerStartupMetric(); + private static final String DESIGNER_START_TABLE_SUFFIX = "record_of_fbp_designerStartTime/single"; + + private DesignerStartupMetric() { + } + + /** + * 获取单例 + */ + public static DesignerStartupMetric getInstance() { + return instance; + } + + /** + * 延迟5分钟提交埋点数据 + * + */ + public void asyncSubmit() { + ScheduledExecutorService scheduledExecutorService = FineExecutors.newSingleThreadScheduledExecutor(new NamedThreadFactory("DesignerStartupMetricSubmit")); + scheduledExecutorService.schedule(new Runnable() { + @Override + public void run() { + collectAndSubmit(); + } + }, 5, TimeUnit.MINUTES); + scheduledExecutorService.shutdown(); + } + + private void collectAndSubmit() { + Map para = new HashMap<>(); + para.put("token", SiteCenterToken.generateToken()); + para.put("content", collect()); + try { + HttpToolbox.post(getUrl(), para); + FineLoggerFactory.getLogger().debug("[DesignerStartup] submit designer startup metric to cloud."); + } catch (Throwable t) { + FineLoggerFactory.getLogger().debug(t,"[DesignerStartup] failed to submit designer startup metric to cloud."); + } + } + + private String getUrl() { + String monitorEntry = CloudCenter.getInstance().acquireUrlByKind("cloud.monitor.api.entrypoint"); + String url = (StringUtils.isNotEmpty(monitorEntry) ? monitorEntry : DEFAULT_MONITOR_URL) + + DESIGNER_START_TABLE_SUFFIX; + return url; + } + + private JSONObject collect() { + JSONObject info = new JSONObject(); + DesignerMetrics designerMetrics = DesignerStartupContext.getInstance().getDesignerMetrics(); + DesignerStartupModel model = designerMetrics.getModel(); + info.put(LANDING_TIME, model.getLandingTime()); + info.put(STARTING_TIME, model.getStartingTime()); + info.put(MODE, model.getMode()); + info.put(INFO, EmbedJson.encode(model.getInfo())); + addDefaultMetric(info); + return info; + } + +} From 613b0f577e0347ac53a7732b8e3545d9bbe69989 Mon Sep 17 00:00:00 2001 From: "Leo.Qin" Date: Fri, 13 Sep 2024 15:35:40 +0800 Subject: [PATCH 2/4] =?UTF-8?q?REPORT-134503=20&&=20REPORT-132845=20?= =?UTF-8?q?=E5=90=AF=E5=8A=A8=E8=AE=BE=E8=AE=A1=E5=99=A8=E5=90=8E=E7=9B=B4?= =?UTF-8?q?=E6=8E=A5=E8=BF=9E=E6=8E=A5=E8=BF=9C=E7=A8=8B=E7=8E=AF=E5=A2=83?= =?UTF-8?q?=EF=BC=8C=E8=AE=BE=E8=AE=A1=E5=99=A8=E6=8F=92=E4=BB=B6=E6=9C=AA?= =?UTF-8?q?=E7=94=9F=E6=95=88=20=E3=80=90=E9=97=AE=E9=A2=98=E5=8E=9F?= =?UTF-8?q?=E5=9B=A0=E3=80=91=201=E3=80=81=E8=8E=B7=E5=8F=96=E8=BF=9C?= =?UTF-8?q?=E7=A8=8B=E6=8F=92=E4=BB=B6=E7=8A=B6=E6=80=81=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E5=8F=91=E7=94=9F=E5=8F=98=E5=8C=96=EF=BC=8C=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E8=BF=9C=E7=A8=8B=E6=8F=92=E4=BB=B6=E7=8A=B6=E6=80=81=E5=A4=B1?= =?UTF-8?q?=E8=B4=A5=E3=80=82=202=E3=80=81=E6=8F=92=E4=BB=B6=E5=BC=95?= =?UTF-8?q?=E6=93=8E=E4=B9=8B=E5=89=8D=E6=9C=AA=E8=80=83=E8=99=91=E8=BF=9C?= =?UTF-8?q?=E7=A8=8B=E8=AE=BE=E8=AE=A1=20=E3=80=90=E6=94=B9=E5=8A=A8?= =?UTF-8?q?=E6=80=9D=E8=B7=AF=E3=80=91=201=E3=80=81=E6=B3=A8=E5=86=8C?= =?UTF-8?q?=E6=8F=92=E4=BB=B6repository=E3=80=82=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E7=9A=84=E8=BF=94=E5=9B=9E=E7=B1=BB=E5=9E=8B?= =?UTF-8?q?=E3=80=82=202=E3=80=81=E8=AE=BE=E8=AE=A1=E5=99=A8=E6=A8=A1?= =?UTF-8?q?=E5=9D=97=E5=90=AF=E5=8A=A8=E7=9A=84=E6=97=B6=E5=80=99=EF=BC=8C?= =?UTF-8?q?=E5=8D=95=E7=8B=AC=E6=B3=A8=E5=86=8C=20=E9=9C=80=E8=A6=81?= =?UTF-8?q?=E5=90=AF=E5=8A=A8=E7=9A=84=E6=8F=92=E4=BB=B6=E5=90=8C=E6=AD=A5?= =?UTF-8?q?=E6=A8=A1=E5=9D=97=20=E5=8F=8A=20=E8=8E=B7=E5=8F=96=E6=8F=92?= =?UTF-8?q?=E4=BB=B6=E7=8A=B6=E6=80=81=E7=9A=84=E6=8E=A5=E5=8F=A3=E4=BF=A1?= =?UTF-8?q?=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/versioncheck/VersionCheckUtils.java | 11 +++-------- .../com/fanruan/boot/env/DesignPluginComponent.java | 11 +++++++++++ .../fanruan/boot/env/function/app/PluginRemote.java | 10 ++++------ .../fanruan/boot/init/DesignWorkContextComponent.java | 2 ++ 4 files changed, 20 insertions(+), 14 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/versioncheck/VersionCheckUtils.java b/designer-base/src/main/java/com/fr/design/versioncheck/VersionCheckUtils.java index 509b103a41..06017ce175 100644 --- a/designer-base/src/main/java/com/fr/design/versioncheck/VersionCheckUtils.java +++ b/designer-base/src/main/java/com/fr/design/versioncheck/VersionCheckUtils.java @@ -28,8 +28,6 @@ import com.fr.plugin.manage.control.PluginTaskCallback; import com.fr.plugin.manage.control.PluginTaskResult; import com.fr.plugin.manage.control.ProgressCallback; import com.fr.report.ReportHelper; -import com.fr.rpc.ExceptionHandler; -import com.fr.rpc.RPCInvokerExceptionInfo; import com.fr.rpc.Result; import com.fr.stable.StringUtils; import com.fr.workspace.WorkContext; @@ -39,7 +37,7 @@ import com.fr.workspace.engine.base.FineObjectPool; import com.fr.workspace.engine.channel.http.FunctionalHttpRequest; import com.fr.workspace.engine.exception.WorkspaceConnectionException; import com.fr.workspace.engine.rpc.WorkspaceProxyPool; -import com.fr.workspace.server.check.VersionInfoOperator; + import java.lang.reflect.Method; import java.text.ParsePosition; import java.text.SimpleDateFormat; @@ -53,7 +51,6 @@ import java.util.Map; import java.util.Set; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; -import javax.swing.SwingWorker; /** * @author pengda @@ -285,16 +282,14 @@ public class VersionCheckUtils { public static JSONArray checkLocalAndRemotePlugin() { JSONArray differentPlugins = new JSONArray(); - JSONArray remotePlugins = FRContext.getCommonOperator().getPluginStatus(); + List remotePlugins = FRContext.getCommonOperator().getPluginStatus(); Map localPluginsMap = new HashMap<>(); List localPlugins = PluginManager.getContexts(); for (PluginContext pluginContext : localPlugins) { localPluginsMap.put(pluginContext.getID(), pluginContext); } - JSONObject remotePlugin; Map pluginsNameMap = ReportHelper.getPluginNameMap(); - for (int i = 0; i < remotePlugins.size(); i++) { - remotePlugin = remotePlugins.getJSONObject(i); + for (JSONObject remotePlugin : remotePlugins) { if (isPluginNeedIgnore(remotePlugin)) { continue; } diff --git a/designer-realize/src/main/java/com/fanruan/boot/env/DesignPluginComponent.java b/designer-realize/src/main/java/com/fanruan/boot/env/DesignPluginComponent.java index be92acac20..a36066386a 100644 --- a/designer-realize/src/main/java/com/fanruan/boot/env/DesignPluginComponent.java +++ b/designer-realize/src/main/java/com/fanruan/boot/env/DesignPluginComponent.java @@ -9,9 +9,15 @@ import com.fanruan.carina.annotions.Stop; import com.fanruan.carina.annotions.Supplemental; import com.fanruan.plugin.autonomy.AutonomyClassManagerGroup; import com.fanruan.plugin.autonomy.AutonomyClassManagerProvider; +import com.fr.json.JSONObject; import com.fr.plugin.ExtraClassManager; +import com.fr.plugin.manage.PluginManager; +import com.fr.plugin.manage.PluginSyncModuleType; +import com.fr.workspace.server.repository.plugin.PluginRepository; import javax.servlet.ServletContext; +import java.util.List; +import java.util.function.Supplier; /** * 设计器插件模块,环境切换的中间模块 @@ -38,6 +44,11 @@ public class DesignPluginComponent extends PluginComponent { @Start public void start() { ExtraClassManager.getInstance().registerAutonomyClassManager(Carina.getApplicationContext().group(AutonomyClassManagerGroup.class).getAll().toArray(new AutonomyClassManagerProvider[0])); + + Supplier> supplier = () -> PluginRepository.getInstance().getPluginStatus(); + PluginManager.registerRemotePluginSupplier(supplier); + PluginManager.setSyncModuleType(PluginSyncModuleType.DESIGN); + super.start(); } diff --git a/designer-realize/src/main/java/com/fanruan/boot/env/function/app/PluginRemote.java b/designer-realize/src/main/java/com/fanruan/boot/env/function/app/PluginRemote.java index 9dd44c79e2..380f608659 100644 --- a/designer-realize/src/main/java/com/fanruan/boot/env/function/app/PluginRemote.java +++ b/designer-realize/src/main/java/com/fanruan/boot/env/function/app/PluginRemote.java @@ -1,7 +1,6 @@ package com.fanruan.boot.env.function.app; import com.fr.base.FRContext; -import com.fr.json.JSONArray; import com.fr.json.JSONException; import com.fr.json.JSONObject; import com.fr.log.FineLoggerFactory; @@ -12,6 +11,7 @@ import com.fr.workspace.WorkContext; import org.jetbrains.annotations.NotNull; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; @@ -57,19 +57,17 @@ public class PluginRemote { private Map getRemoteStatus() { - JSONArray statusArray = FRContext.getCommonOperator().getPluginStatus(); - JSONObject status; + List objectList = FRContext.getCommonOperator().getPluginStatus(); String id; String version; boolean running; Map statusMap = new HashMap<>(); - for (int i = 0; i < statusArray.length(); i++) { + for (JSONObject status : objectList) { try { - status = statusArray.getJSONObject(i); id = status.getString("id"); version = status.getString("version"); running = status.getBoolean("running"); - if(StringUtils.isBlank(id)){ + if (StringUtils.isBlank(id)) { continue; } PluginStatus pluginStatus = PluginStatus.create(id, version, running); 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 6124f3b06c..ec9ed15790 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 @@ -61,6 +61,7 @@ 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.plugin.PluginRepository; import com.fr.workspace.server.repository.resource.PublicResourceRepository; import com.fr.workspace.server.repository.resource.WorkResourceRepository; import com.fr.workspace.server.repository.system.SystemInfoRepository; @@ -109,6 +110,7 @@ public class DesignWorkContextComponent { RepositoryManager.getInstance().pureRegisterRepo4Start(WorkResourceRepository.getInstance()); RepositoryManager.getInstance().pureRegisterRepo4Start(PublicResourceRepository.getInstance()); RepositoryManager.getInstance().pureRegisterRepo4Start(ConfigRepository.getInstance()); + RepositoryManager.getInstance().pureRegisterRepo4Start(PluginRepository.getInstance()); RepositoryManager.getInstance().initLocalRepository(); CompatibleRegister.registerCompatibleEnv(); for (WorkRPCRegister workRPCRegister : ServiceContext.group(WorkspaceKey.class).getAll()) { From e58080000e14d4f287b37a636b7367391d9c5fad Mon Sep 17 00:00:00 2001 From: lemon Date: Fri, 13 Sep 2024 19:18:22 +0800 Subject: [PATCH 3/4] =?UTF-8?q?REPORT-130772=20&=20REPORT-134756=20fix:?= =?UTF-8?q?=E6=9C=AC=E5=9C=B0=E8=BF=98=E6=B2=A1=E6=9C=89=E5=A4=8D=E7=8E=B0?= =?UTF-8?q?=EF=BC=8C=E4=BD=86=E6=98=AF=E8=A7=A3=E5=86=B3=E4=B8=80=E4=BA=9B?= =?UTF-8?q?=E5=B7=B2=E7=9F=A5=E7=9A=84=E7=BC=A9=E6=94=BE=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/fr/design/roleAuthority/RoleTree.java | 4 +++- .../fr/design/style/color/ColorSelectDetailPane.java | 6 ++---- .../com/fr/design/style/color/ColorSelectDialog.java | 8 ++++---- .../fr/design/style/color/CustomChooserPanel.java | 4 ++-- .../fr/design/mainframe/AuthorityToolBarPane.java | 12 ++++++++---- .../mainframe/ElementCasePaneAuthorityEditPane.java | 3 ++- 6 files changed, 21 insertions(+), 16 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/roleAuthority/RoleTree.java b/designer-base/src/main/java/com/fr/design/roleAuthority/RoleTree.java index 743dc4a754..92aeebe9ab 100644 --- a/designer-base/src/main/java/com/fr/design/roleAuthority/RoleTree.java +++ b/designer-base/src/main/java/com/fr/design/roleAuthority/RoleTree.java @@ -33,6 +33,8 @@ import java.util.ArrayList; import java.util.Enumeration; import java.util.List; +import static com.fine.theme.utils.FineUIScale.scale; + /** * Author : daisy * Time: 下午3:32 @@ -48,7 +50,7 @@ public class RoleTree extends UserObjectRefreshJTree { this.setCellRenderer(roleTreeRenderer); this.setEnabled(true); this.setEditable(true); - this.setRowHeight(20); + this.setRowHeight(scale(20)); this.setDigIn(true); Handler handler = createHandlerForRoleTree(); this.replaceMouseListener(this, handler, 0); diff --git a/designer-base/src/main/java/com/fr/design/style/color/ColorSelectDetailPane.java b/designer-base/src/main/java/com/fr/design/style/color/ColorSelectDetailPane.java index 0f6631073d..cf63669c0a 100644 --- a/designer-base/src/main/java/com/fr/design/style/color/ColorSelectDetailPane.java +++ b/designer-base/src/main/java/com/fr/design/style/color/ColorSelectDetailPane.java @@ -78,7 +78,6 @@ public class ColorSelectDetailPane extends BasicPane { // 颜色选择器面板 selectedPanel = new JColorChooser(this.color); - selectedPanel.setPreferredSize(new Dimension(selectedPanel.getWidth(), FineUIScale.scale(SELECT_PANEL_HEIGHT))); selectedPanel.setPreviewPanel(new JPanel()); swatchChooserPanel = new SwatchChooserPanel(); @@ -130,12 +129,11 @@ public class ColorSelectDetailPane extends BasicPane { column( 2, cell(new UILabel(i18nText("Fine-Design_Basic_Preview"))), - cell(previewPanel).with(it -> { + cell(previewPanel).weight(1).with(it -> { it.setBorder(new FineRoundBorder()); - it.setPreferredSize(new Dimension(this.getPreferredSize().width, FineUIScale.scale(120))); it.setBackground(FlatUIUtils.getUIColor("background.normal", Color.WHITE)); }) - )).with(it -> it.setBorder(new ScaledEmptyBorder(0, 10, 0, 10))) + ).weight(1)).weight(1).with(it -> it.setBorder(new ScaledEmptyBorder(0, 10, 0, 10))) ).getComponent(); } diff --git a/designer-base/src/main/java/com/fr/design/style/color/ColorSelectDialog.java b/designer-base/src/main/java/com/fr/design/style/color/ColorSelectDialog.java index e9ee892bf0..6e87e6a12c 100644 --- a/designer-base/src/main/java/com/fr/design/style/color/ColorSelectDialog.java +++ b/designer-base/src/main/java/com/fr/design/style/color/ColorSelectDialog.java @@ -16,6 +16,8 @@ import java.awt.Frame; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import static com.fine.swing.ui.layout.Layouts.cell; +import static com.fine.swing.ui.layout.Layouts.column; import static com.fine.theme.utils.FineUIScale.scale; @@ -86,8 +88,7 @@ public class ColorSelectDialog extends MiddleChartDialog{ private void initComponent() { this.setLayout(new BorderLayout()); - this.add(pane,BorderLayout.NORTH); - this.setBasicDialogSize(scale(545),scale(500)); + this.setBasicDialogSize(545,500); this.setResizable(false); this.applyClosingAction(); @@ -95,8 +96,6 @@ public class ColorSelectDialog extends MiddleChartDialog{ JPanel buttonPane = new JPanel(); buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT)); - this.add(buttonPane, BorderLayout.SOUTH); - ok = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Button_OK")); cancel = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Button_Cancel")); @@ -121,6 +120,7 @@ public class ColorSelectDialog extends MiddleChartDialog{ } }); + this.add(column(10, cell(pane).weight(1), cell(buttonPane)).getComponent()); this.setTitle(pane.title4PopupWindow()); GUICoreUtils.setWindowCenter(getOwner(), this); } diff --git a/designer-base/src/main/java/com/fr/design/style/color/CustomChooserPanel.java b/designer-base/src/main/java/com/fr/design/style/color/CustomChooserPanel.java index d6b2df3023..26ca6bb61f 100644 --- a/designer-base/src/main/java/com/fr/design/style/color/CustomChooserPanel.java +++ b/designer-base/src/main/java/com/fr/design/style/color/CustomChooserPanel.java @@ -599,7 +599,7 @@ class CustomChooserPanel extends AbstractColorChooserPanel implements ColorSelec protected void buildChooser() { setLayout(new BorderLayout(10, 0)); setPreferredSize(new Dimension((int) this.getPreferredSize().getWidth(), scale(180))); - add(buildRightPanel(), BorderLayout.CENTER); + Container rightPane = buildRightPanel(); JPanel container = new JPanel(); container.setLayout(new FlowLayout(FlowLayout.LEFT, 10, 0)); @@ -628,7 +628,7 @@ class CustomChooserPanel extends AbstractColorChooserPanel implements ColorSelec slider.setSize(scale(new Dimension(12, 180))); trackPanel.setSize(scale(new Dimension(12, 180))); - add(container, BorderLayout.WEST); + add(row(cell(container).weight(1), cell(rightPane).weight(1)).getComponent()); slider.addChangeListener(new SliderChangeListener()); updateTextFields(); diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/AuthorityToolBarPane.java b/designer-realize/src/main/java/com/fr/design/mainframe/AuthorityToolBarPane.java index c0679a7053..7e1853c09e 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/AuthorityToolBarPane.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/AuthorityToolBarPane.java @@ -1,6 +1,7 @@ package com.fr.design.mainframe; import com.fine.theme.utils.FineUIScale; +import com.formdev.flatlaf.util.ScaledEmptyBorder; import com.fr.common.inputevent.InputEventBaseOnOS; import com.fr.design.beans.BasicBeanPane; import com.fr.design.file.HistoryTemplateListPane; @@ -37,7 +38,10 @@ import java.awt.event.MouseListener; import java.util.List; import static com.fine.swing.ui.layout.Layouts.cell; +import static com.fine.swing.ui.layout.Layouts.column; +import static com.fine.swing.ui.layout.Layouts.flex; import static com.fine.swing.ui.layout.Layouts.row; +import static com.fine.theme.utils.FineUIScale.scale; /** * Author : daisy @@ -134,14 +138,14 @@ public class AuthorityToolBarPane extends BasicBeanPane extends BasicBeanPane Date: Sat, 14 Sep 2024 11:46:42 +0800 Subject: [PATCH 4/4] =?UTF-8?q?REPORT-134304=E3=80=90fr-fbp=E5=9B=9E?= =?UTF-8?q?=E5=BD=92=E3=80=91=20=E6=A8=A1=E6=9D=BF=E8=AE=BE=E7=BD=AE?= =?UTF-8?q?=E4=B8=8D=E4=BA=86=E5=9B=BE=E7=89=87=E5=AF=BC=E5=87=BA=E5=B1=9E?= =?UTF-8?q?=E6=80=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/fr/design/report/ReportExportAttrPane.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/designer-realize/src/main/java/com/fr/design/report/ReportExportAttrPane.java b/designer-realize/src/main/java/com/fr/design/report/ReportExportAttrPane.java index 9256e3e103..dfcfe3aee6 100644 --- a/designer-realize/src/main/java/com/fr/design/report/ReportExportAttrPane.java +++ b/designer-realize/src/main/java/com/fr/design/report/ReportExportAttrPane.java @@ -45,8 +45,8 @@ public class ReportExportAttrPane extends BasicPane { } private void initPane(BasicStorePane exportPane) { - tabPaneBuilder.addTab(new ImageExportPane().getTitle(), new ImageExportPane()); - paneList.add(new ImageExportPane()); + tabPaneBuilder.addTab(exportPane.getTitle(), exportPane); + paneList.add(exportPane); } @Override