This is an automated email from the ASF dual-hosted git repository.
dockerzhang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/inlong.git
The following commit(s) were added to refs/heads/master by this push:
new 8310421326 [INLONG-11823][Audit] Add CDC audit ID for MySQL Binlog
(#11824)
8310421326 is described below
commit 8310421326440f15fac83d6e252832c6cf763946
Author: fuweng11 <[email protected]>
AuthorDate: Wed Apr 16 09:59:12 2025 +0800
[INLONG-11823][Audit] Add CDC audit ID for MySQL Binlog (#11824)
---
.../java/org/apache/inlong/audit/CdcIdEnum.java | 52 ++++++++++++----------
1 file changed, 29 insertions(+), 23 deletions(-)
diff --git
a/inlong-audit/audit-sdk/src/main/java/org/apache/inlong/audit/CdcIdEnum.java
b/inlong-audit/audit-sdk/src/main/java/org/apache/inlong/audit/CdcIdEnum.java
index 49f0344c37..86afb0c42d 100644
---
a/inlong-audit/audit-sdk/src/main/java/org/apache/inlong/audit/CdcIdEnum.java
+++
b/inlong-audit/audit-sdk/src/main/java/org/apache/inlong/audit/CdcIdEnum.java
@@ -27,6 +27,7 @@ import lombok.Getter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import static org.apache.inlong.audit.entity.AuditType.BINLOG;
import static org.apache.inlong.audit.entity.AuditType.MYSQL;
import static org.apache.inlong.audit.entity.AuditType.TDSQL_MYSQL;
import static org.apache.inlong.audit.entity.CdcType.DELETE;
@@ -49,7 +50,12 @@ public enum CdcIdEnum {
TDSQL_INSERT(101, INSERT, TDSQL_MYSQL, "Insert Audit Metrics for TDSQL"),
TDSQL_DELETE(102, DELETE, TDSQL_MYSQL, "Delete Audit Metrics for TDSQL"),
TDSQL_UPDATE_BEFORE(103, UPDATE_BEFORE, TDSQL_MYSQL, "Update before Audit
Metrics for TDSQL"),
- TDSQL_UPDATE_AFTER(104, UPDATE_AFTER, TDSQL_MYSQL, "Update after Audit
Metrics for TDSQL");
+ TDSQL_UPDATE_AFTER(104, UPDATE_AFTER, TDSQL_MYSQL, "Update after Audit
Metrics for TDSQL"),
+
+ BINLOG_INSERT(201, INSERT, BINLOG, "Insert Audit Metrics for MYSQL
BINLOG"),
+ BINLOG_DELETE(202, DELETE, BINLOG, "Delete Audit Metrics for MYSQL
BINLOG"),
+ BINLOG_UPDATE_BEFORE(203, UPDATE_BEFORE, BINLOG, "Update before Audit
Metrics for MYSQL BINLOG"),
+ BINLOG_UPDATE_AFTER(204, UPDATE_AFTER, BINLOG, "Update after Audit Metrics
for MYSQL BINLOG");
private static final Logger LOGGER =
LoggerFactory.getLogger(CdcIdEnum.class);
private final int auditId;
@@ -67,6 +73,28 @@ public enum CdcIdEnum {
this.description = description;
}
+ public static CdcIdEnum getCdcIdEnum(String auditType, CdcType cdcType) {
+ if (auditType == null || cdcType == null) {
+ throw new IllegalArgumentException("Audit type and CDC type must
not be null");
+ }
+
+ for (CdcIdEnum cdcIdEnum : CdcIdEnum.values()) {
+ if (cdcIdEnum.getCdcType() == cdcType &&
+
auditType.equalsIgnoreCase(cdcIdEnum.getAuditType().value())) {
+ return cdcIdEnum;
+ }
+ }
+
+ String errorMsg = String.format("Audit type %s does not exist for cdc
type %s", auditType, cdcType);
+ LOGGER.error(errorMsg);
+ throw new AuditTypeNotExistException(errorMsg);
+ }
+
+ public static int getCdcId(String auditType, FlowType flowType, CdcType
cdcType) {
+ CdcIdEnum cdcIdEnum = getCdcIdEnum(auditType, cdcType);
+ return cdcIdEnum.getValue(flowType);
+ }
+
public int getValue(FlowType flowType) {
if (flowType == null) {
LOGGER.error("Invalid flow type: must not be null");
@@ -96,26 +124,4 @@ public enum CdcIdEnum {
flowType.getNameInChinese(),
cdcType.getNameInChinese());
}
-
- public static CdcIdEnum getCdcIdEnum(String auditType, CdcType cdcType) {
- if (auditType == null || cdcType == null) {
- throw new IllegalArgumentException("Audit type and CDC type must
not be null");
- }
-
- for (CdcIdEnum cdcIdEnum : CdcIdEnum.values()) {
- if (cdcIdEnum.getCdcType() == cdcType &&
-
auditType.equalsIgnoreCase(cdcIdEnum.getAuditType().value())) {
- return cdcIdEnum;
- }
- }
-
- String errorMsg = String.format("Audit type %s does not exist for cdc
type %s", auditType, cdcType);
- LOGGER.error(errorMsg);
- throw new AuditTypeNotExistException(errorMsg);
- }
-
- public static int getCdcId(String auditType, FlowType flowType, CdcType
cdcType) {
- CdcIdEnum cdcIdEnum = getCdcIdEnum(auditType, cdcType);
- return cdcIdEnum.getValue(flowType);
- }
}