You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@inlong.apache.org by he...@apache.org on 2022/09/27 06:15:41 UTC

[inlong] branch release-1.3.0 updated: [INLONG-6024][Audit] Fix the invalid default value for 'sdk_ts' (#6025)

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

healchow pushed a commit to branch release-1.3.0
in repository https://gitbox.apache.org/repos/asf/inlong.git


The following commit(s) were added to refs/heads/release-1.3.0 by this push:
     new e8e549d4b [INLONG-6024][Audit] Fix the invalid default value for 'sdk_ts' (#6025)
e8e549d4b is described below

commit e8e549d4bd8d1f13badecfd45c67d18d930c46e7
Author: healchow <he...@gmail.com>
AuthorDate: Tue Sep 27 11:16:01 2022 +0800

    [INLONG-6024][Audit] Fix the invalid default value for 'sdk_ts' (#6025)
---
 .../inlong/audit/db/entities/AuditDataPo.java      | 12 ++++--
 .../apache/inlong/audit/service/InsertData.java    | 12 +++---
 .../apache/inlong/audit/service/MySqlService.java  | 17 ++------
 .../src/main/resources/mapper/AuditDataDao.xml     | 49 +++++++++++-----------
 .../src/main/resources/sql/apache_inlong_audit.sql | 41 ++++++++++--------
 inlong-audit/sql/apache_inlong_audit.sql           | 44 ++++++++++---------
 6 files changed, 90 insertions(+), 85 deletions(-)

diff --git a/inlong-audit/audit-store/src/main/java/org/apache/inlong/audit/db/entities/AuditDataPo.java b/inlong-audit/audit-store/src/main/java/org/apache/inlong/audit/db/entities/AuditDataPo.java
index f0ec5d810..c6d5ebd13 100644
--- a/inlong-audit/audit-store/src/main/java/org/apache/inlong/audit/db/entities/AuditDataPo.java
+++ b/inlong-audit/audit-store/src/main/java/org/apache/inlong/audit/db/entities/AuditDataPo.java
@@ -20,21 +20,25 @@ package org.apache.inlong.audit.db.entities;
 import lombok.Getter;
 import lombok.Setter;
 
+import java.sql.Timestamp;
 import java.util.Date;
 
 @Getter
 @Setter
 public class AuditDataPo {
+
     private String ip;
     private String dockerId;
     private String threadId;
     private Date sdkTs;
-    private long packetId;
+    private Long packetId;
     private Date logTs;
     private String inlongGroupId;
     private String inlongStreamId;
     private String auditId;
-    private long count;
-    private long size;
-    private long delay;
+    private Long count;
+    private Long size;
+    private Long delay;
+    private Timestamp updateTime;
+
 }
diff --git a/inlong-audit/audit-store/src/main/java/org/apache/inlong/audit/service/InsertData.java b/inlong-audit/audit-store/src/main/java/org/apache/inlong/audit/service/InsertData.java
index 61cd32826..478920e3a 100644
--- a/inlong-audit/audit-store/src/main/java/org/apache/inlong/audit/service/InsertData.java
+++ b/inlong-audit/audit-store/src/main/java/org/apache/inlong/audit/service/InsertData.java
@@ -1,10 +1,10 @@
-/**
+/*
  * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
+ * 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
+ * the License. You may obtain a copy of the License at
  *
  * http://www.apache.org/licenses/LICENSE-2.0
  *
@@ -20,14 +20,12 @@ package org.apache.inlong.audit.service;
 import org.apache.inlong.audit.protocol.AuditData;
 
 /**
- * InsertData
- * 
+ * Insert Data interface
  */
 public interface InsertData {
 
     /**
-     * insert
-     * @param msgBody
+     * insert audit data to storage.
      */
     void insert(AuditData msgBody);
 }
diff --git a/inlong-audit/audit-store/src/main/java/org/apache/inlong/audit/service/MySqlService.java b/inlong-audit/audit-store/src/main/java/org/apache/inlong/audit/service/MySqlService.java
index e576b789c..812d005d5 100644
--- a/inlong-audit/audit-store/src/main/java/org/apache/inlong/audit/service/MySqlService.java
+++ b/inlong-audit/audit-store/src/main/java/org/apache/inlong/audit/service/MySqlService.java
@@ -1,10 +1,10 @@
-/**
+/*
  * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
+ * 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
+ * the License. You may obtain a copy of the License at
  *
  * http://www.apache.org/licenses/LICENSE-2.0
  *
@@ -25,24 +25,15 @@ import java.util.Date;
 
 /**
  * MySqlService
- * 
  */
 public class MySqlService implements InsertData {
 
-    private AuditDataDao dao;
+    private final AuditDataDao dao;
 
-    /**
-     * Constructor
-     * @param dao
-     */
     public MySqlService(AuditDataDao dao) {
         this.dao = dao;
     }
 
-    /**
-     * insert
-     * @param msgBody
-     */
     @Override
     public void insert(AuditData msgBody) {
         AuditDataPo po = new AuditDataPo();
diff --git a/inlong-audit/audit-store/src/main/resources/mapper/AuditDataDao.xml b/inlong-audit/audit-store/src/main/resources/mapper/AuditDataDao.xml
index 1215347a0..4956847da 100644
--- a/inlong-audit/audit-store/src/main/resources/mapper/AuditDataDao.xml
+++ b/inlong-audit/audit-store/src/main/resources/mapper/AuditDataDao.xml
@@ -19,29 +19,30 @@
 -->
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="org.apache.inlong.audit.db.dao.AuditDataDao">
-  <resultMap id="BaseResultMap" type="org.apache.inlong.audit.db.entities.AuditDataPo">
-    <result column="ip" jdbcType="VARCHAR" property="ip" />
-    <result column="docker_id" jdbcType="VARCHAR" property="dockerId" />
-    <result column="thread_id" jdbcType="VARCHAR" property="threadId" />
-    <result column="sdk_ts" jdbcType="TIMESTAMP" property="sdkTs" />
-    <result column="packet_id" jdbcType="BIGINT" property="packetId" />
-    <result column="log_ts" jdbcType="TIMESTAMP" property="logTs" />
-    <result column="inlong_group_id" jdbcType="VARCHAR" property="inlongGroupId" />
-    <result column="inlong_stream_id" jdbcType="VARCHAR" property="inlongStreamId" />
-    <result column="audit_id" jdbcType="VARCHAR" property="auditId" />
-    <result column="count" jdbcType="BIGINT" property="count" />
-    <result column="size" jdbcType="BIGINT" property="size" />
-    <result column="delay" jdbcType="BIGINT" property="delay" />
-  </resultMap>
+    <resultMap id="BaseResultMap" type="org.apache.inlong.audit.db.entities.AuditDataPo">
+        <result column="ip" jdbcType="VARCHAR" property="ip"/>
+        <result column="docker_id" jdbcType="VARCHAR" property="dockerId"/>
+        <result column="thread_id" jdbcType="VARCHAR" property="threadId"/>
+        <result column="sdk_ts" jdbcType="TIMESTAMP" property="sdkTs"/>
+        <result column="packet_id" jdbcType="BIGINT" property="packetId"/>
+        <result column="log_ts" jdbcType="TIMESTAMP" property="logTs"/>
+        <result column="inlong_group_id" jdbcType="VARCHAR" property="inlongGroupId"/>
+        <result column="inlong_stream_id" jdbcType="VARCHAR" property="inlongStreamId"/>
+        <result column="audit_id" jdbcType="VARCHAR" property="auditId"/>
+        <result column="count" jdbcType="BIGINT" property="count"/>
+        <result column="size" jdbcType="BIGINT" property="size"/>
+        <result column="delay" jdbcType="BIGINT" property="delay"/>
+        <result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>
+    </resultMap>
 
-  <insert id="insert" parameterType="org.apache.inlong.audit.db.entities.AuditDataPo">
-    insert into audit_data (ip, docker_id, thread_id,
-      sdk_ts, packet_id, log_ts,
-      inlong_group_id, inlong_stream_id, audit_id,
-      count, size, delay)
-    values (#{ip,jdbcType=VARCHAR}, #{dockerId,jdbcType=VARCHAR}, #{threadId,jdbcType=VARCHAR},
-      #{sdkTs,jdbcType=TIMESTAMP}, #{packetId,jdbcType=BIGINT}, #{logTs,jdbcType=TIMESTAMP},
-      #{inlongGroupId,jdbcType=VARCHAR}, #{inlongStreamId,jdbcType=VARCHAR}, #{auditId,jdbcType=VARCHAR},
-      #{count,jdbcType=BIGINT}, #{size,jdbcType=BIGINT}, #{delay,jdbcType=BIGINT})
-  </insert>
+    <insert id="insert" parameterType="org.apache.inlong.audit.db.entities.AuditDataPo">
+        insert into audit_data (ip, docker_id, thread_id,
+                                sdk_ts, packet_id, log_ts,
+                                inlong_group_id, inlong_stream_id, audit_id,
+                                `count`, size, delay)
+        values (#{ip,jdbcType=VARCHAR}, #{dockerId,jdbcType=VARCHAR}, #{threadId,jdbcType=VARCHAR},
+                #{sdkTs,jdbcType=TIMESTAMP}, #{packetId,jdbcType=BIGINT}, #{logTs,jdbcType=TIMESTAMP},
+                #{inlongGroupId,jdbcType=VARCHAR}, #{inlongStreamId,jdbcType=VARCHAR}, #{auditId,jdbcType=VARCHAR},
+                #{count,jdbcType=BIGINT}, #{size,jdbcType=BIGINT}, #{delay,jdbcType=BIGINT})
+    </insert>
 </mapper>
\ No newline at end of file
diff --git a/inlong-audit/audit-store/src/main/resources/sql/apache_inlong_audit.sql b/inlong-audit/audit-store/src/main/resources/sql/apache_inlong_audit.sql
index 47d7227da..5ea62c4b4 100644
--- a/inlong-audit/audit-store/src/main/resources/sql/apache_inlong_audit.sql
+++ b/inlong-audit/audit-store/src/main/resources/sql/apache_inlong_audit.sql
@@ -15,32 +15,37 @@
  * limitations under the License.
  */
 
-SET NAMES utf8mb4;
+SET NAMES utf8;
 SET FOREIGN_KEY_CHECKS = 0;
 SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
 SET time_zone = "+00:00";
 
 -- ----------------------------
--- database for Manager Web
+-- Database for InLong Audit
 -- ----------------------------
 CREATE DATABASE IF NOT EXISTS apache_inlong_audit;
+
 USE apache_inlong_audit;
 
-CREATE TABLE `audit_data`
+-- ----------------------------
+-- Table structure for audit_data
+-- ----------------------------
+CREATE TABLE IF NOT EXISTS `audit_data`
 (
-    `id`               int(32)      not null primary key auto_increment COMMENT 'id',
-    `ip`               varchar(32)  NOT NULL DEFAULT '' COMMENT 'client ip',
-    `docker_id`        varchar(100) NOT NULL DEFAULT '' COMMENT 'client docker id',
-    `thread_id`        varchar(50)  NOT NULL DEFAULT '' COMMENT 'client thread id',
-    `sdk_ts`           TIMESTAMP    NOT NULL DEFAULT '0000-00-00 00:00:00' COMMENT 'sdk timestamp',
-    `packet_id`        BIGINT       NOT NULL DEFAULT '0' COMMENT '' COMMENT 'packet id',
-    `log_ts`           TIMESTAMP    NOT NULL DEFAULT '0000-00-00 00:00:00' COMMENT 'log timestamp',
-    `inlong_group_id`  varchar(100) NOT NULL DEFAULT '' COMMENT 'inlong group id',
-    `inlong_stream_id` varchar(100) NOT NULL DEFAULT '' COMMENT 'inlong stream id',
-    `audit_id`         varchar(100) NOT NULL DEFAULT '' COMMENT 'audit id',
-    `count`            BIGINT       NOT NULL DEFAULT '0' COMMENT 'msg count',
-    `size`             BIGINT       NOT NULL DEFAULT '0' COMMENT 'msg size',
-    `delay`            BIGINT       NOT NULL DEFAULT '0' COMMENT 'msg delay',
-    `updateTime`       timestamp    NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT 'update time',
+    `id`               int(32)      NOT NULL PRIMARY KEY AUTO_INCREMENT COMMENT 'Incremental primary key',
+    `ip`               varchar(32)  NOT NULL DEFAULT '' COMMENT 'Client IP',
+    `docker_id`        varchar(100) NOT NULL DEFAULT '' COMMENT 'Client docker id',
+    `thread_id`        varchar(50)  NOT NULL DEFAULT '' COMMENT 'Client thread id',
+    `sdk_ts`           TIMESTAMP    NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'SDK timestamp',
+    `packet_id`        BIGINT       NOT NULL DEFAULT '0' COMMENT 'Packet id',
+    `log_ts`           TIMESTAMP    NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'Log timestamp',
+    `inlong_group_id`  varchar(100) NOT NULL DEFAULT '' COMMENT 'The target inlong group id',
+    `inlong_stream_id` varchar(100) NOT NULL DEFAULT '' COMMENT 'The target inlong stream id',
+    `audit_id`         varchar(100) NOT NULL DEFAULT '' COMMENT 'Audit id',
+    `count`            BIGINT       NOT NULL DEFAULT '0' COMMENT 'Message count',
+    `size`             BIGINT       NOT NULL DEFAULT '0' COMMENT 'Message size',
+    `delay`            BIGINT       NOT NULL DEFAULT '0' COMMENT 'Message delay count',
+    `update_time`      timestamp    NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT 'Update time',
     INDEX ip_packet (`ip`, `inlong_group_id`, `inlong_stream_id`, `log_ts`)
-);
+) ENGINE = InnoDB
+  DEFAULT CHARSET = utf8 COMMENT ='Inlong audit data table';
diff --git a/inlong-audit/sql/apache_inlong_audit.sql b/inlong-audit/sql/apache_inlong_audit.sql
index c7084a3e3..5ea62c4b4 100644
--- a/inlong-audit/sql/apache_inlong_audit.sql
+++ b/inlong-audit/sql/apache_inlong_audit.sql
@@ -15,31 +15,37 @@
  * limitations under the License.
  */
 
-SET NAMES utf8mb4;
+SET NAMES utf8;
 SET FOREIGN_KEY_CHECKS = 0;
 SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
 SET time_zone = "+00:00";
 
 -- ----------------------------
--- database for Manager Web
+-- Database for InLong Audit
 -- ----------------------------
 CREATE DATABASE IF NOT EXISTS apache_inlong_audit;
+
 USE apache_inlong_audit;
 
-CREATE TABLE `audit_data` (
-  `id` int(32) not null primary key auto_increment COMMENT 'id',
-  `ip` varchar(32) NOT NULL DEFAULT '' COMMENT 'client ip',
-  `docker_id` varchar(100) NOT NULL DEFAULT '' COMMENT 'client docker id',
-  `thread_id` varchar(50) NOT NULL DEFAULT '' COMMENT 'client thread id',
-  `sdk_ts` TIMESTAMP NOT NULL DEFAULT '0000-00-00 00:00:00' COMMENT 'sdk timestamp',
-  `packet_id` BIGINT NOT NULL DEFAULT '0' COMMENT '' COMMENT 'packet id',
-  `log_ts` TIMESTAMP NOT NULL DEFAULT '0000-00-00 00:00:00' COMMENT 'log timestamp',
-  `inlong_group_id` varchar(100) NOT NULL DEFAULT '' COMMENT 'inlong group id',
-  `inlong_stream_id` varchar(100) NOT NULL DEFAULT '' COMMENT 'inlong stream id',
-  `audit_id` varchar(100) NOT NULL DEFAULT '' COMMENT 'audit id',
-  `count` BIGINT NOT NULL DEFAULT '0' COMMENT 'msg count',
-  `size` BIGINT NOT NULL DEFAULT '0' COMMENT 'msg size',
-  `delay` BIGINT NOT NULL DEFAULT '0' COMMENT 'msg delay',
-  `updateTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT 'update time',
-  INDEX ip_packet(`ip`,`inlong_group_id`,`inlong_stream_id`,`log_ts`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8
\ No newline at end of file
+-- ----------------------------
+-- Table structure for audit_data
+-- ----------------------------
+CREATE TABLE IF NOT EXISTS `audit_data`
+(
+    `id`               int(32)      NOT NULL PRIMARY KEY AUTO_INCREMENT COMMENT 'Incremental primary key',
+    `ip`               varchar(32)  NOT NULL DEFAULT '' COMMENT 'Client IP',
+    `docker_id`        varchar(100) NOT NULL DEFAULT '' COMMENT 'Client docker id',
+    `thread_id`        varchar(50)  NOT NULL DEFAULT '' COMMENT 'Client thread id',
+    `sdk_ts`           TIMESTAMP    NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'SDK timestamp',
+    `packet_id`        BIGINT       NOT NULL DEFAULT '0' COMMENT 'Packet id',
+    `log_ts`           TIMESTAMP    NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'Log timestamp',
+    `inlong_group_id`  varchar(100) NOT NULL DEFAULT '' COMMENT 'The target inlong group id',
+    `inlong_stream_id` varchar(100) NOT NULL DEFAULT '' COMMENT 'The target inlong stream id',
+    `audit_id`         varchar(100) NOT NULL DEFAULT '' COMMENT 'Audit id',
+    `count`            BIGINT       NOT NULL DEFAULT '0' COMMENT 'Message count',
+    `size`             BIGINT       NOT NULL DEFAULT '0' COMMENT 'Message size',
+    `delay`            BIGINT       NOT NULL DEFAULT '0' COMMENT 'Message delay count',
+    `update_time`      timestamp    NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT 'Update time',
+    INDEX ip_packet (`ip`, `inlong_group_id`, `inlong_stream_id`, `log_ts`)
+) ENGINE = InnoDB
+  DEFAULT CHARSET = utf8 COMMENT ='Inlong audit data table';