Browse Source

REPORT-27106 && REPORT-28229

feature/big-screen
hades 5 years ago
parent
commit
81b36cdd41
  1. 62
      designer-base/src/main/java/com/fr/design/env/DesignerWorkspaceGenerator.java
  2. 7
      designer-base/src/main/java/com/fr/design/mainframe/errorinfo/ErrorInfo.java
  3. 3
      designer-base/src/main/java/com/fr/design/mainframe/messagecollect/StartErrorMessageCollector.java
  4. 0
      designer-base/src/main/java/com/fr/design/mainframe/messagecollect/entity/DesignerErrorMessage.java

62
designer-base/src/main/java/com/fr/design/env/DesignerWorkspaceGenerator.java vendored

@ -1,15 +1,35 @@
package com.fr.design.env; package com.fr.design.env;
import com.fr.concurrent.NamedThreadFactory;
import com.fr.design.EnvChangeEntrance;
import com.fr.design.dialog.FineJOptionPane;
import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.messagecollect.StartErrorMessageCollector;
import com.fr.design.mainframe.messagecollect.entity.DesignerErrorMessage;
import com.fr.general.IOUtils;
import com.fr.log.FineLoggerFactory;
import com.fr.module.ModuleContext;
import com.fr.stable.StringUtils;
import com.fr.workspace.WorkContext; import com.fr.workspace.WorkContext;
import com.fr.workspace.Workspace; import com.fr.workspace.Workspace;
import com.fr.workspace.connect.WorkspaceClient; import com.fr.workspace.connect.WorkspaceClient;
import javax.swing.*;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
/** /**
* 根据配置生成运行环境 * 根据配置生成运行环境
*/ */
public class DesignerWorkspaceGenerator { public class DesignerWorkspaceGenerator {
public static Workspace generate(DesignerWorkspaceInfo config) throws Exception { private static final int WAIT_FREQ = 60;
private static ExecutorService service = ModuleContext.getExecutor().newSingleThreadExecutor(
new NamedThreadFactory("DesignerWorkspaceGenerator"));
public static Workspace generate(final DesignerWorkspaceInfo config) throws Exception {
if (config == null || config.getType() == null) { if (config == null || config.getType() == null) {
return null; return null;
@ -22,7 +42,19 @@ public class DesignerWorkspaceGenerator {
break; break;
} }
case Remote: { case Remote: {
WorkspaceClient client = WorkContext.getConnector().connect(config.getConnection()); Future<WorkspaceClient> future = service.submit(new Callable<WorkspaceClient>() {
@Override
public WorkspaceClient call() throws Exception {
return WorkContext.getConnector().connect(config.getConnection());
}
});
WorkspaceClient client = null;
try {
client = future.get(WAIT_FREQ, TimeUnit.SECONDS);
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
RemoteHandler.handle(config);
}
if (client != null) { if (client != null) {
workspace = new RemoteWorkspace(client, config.getConnection()); workspace = new RemoteWorkspace(client, config.getConnection());
} }
@ -31,4 +63,30 @@ public class DesignerWorkspaceGenerator {
} }
return workspace; return workspace;
} }
enum RemoteHandler {
SELF;
public static void handle(DesignerWorkspaceInfo config) {
StartErrorMessageCollector.getInstance().record(DesignerErrorMessage.REMOTE_DESIGN_NO_RESPONSE.getId(),
DesignerErrorMessage.REMOTE_DESIGN_NO_RESPONSE.getMessage(),
StringUtils.EMPTY);
int result = FineJOptionPane.showOptionDialog(null,
Toolkit.i18nText("Fine-Design_Error_Remote_No_Response_Tip"),
Toolkit.i18nText("Fine-Design_Basic_Error_Tittle"),
JOptionPane.YES_NO_OPTION,
JOptionPane.ERROR_MESSAGE,
IOUtils.readIcon("com/fr/design/images/error/error2.png"),
new Object[] {Toolkit.i18nText("Fine-Design_Error_Remote_No_Response_Wait"), Toolkit.i18nText("Fine-Design_Error_Remote_No_Response_Switch")},
null);
if (result == JOptionPane.YES_OPTION) {
try {
generate(config);
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
} else {
EnvChangeEntrance.getInstance().dealEvnExceptionWhenStartDesigner();
}
}
}
} }

7
designer-realize/src/main/java/com/fr/design/mainframe/errorinfo/ErrorInfo.java → designer-base/src/main/java/com/fr/design/mainframe/errorinfo/ErrorInfo.java

@ -21,6 +21,9 @@ import java.util.Date;
*/ */
public class ErrorInfo { public class ErrorInfo {
private static final String SUFFIX = ".json";
private static final String FOLDER_NAME = "errorInfo";
private String username; private String username;
private String uuid; private String uuid;
private String activekey; private String activekey;
@ -128,8 +131,8 @@ public class ErrorInfo {
public void saveFileToCache(JSONObject jo) { public void saveFileToCache(JSONObject jo) {
String content = jo.toString(); String content = jo.toString();
String fileName = UUID.randomUUID() + ErrorInfoUploader.SUFFIX; String fileName = UUID.randomUUID() + SUFFIX;
File file = new File(StableUtils.pathJoin(ProductConstants.getEnvHome(), ErrorInfoUploader.FOLDER_NAME, fileName)); File file = new File(StableUtils.pathJoin(ProductConstants.getEnvHome(), FOLDER_NAME, fileName));
FileOutputStream out = null; FileOutputStream out = null;
try (InputStream in = new ByteArrayInputStream(content.getBytes(StandardCharsets.UTF_8))) { try (InputStream in = new ByteArrayInputStream(content.getBytes(StandardCharsets.UTF_8))) {
StableUtils.makesureFileExist(file); StableUtils.makesureFileExist(file);

3
designer-realize/src/main/java/com/fr/design/mainframe/messagecollect/StartErrorMessageCollector.java → designer-base/src/main/java/com/fr/design/mainframe/messagecollect/StartErrorMessageCollector.java

@ -1,8 +1,8 @@
package com.fr.design.mainframe.messagecollect; package com.fr.design.mainframe.messagecollect;
import com.fr.config.MarketConfig;
import com.fr.design.DesignerEnvManager; import com.fr.design.DesignerEnvManager;
import com.fr.design.mainframe.errorinfo.ErrorInfo; import com.fr.design.mainframe.errorinfo.ErrorInfo;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
/** /**
@ -30,6 +30,7 @@ public class StartErrorMessageCollector {
} }
public void record(String id, String msg, String detail) { public void record(String id, String msg, String detail) {
FineLoggerFactory.getLogger().error(id + ": " + msg + "detail: " + detail);
ErrorInfo errorInfo = new ErrorInfo(StringUtils.EMPTY, uuid, activeKey); ErrorInfo errorInfo = new ErrorInfo(StringUtils.EMPTY, uuid, activeKey);
errorInfo.setLogid(id); errorInfo.setLogid(id);
errorInfo.setLog(msg); errorInfo.setLog(msg);

0
designer-realize/src/main/java/com/fr/design/mainframe/messagecollect/entity/DesignerErrorMessage.java → designer-base/src/main/java/com/fr/design/mainframe/messagecollect/entity/DesignerErrorMessage.java

Loading…
Cancel
Save