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

guoyp pushed a commit to branch griffin-2.0.0-dev
in repository https://gitbox.apache.org/repos/asf/griffin.git


The following commit(s) were added to refs/heads/griffin-2.0.0-dev by this push:
     new 294f3c78 Initialize base metric model (#662)
294f3c78 is described below

commit 294f3c7866d0627d99c9a76dda342bea373977aa
Author: Jin <[email protected]>
AuthorDate: Wed Aug 28 14:39:07 2024 +0800

    Initialize base metric model (#662)
    
    * add metric definition
    
    * metric tags
    
    ---------
    
    Co-authored-by: William Guo <[email protected]>
---
 griffin-connectors/pom.xml                         |  1 +
 griffin-dqc/pom.xml                                |  1 +
 griffin-metric/pom.xml                             |  2 +-
 griffin-metric/readme.md                           |  0
 .../apache/griffin/metric/model/BaseEntity.java    | 56 ++++++++++++++++++++++
 .../org/apache/griffin/metric/model/MetricD.java   | 56 ++++++++++++++++++++++
 .../org/apache/griffin/metric/model/MetricTag.java | 47 +++++++++++-------
 .../org/apache/griffin/metric/model/MetricV.java   | 53 ++++++++++++++++++++
 .../java/org/apache/griffin/metric/model/Tags.java | 30 ++++++++++++
 pom.xml                                            |  7 +++
 10 files changed, 236 insertions(+), 17 deletions(-)

diff --git a/griffin-connectors/pom.xml b/griffin-connectors/pom.xml
index ae8b9fa7..e7862480 100644
--- a/griffin-connectors/pom.xml
+++ b/griffin-connectors/pom.xml
@@ -28,6 +28,7 @@ under the License.
         <version>2.0.0-SNAPSHOT</version>
     </parent>
 
+
     <artifactId>griffin-connectors</artifactId>
     <name>${project.artifactId}</name>
     <url>https://griffin.apache.org</url>
diff --git a/griffin-dqc/pom.xml b/griffin-dqc/pom.xml
index 6b46b2e0..7d503e5c 100644
--- a/griffin-dqc/pom.xml
+++ b/griffin-dqc/pom.xml
@@ -28,6 +28,7 @@ under the License.
         <version>2.0.0-SNAPSHOT</version>
     </parent>
 
+
     <artifactId>griffin-dqc</artifactId>
     <name>${project.artifactId}</name>
     <url>https://griffin.apache.org</url>
diff --git a/griffin-metric/pom.xml b/griffin-metric/pom.xml
index cb5821ed..ce516428 100644
--- a/griffin-metric/pom.xml
+++ b/griffin-metric/pom.xml
@@ -30,7 +30,7 @@ under the License.
 
     <artifactId>griffin-metric</artifactId>
     <name>${project.artifactId}</name>
-    <url>https://griffin.apache.org</url>
+    <packaging>jar</packaging>
 
 
 </project>
\ No newline at end of file
diff --git a/griffin-metric/readme.md b/griffin-metric/readme.md
new file mode 100644
index 00000000..e69de29b
diff --git 
a/griffin-metric/src/main/java/org/apache/griffin/metric/model/BaseEntity.java 
b/griffin-metric/src/main/java/org/apache/griffin/metric/model/BaseEntity.java
new file mode 100644
index 00000000..83cfaae9
--- /dev/null
+++ 
b/griffin-metric/src/main/java/org/apache/griffin/metric/model/BaseEntity.java
@@ -0,0 +1,56 @@
+/*
+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.griffin.metric.model;
+
+import lombok.Data;
+
+import java.util.Date;
+
+/**
+ * A base class in metric function in griffin, which contains timestamp 
properties of entity creation/update.
+ */
+@Data
+public abstract class BaseEntity implements java.io.Serializable {
+
+    private static final long serialVersionUID = 2110740953277261851L;
+
+    /**
+     * creation time
+     */
+    protected Date ctime;
+
+    /**
+     * update time
+     */
+    protected Date mtime;
+
+    public void prePersist() {
+        Date date = new Date();
+        if (ctime == null) {
+            ctime = date;
+        }
+        if (mtime == null) {
+            mtime = date;
+        }
+    }
+
+    public void preUpdate() {
+        mtime = new Date();
+    }
+}
diff --git 
a/griffin-metric/src/main/java/org/apache/griffin/metric/model/MetricD.java 
b/griffin-metric/src/main/java/org/apache/griffin/metric/model/MetricD.java
new file mode 100644
index 00000000..df4efd21
--- /dev/null
+++ b/griffin-metric/src/main/java/org/apache/griffin/metric/model/MetricD.java
@@ -0,0 +1,56 @@
+/*
+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.griffin.metric.model;
+
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.NoArgsConstructor;
+
+/**
+ * A metric definition entity represents fundamental metadata.
+ */
+@Builder
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+@EqualsAndHashCode(callSuper = false)
+public class MetricD extends BaseEntity {
+
+    /**
+     * An unique identity for a metric.
+     */
+    private long metricId;
+
+    /**
+     * The name of a metric entity.
+     */
+    private String metricName;
+
+    /**
+     * The owner of a metric entity.
+     */
+    private String owner;
+
+    /**
+     * The details of a metric entity.
+     */
+    private String description;
+}
diff --git a/griffin-connectors/pom.xml 
b/griffin-metric/src/main/java/org/apache/griffin/metric/model/MetricTag.java
similarity index 51%
copy from griffin-connectors/pom.xml
copy to 
griffin-metric/src/main/java/org/apache/griffin/metric/model/MetricTag.java
index ae8b9fa7..c8eeda61 100644
--- a/griffin-connectors/pom.xml
+++ 
b/griffin-metric/src/main/java/org/apache/griffin/metric/model/MetricTag.java
@@ -1,5 +1,4 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
+/*
 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
@@ -8,7 +7,7 @@ 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
 
-  https://www.apache.org/licenses/LICENSE-2.0
+  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
@@ -16,21 +15,37 @@ software distributed under the License is distributed on an
 KIND, either express or implied.  See the License for the
 specific language governing permissions and limitations
 under the License.
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
-         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/xsd/maven-4.0.0.xsd";>
+*/
+package org.apache.griffin.metric.model;
 
-    <modelVersion>4.0.0</modelVersion>
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.NoArgsConstructor;
 
-    <parent>
-        <groupId>org.apache.griffin</groupId>
-        <artifactId>griffin</artifactId>
-        <version>2.0.0-SNAPSHOT</version>
-    </parent>
+/**
+ * A metric tag entity represents fundamental information.
+ */
+@Builder
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+@EqualsAndHashCode(callSuper = false)
+public class MetricTag extends BaseEntity {
 
-    <artifactId>griffin-connectors</artifactId>
-    <name>${project.artifactId}</name>
-    <url>https://griffin.apache.org</url>
+    /**
+     * An unique identity for a metric tag.
+     */
+    private long id;
 
+    /**
+     * Key name
+     */
+    private String tagKey;
 
-</project>
\ No newline at end of file
+    /**
+     * The value corresponding to a key
+     */
+    private String tagValue;
+}
diff --git 
a/griffin-metric/src/main/java/org/apache/griffin/metric/model/MetricV.java 
b/griffin-metric/src/main/java/org/apache/griffin/metric/model/MetricV.java
new file mode 100644
index 00000000..0251ab76
--- /dev/null
+++ b/griffin-metric/src/main/java/org/apache/griffin/metric/model/MetricV.java
@@ -0,0 +1,53 @@
+/*
+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.griffin.metric.model;
+
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.NoArgsConstructor;
+import lombok.ToString;
+
+/**
+ * A metric value entity represents fundamental information.
+ */
+@Data
+@ToString
+@Builder
+@NoArgsConstructor
+@AllArgsConstructor
+@EqualsAndHashCode(callSuper = false)
+public class MetricV extends BaseEntity {
+
+    /**
+     * An unique identity for a metric.
+     */
+    private long metricId;
+
+    /**
+     * A double number to store metric value.
+     */
+    private double value;
+
+    /**
+     * The tag property assigned.
+     */
+    private Tags tags;
+}
diff --git 
a/griffin-metric/src/main/java/org/apache/griffin/metric/model/Tags.java 
b/griffin-metric/src/main/java/org/apache/griffin/metric/model/Tags.java
new file mode 100644
index 00000000..62fa9d46
--- /dev/null
+++ b/griffin-metric/src/main/java/org/apache/griffin/metric/model/Tags.java
@@ -0,0 +1,30 @@
+package org.apache.griffin.metric.model;
+
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.NoArgsConstructor;
+
+import java.util.List;
+
+/**
+ * A common tag entity represents the relationships among metric entities and 
metric tag entities.
+ */
+@Data
+@Builder
+@NoArgsConstructor
+@AllArgsConstructor
+@EqualsAndHashCode(callSuper = false)
+public class Tags extends BaseEntity {
+
+    /**
+     * Metric entity's identity.
+     */
+    private long metricId;
+
+    /**
+     * All tag properties assigning to a metric entity.
+     */
+    private List<MetricTag> metricTags;
+}
diff --git a/pom.xml b/pom.xml
index 99b88c66..1e4b1ea1 100644
--- a/pom.xml
+++ b/pom.xml
@@ -140,6 +140,7 @@ under the License.
     </dependencyManagement>
 
     <dependencies>
+        <!--DEV/ TEST ONLY!-->
         <dependency>
             <groupId>org.junit.jupiter</groupId>
             <artifactId>junit-jupiter-api</artifactId>
@@ -174,6 +175,12 @@ under the License.
             <version>${spring.boot.version}</version>
             <optional>true</optional>
         </dependency>
+        <dependency>
+            <groupId>org.projectlombok</groupId>
+            <artifactId>lombok</artifactId>
+            <version>${lombok.version}</version>
+            <scope>provided</scope>
+        </dependency>
     </dependencies>
 
     <build>

Reply via email to