Skip to content

Commit

Permalink
[INLONG-11404][Audit] Optimize the Audit item in dashboard display (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
doleyzi authored Oct 24, 2024
1 parent 23b148e commit 7a1c897
Showing 1 changed file with 53 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
import java.util.LinkedList;
import java.util.List;

import static org.apache.inlong.audit.AuditIdEnum.*;

/**
* Audit item ID generation rules: composed of basic audit item ID + extension bits.
* Each module is assigned two basic audit item IDs, namely reception and transmission.
Expand Down Expand Up @@ -169,22 +171,69 @@ public static List<AuditInformation> getAllAuditInformation(String auditType) {
private static List<AuditInformation> combineAuditInformation(String auditType, FlowType flowType) {
List<AuditInformation> auditInformationList = new LinkedList<>();
boolean[] combinations = {true, false};

for (boolean success : combinations) {
for (boolean isRealtime : combinations) {
for (boolean discard : combinations) {
for (boolean retry : combinations) {
if (discard && retry) {
continue;
if (shouldIncludeCombination(auditType, flowType, success, isRealtime, discard, retry)) {
auditInformationList.add(
buildAuditInformation(auditType, flowType, success, isRealtime, discard, retry));
}
auditInformationList
.add(buildAuditInformation(auditType, flowType, success, isRealtime, discard, retry));
}
}
}
}

return auditInformationList;
}

/**
* Exclude some uncommon audit scenarios
* @param auditType
* @param flowType
* @param success
* @param isRealtime
* @param discard
* @param retry
* @return
*/
private static boolean shouldIncludeCombination(String auditType, FlowType flowType, boolean success,
boolean isRealtime, boolean discard, boolean retry) {
// Exclude the situation when retry and discard occur at the same time
if (discard && retry) {
return false;
}

AuditIdEnum baseAuditId = AuditIdEnum.getAuditId(auditType, flowType);
// Exclude the situation when non-real-time and one of SDK、Agent、DataProxy occur at the same time
if (!isRealtime && isExcludedWhenNotRealtime(baseAuditId)) {
return false;
}

// Exclude the situation when failed、input and one of discard and retry occur at the same time
if (!success && flowType == FlowType.INPUT && (discard || retry)) {
return false;
}

// Exclude the situation when failed、output and discard occur at the same time
if (!success && flowType == FlowType.OUTPUT && discard) {
return false;
}

// Exclude the situation when success、input and retry occur at the same time
if (success && flowType == FlowType.INPUT && retry) {
return false;
}

return true;
}

private static boolean isExcludedWhenNotRealtime(AuditIdEnum baseAuditId) {
return baseAuditId == SDK_INPUT || baseAuditId == SDK_OUTPUT || baseAuditId == AGENT_INPUT
|| baseAuditId == AGENT_OUTPUT || baseAuditId == DATA_PROXY_INPUT || baseAuditId == DATA_PROXY_OUTPUT;
}

/**
* Get max Audit ID.
*
Expand Down

0 comments on commit 7a1c897

Please sign in to comment.