This is an automated email from the ASF dual-hosted git repository.

wenweihuang 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 7292ead7ab [INLONG-11529][Agent] Add exception handling for audit SDK 
(#11530)
7292ead7ab is described below

commit 7292ead7abf6bcf056dbb19bca2becf9c2bc9688
Author: justinwwhuang <hww_jus...@163.com>
AuthorDate: Fri Nov 22 11:37:33 2024 +0800

    [INLONG-11529][Agent] Add exception handling for audit SDK (#11530)
    
    * [INLONG-11529][Agent] Add exception handling for audit SDK
    
    * [INLONG-11529][Agent] Delete useless code
    
    * [INLONG-11529][Agent] Print audit detail and return if args is invalid
---
 .../inlong/agent/metrics/audit/AuditUtils.java     | 20 +++++++++--
 .../inlong/agent/plugin/task/file/TaskType.java    | 39 ----------------------
 2 files changed, 17 insertions(+), 42 deletions(-)

diff --git 
a/inlong-agent/agent-common/src/main/java/org/apache/inlong/agent/metrics/audit/AuditUtils.java
 
b/inlong-agent/agent-common/src/main/java/org/apache/inlong/agent/metrics/audit/AuditUtils.java
index b4f74bfc63..76e4b8f31e 100644
--- 
a/inlong-agent/agent-common/src/main/java/org/apache/inlong/agent/metrics/audit/AuditUtils.java
+++ 
b/inlong-agent/agent-common/src/main/java/org/apache/inlong/agent/metrics/audit/AuditUtils.java
@@ -22,6 +22,9 @@ import org.apache.inlong.agent.constant.AgentConstants;
 import org.apache.inlong.audit.AuditOperator;
 import org.apache.inlong.audit.entity.AuditComponent;
 
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
 import java.util.HashSet;
 
 import static org.apache.inlong.agent.constant.AgentConstants.AUDIT_ENABLE;
@@ -38,6 +41,8 @@ import static 
org.apache.inlong.common.constant.Constants.DEFAULT_AUDIT_VERSION;
  */
 public class AuditUtils {
 
+    private static final Logger LOGGER = 
LoggerFactory.getLogger(AuditUtils.class);
+    public static final int AGENT_ISOLATE_KEY = 1;
     public static int AUDIT_ID_AGENT_READ_SUCCESS = 3;
     public static int AUDIT_ID_AGENT_SEND_SUCCESS = 4;
     public static int AUDIT_ID_AGENT_READ_FAILED = 524291;
@@ -90,8 +95,17 @@ public class AuditUtils {
         if (!IS_AUDIT) {
             return;
         }
-        AuditOperator.getInstance()
-                .add(auditID, DEFAULT_AUDIT_TAG, inlongGroupId, 
inlongStreamId, logTime, count, size, version);
+        if (inlongGroupId == null || inlongStreamId == null) {
+            LOGGER.error("invalid args inlongGroupId: {}, inlongStreamId: {}", 
inlongGroupId, inlongStreamId);
+            return;
+        }
+        try {
+            AuditOperator.getInstance()
+                    .add(auditID, DEFAULT_AUDIT_TAG, inlongGroupId, 
inlongStreamId, logTime, count, size, version);
+        } catch (Throwable e) {
+            LOGGER.error("call audit add inlongGroupId: {}, inlongStreamId: 
{}, auditID {}, error", inlongGroupId,
+                    inlongStreamId, auditID, e);
+        }
     }
 
     public static void add(int auditID, String inlongGroupId, String 
inlongStreamId,
@@ -106,6 +120,6 @@ public class AuditUtils {
         if (!IS_AUDIT) {
             return;
         }
-        AuditOperator.getInstance().flush();
+        AuditOperator.getInstance().flush(AGENT_ISOLATE_KEY);
     }
 }
diff --git 
a/inlong-agent/agent-plugins/src/main/java/org/apache/inlong/agent/plugin/task/file/TaskType.java
 
b/inlong-agent/agent-plugins/src/main/java/org/apache/inlong/agent/plugin/task/file/TaskType.java
deleted file mode 100644
index 65203d0522..0000000000
--- 
a/inlong-agent/agent-plugins/src/main/java/org/apache/inlong/agent/plugin/task/file/TaskType.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * 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.agent.plugin.task.file;
-
-public enum TaskType {
-
-    READER(0),
-    TAILER(1),
-    UPLOADER(2),
-    STATE(3),
-    OTHER(4),
-    DB(5),
-    GAIAReader(6);
-
-    private int type;
-
-    TaskType(int type) {
-        this.type = type;
-    }
-
-    public int getType() {
-        return type;
-    }
-}
\ No newline at end of file

Reply via email to