From f79b56c2532dd0d82fae8115cd5213f853568512 Mon Sep 17 00:00:00 2001 From: yaohwu Date: Sat, 7 May 2022 17:55:23 +0800 Subject: [PATCH 1/2] =?UTF-8?q?REPORT-71028=20=E9=83=A8=E5=88=86execute=20?= =?UTF-8?q?=E5=9F=8B=E7=82=B9=E8=8E=B7=E5=8F=96=E4=B8=8D=E5=88=B0=E9=A2=9D?= =?UTF-8?q?=E5=A4=96=E7=9A=84session=E7=9B=B8=E5=85=B3=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../record/analyzer/advice/MonitorAdvice.java | 56 ++++++------------- 1 file changed, 16 insertions(+), 40 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/record/analyzer/advice/MonitorAdvice.java b/designer-base/src/main/java/com/fr/design/record/analyzer/advice/MonitorAdvice.java index 68f8c8508..b70bf44f9 100644 --- a/designer-base/src/main/java/com/fr/design/record/analyzer/advice/MonitorAdvice.java +++ b/designer-base/src/main/java/com/fr/design/record/analyzer/advice/MonitorAdvice.java @@ -5,22 +5,18 @@ import com.fr.general.GeneralUtils; import com.fr.intelli.measure.Estimator; import com.fr.intelli.metrics.Compute; import com.fr.intelli.metrics.MessageRecorderFactory; +import com.fr.intelli.metrics.SessionBinder; import com.fr.intelli.metrics.SupervisoryConfig; import com.fr.intelli.record.Measurable; import com.fr.intelli.record.MeasureObject; import com.fr.intelli.record.MeasureUnit; import com.fr.log.FineLoggerFactory; import com.fr.measure.DBMeterFactory; -import com.fr.stable.ArrayUtils; import com.fr.stable.StringUtils; -import com.fr.stable.web.Session; -import com.fr.stable.web.SessionProvider; import com.fr.third.net.bytebuddy.asm.Advice; import com.fr.third.net.bytebuddy.implementation.bytecode.assign.Assigner; -import com.fr.web.core.SessionPoolManager; import com.fr.web.session.SessionLocalManager; -import java.lang.annotation.Annotation; import java.lang.reflect.Method; import java.util.ArrayList; import java.util.Arrays; @@ -33,32 +29,31 @@ import java.util.regex.Pattern; * created by Harrison on 2022/03/07 **/ public class MonitorAdvice implements DesignerAnalyzerAdvice { - + private static final Pattern P = Pattern.compile("-?\\d+"); private static final int MIN_ERROR_CODE = 10000000; - + @Advice.OnMethodEnter public static void onMethodEnter(@Advice.Origin Method method, @Advice.AllArguments(typing = Assigner.Typing.DYNAMIC) Object[] args, @Advice.Local("startTime") Long startTime, - @Advice.Local("registeredSession") Boolean registeredSession) { - + @Advice.Local("sessionBinder") SessionBinder sessionBinder) { + startTime = (System.currentTimeMillis()); - registeredSession = (findSessionAnnotation(method, args)); + sessionBinder = new SessionBinder(); + sessionBinder.attachSession(method, args); } - + @Advice.OnMethodExit(onThrowable = Exception.class) public static void onMethodExit(@Advice.This(optional = true, typing = Assigner.Typing.DYNAMIC) Object self, @Advice.Origin Method method, @Advice.AllArguments(typing = Assigner.Typing.DYNAMIC) Object[] args, @Advice.Thrown(typing = Assigner.Typing.DYNAMIC) Exception e, @Advice.Local("startTime") Long startTime, - @Advice.Local("registeredSession") Boolean registeredSession) throws Exception { - + @Advice.Local("sessionBinder") SessionBinder sessionBinder) throws Exception { + String error = StringUtils.EMPTY; - try { - if (e != null) { try { error = getErrorContent(e); @@ -95,14 +90,11 @@ public class MonitorAdvice implements DesignerAnalyzerAdvice { } catch (Exception ignore) { //埋点信息入库失败应该不能影响业务流程 } finally { - if (registeredSession) { - // 如果上面记录了,这里就要释放 - SessionLocalManager.releaseSession(); - } + sessionBinder.detachSession(); } } } - + public static String getErrorContent(Exception e) { int errorCode = GeneralUtils.objectToNumber( extractCodeFromString(e.getMessage()) @@ -110,7 +102,7 @@ public class MonitorAdvice implements DesignerAnalyzerAdvice { // 提取字符串中的第一个数字,最小的错误码为10000000 return e.getClass().getName() + ":" + (errorCode >= MIN_ERROR_CODE ? errorCode : StringUtils.EMPTY); } - + public static String extractCodeFromString(String errorMsg) { Matcher m = P.matcher(errorMsg); if (m.find()) { @@ -118,38 +110,22 @@ public class MonitorAdvice implements DesignerAnalyzerAdvice { } return StringUtils.EMPTY; } - + public static void recordSQLDetail(String uuid) { DBMeterFactory.getMeter().submit(uuid); } - + public static void recordSQL(Compute once, MeasureObject measureObject) { if (SupervisoryConfig.getInstance().isEnableMeasureSql() && once.computeSql()) { measureObject.sqlTime(SessionLocalManager.getSqlTime()); measureObject.sql(SessionLocalManager.getSql()); } } - + public static void recordMemory(Compute once, Measurable measurable, MeasureObject measureObject) { if (SupervisoryConfig.getInstance().isEnableMeasureMemory() && once.computeMemory()) { MeasureUnit unit = measurable.measureUnit(); measureObject.memory(unit.measureMemory()); } } - - public static boolean findSessionAnnotation(Method method, Object[] args) { - Annotation[][] all = method.getParameterAnnotations(); - int len = ArrayUtils.getLength(args); - for (int i = 0; i < len; i++) { - Annotation[] current = all[i]; - for (Annotation annotation : current) { - if (annotation.annotationType().equals(Session.class)) { - SessionLocalManager.setSession( - SessionPoolManager.getSessionIDInfor(GeneralUtils.objectToString(args[i]), SessionProvider.class)); - return true; - } - } - } - return false; - } } From 90875d379d3dbbc1e0489d1a85876b15ea3e6f73 Mon Sep 17 00:00:00 2001 From: shine Date: Mon, 9 May 2022 10:16:12 +0800 Subject: [PATCH 2/2] =?UTF-8?q?REPORT-71075=20fix:=E5=9C=BA=E6=99=AF?= =?UTF-8?q?=E5=9C=B0=E5=9B=BE=E8=B6=85=E9=93=BE=E5=BC=B9=E6=A1=86=E5=92=8C?= =?UTF-8?q?=E6=82=AC=E6=B5=AE=E7=AA=97=E5=9B=BE=E8=A1=A8=E4=B8=80=E4=B8=AA?= =?UTF-8?q?=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../designer/component/VanChartUIListControlPane.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartUIListControlPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartUIListControlPane.java index 823012f58..bfa8b43e9 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartUIListControlPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartUIListControlPane.java @@ -10,6 +10,7 @@ import com.fr.design.gui.itoolbar.UIToolbar; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; +import com.fr.design.mainframe.chart.mode.ChartEditContext; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.stable.Nameable; import com.fr.van.chart.designer.TableLayout4VanChartHelper; @@ -128,7 +129,9 @@ public abstract class VanChartUIListControlPane extends UIListControlPane implem public void populate(Nameable[] nameableArray) { //特殊处理,使用instanceof判断,弹出不同的面板 - if (SwingUtilities.getWindowAncestor(this) instanceof PopupEditDialog) { + //悬浮窗图表弹框 || 场景地图编辑弹框 都是真正的弹框 从if走 + //fvs.chart走super + if (SwingUtilities.getWindowAncestor(this) instanceof JDialog && !ChartEditContext.duchampMode()) { popupEditDialog = new HyperDialog(cardPane); } super.populate(nameableArray); @@ -136,7 +139,7 @@ public abstract class VanChartUIListControlPane extends UIListControlPane implem protected void popupEditDialog(Point mousePos) { //特殊处理,处理连续弹窗情况,弹出面板定为方式不同 - if (SwingUtilities.getWindowAncestor(this) instanceof PopupEditDialog) { + if (SwingUtilities.getWindowAncestor(this) instanceof JDialog && !ChartEditContext.duchampMode()) { GUICoreUtils.centerWindow(popupEditDialog); popupEditDialog.setVisible(true); return;