baomingyu commented on code in PR #9905:
URL: https://github.com/apache/inlong/pull/9905#discussion_r1544273397


##########
inlong-audit/audit-sdk/src/main/java/org/apache/inlong/audit/send/SenderManager.java:
##########
@@ -286,6 +269,9 @@ public void onMessageReceived(ChannelHandlerContext ctx, 
byte[] msg) {
             if (data == null) {
                 LOG.error("Can not find the request id onMessageReceived 
{},message: {}",
                         requestId, baseCommand.getAuditReply().getMessage());
+                for (Map.Entry<Long, AuditData> entry : 
this.dataMap.entrySet()) {

Review Comment:
   It is better ?
   if(LOG.isDebug()) {
       for ?
   }
   



##########
inlong-audit/audit-sdk/src/main/java/org/apache/inlong/audit/AuditReporterImpl.java:
##########
@@ -198,50 +222,201 @@ public void add(int auditID, String auditTag, String 
inlongGroupID, String inlon
         keyJoiner.add(String.valueOf(auditID));
         keyJoiner.add(auditTag);
         keyJoiner.add(String.valueOf(auditVersion));
-        addByKey(keyJoiner.toString(), count, size, delayTime);
+        addByKey(DEFAULT_ISOLATE_KEY, keyJoiner.toString(), count, size, 
delayTime);
+    }
+
+    public void add(AuditDimensions dimensions, AuditValues values) {
+        StringJoiner keyJoiner = new StringJoiner(FIELD_SEPARATORS);
+        keyJoiner.add(String.valueOf(dimensions.getLogTime() / PERIOD));
+        keyJoiner.add(dimensions.getInlongGroupID());
+        keyJoiner.add(dimensions.getInlongStreamID());
+        keyJoiner.add(String.valueOf(dimensions.getAuditID()));
+        keyJoiner.add(dimensions.getAuditTag());
+        keyJoiner.add(String.valueOf(dimensions.getAuditVersion()));
+        addByKey(dimensions.getIsolateKey(), keyJoiner.toString(), 
values.getCount(),
+                values.getSize(), values.getDelayTime());
     }
 
     /**
      * Add audit info by key.
      */
-    private void addByKey(String key, long count, long size, long delayTime) {
-        if (countMap.get(key) == null) {
-            countMap.put(key, new StatInfo(0L, 0L, 0L));
+    private void addByKey(long isolateKey, String statKey, long count, long 
size, long delayTime) {
+        if (null == this.preStatMap.get(isolateKey)) {
+            this.preStatMap.putIfAbsent(isolateKey, new ConcurrentHashMap<>());

Review Comment:
   'if' is not neccessary  check while use putIfAbsent function.



##########
inlong-audit/audit-sdk/src/main/java/org/apache/inlong/audit/AuditReporterImpl.java:
##########
@@ -198,50 +222,201 @@ public void add(int auditID, String auditTag, String 
inlongGroupID, String inlon
         keyJoiner.add(String.valueOf(auditID));
         keyJoiner.add(auditTag);
         keyJoiner.add(String.valueOf(auditVersion));
-        addByKey(keyJoiner.toString(), count, size, delayTime);
+        addByKey(DEFAULT_ISOLATE_KEY, keyJoiner.toString(), count, size, 
delayTime);
+    }
+
+    public void add(AuditDimensions dimensions, AuditValues values) {
+        StringJoiner keyJoiner = new StringJoiner(FIELD_SEPARATORS);
+        keyJoiner.add(String.valueOf(dimensions.getLogTime() / PERIOD));
+        keyJoiner.add(dimensions.getInlongGroupID());
+        keyJoiner.add(dimensions.getInlongStreamID());
+        keyJoiner.add(String.valueOf(dimensions.getAuditID()));
+        keyJoiner.add(dimensions.getAuditTag());
+        keyJoiner.add(String.valueOf(dimensions.getAuditVersion()));
+        addByKey(dimensions.getIsolateKey(), keyJoiner.toString(), 
values.getCount(),
+                values.getSize(), values.getDelayTime());
     }
 
     /**
      * Add audit info by key.
      */
-    private void addByKey(String key, long count, long size, long delayTime) {
-        if (countMap.get(key) == null) {
-            countMap.put(key, new StatInfo(0L, 0L, 0L));
+    private void addByKey(long isolateKey, String statKey, long count, long 
size, long delayTime) {
+        if (null == this.preStatMap.get(isolateKey)) {
+            this.preStatMap.putIfAbsent(isolateKey, new ConcurrentHashMap<>());
         }
-        countMap.get(key).count.addAndGet(count);
-        countMap.get(key).size.addAndGet(size);
-        countMap.get(key).delay.addAndGet(delayTime);
+        ConcurrentHashMap<String, StatInfo> statMap = 
this.preStatMap.get(isolateKey);
+        if (null == statMap.get(statKey)) {
+            statMap.putIfAbsent(statKey, new StatInfo(0L, 0L, 0L));

Review Comment:
   'if' is not neccessary  check while use putIfAbsent function.



-- 
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