|
67 | 67 | import java.util.concurrent.Executors; |
68 | 68 | import java.util.concurrent.ScheduledExecutorService; |
69 | 69 | import java.util.concurrent.TimeUnit; |
| 70 | +import java.util.stream.Collectors; |
70 | 71 |
|
71 | 72 | /** |
72 | 73 | * Audit service layer implementation |
@@ -116,6 +117,10 @@ public Boolean refreshBaseItemCache() { |
116 | 117 | auditIndicatorMap.clear(); |
117 | 118 | List<AuditInformation> auditInformationList = AuditOperator.getInstance().getAllAuditInformation(); |
118 | 119 | List<AuditInformation> metricInformationList = AuditOperator.getInstance().getAllMetricInformation(); |
| 120 | + List<AuditInformation> cdcMetricInformationList = AuditOperator.getInstance().getAllCdcIdInformation(); |
| 121 | + cdcMetricInformationList.forEach(v -> { |
| 122 | + auditItemMap.put(String.valueOf(v.getAuditId()), v.getNameInChinese()); |
| 123 | + }); |
119 | 124 | auditInformationList.forEach(v -> { |
120 | 125 | auditItemMap.put(String.valueOf(v.getAuditId()), v.getNameInChinese()); |
121 | 126 | }); |
@@ -193,6 +198,15 @@ public List<AuditVO> listByCondition(AuditRequest request) throws Exception { |
193 | 198 | // properly overwrite audit ids by role and stream config |
194 | 199 | if (InlongConstants.DATASYNC_REALTIME_MODE.equals(groupEntity.getInlongGroupMode()) |
195 | 200 | || InlongConstants.DATASYNC_OFFLINE_MODE.equals(groupEntity.getInlongGroupMode())) { |
| 201 | + List<AuditInformation> cdcAuditInfoList = |
| 202 | + getCdcAuditInfoList(sourceNodeType, IndicatorType.RECEIVED_SUCCESS); |
| 203 | + List<String> cdcAuditIdList = |
| 204 | + cdcAuditInfoList.stream().map(v -> String.valueOf(v.getAuditId())) |
| 205 | + .collect(Collectors.toList()); |
| 206 | + if (CollectionUtils.isNotEmpty(cdcAuditIdList)) { |
| 207 | + String tempSourceNodeType = sourceNodeType; |
| 208 | + cdcAuditIdList.forEach(v -> auditIdMap.put(v, tempSourceNodeType)); |
| 209 | + } |
196 | 210 | auditIdMap.put(getAuditId(sourceNodeType, IndicatorType.RECEIVED_SUCCESS), sourceNodeType); |
197 | 211 | request.setAuditIds(getAuditIds(groupId, streamId, sourceNodeType, sinkNodeType)); |
198 | 212 | } else { |
@@ -250,6 +264,14 @@ private List<String> getAuditIds(String groupId, String streamId, String sourceN |
250 | 264 | InlongGroupEntity inlongGroup = inlongGroupMapper.selectByGroupId(groupId); |
251 | 265 | if (InlongConstants.DATASYNC_REALTIME_MODE.equals(inlongGroup.getInlongGroupMode()) |
252 | 266 | || InlongConstants.DATASYNC_OFFLINE_MODE.equals(inlongGroup.getInlongGroupMode())) { |
| 267 | + List<AuditInformation> cdcAuditInfoList = |
| 268 | + getCdcAuditInfoList(sourceNodeType, IndicatorType.RECEIVED_SUCCESS); |
| 269 | + if (CollectionUtils.isNotEmpty(cdcAuditInfoList)) { |
| 270 | + List<String> cdcAuditIdList = |
| 271 | + cdcAuditInfoList.stream().map(v -> String.valueOf(v.getAuditId())) |
| 272 | + .collect(Collectors.toList()); |
| 273 | + auditSet.addAll(cdcAuditIdList); |
| 274 | + } |
253 | 275 | auditSet.add(getAuditId(sourceNodeType, IndicatorType.RECEIVED_SUCCESS)); |
254 | 276 | } else { |
255 | 277 | auditSet.add(getAuditId(sinkNodeType, IndicatorType.RECEIVED_SUCCESS)); |
@@ -294,4 +316,16 @@ public List<AuditProxy> getAuditProxy(String component) throws Exception { |
294 | 316 | } |
295 | 317 | } |
296 | 318 |
|
| 319 | + @Override |
| 320 | + public List<AuditInformation> getCdcAuditInfoList(String type, IndicatorType indicatorType) { |
| 321 | + if (StringUtils.isBlank(type)) { |
| 322 | + return null; |
| 323 | + } |
| 324 | + |
| 325 | + FlowType flowType = indicatorType.getCode() % 2 == 0 ? FlowType.INPUT : FlowType.OUTPUT; |
| 326 | + List<AuditInformation> cdcAuditInfo = AuditOperator.getInstance().getAllCdcIdInformation(type, flowType); |
| 327 | + Preconditions.expectNotNull(cdcAuditInfo, ErrorCodeEnum.AUDIT_ID_TYPE_NOT_SUPPORTED, |
| 328 | + String.format(ErrorCodeEnum.AUDIT_ID_TYPE_NOT_SUPPORTED.getMessage(), type)); |
| 329 | + return cdcAuditInfo; |
| 330 | + } |
297 | 331 | } |
0 commit comments