diff --git a/griffin-bom/pom.xml b/griffin-bom/pom.xml
index 2ed73a84b..20db8ab74 100644
--- a/griffin-bom/pom.xml
+++ b/griffin-bom/pom.xml
@@ -28,7 +28,6 @@ under the License.
2.0.0-SNAPSHOT
- org.apache.griffin
griffin-bom
2.0.0-SNAPSHOT
pom
@@ -36,8 +35,10 @@ under the License.
https://griffin.apache.org
+ 1.8
2.7.3
- 3.5.2
+ 2021.0.3
+ 3.5.7
1.11
1.1.1
3.12.0
@@ -46,21 +47,24 @@ under the License.
1.10
1.5
4.3
+ 2.14.0
4.5.13
4.4.15
- 2.13.4
- 1.7.36
- 1.2.11
+ 2.18.1
+ 2.0.13
+ 1.4.12
2.2.220
- 8.0.28
- 2.11.0
+ 8.0.33
0.238.1
2.10.13
- 2021.0.3
1.33
+ 1.18.20
+ 33.3.1-jre
+ 1.7.30
+ UTF-8
+ UTF-8
-
@@ -118,8 +122,8 @@ under the License.
- mysql
- mysql-connector-java
+ com.mysql
+ mysql-connector-j
${mysql-connector.version}
@@ -190,9 +194,13 @@ under the License.
${snakeyaml.version}
+
+ org.projectlombok
+ lombok
+ ${lombok.version}
+ provided
+
+
-
-
-
\ 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 da2526773..7301a1bf9 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 76cabdb11..4deffcacc 100644
--- a/griffin-metric/pom.xml
+++ b/griffin-metric/pom.xml
@@ -24,26 +24,18 @@ under the License.
org.apache.griffin
- griffin
+ griffin-bom
2.0.0-SNAPSHOT
+ ../griffin-bom/pom.xml
griffin-metric
${project.artifactId}
jar
-
-
-
- org.apache.griffin
- griffin-bom
- ${project.version}
- pom
- import
-
-
-
-
+
+ ${spring-boot.version}
+
@@ -80,10 +72,11 @@ under the License.
commons-collections4
-
- com.baomidou
- mybatis-plus
-
+
+
+
+
+
com.baomidou
mybatis-plus-boot-starter
@@ -109,12 +102,21 @@ under the License.
com.h2database
h2
-
- mysql
- mysql-connector-java
+ com.mysql
+ mysql-connector-j
+
+
+
+ org.yaml
+ snakeyaml
+
+
+
+ org.projectlombok
+ lombok
@@ -123,6 +125,7 @@ under the License.
org.springframework.boot
spring-boot-maven-plugin
+ 3.4.0
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 350f297f2..148507243 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 @@ Licensed to the Apache Software Foundation (ASF) under one
import com.baomidou.mybatisplus.annotation.TableName;
+import java.util.List;
+
/**
* A metric value entity represents fundamental information.
*/
@@ -44,9 +46,15 @@ Licensed to the Apache Software Foundation (ASF) under one
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 tags;
}
diff --git a/griffin-metric/src/main/resources/sql/create_h2.sql b/griffin-metric/src/main/resources/sql/create_h2.sql
index 5bdc36711..cb443f0ce 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 64277856f..c410bff85 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 @@ Licensed to the Apache Software Foundation (ASF) under one
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 void testIngestMetricV() {
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 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 createSampleTags() {
List 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-h2.yaml b/griffin-metric/src/test/resources/application-h2.yaml
new file mode 100644
index 000000000..4fff1663d
--- /dev/null
+++ b/griffin-metric/src/test/resources/application-h2.yaml
@@ -0,0 +1,59 @@
+#
+# 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.
+#
+server:
+ port: 8888
+
+spring:
+ application:
+ name: persist-service
+ sql:
+ init:
+ schema-locations: classpath:sql/create_h2.sql
+ continue-on-error: false
+ mode: embedded
+ datasource:
+ 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
+ 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
+
+logging:
+ level:
+ root: info
\ No newline at end of file
diff --git a/griffin-metric/src/test/resources/application-mysql.yaml b/griffin-metric/src/test/resources/application-mysql.yaml
new file mode 100755
index 000000000..29a165fbc
--- /dev/null
+++ b/griffin-metric/src/test/resources/application-mysql.yaml
@@ -0,0 +1,50 @@
+#
+# 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.
+#
+server:
+ port: 8080
+
+spring:
+ application:
+ name: persist-service
+ 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
+
+
+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 d91896a8a..12890f7ef
--- 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 cf3a2d879..5601c40b3 100644
--- a/pom.xml
+++ b/pom.xml
@@ -40,25 +40,21 @@ under the License.
UTF-8
UTF-8
- 2.6.1
- 1.8
- 5.9.0
- 3.12.4
- 3.1.12
3.3
3.3.0
- 2.5.3
+ 3.1.1
2.10.3
2.4
- 3.0.0-M6
+ 3.5.2
3.1.1
3.2.1
false
false
3.2.0
3.0.0
- 1.18.20
-
+ 5.9.0
+ 3.12.4
+ 3.1.12
@@ -94,6 +90,13 @@ under the License.
HEAD
+
+
+ central
+ https://repo.maven.apache.org/maven2
+
+
+
@@ -129,42 +132,42 @@ under the License.
${project.version}
-
- org.junit
- junit-bom
- ${junit.version}
- pom
- import
-
+
+
+
+
+
+
+
-
-
-
- org.junit.jupiter
- junit-jupiter-api
- test
-
-
- org.junit.vintage
- junit-vintage-engine
- test
-
-
- org.springframework.boot
- spring-boot-configuration-processor
- ${spring.boot.version}
- true
-
-
- org.projectlombok
- lombok
- ${lombok.version}
- provided
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -183,7 +186,7 @@ under the License.
org.apache.maven.plugins
maven-release-plugin
- ${maven-release-plugin.version}
+ 3.1.1
@{project.version}
@@ -224,7 +227,7 @@ under the License.
org.apache.maven.plugins
maven-surefire-plugin
- 3.1.2
+ ${maven-surefire-plugin.version}
false
true
@@ -241,9 +244,9 @@ under the License.
true
false
${project.build.directory}/surefire-reports
-
+
${project.build.directory}/tmp
-
+