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

yangzhg pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-doris.git


The following commit(s) were added to refs/heads/master by this push:
     new 6f46c52  Make the max stmt length to be loaded in audit table can be 
defined by user. (#5673)
6f46c52 is described below

commit 6f46c52f1d0f91476cded0112b8e3bf8706973b7
Author: Shun <[email protected]>
AuthorDate: Wed Apr 21 09:14:32 2021 +0800

    Make the max stmt length to be loaded in audit table can be defined by 
user. (#5673)
---
 fe_plugins/auditloader/src/main/assembly/plugin.conf           |  3 +++
 .../java/org/apache/doris/plugin/audit/AuditLoaderPlugin.java  | 10 +++++++---
 2 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/fe_plugins/auditloader/src/main/assembly/plugin.conf 
b/fe_plugins/auditloader/src/main/assembly/plugin.conf
index 53b9a7c..4013920 100755
--- a/fe_plugins/auditloader/src/main/assembly/plugin.conf
+++ b/fe_plugins/auditloader/src/main/assembly/plugin.conf
@@ -23,6 +23,9 @@ max_batch_size=52428800
 # The max interval of batch loaded, default is 60 seconds
 max_batch_interval_sec=60
 
+# the max stmt length to be loaded in audit table, default is 4096
+max_stmt_length=4096
+
 # Doris FE host for loading the audit, default is 127.0.0.1:8030.
 # this should be the host port for stream load
 frontend_host_port=127.0.0.1:8030
diff --git 
a/fe_plugins/auditloader/src/main/java/org/apache/doris/plugin/audit/AuditLoaderPlugin.java
 
b/fe_plugins/auditloader/src/main/java/org/apache/doris/plugin/audit/AuditLoaderPlugin.java
index a785768..8646cbc 100755
--- 
a/fe_plugins/auditloader/src/main/java/org/apache/doris/plugin/audit/AuditLoaderPlugin.java
+++ 
b/fe_plugins/auditloader/src/main/java/org/apache/doris/plugin/audit/AuditLoaderPlugin.java
@@ -62,8 +62,6 @@ public class AuditLoaderPlugin extends Plugin implements 
AuditPlugin {
     private volatile boolean isClosed = false;
     private volatile boolean isInit = false;
 
-    // the max stmt length to be loaded in audit table.
-    private static final int MAX_STMT_LENGTH = 4096;
     // the max auditEventQueue size to store audit_event
     private static final int MAX_AUDIT_EVENT_SIZE = 4096;
 
@@ -160,7 +158,7 @@ public class AuditLoaderPlugin extends Plugin implements 
AuditPlugin {
         auditBuffer.append(event.feIp).append("\t");
         // trim the query to avoid too long
         // use `getBytes().length` to get real byte length
-        int maxLen = Math.min(MAX_STMT_LENGTH, event.stmt.getBytes().length);
+        int maxLen = Math.min(conf.max_stmt_length, 
event.stmt.getBytes().length);
         String stmt = new String(event.stmt.getBytes(), 0, 
maxLen).replace("\t", " ");
         LOG.debug("receive audit event with stmt: {}", stmt);
         auditBuffer.append(stmt).append("\n");
@@ -194,6 +192,8 @@ public class AuditLoaderPlugin extends Plugin implements 
AuditPlugin {
         public static final String PROP_PASSWORD = "password";
         public static final String PROP_DATABASE = "database";
         public static final String PROP_TABLE = "table";
+        // the max stmt length to be loaded in audit table.
+        public static final String MAX_STMT_LENGTH = "max_stmt_length";
 
         public long maxBatchSize = 50 * 1024 * 1024;
         public long maxBatchIntervalSec = 60;
@@ -204,6 +204,7 @@ public class AuditLoaderPlugin extends Plugin implements 
AuditPlugin {
         public String table = "doris_audit_tbl__";
         // the identity of FE which run this plugin
         public String feIdentity = "";
+        public int max_stmt_length = 4096;
 
         public void init(Map<String, String> properties) throws 
PluginException {
             try {
@@ -228,6 +229,9 @@ public class AuditLoaderPlugin extends Plugin implements 
AuditPlugin {
                 if (properties.containsKey(PROP_TABLE)) {
                     table = properties.get(PROP_TABLE);
                 }
+                if (properties.containsKey(MAX_STMT_LENGTH)) {
+                    max_stmt_length = 
Integer.parseInt(properties.get(MAX_STMT_LENGTH));
+                }
             } catch (Exception e) {
                 throw new PluginException(e.getMessage());
             }

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to