Harrison
2 years ago
9 changed files with 340 additions and 18 deletions
@ -0,0 +1,22 @@
|
||||
package com.fr.startup.metric; |
||||
|
||||
/** |
||||
* created by Harrison on 2022/08/12 |
||||
**/ |
||||
public class DesignerMetrics { |
||||
|
||||
private DesignerStartupModel model = new DesignerStartupModel(); |
||||
|
||||
private DesignerStartupPageStatistic statistic = new DesignerStartupPageStatistic(); |
||||
|
||||
public DesignerMetrics() { |
||||
} |
||||
|
||||
public DesignerStartupModel getModel() { |
||||
return model; |
||||
} |
||||
|
||||
public DesignerStartupPageStatistic getStatistic() { |
||||
return statistic; |
||||
} |
||||
} |
@ -0,0 +1,193 @@
|
||||
package com.fr.startup.metric; |
||||
|
||||
import com.fr.json.JSONArray; |
||||
import com.fr.json.JSONObject; |
||||
import com.fr.plugin.context.PluginContext; |
||||
import com.fr.plugin.manage.PluginManager; |
||||
import com.fr.stable.os.AbstractOperatingSystem; |
||||
import com.fr.stable.os.OperatingSystem; |
||||
import com.fr.start.common.DesignerStartupConfig; |
||||
import com.fr.workspace.WorkContext; |
||||
|
||||
import java.lang.management.ManagementFactory; |
||||
import java.util.List; |
||||
import java.util.stream.Collectors; |
||||
|
||||
/** |
||||
* 设计器启动数据 |
||||
* |
||||
* created by Harrison on 2022/08/12 |
||||
**/ |
||||
public class DesignerStartupModel { |
||||
|
||||
/** |
||||
* landingTime:用户从双击图标/.bat启动等,到出现起始页的时间 |
||||
*/ |
||||
private long landingTime; |
||||
|
||||
/** |
||||
* startingTime:用户从起始页进入设计器,完全可用的时间 |
||||
*/ |
||||
private long startingTime; |
||||
|
||||
/** |
||||
* info:设计器环境的详细信息。记录环境信息、机器信息、远程or本地、插件信息。 |
||||
*/ |
||||
private MachineInfo info; |
||||
|
||||
/** |
||||
* mode:模式,0-有设计器起动页;1-无设计器起始页 |
||||
*/ |
||||
private int mode; |
||||
|
||||
public DesignerStartupModel() { |
||||
} |
||||
|
||||
public DesignerStartupModel(long landingTime, long startingTime, MachineInfo info, int mode) { |
||||
this.landingTime = landingTime; |
||||
this.startingTime = startingTime; |
||||
this.info = info; |
||||
this.mode = mode; |
||||
} |
||||
|
||||
public long getLandingTime() { |
||||
return landingTime; |
||||
} |
||||
|
||||
public void setLandingTime(long landingTime) { |
||||
this.landingTime = landingTime; |
||||
} |
||||
|
||||
public long getStartingTime() { |
||||
return startingTime; |
||||
} |
||||
|
||||
public void setStartingTime(long startingTime) { |
||||
this.startingTime = startingTime; |
||||
} |
||||
|
||||
public MachineInfo getInfo() { |
||||
return info; |
||||
} |
||||
|
||||
public void setInfo(MachineInfo info) { |
||||
this.info = info; |
||||
} |
||||
|
||||
public int getMode() { |
||||
return mode; |
||||
} |
||||
|
||||
public void setMode(int mode) { |
||||
this.mode = mode; |
||||
} |
||||
|
||||
private void fillInfo() { |
||||
|
||||
MachineInfo info = new MachineInfo(); |
||||
AbstractOperatingSystem operatingSystem = OperatingSystem.getOperatingSystem(); |
||||
info.setSystem(operatingSystem.getDisplayString()); |
||||
|
||||
try { |
||||
final int byteToMb = 1024 * 1024; |
||||
com.sun.management.OperatingSystemMXBean operatingSystemMXBean = (com.sun.management.OperatingSystemMXBean) ManagementFactory.getOperatingSystemMXBean(); |
||||
long free = operatingSystemMXBean.getFreePhysicalMemorySize() / byteToMb; |
||||
long total = operatingSystemMXBean.getTotalPhysicalMemorySize() / byteToMb; |
||||
long used = total - free; |
||||
JSONObject jo = new JSONObject(); |
||||
jo.put("free", free); |
||||
jo.put("used", used); |
||||
jo.put("total", total); |
||||
info.setMachine(jo.toString()); |
||||
} catch (Exception ignored) { |
||||
} |
||||
|
||||
boolean local = WorkContext.getCurrent().isLocal(); |
||||
info.setWork(local ? 1 : 0); |
||||
|
||||
List<PluginContext> contexts = PluginManager.getContexts(); |
||||
List<String> contextNames = contexts.stream() |
||||
.map(PluginContext::getName) |
||||
.collect(Collectors.toList()); |
||||
JSONArray contextNameJa = new JSONArray(contextNames); |
||||
info.setPlugins(contextNameJa.toString()); |
||||
this.setInfo(info); |
||||
|
||||
} |
||||
|
||||
private void fillMode() { |
||||
|
||||
this.setMode(DesignerStartupConfig.getInstance().isEnabled() ? 0 : 1); |
||||
} |
||||
|
||||
public void fill() { |
||||
|
||||
fillInfo(); |
||||
fillMode(); |
||||
} |
||||
|
||||
private static class MachineInfo { |
||||
|
||||
/** |
||||
* 系统信息 |
||||
*/ |
||||
private String system; |
||||
|
||||
/** |
||||
* 机器信息 |
||||
*/ |
||||
private String machine; |
||||
|
||||
/** |
||||
* work:0-远程;1-本地; |
||||
*/ |
||||
private int work; |
||||
|
||||
/** |
||||
* 插件列表 |
||||
*/ |
||||
private String plugins; |
||||
|
||||
public MachineInfo() { |
||||
} |
||||
|
||||
public MachineInfo(String system, String machine, int work, String plugins) { |
||||
this.system = system; |
||||
this.machine = machine; |
||||
this.work = work; |
||||
this.plugins = plugins; |
||||
} |
||||
|
||||
public String getSystem() { |
||||
return system; |
||||
} |
||||
|
||||
public void setSystem(String system) { |
||||
this.system = system; |
||||
} |
||||
|
||||
public String getMachine() { |
||||
return machine; |
||||
} |
||||
|
||||
public void setMachine(String machine) { |
||||
this.machine = machine; |
||||
} |
||||
|
||||
public int getWork() { |
||||
return work; |
||||
} |
||||
|
||||
public void setWork(int work) { |
||||
this.work = work; |
||||
} |
||||
|
||||
public String getPlugins() { |
||||
return plugins; |
||||
} |
||||
|
||||
public void setPlugins(String plugins) { |
||||
this.plugins = plugins; |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,71 @@
|
||||
package com.fr.startup.metric; |
||||
|
||||
/** |
||||
* 设计器启动页使用数据 |
||||
* |
||||
* created by Harrison on 2022/08/12 |
||||
**/ |
||||
public class DesignerStartupPageStatistic { |
||||
|
||||
/** |
||||
* operate:0-双击工作目录进入 或 点击蓝色箭头进入;1-切换其他工作目录;2-点击展开全部;3-点击工作目录中的模版直接打开 或 直接点击蓝色箭头进入 |
||||
*/ |
||||
private int operate; |
||||
|
||||
/** |
||||
* workplace:工作目录名称,当operate为 0或1时记录 |
||||
*/ |
||||
private String workspace; |
||||
|
||||
/** |
||||
* workplaceNumber:工作目录的个数,当operate为 0或1或2或3时记录 |
||||
*/ |
||||
private String workspaceNum; |
||||
|
||||
/** |
||||
* template:模板名称,当operate为 3时记录 |
||||
*/ |
||||
private String template; |
||||
|
||||
public DesignerStartupPageStatistic(int operate, String workspace, String workspaceNum, String template) { |
||||
this.operate = operate; |
||||
this.workspace = workspace; |
||||
this.workspaceNum = workspaceNum; |
||||
this.template = template; |
||||
} |
||||
|
||||
public DesignerStartupPageStatistic() { |
||||
} |
||||
|
||||
public int getOperate() { |
||||
return operate; |
||||
} |
||||
|
||||
public void setOperate(int operate) { |
||||
this.operate = operate; |
||||
} |
||||
|
||||
public String getWorkspace() { |
||||
return workspace; |
||||
} |
||||
|
||||
public void setWorkspace(String workspace) { |
||||
this.workspace = workspace; |
||||
} |
||||
|
||||
public String getWorkspaceNum() { |
||||
return workspaceNum; |
||||
} |
||||
|
||||
public void setWorkspaceNum(String workspaceNum) { |
||||
this.workspaceNum = workspaceNum; |
||||
} |
||||
|
||||
public String getTemplate() { |
||||
return template; |
||||
} |
||||
|
||||
public void setTemplate(String template) { |
||||
this.template = template; |
||||
} |
||||
} |
Loading…
Reference in new issue