Skip to content

Commit

Permalink
refresh pom structure (#676)
Browse files Browse the repository at this point in the history
  • Loading branch information
toyboxman authored Jan 16, 2025
1 parent 4eb8fd9 commit bfa2835
Show file tree
Hide file tree
Showing 10 changed files with 264 additions and 137 deletions.
36 changes: 24 additions & 12 deletions griffin-bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand All @@ -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>
Expand All @@ -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 -->
Expand Down Expand Up @@ -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>
1 change: 1 addition & 0 deletions griffin-doc/dev-2/new-metric-build.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ T_TAG_D
Response:
{
"id": 2,
"metricId": 1,
"value": 5.0
}
Expand Down
39 changes: 21 additions & 18 deletions griffin-metric/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -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>
Expand All @@ -109,20 +102,30 @@ 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>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>3.4.0</version>
</plugin>
</plugins>
</build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand All @@ -44,14 +46,22 @@ 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;

/**
* A double number to store metric value.
*/
@TableField(value = "val")
private double value;

private List<MetricTagD> tags;
}
18 changes: 10 additions & 8 deletions griffin-metric/src/main/resources/sql/create_h2.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
);
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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<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;
}
}
Expand Down
Loading

0 comments on commit bfa2835

Please sign in to comment.