doleyzi commented on code in PR #10232:
URL: https://github.com/apache/inlong/pull/10232#discussion_r1603295992


##########
inlong-audit/audit-sdk/src/main/java/org/apache/inlong/audit/util/AuditManagerUtils.java:
##########
@@ -0,0 +1,87 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 org.apache.inlong.audit.util;
+
+import 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.
+ * Based on reception and transmission, and expanded through extension bits,
+ * audit item IDs such as success and failure, real-time and non-real-time, 
retry and discard can be generated.
+ */
+public class AuditManagerUtils {
+
+    public static final int AUDIT_SUFFIX_LENGTH = 16;
+    public static final int AUDIT_MAX_PREFIX_LENGTH = 14;
+
+    private static String buildSuccessAndFailureFlag(boolean success) {
+        return success ? "0" : "1";
+    }
+
+    private static String buildRealtimeFlag(boolean isRealtime) {
+        return isRealtime ? "0" : "1";
+    }
+
+    private static String buildDiscardFlag(boolean discard) {
+        return discard ? "1" : "0";
+    }
+
+    private static String buildRetryFlag(boolean retry) {
+        return retry ? "1" : "0";
+    }
+
+    private static String buildAuditIdSuffix(int auditId) {
+        StringBuilder auditIdBinaryString = new 
StringBuilder(Integer.toBinaryString(auditId));
+        for (int i = auditIdBinaryString.length(); i < AUDIT_SUFFIX_LENGTH; 
i++) {
+            auditIdBinaryString.insert(0, "0");
+        }
+        return auditIdBinaryString.toString();
+    }
+
+    /**
+     * Generate success and failure, real-time and non-real-time, retry, 
discard and other Audit item IDs through the baseline Audit ID.

Review Comment:
   done



##########
inlong-audit/audit-sdk/README.md:
##########
@@ -11,7 +11,7 @@ The Audit Sdk uses log production time as the audit standard,
 which can ensure that each module is reconciled in accordance with the unified 
audit standard.
 
 ## Usage
-### setAuditProxy API
+### SetAuditProxy API

Review Comment:
   done



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to