From 87bbc71a0a842625d0b05a1ae7d827a7e00d2586 Mon Sep 17 00:00:00 2001 From: wenweihuang Date: Thu, 21 Nov 2024 20:02:52 +0800 Subject: [PATCH 1/3] [INLONG-11529][Agent] Add exception handling for audit SDK --- .../inlong/agent/metrics/audit/AuditUtils.java | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 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..914663bd46 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.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 @@ */ 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,15 @@ public static void add(int auditID, String inlongGroupId, String inlongStreamId, 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); + } + try { + AuditOperator.getInstance() + .add(auditID, DEFAULT_AUDIT_TAG, inlongGroupId, inlongStreamId, logTime, count, size, version); + } catch (Throwable e) { + LOGGER.error("call audit add error", e); + } } public static void add(int auditID, String inlongGroupId, String inlongStreamId, @@ -106,6 +118,6 @@ public static void send() { if (!IS_AUDIT) { return; } - AuditOperator.getInstance().flush(); + AuditOperator.getInstance().flush(AGENT_ISOLATE_KEY); } } From 9873d7991c0c606c40ba06eddd6294b8295aecbb Mon Sep 17 00:00:00 2001 From: wenweihuang Date: Thu, 21 Nov 2024 21:20:52 +0800 Subject: [PATCH 2/3] [INLONG-11529][Agent] Delete useless code --- .../agent/plugin/task/file/TaskType.java | 39 ------------------- 1 file changed, 39 deletions(-) delete mode 100644 inlong-agent/agent-plugins/src/main/java/org/apache/inlong/agent/plugin/task/file/TaskType.java 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 From 3068324c62270c04cae93bf45a031f279594b290 Mon Sep 17 00:00:00 2001 From: wenweihuang Date: Fri, 22 Nov 2024 10:58:59 +0800 Subject: [PATCH 3/3] [INLONG-11529][Agent] Print audit detail and return if args is invalid --- .../org/apache/inlong/agent/metrics/audit/AuditUtils.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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 914663bd46..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 @@ -97,12 +97,14 @@ public static void add(int auditID, String inlongGroupId, String inlongStreamId, } 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 error", e); + LOGGER.error("call audit add inlongGroupId: {}, inlongStreamId: {}, auditID {}, error", inlongGroupId, + inlongStreamId, auditID, e); } }