Browse Source

Pull request #9164: REPORT-73396【设计器环境监测】删除fine-decision-11.0,触发的是重置finedb

Merge in DESIGN/design from ~HARRISON/design:feature/x to feature/x

* commit '5398db8af809b7aaaba73621a0c6052cc3efabdd':
  REPORT-73396【设计器环境监测】删除fine-decision-11.0,触发的是重置finedb 恢复一个字段
  REPORT-73396【设计器环境监测】删除fine-decision-11.0,触发的是重置finedb 通过守护进程,处理一下设计器启动不了且没有直接报错的场景。 (mac 下还是有问题,守护进程不支持 mac
feature/x
Harrison 2 years ago
parent
commit
430cf576cf
  1. 13
      designer-base/src/main/java/com/fr/env/detect/EnvDetectorCenter.java
  2. 66
      designer-base/src/main/java/com/fr/exit/DesignerExiter.java
  3. 6
      designer-realize/src/main/java/com/fr/start/DesignerSubListener.java
  4. 1
      designer-realize/src/main/java/com/fr/start/DesignerSuperListener.java

13
designer-base/src/main/java/com/fr/env/detect/EnvDetectorCenter.java vendored

@ -54,7 +54,6 @@ public class EnvDetectorCenter {
}
};
private final Listener<Null> START_UP_COMPLETE_LISTENER = new Listener<Null>() {
@Override
@ -196,6 +195,18 @@ public class EnvDetectorCenter {
.collect(Collectors.toList());
}
/**
* 预期外的终止
*
* @return 检测结果
*/
public List<DetectorResult> terminateUnexpectedly() {
Stream<DetectorResult> resultStream = DetectorBridge.getInstance().detect();
return resultStream
.filter((e) -> e.getStatus() == DetectorStatus.EXCEPTION)
.collect(Collectors.toList());
}
private void listen() {

66
designer-base/src/main/java/com/fr/exit/DesignerExiter.java

@ -17,7 +17,9 @@ import com.fr.log.FineLoggerFactory;
import com.fr.process.engine.core.FineProcessContext;
import com.fr.process.engine.core.FineProcessEngineEvent;
import java.util.ArrayList;
import java.util.List;
import java.util.function.Supplier;
/**
* @author hades
@ -32,16 +34,43 @@ public class DesignerExiter {
return INSTANCE;
}
/**
* 预期外的退出
* 首先检测是否有检测到的异常如果没有则运行默认行为
*
* @param defaultAction 默认行为
*/
public void exitUnexpectedly(Runnable defaultAction) {
// 尝试进行检测
List<DetectorResult> results = runAndGet(() -> EnvDetectorCenter.getInstance().terminateUnexpectedly(), ArrayList::new);
try {
if (!Collections.isEmpty(results)) {
showNewExitDialog(results);
}
} finally {
// 正常的话上面会直接退出, system.exit(0)
// 只有异常,或者不命中,才会走到这里
defaultAction.run();
}
}
public void exit(Throwable throwable) {
FineLoggerFactory.getLogger().error(throwable.getMessage(), throwable);
doThrowableAction(() -> {
FineLoggerFactory.getLogger().error(throwable.getMessage(), throwable);
}, () -> {
throwable.printStackTrace(System.err);
});
StartErrorMessageCollector.getInstance().record(DesignerErrorMessage.UNEXCEPTED_START_FAILED.getId(),
DesignerErrorMessage.UNEXCEPTED_START_FAILED.getMessage(),
throwable.getMessage());
doThrowableAction(() -> {
StartErrorMessageCollector.getInstance().record(DesignerErrorMessage.UNEXCEPTED_START_FAILED.getId(),
DesignerErrorMessage.UNEXCEPTED_START_FAILED.getMessage(),
throwable.getMessage());
});
// 尝试进行检测
List<DetectorResult> results = EnvDetectorCenter.getInstance().terminate(throwable);
List<DetectorResult> results = runAndGet(() -> EnvDetectorCenter.getInstance().terminate(throwable), ArrayList::new);
if (Collections.isEmpty(results)) {
// 为空,则
@ -89,4 +118,31 @@ public class DesignerExiter {
private void beforeExit() {
DesignerWorkspaceGenerator.stop();
}
/* 忽视异常的调用方法 */
private void doThrowableAction(Runnable runnable) {
doThrowableAction(runnable, null);
}
private void doThrowableAction(Runnable runnable, Runnable defaultRunnable) {
try {
runnable.run();
} catch (Throwable ignore) {
if (defaultRunnable != null) {
defaultRunnable.run();
}
}
}
private <T> T runAndGet(Supplier<T> supplier, Supplier<T> defaultCallable) {
try {
return supplier.get();
} catch (Exception ignore) {
return defaultCallable.get();
}
}
}

6
designer-realize/src/main/java/com/fr/start/DesignerSubListener.java

@ -4,6 +4,7 @@ import com.fr.design.mainframe.DesignerContext;
import com.fr.event.Event;
import com.fr.event.Listener;
import com.fr.event.Null;
import com.fr.exit.DesignerExiter;
import com.fr.process.engine.core.CarryMessageEvent;
import com.fr.process.engine.core.FineProcessContext;
import com.fr.process.engine.core.FineProcessEngineEvent;
@ -31,7 +32,10 @@ public class DesignerSubListener {
@Override
public void on(Event event, Null param) {
if (DesignerContext.getDesignerFrame() == null || !DesignerContext.getDesignerFrame().isShowing()) {
FineProcessContext.getParentPipe().fire(new CarryMessageEvent(DesignerProcessType.INSTANCE.obtain()));
DesignerExiter.getInstance().exitUnexpectedly(() -> {
FineProcessContext.getParentPipe().fire(new CarryMessageEvent(DesignerProcessType.INSTANCE.obtain()));
});
}
}
});

1
designer-realize/src/main/java/com/fr/start/DesignerSuperListener.java

@ -95,6 +95,7 @@ public class DesignerSuperListener {
public void run() {
cancel = true;
ProcessEventPipe pipe = process.getPipe();
// 确认设计器是否启动完成
pipe.fire(FineProcessEngineEvent.READY);
if (StringUtils.isNotEmpty(pipe.info())) {
frameReport();

Loading…
Cancel
Save