taskFinishAgentNum = new ConcurrentHashMap<>();
+
+
+ @Resource
+ private SlaService slaService;
+
+ @Resource
+ private ManagerService managerService;
+
+ @Override
+ public RemotingCommand processRequest(ChannelHandlerContext channelHandlerContext, RemotingCommand remotingCommand) throws InterruptedException {
+ AgentReq req = remotingCommand.getReq(AgentReq.class);
+ String logMsg = logPrefix + "processRequest ";
+ switch (req.getCmd()) {
+ case AgentReq.TASK_RESULT_CMD ->//处理完成返回结果事件
+ processTREvent(req, logMsg);
+ case AgentReq.TOTAL_DATA_COUNT_CMD ->//处理数据统计事件
+ dataStatService.processTotalCountCtxEvent(req);
+ case AgentReq.UP_TASK_STATUS ->//处理任务状态变更事件
+ processUpStatusEvent(req, logMsg);
+ }
+ return null;
+ }
+
+
+ private synchronized void processTREvent(AgentReq req, String logMsg) {
+ //处理回调过来的返回数据
+ TaskResult tr = req.getTaskResult();
+ try {
+ MibenchTask task = dao.fetch(MibenchTask.class, tr.getId());
+ //场景调试的情况
+ if (tr.isDebug()) {
+ // 更新场景接口结果数据 调用 dashboard 接口,更新scene api info debug result
+ if (tr.getSuccess().get() == 1) {
+ task.setState(TaskStatus.Success.code);
+ } else if (tr.getFailure().get() == 1) {
+ task.setState(TaskStatus.Failure.code);
+ }
+ task.setOk(tr.isOk());
+ CommonReqInfo commonReqInfo = tr.getCommonReqInfo();
+ if (commonReqInfo != null) {
+ task.setReqParamType(commonReqInfo.getParamsType());
+ task.setRequestParams(commonReqInfo.getParamJson());
+ if (commonReqInfo.getHeaders() != null) {
+ task.setDebugReqHeaders(gson.toJson(commonReqInfo.getHeaders()));
+ }
+ if (commonReqInfo.getDebugUrl() != null){
+ task.setDebugUrl(commonReqInfo.getDebugUrl());
+ }
+ }
+ task.setDebugResult(tr.getResult());
+ if (tr.getRespHeaders() != null) {
+ task.setDebugResultHeader(gson.toJson(tr.getRespHeaders()));
+ }
+ if (tr.getTriggerCpInfo() != null) {
+ task.setDebugTriggerCp(tr.getTriggerCpInfo());
+ }
+ if (tr.getTriggerFilterCondition() != null){
+ task.setDebugTriggerFilterCondition(tr.getTriggerFilterCondition());
+ }
+ task.setDebugRt((int) tr.getRt());
+ task.setDebugSize((int) tr.getSize());
+ dao.update(task);
+ } else {
+ //执行压测的情况下
+ String quitMsg = "";
+ int finNum = countTaskFinAgent(task.getId());
+ if (checkBenchTaskFinish(finNum, task.getAgentNum())) {
+ //即该链路任务全部执行结束
+ task.setState(TaskStatus.Success.code);
+ //结束链路任务状态
+ dao.update(task);
+ //手动结束 需要通知结束报告
+ if (tr.isQuitByManual()) {
+ //手动的需要通知sla任务停止
+ if (tr.getCancelType() == CancelType.Manual.code) {
+ slaService.stopSlaTaskByManual(tr.getReportId());
+ quitMsg = "当前压测任务已手动停止,操作人: " + tr.getOpUser() + ",停止时间: " + getDateTime(System.currentTimeMillis());
+ }
+ if (tr.getCancelType() == CancelType.BySla.code) {
+ slaService.slaTaskFinish(tr.getReportId());
+ quitMsg = "当前压测任务触发SLA警报已停止,触发规则: " + tr.getCancelBySlaRule() + ",停止时间: " + getDateTime(System.currentTimeMillis());
+ }
+ } else {
+ //自然结束
+ //更新场景状态
+ sceneInfoService.updateSceneStatus(tr.getSceneId(), TaskStatus.Success.code);
+
+ slaService.slaTaskFinish(tr.getReportId());
+ quitMsg = "当前压测任务已完成,结束时间: " + getDateTime(System.currentTimeMillis());
+ }
+ //检查整个场景全部任务是否完成
+ int finishTaskNum;
+ if (reportFinishNum.containsKey(task.getReportId())) {
+ finishTaskNum = reportFinishNum.get(task.getReportId()).incrementAndGet();
+ } else {
+ reportFinishNum.put(task.getReportId(), new AtomicInteger(1));
+ finishTaskNum = reportFinishNum.get(task.getReportId()).get();
+ }
+ if (finishTaskNum >= task.getConnectTaskNum()) {
+ //本次压测所有任务完成再通知dashboard
+ try {
+ this.notifyFinish(task, quitMsg);
+ } catch (Exception e) {
+ log.error(logMsg + "======FAILED TO NOTIFY FINISH!", e);
+ }
+ }
+ }
+ }
+ } catch (Exception ex) {
+ log.error(logMsg + " throws error cmd " + req.getCmd() + "; " + ex.getMessage());
+ }
+ }
+
+ private void processUpStatusEvent(AgentReq req, String logMsg) {
+ //更新状态
+ try {
+ TaskStatusBo statusBo = req.getStatusBo();
+ log.info("processUpStatusEvent task id :{}", statusBo.getTaskId());
+ MibenchTask dagTask = dao.fetch(MibenchTask.class, statusBo.getTaskId());
+ log.info("processUpStatusEvent dag task :{}", dagTask);
+ if (dagTask == null){
+ Thread.sleep(500);
+ dagTask = dao.fetch(MibenchTask.class, statusBo.getTaskId());
+ }
+ if (dagTask == null){
+ log.error("processUpStatusEvent dag is null");
+ return;
+ }
+ dagTask.setState(statusBo.getTaskStatus().code);
+ dagTask.setUtime(System.currentTimeMillis());
+ int v = dao.update(dagTask);
+ if (v > 0) {
+ if (statusBo.getTaskStatus() == TaskStatus.Stopped) {
+ //已经停止,更新场景状态为 停止
+ sceneInfoService.updateSceneStatus(statusBo.getSceneId(), TaskStatus.Stopped.code);
+ }else if (statusBo.getTaskStatus() == TaskStatus.Running){
+ //任务启动
+ log.info("taskRunningNotify in bench mode:{},increase mode :{},dagTask increasePercent:{}", dagTask.getBenchMode(),dagTask.getIncreaseMode(),dagTask.getIncreasePercent());
+ managerService.taskRunningNotify(dagTask);
+ }
+ log.info(logMsg + "update task cmd " + req.getCmd());
+ }
+ } catch (Exception ex) {
+ log.error(logMsg + " throws error cmd " + req.getCmd() + "; " + ex.getMessage());
+ }
+ }
+
+ /**
+ * 累计该任务执行完成的压测机数量
+ */
+ private int countTaskFinAgent(int taskId) {
+// synchronized (taskFinishAgentNum) {
+ if (!taskFinishAgentNum.containsKey(taskId)) {
+ taskFinishAgentNum.put(taskId, new AtomicInteger(1));
+ return 1;
+ } else {
+ return taskFinishAgentNum.get(taskId).incrementAndGet();
+ }
+// }
+ }
+
+ private static boolean checkBenchTaskFinish(int finNum, int useAgentNum) {
+ return finNum >= useAgentNum;
+ }
+
+ private void notifyFinish(MibenchTask task, String quitMsg) {
+ //扣除前期大概的初始化时间
+ long now = System.currentTimeMillis() - 500;
+ this.benchBroadcastService.notifyEvent(EmitterTypeEnum.FINISH, task.getReportId(), ReportInfoBo.builder()
+ .sceneId((long) task.getSceneId())
+ .reportId(task.getReportId())
+ .duration((int) ((now - task.getCtime()) / 1000))
+ .finishTime(now)
+ .extra(quitMsg)
+ .build());
+ }
+
+ private String getDateTime(long now) {
+ Date millisecondDate = new Date(now);
+ SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+ return formatter.format(millisecondDate);
+ }
+
+ @Override
+ public boolean rejectRequest() {
+ return false;
+ }
+
+ @Override
+ public int cmdId() {
+ return MibenchCmd.MANAGER;
+ }
+}
diff --git a/ozburst-all/mimeter-engine/mimeter-agent-manager/src/main/java/run/mone/mimeter/agent/manager/processor/PingProcessor.java b/ozburst-all/mimeter-engine/mimeter-agent-manager/src/main/java/run/mone/mimeter/agent/manager/processor/PingProcessor.java
new file mode 100644
index 000000000..028ac02db
--- /dev/null
+++ b/ozburst-all/mimeter-engine/mimeter-agent-manager/src/main/java/run/mone/mimeter/agent/manager/processor/PingProcessor.java
@@ -0,0 +1,157 @@
+/*
+ * Copyright 2020 Xiaomi
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package run.mone.mimeter.agent.manager.processor;
+
+import com.google.common.collect.Lists;
+import com.xiami.mione.tesla.k8s.service.K8sProxyService;
+import com.xiaomi.data.push.context.AgentContext;
+import com.xiaomi.data.push.rpc.common.RemotingHelper;
+import com.xiaomi.data.push.rpc.netty.AgentChannel;
+import com.xiaomi.data.push.rpc.netty.NettyRequestProcessor;
+import com.xiaomi.data.push.rpc.protocol.RemotingCommand;
+import com.xiaomi.mione.tesla.k8s.bo.PodNode;
+import com.xiaomi.youpin.docean.anno.Component;
+import com.xiaomi.youpin.docean.plugin.dubbo.anno.Reference;
+import io.netty.channel.ChannelHandlerContext;
+import org.nutz.dao.Cnd;
+import org.nutz.dao.impl.NutDao;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.BeanUtils;
+import org.springframework.util.StringUtils;
+import run.mone.mimeter.agent.manager.bo.AgentInfo;
+import run.mone.mimeter.engine.agent.bo.data.AgentInfoDTO;
+import run.mone.mimeter.engine.agent.bo.data.AgentReq;
+import run.mone.mimeter.engine.agent.bo.MibenchCmd;
+
+import javax.annotation.Resource;
+import java.nio.charset.StandardCharsets;
+import java.util.List;
+import java.util.Optional;
+
+/**
+ * @author goodjava@qq.com
+ * @date 2022/5/11
+ *
+ * 处理agent 发过来的ping信息
+ */
+@Component
+public class PingProcessor implements NettyRequestProcessor {
+
+ private static final Logger log = LoggerFactory.getLogger(PingProcessor.class);
+
+
+ @Reference(interfaceClass = K8sProxyService.class, group = "${k8s.proxy.dubbo.group}", timeout = 10000, check = false)
+ private K8sProxyService k8sProxyService;
+
+ @Resource(name = "$daoName:mibench_st_db", description = "mysql")
+ private NutDao dao;
+
+ @Override
+ public RemotingCommand processRequest(ChannelHandlerContext ctx, RemotingCommand remotingCommand) throws Exception {
+ AgentReq req = remotingCommand.getReq(AgentReq.class);
+ Optional.ofNullable(req.getUser()).ifPresent(it -> {
+ log.info("client:{} ping", req.getUser().getName());
+ final String remoteAddress = RemotingHelper.parseChannelRemoteAddr(ctx.channel());
+ AgentChannel ch = AgentContext.ins().map.get(remoteAddress);
+ if (null == ch) {
+ ch = new AgentChannel();
+ ch.setChannel(ctx.channel());
+ AgentContext.ins().map.putIfAbsent(remoteAddress, ch);
+ }
+ // 机器信息入库
+ insertAgentInfoToDB(req);
+ });
+
+ RemotingCommand res = RemotingCommand.createResponseCommand(100, "ok");
+ res.setBody("ok".getBytes(StandardCharsets.UTF_8));
+ return res;
+ }
+
+ @Override
+ public boolean rejectRequest() {
+ return false;
+ }
+
+ @Override
+ public int cmdId() {
+ return MibenchCmd.PING;
+ }
+
+ /**
+ * agent入库
+ *
+ * @param req
+ */
+ private void insertAgentInfoToDB(AgentReq req) {
+ try {
+ AgentInfoDTO agentInfoDTO = req.getAgentInfoDTO();
+ long now = System.currentTimeMillis();
+ if (agentInfoDTO.getIp() == null || agentInfoDTO.getIp().equals("")) {
+ return;
+ }
+
+ String nodeIp = "";
+ List agents = k8sProxyService.getNodeIP(Lists.newArrayList(agentInfoDTO.getIp())).getData();
+ if (agents != null && agents.size() != 0) {
+ log.info("[PingProcessor.insertAgentInfoToDB], getNodeIP agents: {}, podIp: {}", agents, agentInfoDTO.getIp());
+ nodeIp = agents.get(0).getNodeIP();
+ } else {
+ //如果最终获取不到nodeId
+ nodeIp = agentInfoDTO.getIp() + "_" + agentInfoDTO.getDesc();
+ }
+ AgentInfo agentInfo = StringUtils.isEmpty(nodeIp)
+ ? null
+ : dao.fetch(AgentInfo.class, Cnd.where("node_ip", "=", nodeIp));
+
+ if (agentInfo != null) {
+ //更新
+ agentInfo.setUseCpu(agentInfoDTO.getUseCpu());
+ agentInfo.setUseMem(agentInfoDTO.getUseMem());
+ agentInfo.setIp(agentInfoDTO.getIp());
+ agentInfo.setEnable(true);
+ agentInfo.setUtime(now);
+ agentInfo.setClientDesc(agentInfoDTO.getDesc());
+ log.info("old !!! update agent info podIp:{}, nodeIp:{}, agentInfo: {}", agentInfoDTO.getIp(), nodeIp, agentInfo);
+ dao.update(agentInfo);
+ } else {
+ AgentInfo ipAgentInfo = dao.fetch(AgentInfo.class, Cnd.where("ip", "=", agentInfoDTO.getIp()));
+ if (ipAgentInfo != null) {
+ ipAgentInfo.setNodeIp(nodeIp);
+ ipAgentInfo.setUtime(now);
+ ipAgentInfo.setEnable(true);
+ log.info("new !!! update agent info podIp:{},nodeIp:{}", agentInfoDTO.getIp(), nodeIp);
+ dao.update(ipAgentInfo);
+ } else {
+ agentInfo = new AgentInfo();
+ BeanUtils.copyProperties(agentInfoDTO, agentInfo);
+ agentInfo.setCtime(now);
+ agentInfo.setUtime(now);
+ agentInfo.setEnable(true);
+ agentInfo.setClientDesc(agentInfoDTO.getDesc());
+ agentInfo.setNodeIp(nodeIp);
+ log.info("new!!! insert agent info podIp:{},nodeIp:{}", agentInfoDTO.getIp(), nodeIp);
+ dao.insert(agentInfo);
+ }
+ }
+ } catch (Exception e) {
+ log.error("update agent info error:{}", e.getMessage());
+ }
+ }
+
+
+}
diff --git a/ozburst-all/mimeter-engine/mimeter-agent-manager/src/main/resources/upload.html b/ozburst-all/mimeter-engine/mimeter-agent-manager/src/main/resources/upload.html
new file mode 100644
index 000000000..05ed87388
--- /dev/null
+++ b/ozburst-all/mimeter-engine/mimeter-agent-manager/src/main/resources/upload.html
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/ozburst-all/mimeter-engine/mimeter-agent-service/pom.xml b/ozburst-all/mimeter-engine/mimeter-agent-service/pom.xml
new file mode 100644
index 000000000..588b5030c
--- /dev/null
+++ b/ozburst-all/mimeter-engine/mimeter-agent-service/pom.xml
@@ -0,0 +1,156 @@
+
+
+
+ mimeter-engine
+ run.mone
+ 1.0-SNAPSHOT
+
+ 4.0.0
+
+ mimeter-agent-service
+
+
+
+
+
+
+
+
+
+ run.mone
+ mimeter-api
+ 1.0-SNAPSHOT
+
+
+
+ com.xiaomi.youpin
+ tesla-filter-api
+ 1.0.1-SNAPSHOT
+
+
+ run.mone
+ mimeter-dashboard-api
+ 1.0.0-SNAPSHOT
+
+
+ com.xiaomi.youpin
+ youpin-infra-rpc
+
+
+
+
+
+ javax.annotation
+ javax.annotation-api
+ 1.3.2
+ provided
+
+
+
+ ch.qos.logback
+ logback-classic
+ 1.1.2
+ provided
+
+
+
+ ch.qos.logback
+ logback-core
+ 1.1.2
+ provided
+
+
+
+ junit
+ junit
+ 4.12
+ test
+
+
+
+ run.mone
+ log
+ 1.6.1-SNAPSHOT
+
+
+
+ run.mone
+ event
+ 1.4-SNAPSHOT
+
+
+
+ com.xiaomi.mone
+ sautumn-serverless-api
+ 1.0.0-SNAPSHOT
+ provided
+
+
+
+ run.mone
+ docean
+ 1.4-SNAPSHOT
+
+
+
+
+ run.mone
+ http
+ 1.4-SNAPSHOT
+
+
+ fastjson
+ com.alibaba
+
+
+
+
+
+
+ run.mone
+ docean-plugin-rpc
+ 1.4-SNAPSHOT
+ provided
+
+
+
+ com.xiaomi.youpin
+ prometheus-client
+ 0.0.5-SNAPSHOT
+
+
+
+ com.google.guava
+ guava
+ 25.1-jre
+ provided
+
+
+
+ run.mone
+ antlr
+ 1.4-SNAPSHOT
+
+
+
+ com.xiaomi.youpin
+ hera-trace
+ 1.4-SNAPSHOT
+
+
+
+ com.xiaomi.youpin
+ tesla-traffic-recording-api
+ 1.0.0-SNAPSHOT
+
+
+ org.apache.dubbo
+ dubbo
+
+
+
+
+
+
\ No newline at end of file
diff --git a/ozburst-all/mimeter-engine/mimeter-agent-service/src/main/java/run/mone/mimeter/engine/bo/DataMapCache.java b/ozburst-all/mimeter-engine/mimeter-agent-service/src/main/java/run/mone/mimeter/engine/bo/DataMapCache.java
new file mode 100644
index 000000000..f47cc97d1
--- /dev/null
+++ b/ozburst-all/mimeter-engine/mimeter-agent-service/src/main/java/run/mone/mimeter/engine/bo/DataMapCache.java
@@ -0,0 +1,18 @@
+package run.mone.mimeter.engine.bo;
+
+import lombok.Data;
+
+import java.util.List;
+import java.util.TreeMap;
+import java.util.concurrent.atomic.AtomicInteger;
+
+@Data
+public class DataMapCache {
+ private AtomicInteger countFinLinkNum;
+ private TreeMap> dataMap;
+
+ public DataMapCache(AtomicInteger countFinLinkNum, TreeMap> dataMap) {
+ this.countFinLinkNum = countFinLinkNum;
+ this.dataMap = dataMap;
+ }
+}
diff --git a/ozburst-all/mimeter-engine/mimeter-agent-service/src/main/java/run/mone/mimeter/engine/bo/TaskStatus.java b/ozburst-all/mimeter-engine/mimeter-agent-service/src/main/java/run/mone/mimeter/engine/bo/TaskStatus.java
new file mode 100644
index 000000000..addfec207
--- /dev/null
+++ b/ozburst-all/mimeter-engine/mimeter-agent-service/src/main/java/run/mone/mimeter/engine/bo/TaskStatus.java
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2020 Xiaomi
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package run.mone.mimeter.engine.bo;
+
+/**
+ *
+ * @author zhangzhiyong
+ * @date 29/05/2018
+ */
+public enum TaskStatus {
+ Init(0),
+ Success(1),
+ Failure(2),
+ Retry(3),
+ Running(4),
+ ;
+
+ public int code;
+
+ private TaskStatus(int code) {
+ this.code = code;
+ }
+}
diff --git a/ozburst-all/mimeter-engine/mimeter-agent-service/src/main/java/run/mone/mimeter/engine/client/base/BaseClient.java b/ozburst-all/mimeter-engine/mimeter-agent-service/src/main/java/run/mone/mimeter/engine/client/base/BaseClient.java
new file mode 100644
index 000000000..05c08b250
--- /dev/null
+++ b/ozburst-all/mimeter-engine/mimeter-agent-service/src/main/java/run/mone/mimeter/engine/client/base/BaseClient.java
@@ -0,0 +1,214 @@
+package run.mone.mimeter.engine.client.base;
+
+import com.google.common.collect.Lists;
+import com.xiaomi.youpin.docean.Ioc;
+import com.xiaomi.youpin.docean.anno.Component;
+import com.xiaomi.youpin.docean.listener.event.EventType;
+import lombok.extern.slf4j.Slf4j;
+import run.mone.mimeter.engine.agent.bo.data.CommonReqInfo;
+import run.mone.mimeter.engine.agent.bo.data.Result;
+import run.mone.mimeter.engine.agent.bo.stat.SceneTotalCountContext;
+import run.mone.mimeter.engine.agent.bo.task.Task;
+import run.mone.mimeter.engine.agent.bo.task.TaskContext;
+import run.mone.mimeter.engine.filter.common.BasePostFilter;
+import run.mone.mimeter.engine.filter.common.BasePreFilter;
+import run.mone.mimeter.engine.filter.common.FilterOrder;
+import run.mone.mimeter.engine.filter.common.MimeterFilterInfo;
+import run.mone.mimeter.engine.filter.postFilter.IPostFilterChain;
+import run.mone.mimeter.engine.filter.postFilter.PostFilterAnno;
+import run.mone.mimeter.engine.filter.postFilter.filters.MimeterPostFilter;
+import run.mone.mimeter.engine.filter.preFilter.filters.MimeterPreFilter;
+import run.mone.mimeter.engine.filter.postFilter.PostFilter;
+import run.mone.mimeter.engine.filter.preFilter.IPreFilterChain;
+import run.mone.mimeter.engine.filter.preFilter.PreFilter;
+import run.mone.mimeter.engine.filter.preFilter.PreFilterAnno;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.CopyOnWriteArrayList;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.stream.Collectors;
+
+/**
+ * @author dongzhenxing
+ */
+@Slf4j
+@Component
+public class BaseClient implements IClient, IPreFilterChain, IPostFilterChain {
+
+ private final CopyOnWriteArrayList preFilterList = new CopyOnWriteArrayList<>();
+
+ private final CopyOnWriteArrayList postFilterList = new CopyOnWriteArrayList<>();
+
+
+ private volatile BasePreFilter lastFilter;
+
+ private volatile BasePostFilter firstFilter;
+
+ /**
+ * 前置过滤器链是否初始化完成
+ */
+ private final AtomicBoolean preFilterInit = new AtomicBoolean(false);
+
+ /**
+ * 后置过滤器链是否初始化完成
+ */
+ private final AtomicBoolean postFilterInit = new AtomicBoolean(false);
+
+
+ @Override
+ public Result call(Task task, TaskContext context, CommonReqInfo commonReqInfo, SceneTotalCountContext totalCountContext) {
+ return Result.success("ok");
+ }
+
+ @Override
+ public CommonReqInfo doPreFilter(Task task,TaskContext context, CommonReqInfo reqInfo) {
+ if (!preFilterInit.get()) {
+ //filter 没加载完成,使用原参数
+ return reqInfo;
+ }
+ try {
+ return this.lastFilter.doFilter(task, context,reqInfo);
+ } catch (Exception e) {
+ log.error("do filter failed:{}", e.getMessage());
+ //filter 执行错误,使用原参数
+ return reqInfo;
+ }
+ }
+
+ @Override
+ public Object doPostFilter(Task task, Object resInfo) {
+ if (!postFilterInit.get()) {
+ //filter 没加载完成,返回结果不做处理
+ return resInfo;
+ }
+ try {
+ return this.firstFilter.doFilter(task, resInfo);
+ } catch (Exception e) {
+ log.error("do filter failed:{}", e.getMessage());
+ //filter 执行错误,使用原参数
+ return resInfo;
+ }
+ }
+
+ public void init() {
+ //加载前置过滤器
+ this.loadPreFilter();
+
+ //加载后置过滤器
+ this.loadPostFilter();
+ }
+
+ private void loadPreFilter() {
+ Ioc bizIoc = Ioc.ins().getBean("bizIoc");
+ bizIoc.regListener(event -> {
+ if (event.getEventType().equals(EventType.initFinish)){
+ Map preFilterMaps = bizIoc.getBeansWithAnnotation(PreFilterAnno.class);
+ List