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 bfa2835b refresh pom structure (#676) bfa2835b is described below commit bfa2835bc88be5ea64c5fa634cb4ccd49144c3cd Author: Jin <liu...@apache.org> AuthorDate: Thu Jan 16 10:09:27 2025 +0800 refresh pom structure (#676) --- griffin-bom/pom.xml | 36 ++++++---- griffin-doc/dev-2/new-metric-build.md | 1 + griffin-metric/pom.xml | 39 +++++----- .../org/apache/griffin/metric/entity/MetricV.java | 14 +++- .../src/main/resources/sql/create_h2.sql | 18 ++--- .../apache/griffin/metric/entity/MetricTest.java | 75 ++++++++++++-------- .../{application.yaml => application-h2.yaml} | 27 +++++-- .../{application.yaml => application-mysql.yaml} | 12 +++- griffin-metric/src/test/resources/application.yaml | 27 +------ pom.xml | 82 +++++++++++----------- 10 files changed, 187 insertions(+), 144 deletions(-) diff --git a/griffin-bom/pom.xml b/griffin-bom/pom.xml index dcec850c..3ffbdd64 100644 --- a/griffin-bom/pom.xml +++ b/griffin-bom/pom.xml @@ -28,7 +28,6 @@ under the License. <version>2.0.0-SNAPSHOT</version> </parent> - <groupId>org.apache.griffin</groupId> <artifactId>griffin-bom</artifactId> <version>2.0.0-SNAPSHOT</version> <packaging>pom</packaging> @@ -38,6 +37,7 @@ under the License. <properties> <spring-boot.version>3.3.4</spring-boot.version> <mybatis-plus.version>3.5.2</mybatis-plus.version> + <spring-cloud-dependencies.version>2021.0.3</spring-cloud-dependencies.version> <commons-codec.version>1.11</commons-codec.version> <commons-logging.version>1.1.1</commons-logging.version> <commons-lang3.version>3.12.0</commons-lang3.version> @@ -46,21 +46,29 @@ under the License. <commons-configuration.version>1.10</commons-configuration.version> <commons-email.version>1.5</commons-email.version> <commons-collections4.version>4.3</commons-collections4.version> + <commons-io.version>2.14.0</commons-io.version> <httpclient.version>4.5.13</httpclient.version> <httpcore.version>4.4.15</httpcore.version> - <jackson.version>2.13.4</jackson.version> - <slf4j.version>1.7.36</slf4j.version> - <logback.version>1.2.11</logback.version> + <jackson.version>2.18.1</jackson.version> + <slf4j.version>2.0.13</slf4j.version> + <logback.version>1.4.12</logback.version> <h2.version>2.2.220</h2.version> - <mysql-connector.version>8.0.28</mysql-connector.version> - <commons-io.version>2.11.0</commons-io.version> + <mysql-connector.version>8.0.33</mysql-connector.version> <presto-jdbc.version>0.238.1</presto-jdbc.version> <joda-time.version>2.10.13</joda-time.version> - <spring-cloud-dependencies.version>2021.0.3</spring-cloud-dependencies.version> - <snakeyaml.version>1.33</snakeyaml.version> + <snakeyaml.version>2.0</snakeyaml.version> + <junit.version>5.9.0</junit.version> + <mockito.version>3.12.4</mockito.version> + <spotbugs.version>3.1.12</spotbugs.version> + <lombok.version>1.18.20</lombok.version> + <guava.version>33.3.1-jre</guava.version> + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> + <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> + <java.version>1.8</java.version> + <maven.compiler.source>${java.version}</maven.compiler.source> + <maven.compiler.target>${java.version}</maven.compiler.target> </properties> - <dependencyManagement> <dependencies> <!-- spring --> @@ -190,9 +198,13 @@ under the License. <version>${snakeyaml.version}</version> </dependency> + <dependency> + <groupId>org.projectlombok</groupId> + <artifactId>lombok</artifactId> + <version>${lombok.version}</version> + <scope>provided</scope> + </dependency> + </dependencies> </dependencyManagement> - - - </project> \ No newline at end of file diff --git a/griffin-doc/dev-2/new-metric-build.md b/griffin-doc/dev-2/new-metric-build.md index da252677..7301a1bf 100644 --- a/griffin-doc/dev-2/new-metric-build.md +++ b/griffin-doc/dev-2/new-metric-build.md @@ -98,6 +98,7 @@ T_TAG_D Response: { + "id": 2, "metricId": 1, "value": 5.0 } diff --git a/griffin-metric/pom.xml b/griffin-metric/pom.xml index 76cabdb1..61e690e2 100644 --- a/griffin-metric/pom.xml +++ b/griffin-metric/pom.xml @@ -24,26 +24,18 @@ under the License. <parent> <groupId>org.apache.griffin</groupId> - <artifactId>griffin</artifactId> + <artifactId>griffin-bom</artifactId> <version>2.0.0-SNAPSHOT</version> + <relativePath>../griffin-bom/pom.xml</relativePath> </parent> <artifactId>griffin-metric</artifactId> <name>${project.artifactId}</name> <packaging>jar</packaging> - <dependencyManagement> - <dependencies> - <dependency> - <groupId>org.apache.griffin</groupId> - <artifactId>griffin-bom</artifactId> - <version>${project.version}</version> - <type>pom</type> - <scope>import</scope> - </dependency> - </dependencies> - </dependencyManagement> - + <properties> + <imported.property>${spring-boot.version}</imported.property> + </properties> <dependencies> <!--springboot--> <dependency> @@ -80,10 +72,11 @@ under the License. <artifactId>commons-collections4</artifactId> </dependency> - <dependency> - <groupId>com.baomidou</groupId> - <artifactId>mybatis-plus</artifactId> - </dependency> +<!-- <dependency>--> +<!-- <groupId>com.baomidou</groupId>--> +<!-- <artifactId>mybatis-plus</artifactId>--> +<!-- <version>${mybatis-plus.version}</version>--> +<!-- </dependency>--> <dependency> <groupId>com.baomidou</groupId> <artifactId>mybatis-plus-boot-starter</artifactId> @@ -109,13 +102,22 @@ under the License. <dependency> <groupId>com.h2database</groupId> <artifactId>h2</artifactId> -<!-- <scope>test</scope>--> </dependency> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> </dependency> + + <dependency> + <groupId>org.yaml</groupId> + <artifactId>snakeyaml</artifactId> + </dependency> + + <dependency> + <groupId>org.projectlombok</groupId> + <artifactId>lombok</artifactId> + </dependency> </dependencies> <build> @@ -123,6 +125,7 @@ under the License. <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> + <version>3.4.0</version> </plugin> </plugins> </build> diff --git a/griffin-metric/src/main/java/org/apache/griffin/metric/entity/MetricV.java b/griffin-metric/src/main/java/org/apache/griffin/metric/entity/MetricV.java index 350f297f..14850724 100644 --- a/griffin-metric/src/main/java/org/apache/griffin/metric/entity/MetricV.java +++ b/griffin-metric/src/main/java/org/apache/griffin/metric/entity/MetricV.java @@ -31,6 +31,8 @@ import lombok.ToString; import com.baomidou.mybatisplus.annotation.TableName; +import java.util.List; + /** * A metric value entity represents fundamental information. */ @@ -44,9 +46,15 @@ import com.baomidou.mybatisplus.annotation.TableName; public class MetricV extends BaseEntity { /** - * An unique identity for a metric. + * An incremental identity in metric value table. */ - @TableId(value="mid", type = IdType.AUTO) + @TableId(value="vid", type = IdType.AUTO) + private Long id; + + /** + * metric identity in metric definition table. + */ + @TableField(value="mid") private Long metricId; /** @@ -54,4 +62,6 @@ public class MetricV extends BaseEntity { */ @TableField(value = "val") private double value; + + private List<MetricTagD> tags; } diff --git a/griffin-metric/src/main/resources/sql/create_h2.sql b/griffin-metric/src/main/resources/sql/create_h2.sql index 5bdc3671..cb443f0c 100644 --- a/griffin-metric/src/main/resources/sql/create_h2.sql +++ b/griffin-metric/src/main/resources/sql/create_h2.sql @@ -8,6 +8,16 @@ CREATE TABLE t_metric_d ( mtime TIMESTAMP DEFAULT CURRENT_TIMESTAMP ); +DROP TABLE IF EXISTS t_metric_v; +CREATE TABLE t_metric_v ( + vid BIGINT not null AUTO_INCREMENT, + mid BIGINT references t_metric_d(mid), + val DOUBLE NOT NULL, + ctime TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + mtime TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + PRIMARY KEY(vid,mid) +); + DROP TABLE IF EXISTS t_tag_d; CREATE TABLE t_tag_d ( tid BIGINT PRIMARY KEY AUTO_INCREMENT, @@ -25,11 +35,3 @@ CREATE TABLE t_metric_tag ( mtime TIMESTAMP DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY(tid,mid) ); - -DROP TABLE IF EXISTS t_metric_v; -CREATE TABLE t_metric_v ( - mid BIGINT PRIMARY KEY references t_metric_d(mid), - val DOUBLE NOT NULL, - ctime TIMESTAMP DEFAULT CURRENT_TIMESTAMP, - mtime TIMESTAMP DEFAULT CURRENT_TIMESTAMP -); diff --git a/griffin-metric/src/test/java/org/apache/griffin/metric/entity/MetricTest.java b/griffin-metric/src/test/java/org/apache/griffin/metric/entity/MetricTest.java index 64277856..c410bff8 100644 --- a/griffin-metric/src/test/java/org/apache/griffin/metric/entity/MetricTest.java +++ b/griffin-metric/src/test/java/org/apache/griffin/metric/entity/MetricTest.java @@ -28,54 +28,52 @@ import static org.junit.jupiter.api.Assertions.*; public class MetricTest { + public static final long METRIC_A_ID = 100L; + public static final long VALUE_ID_1 = 1001L; + public static final long VALUE_ID_2 = 1002L; + public static final String METRIC_A_NAME = "Metric A"; + public static final String OWNER_A = "Owner A"; + public static final String DESCRIPTION_A = "Description A"; private MetricD metricD; + public static final long PERFMETRIC_TAGD_ID = 5000L; + public static final long CAPACITYMETRIC_TAGD_ID = 5001L; + private MetricTagD perfMetricTagD, capacityMetricTagD; private MetricV metricV1; private MetricV metricV2; - private TagAttachment tagAttachment; @BeforeEach public void setUp() { // Initialize MetricD metricD = MetricD.builder() - .metricId(1L) - .metricName("Metric A") - .owner("Owner A") - .description("Description A") + .metricId(METRIC_A_ID) + .metricName(METRIC_A_NAME) + .owner(OWNER_A) + .description(DESCRIPTION_A) .build(); // Initialize MetricV metricV1 = MetricV.builder() - .metricId(1L) + .id(VALUE_ID_1) + .metricId(METRIC_A_ID) .value(100.5) - .tags(TagAttachment.builder() - .metricId(1L) - .metricTags(createSampleTags()) - .build()) + .tags(createSampleTags()) .build(); metricV2 = MetricV.builder() - .metricId(1L) + .id(VALUE_ID_2) + .metricId(METRIC_A_ID) .value(200.75) - .tags(TagAttachment.builder() - .metricId(1L) - .metricTags(createSampleTags()) - .build()) - .build(); - - // Initialize Tags - tagAttachment = TagAttachment.builder() - .metricId(1L) - .metricTags(createSampleTags()) + .tags(createSampleTags()) .build(); } @Test public void testCreateMetricD() { assertNotNull(metricD); - assertEquals(1L, metricD.getMetricId()); - assertEquals("Metric A", metricD.getMetricName()); - assertEquals("Owner A", metricD.getOwner()); - assertEquals("Description A", metricD.getDescription()); + assertEquals(METRIC_A_ID, metricD.getMetricId()); + assertEquals(METRIC_A_NAME, metricD.getMetricName()); + assertEquals(OWNER_A, metricD.getOwner()); + assertEquals(DESCRIPTION_A, metricD.getDescription()); } @Test @@ -87,26 +85,41 @@ public class MetricTest { assertEquals(2, metricVs.size()); assertTrue(metricVs.contains(metricV1)); assertTrue(metricVs.contains(metricV2)); + assertEquals(metricV1.getMetricId(), metricV2.getMetricId()); + assertEquals(metricD.getMetricId(), metricV1.getMetricId()); + assertEquals(metricD.getMetricId(), metricV2.getMetricId()); } @Test public void testFetchMetricDWithTags() { // Mock fetch logic here. This would typically involve querying a database or service. MetricD fetchedMetricD = metricD; // Simulate fetching - TagAttachment fetchedTagAttachment = tagAttachment; // Simulate fetching tags + List<MetricTagD> fetchedTagAttachment = metricV1.getTags(); assertNotNull(fetchedMetricD); - assertEquals(1L, fetchedMetricD.getMetricId()); + assertEquals(METRIC_A_ID, fetchedMetricD.getMetricId()); assertNotNull(fetchedTagAttachment); - assertEquals(1L, fetchedTagAttachment.getMetricId()); - assertEquals(2, fetchedTagAttachment.getMetricTags().size()); + assertEquals(2, fetchedTagAttachment.size()); } private List<MetricTagD> createSampleTags() { List<MetricTagD> tags = new ArrayList<>(); - tags.add(new MetricTagD(1L, "key1", "value1")); - tags.add(new MetricTagD(2L, "key2", "value2")); + + // Initialize MetricTagD + perfMetricTagD = MetricTagD.builder() + .id(PERFMETRIC_TAGD_ID) + .tagKey("perf") + .tagValue("baseline") + .build(); + capacityMetricTagD = MetricTagD.builder() + .id(CAPACITYMETRIC_TAGD_ID) + .tagKey("capacity") + .tagValue("overall") + .build(); + + tags.add(perfMetricTagD); + tags.add(capacityMetricTagD); return tags; } } diff --git a/griffin-metric/src/test/resources/application.yaml b/griffin-metric/src/test/resources/application-h2.yaml similarity index 69% copy from griffin-metric/src/test/resources/application.yaml copy to griffin-metric/src/test/resources/application-h2.yaml index d91896a8..4fff1663 100644 --- a/griffin-metric/src/test/resources/application.yaml +++ b/griffin-metric/src/test/resources/application-h2.yaml @@ -14,19 +14,32 @@ # See the License for the specific language governing permissions and # limitations under the License. # +server: + port: 8888 spring: + application: + name: persist-service sql: init: - schema-locations: classpath:sql/create_mysql.sql + schema-locations: classpath:sql/create_h2.sql + continue-on-error: false + mode: embedded datasource: - driver-class-name: com.mysql.cj.jdbc.Driver - url: jdbc:mysql://127.0.0.1:3306/griffin - username: root + driver-class-name: org.h2.Driver + url: jdbc:h2:mem:griffin # configure in-memory database + username: sa password: "" hikari: maximum-pool-size: 5 + h2: + console: + path: /h2-console # configure the path of h2 console + enabled: on # start up the h2 console + settings: + web-allow-others: true + trace: true mybatis-plus: mapper-locations: classpath:mapper/*Mapper.xml @@ -39,4 +52,8 @@ mybatis-plus: global-config: db-config: id-type: auto - banner: false \ No newline at end of file + banner: false + +logging: + level: + root: info \ No newline at end of file diff --git a/griffin-metric/src/test/resources/application.yaml b/griffin-metric/src/test/resources/application-mysql.yaml old mode 100644 new mode 100755 similarity index 92% copy from griffin-metric/src/test/resources/application.yaml copy to griffin-metric/src/test/resources/application-mysql.yaml index d91896a8..29a165fb --- a/griffin-metric/src/test/resources/application.yaml +++ b/griffin-metric/src/test/resources/application-mysql.yaml @@ -14,8 +14,12 @@ # See the License for the specific language governing permissions and # limitations under the License. # +server: + port: 8080 spring: + application: + name: persist-service sql: init: schema-locations: classpath:sql/create_mysql.sql @@ -27,7 +31,6 @@ spring: hikari: maximum-pool-size: 5 - mybatis-plus: mapper-locations: classpath:mapper/*Mapper.xml type-aliases-package: org.apache.griffin.metric.dao.entity @@ -39,4 +42,9 @@ mybatis-plus: global-config: db-config: id-type: auto - banner: false \ No newline at end of file + banner: false + + +logging: + level: + root: info \ No newline at end of file diff --git a/griffin-metric/src/test/resources/application.yaml b/griffin-metric/src/test/resources/application.yaml old mode 100644 new mode 100755 index d91896a8..12890f7e --- a/griffin-metric/src/test/resources/application.yaml +++ b/griffin-metric/src/test/resources/application.yaml @@ -14,29 +14,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - spring: - sql: - init: - schema-locations: classpath:sql/create_mysql.sql - datasource: - driver-class-name: com.mysql.cj.jdbc.Driver - url: jdbc:mysql://127.0.0.1:3306/griffin - username: root - password: "" - hikari: - maximum-pool-size: 5 - - -mybatis-plus: - mapper-locations: classpath:mapper/*Mapper.xml - type-aliases-package: org.apache.griffin.metric.dao.entity - configuration: - cache-enabled: false - call-setters-on-nulls: true - map-underscore-to-camel-case: true - jdbc-type-for-null: NULL - global-config: - db-config: - id-type: auto - banner: false \ No newline at end of file + profiles: + active: h2 \ No newline at end of file diff --git a/pom.xml b/pom.xml index cf3a2d87..002efce8 100644 --- a/pom.xml +++ b/pom.xml @@ -40,14 +40,9 @@ under the License. <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> - <spring.boot.version>2.6.1</spring.boot.version> - <java.version>1.8</java.version> - <junit.version>5.9.0</junit.version> - <mockito.version>3.12.4</mockito.version> - <spotbugs.version>3.1.12</spotbugs.version> <maven-compiler-plugin.version>3.3</maven-compiler-plugin.version> <maven-assembly-plugin.version>3.3.0</maven-assembly-plugin.version> - <maven-release-plugin.version>2.5.3</maven-release-plugin.version> + <maven-release-plugin.version>3.1.1</maven-release-plugin.version> <maven-javadoc-plugin.version>2.10.3</maven-javadoc-plugin.version> <maven-source-plugin.version>2.4</maven-source-plugin.version> <maven-surefire-plugin.version>3.0.0-M6</maven-surefire-plugin.version> @@ -57,8 +52,6 @@ under the License. <jacoco.skip>false</jacoco.skip> <maven-jar-plugin.version>3.2.0</maven-jar-plugin.version> <exec-maven-plugin.version>3.0.0</exec-maven-plugin.version> - <lombok.version>1.18.20</lombok.version> - </properties> <licenses> @@ -94,6 +87,13 @@ under the License. <tag>HEAD</tag> </scm> + <repositories> + <repository> + <id>central</id> + <url>https://repo.maven.apache.org/maven2</url> + </repository> + </repositories> + <distributionManagement> </distributionManagement> @@ -129,42 +129,42 @@ under the License. <version>${project.version}</version> </dependency> - <dependency> - <groupId>org.junit</groupId> - <artifactId>junit-bom</artifactId> - <version>${junit.version}</version> - <type>pom</type> - <scope>import</scope> - </dependency> +<!-- <dependency>--> +<!-- <groupId>org.junit</groupId>--> +<!-- <artifactId>junit-bom</artifactId>--> +<!-- <version>${junit.version}</version>--> +<!-- <type>pom</type>--> +<!-- <scope>import</scope>--> +<!-- </dependency>--> </dependencies> </dependencyManagement> - <dependencies> - <!--DEV/ TEST ONLY!--> - <dependency> - <groupId>org.junit.jupiter</groupId> - <artifactId>junit-jupiter-api</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.junit.vintage</groupId> - <artifactId>junit-vintage-engine</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.springframework.boot</groupId> - <artifactId>spring-boot-configuration-processor</artifactId> - <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> +<!-- <dependencies>--> +<!-- <!–DEV/ TEST ONLY!–>--> +<!-- <dependency>--> +<!-- <groupId>org.junit.jupiter</groupId>--> +<!-- <artifactId>junit-jupiter-api</artifactId>--> +<!-- <scope>test</scope>--> +<!-- </dependency>--> +<!-- <dependency>--> +<!-- <groupId>org.junit.vintage</groupId>--> +<!-- <artifactId>junit-vintage-engine</artifactId>--> +<!-- <scope>test</scope>--> +<!-- </dependency>--> +<!-- <dependency>--> +<!-- <groupId>org.springframework.boot</groupId>--> +<!-- <artifactId>spring-boot-configuration-processor</artifactId>--> +<!-- <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> <pluginManagement> @@ -183,7 +183,7 @@ under the License. <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-release-plugin</artifactId> - <version>${maven-release-plugin.version}</version> + <version>3.1.1</version> <configuration> <tagNameFormat>@{project.version}</tagNameFormat> </configuration>