Skip to content

Commit

Permalink
Update to Java21 (#62) (#64)
Browse files Browse the repository at this point in the history
* Update to Java21 (#62)

General changes:
- updated spring boot, spring versions
- updated test framework to junit-jupiter
- updated maven compiler
- updated other dependencies as needed to support java21



Update messaging lib and commons versions

Signed-off-by: Angelica Ochoa <[email protected]>

* Bug fix: always publish requests or samples even when validation fails (#65)

Signed-off-by: Angelica Ochoa <[email protected]>

* patch for writing validation report as string (#66)

* Fix test layer (#67)

Signed-off-by: Angelica Ochoa <[email protected]>

* Update SMILE dependencies to 2.0.0.RELEASE (#68)

Signed-off-by: Angelica Ochoa <[email protected]>

---------

Signed-off-by: Angelica Ochoa <[email protected]>
  • Loading branch information
ao508 authored Nov 15, 2024
1 parent b120d8b commit 30f3f2a
Show file tree
Hide file tree
Showing 11 changed files with 218 additions and 156 deletions.
6 changes: 3 additions & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
defaults: &defaults
docker:
- image: cimg/openjdk:8.0.275
- image: cimg/openjdk:21.0

version: 2.1

orbs:
maven: circleci/maven@1.0.3
maven: circleci/maven@1.4.1

jobs:
run_checkstyle:
Expand All @@ -25,7 +25,7 @@ jobs:
git checkout ${SMILE_COMMONS_VERSION}
- run:
name: "Build project..."
command: mvn clean install
command: mvn clean install -U
- run:
name: "Run checkstyle plugin..."
command: mvn checkstyle:checkstyle
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
FROM maven:3.6.1-jdk-11-slim
FROM maven:3.8.8
RUN mkdir /request-filter
ADD . /request-filter
WORKDIR /request-filter
RUN mvn clean install

FROM openjdk:11-slim
FROM openjdk:21
COPY --from=0 /request-filter/target/smile_request_filter.jar /request-filter/smile_request_filter.jar
ENTRYPOINT ["java"]
9 changes: 9 additions & 0 deletions jitpack.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
jdk:
- openjdk21

before_install:
- sdk install maven 3.8.8
- sdk use maven 3.8.8
- sdk install java 21.0.2-open
- sdk use java 21.0.2-open
- sdk update
52 changes: 23 additions & 29 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.3.3.RELEASE</version>
<version>3.3.3</version>
</parent>

<repositories>
Expand All @@ -29,18 +29,17 @@
</pluginRepositories>

<properties>
<java.version>1.8</java.version>
<maven.compiler.version>1.8</maven.compiler.version>
<spring.version>5.2.6.RELEASE</spring.version>
<spring.boot.version>2.3.3.RELEASE</spring.boot.version>
<slf4j.version>1.7.30</slf4j.version>
<jackson.version>2.11.2</jackson.version>
<java.version>21</java.version>
<maven.compiler.version>3.11.0</maven.compiler.version>
<spring.version>6.1.12</spring.version>
<spring.boot.version>3.3.3</spring.boot.version>
<jackson.version>2.17.2</jackson.version>
<!-- smile messaging -->
<smile_messaging_java.group>com.github.mskcc</smile_messaging_java.group>
<smile_messaging_java.version>1.4.1.RELEASE</smile_messaging_java.version>
<smile_messaging_java.version>2.0.0.RELEASE</smile_messaging_java.version>
<!-- smile commons centralized config properties -->
<smile_commons.group>com.github.mskcc</smile_commons.group>
<smile_commons.version>1.4.1.RELEASE</smile_commons.version>
<smile_commons.version>2.0.0.RELEASE</smile_commons.version>
</properties>

<dependencies>
Expand All @@ -58,20 +57,22 @@
</dependency>
<!-- testing -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-test</artifactId>
<version>${spring.boot.version}</version>
<scope>test</scope>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>${spring.version}</version>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.10.3</version>
<scope>test</scope>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>3.3.3</version>
<scope>test</scope>
<type>jar</type>
</dependency>
Expand All @@ -85,19 +86,12 @@
<dependency>
<groupId>org.skyscreamer</groupId>
<artifactId>jsonassert</artifactId>
<version>1.5.0</version>
</dependency>
<!-- string utils -->
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>19.0</version>
<type>jar</type>
<version>1.5.3</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.11</version>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.3.4</version>
</dependency>
</dependencies>

Expand Down Expand Up @@ -130,10 +124,10 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.1</version>
<version>${maven.compiler.version}</version>
<configuration>
<source>${maven.compiler.version}</source>
<target>${maven.compiler.version}</target>
<source>${java.version}</source>
<target>${java.version}</target>
<compilerArgument>-Xlint:deprecation</compilerArgument>
</configuration>
</plugin>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package org.mskcc.smile.service.impl;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.nats.client.Message;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.Map;
import java.util.concurrent.BlockingQueue;
Expand All @@ -29,16 +29,16 @@
@Service
public class PromotedRequestMsgHandlingServiceImpl implements PromotedRequestMsgHandlingService {

@Value("${igo.validate_promoted_request_topic}")
@Value("${igo.validate_promoted_request_topic:}")
private String VALIDATE_PROMOTED_REQUEST_TOPIC;

@Value("${igo.cmo_promoted_label_topic}")
@Value("${igo.cmo_promoted_label_topic:}")
private String CMO_PROMOTED_LABEL_TOPIC;

@Value("${igo.promoted_request_topic}")
@Value("${igo.promoted_request_topic:}")
private String IGO_PROMOTED_REQUEST_TOPIC;

@Value("${num.promoted_request_handler_threads}")
@Value("${num.promoted_request_handler_threads:1}")
private int NUM_PROMOTED_REQUEST_HANDLERS;

@Autowired
Expand Down Expand Up @@ -75,14 +75,16 @@ public void run() {
validRequestChecker.generatePromotedRequestValidationMap(requestJson);
Map<String, Object> requestStatus =
mapper.convertValue(promotedRequestJsonMap.get("status"), Map.class);
String requestWithStatus = updateJsonWithValidationMap(requestJson, requestStatus);

if ((Boolean) requestStatus.get("validationStatus")) {
// if request is cmo then publish to CMO_PROMOTED_LABEL_TOPIC
// otherwise publish to IGO_PROMOTED_REQUEST_TOPIC
String topic = validRequestChecker.isCmo(requestJson)
? CMO_PROMOTED_LABEL_TOPIC : IGO_PROMOTED_REQUEST_TOPIC;
String requestId = validRequestChecker.getRequestId(requestJson);
LOG.info("Promoted request passed sanity checks - publishing to: " + topic);
messagingGateway.publish(requestId, topic, requestJson);
messagingGateway.publish(requestId, topic, requestWithStatus);
}
}
if (interrupted && promotedRequestQueue.isEmpty()) {
Expand Down Expand Up @@ -162,4 +164,19 @@ public void onMessage(Message msg, Object message) {
}
});
}

/**
* Updates the input json with the validation map provided.
* The validation map contains the validation report and validation status.
* @param inputJson
* @param validationMap
* @return String
* @throws JsonProcessingException
*/
private String updateJsonWithValidationMap(String inputJson, Map<String, Object> validationMap)
throws JsonProcessingException {
Map<String, Object> inputJsonMap = mapper.readValue(inputJson, Map.class);
inputJsonMap.put("status", validationMap);
return mapper.writeValueAsString(inputJsonMap);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import com.fasterxml.jackson.databind.ObjectMapper;
import io.nats.client.Message;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.CountDownLatch;
Expand All @@ -28,16 +27,16 @@
@Service
public class RequestFilterMsgHandlingServiceIml implements RequestFilterMessageHandlingService {

@Value("${igo.request_filter_topic}")
@Value("${igo.request_filter_topic:}")
private String IGO_REQUEST_FILTER_TOPIC;

@Value("${igo.cmo_label_generator_topic}")
@Value("${igo.cmo_label_generator_topic:}")
private String CMO_LABEL_GENERATOR_TOPIC;

@Value("${igo.new_request_topic}")
@Value("${igo.new_request_topic:}")
private String IGO_NEW_REQUEST_TOPIC;

@Value("${num.new_request_handler_threads}")
@Value("${num.new_request_handler_threads:1}")
private int NUM_NEW_REQUEST_HANDLERS;

@Autowired
Expand Down Expand Up @@ -79,25 +78,27 @@ public void run() {
if (passCheck) {
LOG.info("Request'" + requestId + "' passed sanity check, publishing to: "
+ CMO_LABEL_GENERATOR_TOPIC);
// even if sanity check passed there might still be information worth
// reporting from the sample-level validation reports
messagingGateway.publish(requestId,
CMO_LABEL_GENERATOR_TOPIC,
filteredRequestJson);
} else {
LOG.error("Sanity check failed on request: " + requestId);
LOG.error("Sanity check failed on request: " + filteredRequestJson);
}
// even if sanity check failed there might still be information worth
// reporting from the sample-level validation reports
messagingGateway.publish(requestId,
CMO_LABEL_GENERATOR_TOPIC,
filteredRequestJson);
} else {
LOG.info("Handling non-CMO request...");
if (passCheck) {
LOG.info("Request '" + requestId + "' passed sanity check, publishing to: "
+ IGO_NEW_REQUEST_TOPIC);
messagingGateway.publish(requestId,
IGO_NEW_REQUEST_TOPIC,
filteredRequestJson);
} else {
LOG.error("Sanity check failed on request: " + requestId);
LOG.error("Sanity check failed on request: " + filteredRequestJson);
}
// even if sanity check failed there might still be information worth
// reporting from the sample-level validation reports
messagingGateway.publish(requestId,
IGO_NEW_REQUEST_TOPIC,
filteredRequestJson);
}
// data dog log message
String ddogLogMessage = validRequestChecker.generateValidationReport(
Expand Down
Loading

0 comments on commit 30f3f2a

Please sign in to comment.