From d453a5be06633fee5e2303495297a4276a155614 Mon Sep 17 00:00:00 2001 From: "alex.sung" Date: Thu, 5 Sep 2019 15:19:41 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E5=AE=A2=E6=88=B7=E7=AB=AF=E6=90=BA?= =?UTF-8?q?=E5=B8=A6=E9=89=B4=E6=9D=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../solid/SolidCollectConstants.java | 18 +++++++ .../messagecollect/solid/SolidCollector.java | 47 +++++++++++++++---- 2 files changed, 56 insertions(+), 9 deletions(-) create mode 100644 designer-realize/src/main/java/com/fr/design/mainframe/messagecollect/solid/SolidCollectConstants.java diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/messagecollect/solid/SolidCollectConstants.java b/designer-realize/src/main/java/com/fr/design/mainframe/messagecollect/solid/SolidCollectConstants.java new file mode 100644 index 0000000000..452da9ecc5 --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/mainframe/messagecollect/solid/SolidCollectConstants.java @@ -0,0 +1,18 @@ +package com.fr.design.mainframe.messagecollect.solid; + +/** + * Created by alex sung on 2019/9/5. + */ +public class SolidCollectConstants { + private SolidCollectConstants(){} + + /** + * 客户端请求subject + */ + public static final String REQUEST_SUBJECT = "solid"; + + /** + * 客户端请求超时鉴权时间,默认1h失效 + */ + public static final long TIME_OUT = 60 * 60 * 1000; +} diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/messagecollect/solid/SolidCollector.java b/designer-realize/src/main/java/com/fr/design/mainframe/messagecollect/solid/SolidCollector.java index eb5c05912c..eaaa532311 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/messagecollect/solid/SolidCollector.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/messagecollect/solid/SolidCollector.java @@ -2,14 +2,21 @@ package com.fr.design.mainframe.messagecollect.solid; import com.fr.general.CloudCenter; import com.fr.general.http.HttpToolbox; +import com.fr.json.JSON; +import com.fr.json.JSONFactory; import com.fr.log.FineLoggerFactory; +import com.fr.security.JwtUtils; import com.fr.stable.CommonUtils; import com.fr.stable.StringUtils; import com.fr.workspace.WorkContext; +import java.io.IOException; import java.util.HashMap; import java.util.Map; +import static com.fr.design.mainframe.messagecollect.solid.SolidCollectConstants.REQUEST_SUBJECT; +import static com.fr.design.mainframe.messagecollect.solid.SolidCollectConstants.TIME_OUT; + /** * 设计器固化信息回传类 * Created by alex sung on 2019/8/22. @@ -19,6 +26,7 @@ import java.util.Map; public class SolidCollector { private static final String CONTENT_URL = "/v10/collect/solid"; private static final String DELETE_URL = "/v10/collect/solid/delete"; + private static final String UNLOCK_URL = "/v10/collect/solid/unlock"; private static final String ATTR_CIPHER_TEXT = "cipherText"; private static final String ATTR_SIGNATURE = "signature"; private static final String SOLID_UPLOAD_URL = CloudCenter.getInstance().acquireUrlByKind("design.solid"); @@ -40,19 +48,32 @@ public class SolidCollector { * 回传文件给云中心,并删除服务端本地文件 */ public void sendToCloudCenterAndDeleteFile() { + if (WorkContext.getCurrent().isLocal()) { + return; + } try { String content = requestContent(); - if(StringUtils.isNotEmpty(content)){ - Map params = new HashMap<>(); - params.put(ATTR_CIPHER_TEXT, requestContent()); - params.put(ATTR_SIGNATURE, String.valueOf(CommonUtils.signature())); - HttpToolbox.post(SOLID_UPLOAD_URL, params); + if (StringUtils.isNotEmpty(content)) { + String cipherText = JSONFactory.createJSON(JSON.OBJECT).optString("data"); + if(StringUtils.isNotEmpty(cipherText)){ + Map params = new HashMap<>(); + params.put(ATTR_CIPHER_TEXT, cipherText); + params.put(ATTR_SIGNATURE, String.valueOf(CommonUtils.signature())); + HttpToolbox.post(SOLID_UPLOAD_URL, params); - String deleteUrl = WorkContext.getCurrent().getPath() + DELETE_URL; - HttpToolbox.post(deleteUrl, new HashMap()); + String deleteUrl = WorkContext.getCurrent().getPath() + DELETE_URL; + HttpToolbox.post(deleteUrl, getParams()); + } } } catch (Exception e) { FineLoggerFactory.getLogger().info(e.getMessage(), e); + } finally { + String unlockUrl = WorkContext.getCurrent().getPath() + UNLOCK_URL; + try { + HttpToolbox.post(unlockUrl, getParams()); + } catch (IOException e) { + FineLoggerFactory.getLogger().warn(e.getMessage(), e); + } } } @@ -60,7 +81,15 @@ public class SolidCollector { * 获取服务端固化文件内容 * @return 回传内容 */ - public String requestContent() throws Exception{ - return HttpToolbox.get(WorkContext.getCurrent().getPath() + CONTENT_URL); + public String requestContent() throws Exception { + Map params = new HashMap(); + params.put("token", JwtUtils.createDefaultJWT(REQUEST_SUBJECT, TIME_OUT)); + return HttpToolbox.get(WorkContext.getCurrent().getPath() + CONTENT_URL, params); + } + + private Map getParams() { + Map params = new HashMap(); + params.put("token", JwtUtils.createDefaultJWT(REQUEST_SUBJECT, TIME_OUT)); + return params; } } From 7519d03aefd365d9691f6010c4cb16dc28d00424 Mon Sep 17 00:00:00 2001 From: vito Date: Thu, 5 Sep 2019 17:21:16 +0800 Subject: [PATCH 2/4] =?UTF-8?q?REPORT-19945=20=E8=AE=BE=E8=AE=A1=E5=99=A8?= =?UTF-8?q?=E5=90=AF=E5=8A=A8=E4=BF=A1=E6=81=AF=E6=94=B6=E9=9B=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mainframe/InformationCollector.java | 201 ++++++++++-------- .../StartupMessageCollector.java | 89 ++++++++ .../com/fr/start/module/DesignerStartup.java | 11 +- 3 files changed, 209 insertions(+), 92 deletions(-) create mode 100644 designer-realize/src/main/java/com/fr/design/mainframe/messagecollect/StartupMessageCollector.java diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/InformationCollector.java b/designer-realize/src/main/java/com/fr/design/mainframe/InformationCollector.java index 0ec61e5e70..7c3ca2dac0 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/InformationCollector.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/InformationCollector.java @@ -1,9 +1,7 @@ -/** - * - */ package com.fr.design.mainframe; import com.fr.base.FRContext; +import com.fr.concurrent.NamedThreadFactory; import com.fr.config.MarketConfig; import com.fr.design.DesignerEnvManager; import com.fr.design.mainframe.errorinfo.ErrorInfoUploader; @@ -30,6 +28,7 @@ import com.fr.stable.xml.XMLTools; import com.fr.stable.xml.XMLWriter; import com.fr.stable.xml.XMLableReader; import com.fr.third.javax.xml.stream.XMLStreamException; +import com.sun.management.OperatingSystemMXBean; import java.io.BufferedWriter; import java.io.ByteArrayInputStream; @@ -43,6 +42,8 @@ import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.io.UnsupportedEncodingException; +import java.lang.management.ManagementFactory; +import java.nio.charset.StandardCharsets; import java.text.DateFormat; import java.util.ArrayList; import java.util.Date; @@ -53,15 +54,19 @@ import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; /** - * @author neil + * 设计器信息收集 * + * @author neil * @date: 2015-4-8-下午5:11:46 */ public class InformationCollector implements XMLReadable, XMLWriter { - // 24小时上传一次 + /** + * 24小时上传一次 + */ private static final long DELTA = 24 * 3600 * 1000L; private static final long SEND_DELAY = 300 * 1000L; + private static final int BYTE_TO_MB = 1024 * 1024; private static final String FILE_NAME = "fr.info"; private static final String XML_START_STOP_LIST = "StartStopList"; private static final String XML_START_STOP = "StartStop"; @@ -74,26 +79,33 @@ public class InformationCollector implements XMLReadable, XMLWriter { private static final String XML_UUID = "UUID"; private static final String XML_KEY = "ActiveKey"; private static final String XML_OS = "OS"; + private static final String XML_ARCH = "arch"; + private static final String XML_AVAILABLE_PROCESSORS = "cpu"; + private static final String XML_PHYSICAL_MEMORY = "systemMemory"; private static InformationCollector collector; - //启动时间与关闭时间列表 - private List startStop = new ArrayList(); - //上一次的发送时间 + /** + * 启动时间与关闭时间列表 + */ + private List startStop = new ArrayList<>(); + /** + * 上一次的发送时间 + */ private String lastTime; private StartStopTime current = new StartStopTime(); - public static InformationCollector getInstance(){ + public static InformationCollector getInstance() { if (collector == null) { collector = new InformationCollector(); - readEncodeXMLFile(collector, collector.getInfoFile()); + readEncodeXMLFile(collector, collector.getInfoFile()); } return collector; } - private static void readEncodeXMLFile(XMLReadable xmlReadable, File xmlFile){ + private static void readEncodeXMLFile(XMLReadable xmlReadable, File xmlFile) { if (xmlFile == null || !xmlFile.exists()) { return; } @@ -119,13 +131,13 @@ public class InformationCollector implements XMLReadable, XMLWriter { } - private static String getDecodeFileContent(File xmlFile) throws FileNotFoundException, UnsupportedEncodingException{ + private static String getDecodeFileContent(File xmlFile) throws FileNotFoundException, UnsupportedEncodingException { InputStream encodeInputStream = new FileInputStream(xmlFile); String encodeContent = IOUtils.inputStream2String(encodeInputStream); return DesUtils.getDecString(encodeContent); } - private long getLastTimeMillis(){ + private long getLastTimeMillis() { if (StringUtils.isEmpty(this.lastTime)) { return 0; } @@ -142,23 +154,36 @@ public class InformationCollector implements XMLReadable, XMLWriter { JSONObject content = new JSONObject(); JSONArray startStopArray = new JSONArray(); - for (int i = 0; i < startStop.size(); i++) { + for (StartStopTime startStopTime : startStop) { JSONObject jo = new JSONObject(); - jo.put(ATTR_START, startStop.get(i).getStartDate()); - jo.put(ATTR_STOP, startStop.get(i).getStopDate()); + jo.put(ATTR_START, startStopTime.getStartDate()); + jo.put(ATTR_STOP, startStopTime.getStopDate()); startStopArray.put(jo); - DesignerEnvManager envManager = DesignerEnvManager.getEnvManager(); - content.put(XML_START_STOP, startStopArray); - content.put(XML_UUID, envManager.getUUID()); - content.put(XML_JAR, GeneralUtils.readBuildNO()); - content.put(XML_VERSION, ProductConstants.RELEASE_VERSION); - content.put(XML_USERNAME, MarketConfig.getInstance().getBbsUsername()); - content.put(XML_KEY, envManager.getActivationKey()); - content.put(XML_OS, System.getProperty("os.name")); } + DesignerEnvManager envManager = DesignerEnvManager.getEnvManager(); + content.put(XML_START_STOP, startStopArray); + content.put(XML_UUID, envManager.getUUID()); + content.put(XML_JAR, GeneralUtils.readBuildNO()); + content.put(XML_VERSION, ProductConstants.RELEASE_VERSION); + content.put(XML_USERNAME, MarketConfig.getInstance().getBbsUsername()); + content.put(XML_KEY, envManager.getActivationKey()); + content.put(XML_OS, System.getProperty("os.name")); + content.put(XML_ARCH, System.getProperty("os.arch")); + content.put(XML_AVAILABLE_PROCESSORS, Runtime.getRuntime().availableProcessors()); + content.put(XML_PHYSICAL_MEMORY, getTotalPhysicalMemorySize()); return content; } + /** + * 获取物理内存,单位GB + * + * @return 物理内存 + */ + private static long getTotalPhysicalMemorySize() { + OperatingSystemMXBean bean = (OperatingSystemMXBean) ManagementFactory.getOperatingSystemMXBean(); + return bean.getTotalPhysicalMemorySize() / BYTE_TO_MB; + } + private void sendUserInfo(){ long currentTime = new Date().getTime(); long lastTime = getLastTimeMillis(); @@ -186,18 +211,18 @@ public class InformationCollector implements XMLReadable, XMLWriter { /** * 收集开始使用时间,发送信息 */ - public void collectStartTime(){ + public void collectStartTime() { this.current.setStartDate(dateToString()); sendUserInfoInOtherThread(); } - private void sendUserInfoInOtherThread(){ + private void sendUserInfoInOtherThread() { if (!DesignerEnvManager.getEnvManager().isJoinProductImprove() || !FRContext.isChineseEnv()) { return; } - ScheduledExecutorService service = Executors.newSingleThreadScheduledExecutor(); + ScheduledExecutorService service = Executors.newSingleThreadScheduledExecutor(new NamedThreadFactory("InformationCollector")); service.schedule(new Runnable() { @Override public void run() { @@ -210,67 +235,66 @@ public class InformationCollector implements XMLReadable, XMLWriter { }, SEND_DELAY, TimeUnit.MILLISECONDS); } - /** - * 收集结束使用时间 - */ - public void collectStopTime(){ + /** + * 收集结束使用时间 + */ + public void collectStopTime() { this.current.setStopDate(dateToString()); } - private String dateToString(){ + private String dateToString() { DateFormat df = FRContext.getDefaultValues().getDateTimeFormat(); return df.format(new Date()); } - private void reset(){ + private void reset() { this.startStop.clear(); this.lastTime = dateToString(); } - private File getInfoFile() { - return new File(StableUtils.pathJoin(ProductConstants.getEnvHome(), FILE_NAME)); - } - - /** - * 保存xml文件 - */ - public void saveXMLFile() { - File xmlFile = this.getInfoFile(); - try{ - ByteArrayOutputStream out = new ByteArrayOutputStream(); + private File getInfoFile() { + return new File(StableUtils.pathJoin(ProductConstants.getEnvHome(), FILE_NAME)); + } + + /** + * 保存xml文件 + */ + public void saveXMLFile() { + File xmlFile = this.getInfoFile(); + try { + ByteArrayOutputStream out = new ByteArrayOutputStream(); XMLTools.writeOutputStreamXML(this, out); out.flush(); out.close(); - String fileContent = new String(out.toByteArray(), EncodeConstants.ENCODING_UTF_8); + String fileContent = new String(out.toByteArray(), StandardCharsets.UTF_8); String encodeCotent = DesUtils.getEncString(fileContent); writeEncodeContentToFile(encodeCotent, xmlFile); - }catch (Exception e) { - FineLoggerFactory.getLogger().error(e.getMessage(), e); + } catch (Exception e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); } - } + } /** * 将文件内容写到输出流中 */ - private static void writeEncodeContentToFile(String fileContent, File file){ + private static void writeEncodeContentToFile(String fileContent, File file) { BufferedWriter bw = null; try { FileOutputStream fos = new FileOutputStream(file); - OutputStreamWriter osw = new OutputStreamWriter(fos, EncodeConstants.ENCODING_UTF_8); + OutputStreamWriter osw = new OutputStreamWriter(fos, StandardCharsets.UTF_8); bw = new BufferedWriter(osw); bw.write(fileContent); } catch (Exception e) { - FineLoggerFactory.getLogger().error(e.getMessage(), e); + FineLoggerFactory.getLogger().error(e.getMessage(), e); } finally { - if(bw != null){ + if (bw != null) { try { bw.close(); - } catch (IOException e) { + } catch (IOException ignore) { } } } - } @Override @@ -285,56 +309,57 @@ public class InformationCollector implements XMLReadable, XMLWriter { writer.end(); } - private void writeStartStopList(XMLPrintWriter writer){ + private void writeStartStopList(XMLPrintWriter writer) { //启停 - writer.startTAG(XML_START_STOP_LIST); - for (int i = 0; i < startStop.size(); i++) { - startStop.get(i).writeXML(writer); + writer.startTAG(XML_START_STOP_LIST); + for (StartStopTime startStopTime : startStop) { + startStopTime.writeXML(writer); } - writer.end(); + writer.end(); } - private void writeTag(String tag, String content, XMLPrintWriter writer){ + private void writeTag(String tag, String content, XMLPrintWriter writer) { if (StringUtils.isEmpty(content)) { return; } - writer.startTAG(tag); - writer.textNode(content); - writer.end(); + writer.startTAG(tag); + writer.textNode(content); + writer.end(); } @Override public void readXML(XMLableReader reader) { - if (reader.isChildNode()) { - String name = reader.getTagName(); - if (XML_START_STOP_LIST.equals(name)) { - readStartStopList(reader); - } else if(XML_LAST_TIME.equals(name)){ - readLastTime(reader); + if (reader.isChildNode()) { + String name = reader.getTagName(); + if (XML_START_STOP_LIST.equals(name)) { + readStartStopList(reader); + } else if (XML_LAST_TIME.equals(name)) { + readLastTime(reader); } - } + } } - private void readLastTime(XMLableReader reader){ + private void readLastTime(XMLableReader reader) { String tmpVal; if (StringUtils.isNotBlank(tmpVal = reader.getElementValue())) { this.lastTime = tmpVal; } } - private void readStartStopList(XMLableReader reader){ - startStop.clear(); + private void readStartStopList(XMLableReader reader) { + startStop.clear(); reader.readXMLObject(new XMLReadable() { - public void readXML(XMLableReader reader) { - if (XML_START_STOP.equals(reader.getTagName())) { - StartStopTime startStopTime = new StartStopTime(); - reader.readXMLObject(startStopTime); - startStop.add(startStopTime); - } - } - }); + @Override + public void readXML(XMLableReader reader) { + if (XML_START_STOP.equals(reader.getTagName())) { + StartStopTime startStopTime = new StartStopTime(); + reader.readXMLObject(startStopTime); + startStop.add(startStopTime); + } + } + }); } private class StartStopTime implements XMLReadable, XMLWriter { @@ -358,17 +383,19 @@ public class InformationCollector implements XMLReadable, XMLWriter { this.stopDate = endDate; } + @Override public void writeXML(XMLPrintWriter writer) { - writer.startTAG(XML_START_STOP); - if (StringUtils.isNotEmpty(startDate)) { - writer.attr(ATTR_START, this.startDate); + writer.startTAG(XML_START_STOP); + if (StringUtils.isNotEmpty(startDate)) { + writer.attr(ATTR_START, this.startDate); } - if (StringUtils.isNotEmpty(stopDate)) { - writer.attr(ATTR_STOP, this.stopDate); + if (StringUtils.isNotEmpty(stopDate)) { + writer.attr(ATTR_STOP, this.stopDate); } - writer.end(); + writer.end(); } + @Override public void readXML(XMLableReader reader) { this.startDate = reader.getAttrAsString(ATTR_START, StringUtils.EMPTY); this.stopDate = reader.getAttrAsString(ATTR_STOP, StringUtils.EMPTY); diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/messagecollect/StartupMessageCollector.java b/designer-realize/src/main/java/com/fr/design/mainframe/messagecollect/StartupMessageCollector.java new file mode 100644 index 0000000000..2fcd2328ca --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/mainframe/messagecollect/StartupMessageCollector.java @@ -0,0 +1,89 @@ +package com.fr.design.mainframe.messagecollect; + +import com.fr.concurrent.NamedThreadFactory; +import com.fr.design.mainframe.SiteCenterToken; +import com.fr.event.Event; +import com.fr.event.EventDispatcher; +import com.fr.event.Listener; +import com.fr.general.CloudCenter; +import com.fr.general.ComparatorUtils; +import com.fr.general.http.HttpToolbox; +import com.fr.json.JSONObject; +import com.fr.log.FineLoggerFactory; +import com.fr.module.ModuleContext; +import com.fr.module.engine.FineModule; +import com.fr.runtime.FineRuntime; +import com.fr.stable.StringUtils; + +import java.util.HashMap; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; + +/** + * 启动信息收集 + * + * @author vito + * @version 10.0 + * Created by vito on 2019/9/4 + */ +public class StartupMessageCollector { + + private static final String XML_STARTUP_TIME = "t"; + private static final String XML_STARTUP_LOG = "startupLog"; + private static final String XML_STARTUP_Memory = "designerMemory"; + private static final String XML_STARTUP_COST = "cost"; + private static final String STARTUP_URL_KEY = "user.info.v10.startup"; + private static final String LOG_TYPE = "single"; + private static final int BYTE_TO_MB = 1024 * 1024; + + public static final StartupMessageCollector INSTANCE = new StartupMessageCollector(); + + private StartupMessageCollector() { + } + + public static StartupMessageCollector getInstance() { + return INSTANCE; + } + + public void recordStartupLog() { + EventDispatcher.listen(FineRuntime.ApplicationEvent.AFTER_START, new Listener() { + + @Override + public void on(Event event, Long param) { + final String url = CloudCenter.getInstance().acquireUrlByKind(STARTUP_URL_KEY); + if (StringUtils.isEmpty(url)) { + return; + } + ExecutorService es = Executors.newSingleThreadExecutor(new NamedThreadFactory("StartupMessageCollector")); + es.submit(new Runnable() { + @Override + public void run() { + FineModule root = (FineModule) ModuleContext.getRoot().getRoot(); + JSONObject profile = root.profile(); + JSONObject json = JSONObject.create() + .put(XML_STARTUP_TIME, FineRuntime.getAppStartTime() + FineRuntime.getStartingTime()) + .put(XML_STARTUP_COST, FineRuntime.getStartingTime()) + .put(XML_STARTUP_LOG, profile) + .put(XML_STARTUP_Memory, Runtime.getRuntime().totalMemory() / BYTE_TO_MB); + sendInfo(json, url + LOG_TYPE); + } + }); + es.shutdown(); + } + }); + } + + private boolean sendInfo(JSONObject content, String url) { + boolean success = false; + try { + HashMap para = new HashMap<>(); + para.put("token", SiteCenterToken.generateToken()); + para.put("content", content); + String res = HttpToolbox.post(url, para); + success = ComparatorUtils.equals(new JSONObject(res).get("status"), "success"); + } catch (Exception e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); + } + return success; + } +} diff --git a/designer-realize/src/main/java/com/fr/start/module/DesignerStartup.java b/designer-realize/src/main/java/com/fr/start/module/DesignerStartup.java index 4a3db7b2cc..5f8fe70232 100644 --- a/designer-realize/src/main/java/com/fr/start/module/DesignerStartup.java +++ b/designer-realize/src/main/java/com/fr/start/module/DesignerStartup.java @@ -1,14 +1,15 @@ package com.fr.start.module; +import com.fr.concurrent.NamedThreadFactory; import com.fr.design.file.HistoryTemplateListCache; import com.fr.design.mainframe.DesignerContext; +import com.fr.design.mainframe.messagecollect.StartupMessageCollector; import com.fr.event.Event; import com.fr.event.Listener; import com.fr.module.Activator; import com.fr.record.analyzer.EnableMetrics; import com.fr.record.analyzer.Metrics; -import com.fr.runtime.FineRuntime; import com.fr.start.Designer; import com.fr.start.ServerStarter; import com.fr.start.SplashContext; @@ -42,7 +43,7 @@ public class DesignerStartup extends Activator { startSub(EnvBasedModule.class); //designer模块启动好后,查看demo browserDemo(); - ExecutorService service = Executors.newFixedThreadPool(2); + ExecutorService service = Executors.newSingleThreadExecutor(new NamedThreadFactory("FineEmbedServerStart")); service.submit(new Runnable() { @Override public void run() { @@ -67,7 +68,7 @@ public class DesignerStartup extends Activator { DesignerContext.getDesignerFrame().getProgressDialog().setVisible(true); startSub(StartFinishActivator.class); - FineRuntime.startFinish(); + StartupMessageCollector.getInstance().recordStartupLog(); } private void browserDemo() { @@ -87,7 +88,7 @@ public class DesignerStartup extends Activator { @Override public void on(Event event, Workspace current) { - getSub(EnvBasedModule.class).stop(); + stopSub(EnvBasedModule.class); } }); /*切换环境后,重新启动所有相关模块,最先执行*/ @@ -95,7 +96,7 @@ public class DesignerStartup extends Activator { @Override public void on(Event event, Workspace current) { - getSub(EnvBasedModule.class).start(); + startSub(EnvBasedModule.class); // 切换后的环境是本地环境才启动内置服务器 if (current.isLocal()) { ExecutorService service = Executors.newSingleThreadExecutor(); From eefd765e98d18fbad56e8c0eb648f4b3c629a80d Mon Sep 17 00:00:00 2001 From: vito Date: Fri, 6 Sep 2019 09:58:09 +0800 Subject: [PATCH 3/4] =?UTF-8?q?REPORT-19945=20=E8=AE=BE=E8=AE=A1=E5=99=A8?= =?UTF-8?q?=E5=90=AF=E5=8A=A8=E4=BF=A1=E6=81=AF=E6=94=B6=E9=9B=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mainframe/messagecollect/StartupMessageCollector.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/messagecollect/StartupMessageCollector.java b/designer-realize/src/main/java/com/fr/design/mainframe/messagecollect/StartupMessageCollector.java index 2fcd2328ca..288cac4000 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/messagecollect/StartupMessageCollector.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/messagecollect/StartupMessageCollector.java @@ -1,6 +1,7 @@ package com.fr.design.mainframe.messagecollect; import com.fr.concurrent.NamedThreadFactory; +import com.fr.design.DesignerEnvManager; import com.fr.design.mainframe.SiteCenterToken; import com.fr.event.Event; import com.fr.event.EventDispatcher; @@ -32,6 +33,7 @@ public class StartupMessageCollector { private static final String XML_STARTUP_LOG = "startupLog"; private static final String XML_STARTUP_Memory = "designerMemory"; private static final String XML_STARTUP_COST = "cost"; + private static final String XML_UUID = "UUID"; private static final String STARTUP_URL_KEY = "user.info.v10.startup"; private static final String LOG_TYPE = "single"; private static final int BYTE_TO_MB = 1024 * 1024; @@ -61,6 +63,7 @@ public class StartupMessageCollector { FineModule root = (FineModule) ModuleContext.getRoot().getRoot(); JSONObject profile = root.profile(); JSONObject json = JSONObject.create() + .put(XML_UUID, DesignerEnvManager.getEnvManager().getUUID()) .put(XML_STARTUP_TIME, FineRuntime.getAppStartTime() + FineRuntime.getStartingTime()) .put(XML_STARTUP_COST, FineRuntime.getStartingTime()) .put(XML_STARTUP_LOG, profile) From a313085e0204f9e6f68018d7ce34b56e6b8e8d46 Mon Sep 17 00:00:00 2001 From: "alex.sung" Date: Tue, 1 Oct 2019 04:31:49 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E8=A1=A5=E5=85=85=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../design/mainframe/messagecollect/solid/SolidCollector.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/messagecollect/solid/SolidCollector.java b/designer-realize/src/main/java/com/fr/design/mainframe/messagecollect/solid/SolidCollector.java index eaaa532311..68cc882a92 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/messagecollect/solid/SolidCollector.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/messagecollect/solid/SolidCollector.java @@ -51,10 +51,11 @@ public class SolidCollector { if (WorkContext.getCurrent().isLocal()) { return; } + FineLoggerFactory.getLogger().info("start to get solid content from server..."); try { String content = requestContent(); if (StringUtils.isNotEmpty(content)) { - String cipherText = JSONFactory.createJSON(JSON.OBJECT).optString("data"); + String cipherText = JSONFactory.createJSON(JSON.OBJECT, content).optString("data"); if(StringUtils.isNotEmpty(cipherText)){ Map params = new HashMap<>(); params.put(ATTR_CIPHER_TEXT, cipherText); @@ -65,6 +66,7 @@ public class SolidCollector { HttpToolbox.post(deleteUrl, getParams()); } } + FineLoggerFactory.getLogger().info("send solid content to cloud center success."); } catch (Exception e) { FineLoggerFactory.getLogger().info(e.getMessage(), e); } finally {