Browse Source

/*patrol_analyse_log记录每个任务中的每个点位初筛大模型调用详情。*/

master
htjcAdmin 4 months ago
parent
commit
d32c9a386b
5 changed files with 63 additions and 21 deletions
  1. +6
    -0
      inspect-main/inspect-main-task/src/main/java/com/inspect/analysis/constant/AnalyseConstants.java
  2. +7
    -14
      inspect-main/inspect-main-task/src/main/java/com/inspect/analysis/domain/AnalyseLog.java
  3. +11
    -3
      inspect-main/inspect-main-task/src/main/java/com/inspect/analysis/service/impl/AnalyseResponseServiceImpl.java
  4. +32
    -2
      inspect-main/inspect-main-task/src/main/java/com/inspect/partrolresult/service/AnalyseRequestServiceImpl.java
  5. +7
    -2
      inspect-main/inspect-main-task/src/main/resources/mapper/task/ResultAnalysisMapper.xml

+ 6
- 0
inspect-main/inspect-main-task/src/main/java/com/inspect/analysis/constant/AnalyseConstants.java View File

@ -40,6 +40,12 @@ public class AnalyseConstants {
public static final String ANALYSIS_BIG_URL_METER = "ANALYSIS_BIG_URL_METER";
public static final String MAX_NUM = "MAX_NUM";
public static final String ANALYSE_LOG_TYPE_SEND = "0";
public static final String ANALYSE_LOG_TYPE_RECV = "1";
public static final String ANALYSE_LOG_TYPE_OFFLINE = "2";
public static final String ANALYSE_LOG_TYPE_TIMEOUT = "3";
public static final String ALGORITHM_REQUEST_QUEUE = "algorithm:request:queue";
public static final String ALGORITHM_RESPONSE_QUEUE = "algorithm:response:queue";


+ 7
- 14
inspect-main/inspect-main-task/src/main/java/com/inspect/analysis/domain/AnalyseLog.java View File

@ -13,26 +13,17 @@ public class AnalyseLog {
private String taskPatrolId;
private String filter;
private String requestId;
private String objectId;
private String requestUrl;
public AnalyseLog(String content, String type, String taskPatrolId, String filter, String requestId) {
public AnalyseLog(String content, String type, String taskPatrolId, String filter, String requestId, String objectId, String requestUrl) {
this.content = content;
this.type = type;
this.taskPatrolId = taskPatrolId;
this.filter = filter;
this.requestId = requestId;
}
@Override
public boolean equals(Object object) {
if (this == object) return true;
if (object == null || getClass() != object.getClass()) return false;
AnalyseLog that = (AnalyseLog) object;
return Objects.equals(content, that.content) && Objects.equals(type, that.type) && Objects.equals(taskPatrolId, that.taskPatrolId) && Objects.equals(filter, that.filter) && Objects.equals(requestId, that.requestId);
}
@Override
public int hashCode() {
return Objects.hash(content, type, taskPatrolId, filter, requestId);
this.objectId = objectId;
this.requestUrl = requestUrl;
}
@Override
@ -43,6 +34,8 @@ public class AnalyseLog {
", taskPatrolId='" + taskPatrolId + '\'' +
", filter='" + filter + '\'' +
", requestId='" + requestId + '\'' +
", objectId='" + objectId + '\'' +
", requestUrl='" + requestUrl + '\'' +
'}';
}
}

+ 11
- 3
inspect-main/inspect-main-task/src/main/java/com/inspect/analysis/service/impl/AnalyseResponseServiceImpl.java View File

@ -85,7 +85,7 @@ public class AnalyseResponseServiceImpl implements IAnalyseResponseService {
analyseResult.isCompensate(),
analyseResult.getRequestId(),
analyseResult
);
);
redisService.redisTemplate.opsForList().rightPush(
AnalyseConstants.ALGORITHM_RESPONSE_QUEUE,
new Gson().toJson(analyseResult)
@ -127,7 +127,7 @@ public class AnalyseResponseServiceImpl implements IAnalyseResponseService {
analyseRequest.getTaskPatrolId(),
requestId,
analyseRequest);
if(delayQueueService.containRequest(AnalyseConstants.ALGORITHM_REQUEST_DELAY_QUEUE, analyseRequest)) {
if (delayQueueService.containRequest(AnalyseConstants.ALGORITHM_REQUEST_DELAY_QUEUE, analyseRequest)) {
boolean isRemoved = delayQueueService.removeRequest(AnalyseConstants.ALGORITHM_REQUEST_DELAY_QUEUE, analyseRequest);
log.info("ALGORITHM_FILTER_RESULT Redisson Removed requestId: {}, Result: {}, analyseRequest: {}", requestId, isRemoved ? "success" : "fail", analyseRequest);
} else {
@ -205,7 +205,15 @@ public class AnalyseResponseServiceImpl implements IAnalyseResponseService {
//qinyl
try {
analysisLogService.log(new AnalyseLog(analyseResult.toString(), "1", analyseResult.getTaskPatrolId(), analyseResult.getFilter(), requestId));
final String objectId = analyseResult.getResultsList() != null && !analyseResult.getResultsList().isEmpty()
? analyseResult.getResultsList().get(0).getObjectId() : "00000000";
analysisLogService.log(new AnalyseLog(analyseResult.toString(),
analyseResult.isCompensate() ? AnalyseConstants.ANALYSE_LOG_TYPE_TIMEOUT : AnalyseConstants.ANALYSE_LOG_TYPE_RECV,
analyseResult.getTaskPatrolId(),
analyseResult.getFilter(),
requestId,
objectId,
StringUtils.EMPTY));
repositAnalyseAlgorithmResult(analyseResult);
} catch (Exception e) {
log.error("error", e);


+ 32
- 2
inspect-main/inspect-main-task/src/main/java/com/inspect/partrolresult/service/AnalyseRequestServiceImpl.java View File

@ -8,6 +8,8 @@ import java.io.IOException;
import java.util.*;
import java.util.concurrent.TimeUnit;
import com.inspect.analysis.domain.AnalyseLog;
import com.inspect.analysis.service.IAnalyseLogService;
import com.inspect.base.core.constant.AlgConstants;
import com.inspect.base.core.constant.RedisConst;
import com.inspect.base.core.utils.DateUtils;
@ -44,6 +46,9 @@ public class AnalyseRequestServiceImpl implements IAnalyseRequestService {
@Resource
private DelayQueueService<AnalyseRequest> delayQueueService;
@Resource
private IAnalyseLogService analysisLogService;
//qinyl
public void sendRequest(AnalyseRequest analyseReq, String[] typeList, boolean isFilter) throws IOException {
final long requestTimeout = 1L;
@ -124,10 +129,35 @@ public class AnalyseRequestServiceImpl implements IAnalyseRequestService {
delayQueueService.submitRequest(AnalyseConstants.ALGORITHM_REQUEST_DELAY_QUEUE, analyseReq, requestTimeout, TimeUnit.DAYS);
}
if (!retryDelegate.callRemoteAnalyseService(analyseReq)) {
log.info("FINALLY FAIL CALL REMOTE ANALYSE SERVICE, requestId: {}, taskPatrolId: {}",
if (retryDelegate.callRemoteAnalyseService(analyseReq)) {
log.info("CALL_REMOTE_ANALYSE SUCCESS, requestId: {}, taskPatrolId: {}",
analyseReq.getRequestId(),
analyseReq.getTaskPatrolId());
final String objectId = analyseReq.getObjectList() != null && !analyseReq.getObjectList().isEmpty()
? analyseReq.getObjectList().get(0).getObjectId() : "00000000";
analysisLogService.log(
new AnalyseLog(("远端算法服务器收到请求"),
AnalyseConstants.ANALYSE_LOG_TYPE_SEND,
analyseReq.getTaskPatrolId(),
analyseReq.isFilter() ? "1" : "0",
requestId,
objectId,
requestUrl));
} else {
log.info("CALL_REMOTE_ANALYSE RETRYABLE FAIL, requestId: {}, taskPatrolId: {}",
analyseReq.getRequestId(),
analyseReq.getTaskPatrolId());
final String objectId = analyseReq.getObjectList() != null && !analyseReq.getObjectList().isEmpty()
? analyseReq.getObjectList().get(0).getObjectId() : "00000000";
analysisLogService.log(
new AnalyseLog(analyseReq.isFilter() ? ("初筛远程服务器掉线") : ("大模型远程服务器掉线"),
AnalyseConstants.ANALYSE_LOG_TYPE_OFFLINE,
analyseReq.getTaskPatrolId(),
analyseReq.isFilter() ? "1" : "0",
requestId,
objectId,
requestUrl));
throw new IOException("Remote analyse service failed");
}
}


+ 7
- 2
inspect-main/inspect-main-task/src/main/resources/mapper/task/ResultAnalysisMapper.xml View File

@ -560,9 +560,14 @@
</select>
<!-- <insert id="insertAnalyseLog" parameterType="com.inspect.analysis.domain.AnalyseLog">-->
<!-- insert into patrol_analyse_log (content,type,create_time,task_patrol_id,filter,request_id)-->
<!-- values(#{content},#{type},now(),#{taskPatrolId},#{filter},#{requestId})-->
<!-- </insert>-->
<insert id="insertAnalyseLog" parameterType="com.inspect.analysis.domain.AnalyseLog">
insert into patrol_analyse_log (content,type,create_time,task_patrol_id,filter,request_id)
values(#{content},#{type},now(),#{taskPatrolId},#{filter},#{requestId})
insert into patrol_analyse_log (task_patrol_id,object_id,request_id,request_url,filter,type,content,create_time)
values(#{taskPatrolId},#{objectId},#{requestId},#{requestUrl},#{filter},#{type},#{content},now())
</insert>
<select id="selectTaskAbnormalData" parameterType="ResultAnalysis" resultMap="ResultAnalysisResult">


Loading…
Cancel
Save