Skip to content

Commit e56e4ea

Browse files
feat: Converting MCE to a Spring boot Application (datahub-project#1629)
1 parent ee791b7 commit e56e4ea

File tree

14 files changed

+343
-222
lines changed

14 files changed

+343
-222
lines changed

build.gradle

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,10 @@ project.ext.externalDependency = [
6666
'springCore': 'org.springframework:spring-core:5.1.6.RELEASE',
6767
'springJdbc': 'org.springframework:spring-jdbc:5.1.6.RELEASE',
6868
'springWeb': 'org.springframework:spring-web:5.1.6.RELEASE',
69+
'springBootStarterWeb': 'org.springframework.boot:spring-boot-starter-web:2.1.2.RELEASE',
70+
'springBootStarterJetty': 'org.springframework.boot:spring-boot-starter-jetty:2.1.2.RELEASE',
71+
'springKafka': 'org.springframework.kafka:spring-kafka:2.2.3.RELEASE',
72+
'springActuator': 'org.springframework.boot:spring-boot-starter-actuator:2.1.2.RELEASE',
6973
'testng': 'org.testng:testng:6.9.9'
7074
]
7175

@@ -102,4 +106,4 @@ subprojects {
102106
}
103107
}
104108
}
105-
}
109+
}

docker/mce-consumer/Dockerfile

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,13 @@ MAINTAINER Kerem Sahin [email protected]
44

55
COPY . datahub-src
66
RUN cd datahub-src && ./gradlew :metadata-jobs:mce-consumer-job:build \
7-
&& cp metadata-jobs/mce-consumer-job/build/distributions/mce-consumer-job.zip ../mce-consumer-job.zip \
8-
&& cd .. && rm -rf datahub-src && unzip mce-consumer-job.zip
7+
&& cp metadata-jobs/mce-consumer-job/build/libs/mce-consumer-job.jar ../mce-consumer-job.jar \
8+
&& cd .. && rm -rf datahub-src
99

1010
FROM openjdk:8-jre-alpine
1111

12-
COPY --from=builder /mce-consumer-job /mce-consumer-job/
12+
COPY --from=builder /mce-consumer-job.jar /mce-consumer-job.jar
13+
14+
EXPOSE 9090
15+
16+
ENTRYPOINT ["java", "-jar", "mce-consumer-job.jar"]

docker/mce-consumer/docker-compose.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,16 @@ services:
55
image: keremsahin/datahub-mce-consumer:latest
66
hostname: datahub-mce-consumer
77
container_name: datahub-mce-consumer
8+
ports:
9+
- "9090:9090"
810
environment:
911
- KAFKA_BOOTSTRAP_SERVER=broker:29092
1012
- KAFKA_SCHEMAREGISTRY_URL=http://schema-registry:8081
1113
- GMS_HOST=datahub-gms
1214
- GMS_PORT=8080
13-
command: "sh -c './mce-consumer-job/bin/mce-consumer-job'"
15+
- KAFKA_MCE_TOPIC_NAME=MetadataChangeEvent
16+
- KAFKA_FMCE_TOPIC_NAME=FailedMetadataChangeEvent
1417

1518
networks:
1619
default:
17-
name: datahub_network
20+
name: datahub_network

docker/quickstart/docker-compose.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,8 @@ services:
241241
image: keremsahin/datahub-mce-consumer:latest
242242
hostname: datahub-mce-consumer
243243
container_name: datahub-mce-consumer
244+
ports:
245+
- "9090:9090"
244246
environment:
245247
- KAFKA_BOOTSTRAP_SERVER=broker:29092
246248
- KAFKA_SCHEMAREGISTRY_URL=http://schema-registry:8081
@@ -250,7 +252,7 @@ services:
250252
- kafka-setup
251253
- datahub-gms
252254
command: "sh -c 'while ping -c1 kafka-setup &>/dev/null; do echo waiting for kafka-setup... && sleep 1; done; \
253-
echo kafka-setup done! && ./mce-consumer-job/bin/mce-consumer-job'"
255+
echo kafka-setup done! && java -jar mce-consumer-job.jar'"
254256

255257
networks:
256258
default:

metadata-jobs/mce-consumer-job/README.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,14 @@ Quickest way to try out `MCE Consumer Job` is running the [Docker image](../../d
2929
If you do modify things and want to try it out quickly without building the Docker image, you can also run
3030
the application directly from command line after a successful [build](#build):
3131
```
32-
./gradlew :metadata-jobs:mce-consumer-job:run
33-
```
32+
./gradlew :metadata-jobs:mce-consumer-job:bootRun
33+
```
34+
## Endpoints
35+
Spring boot actuator has been enabled for MCE Application.
36+
`healthcheck`, `metrics` and `info` web endpoints are enabled by default.
37+
38+
`healthcheck` - http://localhost:9090/actuator/health
39+
`metrics` - http://localhost:9090/actuator/metrics
40+
41+
To retrieve a specific metric - http://localhost:9090/actuator/metrics/kafka.consumer.records.consumed.total
42+

metadata-jobs/mce-consumer-job/build.gradle

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1-
apply plugin: 'application'
2-
apply plugin: 'java'
1+
plugins {
2+
id 'org.springframework.boot' version '2.1.2.RELEASE'
3+
id 'java'
4+
}
5+
36
apply plugin: 'pegasus'
47

58
configurations {
@@ -23,6 +26,13 @@ dependencies {
2326
compile externalDependency.kafkaAvroSerde
2427
compile externalDependency.kafkaStreams
2528
compile externalDependency.kafkaSerializers
29+
compile (externalDependency.springBootStarterWeb) {
30+
exclude module: "spring-boot-starter-tomcat"
31+
}
32+
compile externalDependency.springBootStarterJetty
33+
compile externalDependency.springKafka
34+
35+
compile externalDependency.springActuator
2636

2737
compileOnly externalDependency.lombok
2838

@@ -47,4 +57,6 @@ clean {
4757
project.delete("src/main/resources/avro")
4858
}
4959

50-
mainClassName = 'com.linkedin.metadata.kafka.MceStreamTask'
60+
bootJar {
61+
mainClassName = 'com.linkedin.metadata.kafka.MceConsumerApplication'
62+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package com.linkedin.metadata.kafka;
2+
3+
import org.springframework.boot.SpringApplication;
4+
import org.springframework.boot.autoconfigure.SpringBootApplication;
5+
import org.springframework.boot.autoconfigure.elasticsearch.rest.RestClientAutoConfiguration;
6+
import org.springframework.boot.autoconfigure.kafka.KafkaAutoConfiguration;
7+
8+
@SpringBootApplication(exclude = {RestClientAutoConfiguration.class, KafkaAutoConfiguration.class})
9+
public class MceConsumerApplication {
10+
11+
public static void main(String[] args) {
12+
SpringApplication.run(MceConsumerApplication.class, args);
13+
}
14+
15+
}

metadata-jobs/mce-consumer-job/src/main/java/com/linkedin/metadata/kafka/MceStreamTask.java

Lines changed: 0 additions & 208 deletions
This file was deleted.

0 commit comments

Comments
 (0)