Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DSM] PEPPER-1402 PEPPER-1397 refactoring DSM event transmission into DSS and retrying failed events #2874

Merged
merged 36 commits into from
Jun 6, 2024
Merged
Show file tree
Hide file tree
Changes from 27 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
b75f783
PEPPER-1402 WIP some refactoring and test working now
pegahtah Apr 11, 2024
8f7ce29
Merge remote-tracking branch 'origin/develop' into PEPPER-1402_PEPPER…
pegahtah Apr 12, 2024
864f014
Merge branch 'develop' into PEPPER-1402_PEPPER-1397_trigger_ddp
pegahtah Apr 24, 2024
4e39668
PEPPER-1402 PEPPER-1397
pegahtah Apr 24, 2024
962e9f6
PEPPER-1402 PEPPER-1397
pegahtah Apr 24, 2024
d0d09f8
PEPPER-1402 PEPPER-1397
pegahtah Apr 24, 2024
ef86513
PEPPER-1402 PEPPER-1397
pegahtah Apr 26, 2024
5aca459
PEPPER-1402 PEPPER-1397
pegahtah Apr 26, 2024
b9aba34
PEPPER-1402 merged develop in and added changes
pegahtah May 9, 2024
a91eb51
PEPPER-1402 checkstyle fix
pegahtah May 9, 2024
2011496
Merge branch 'develop' into PEPPER-1402_PEPPER-1397_trigger_ddp
pegahtah May 21, 2024
c392262
PEPPER-1402 more refactoring, changed EventUtil to EventService
pegahtah May 21, 2024
73192f6
PEPPER-1402 PEPPER-1397 added tests for all scenarios, changed the cl…
pegahtah May 23, 2024
5c40fa7
PEPPER-1402 PEPPER-1397 checkstyle fix
pegahtah May 23, 2024
b483a7f
Merge remote-tracking branch 'origin/develop' into PEPPER-1402_PEPPER…
pegahtah May 23, 2024
2d31cc2
PEPPER-1402 PEPPER-1397 deleting unused classes
pegahtah May 23, 2024
4114d03
PEPPER-1402 PEPPER-1397 deleting unused classes
pegahtah May 23, 2024
71acc96
PEPPER-1402 PEPPER-1397 small clean ups
pegahtah May 23, 2024
a68831a
PEPPER-1402 PEPPER-1397 fixed a bug in TestHelper and moved dto and d…
pegahtah May 23, 2024
9a33f71
PEPPER-1402 PEPPER-1397 fixed java doc comment
pegahtah May 23, 2024
90db874
PEPPER-1402 PEPPER-1397 small letters
pegahtah May 23, 2024
f41e052
PEPPER-1402 PEPPER-1397 small letters
pegahtah May 23, 2024
991aad6
PEPPER-1402 changes to add jitters using IntervalFunction and Retry, …
pegahtah May 24, 2024
b060d15
PEPPER-1402 Adding logging
pegahtah May 28, 2024
0389076
PEPPER-1402 Moved DsmNotificationEventType.java and DsmNotificationPa…
pegahtah May 28, 2024
4a64816
Merge remote-tracking branch 'origin/develop' into PEPPER-1402_PEPPER…
pegahtah May 28, 2024
3b72df0
PEPPER-1402 based on PR comments I increased the initial wait time fo…
pegahtah Jun 3, 2024
4c27130
Merge remote-tracking branch 'origin/develop' into PEPPER-1402_PEPPER…
pegahtah Jun 3, 2024
5158814
PEPPER-1402 cleaned up code
pegahtah Jun 3, 2024
81336d8
PEPPER-1402 cleaned up code
pegahtah Jun 3, 2024
66308da
PEPPER-1402 cleaned up code
pegahtah Jun 3, 2024
f5834d3
PEPPER-1402 made BaseKitTestUtil an abstract class
pegahtah Jun 3, 2024
d8dd384
PEPPER-1402 changed BaseKitTestUtil into KitTestUtil and removed Pepp…
pegahtah Jun 5, 2024
c3dbf1c
Merge branch 'develop' into PEPPER-1402_PEPPER-1397_trigger_ddp
pegahtah Jun 6, 2024
66ddffb
Merge remote-tracking branch 'origin/develop' into PEPPER-1402_PEPPER…
pegahtah Jun 6, 2024
dad9982
PEPPER-1402 resolving conflicts
pegahtah Jun 6, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions pepper-apis/ddp-common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -143,5 +143,11 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>jakarta.validation</groupId>
<artifactId>jakarta.validation-api</artifactId>
<version>2.0.2</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.broadinstitute.ddp.model.dsm;
package org.broadinstitute.ddp.notficationevent;

public enum DsmNotificationEventType {
/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
package org.broadinstitute.ddp.json.dsm;
package org.broadinstitute.ddp.notficationevent;

import java.util.Optional;
import javax.validation.constraints.NotBlank;

import com.google.gson.JsonElement;
import com.google.gson.annotations.SerializedName;
import org.broadinstitute.ddp.model.dsm.DsmNotificationEventType;
import org.broadinstitute.ddp.model.dsm.KitReasonType;

public class DsmNotificationPayload {

Expand Down Expand Up @@ -39,6 +37,17 @@ public DsmNotificationPayload(String eventType, String kitRequestId, KitReasonTy
this.kitReasonType = kitReasonType;
}

/**
* Creates a new event to be sent to DSS.
* eventInfo could be ddpParticipantId for participant events, or ddpKitRequestId for kit events.
* **/
public DsmNotificationPayload(String eventType, long eventDate, KitReasonType kitReasonType, String eventInfo) {
this.eventType = eventType;
this.eventDate = eventDate;
this.eventInfo = eventInfo;
this.kitReasonType = kitReasonType;
}

public String getEventType() {
return eventType;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.broadinstitute.ddp.model.dsm;
package org.broadinstitute.ddp.notficationevent;

/**
* The reason of a kit. What each reason means and how it affects workflow will depend on the study's configuration.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import java.util.List;

import com.typesafe.config.Config;

import com.zaxxer.hikari.HikariConfig;
import com.zaxxer.hikari.HikariDataSource;
import liquibase.Contexts;
Expand Down
5 changes: 5 additions & 0 deletions pepper-apis/dsm-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,11 @@
<version>2.4.11</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>io.github.resilience4j</groupId>
<artifactId>resilience4j-retry</artifactId>
<version>2.2.0</version>
</dependency>
</dependencies>
<build>
<plugins>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
import org.broadinstitute.ddp.exception.DDPInternalError;
import org.broadinstitute.ddp.logging.LogUtil;
import org.broadinstitute.ddp.util.LiquibaseUtil;

import org.broadinstitute.dsm.db.dao.ddp.onchistory.OncHistoryDetailDaoImpl;
import org.broadinstitute.dsm.db.dao.kit.KitDao;
import org.broadinstitute.dsm.db.dao.mercury.ClinicalOrderDao;
Expand Down Expand Up @@ -97,10 +96,10 @@
import org.broadinstitute.dsm.route.NDIRoute;
import org.broadinstitute.dsm.route.OncHistoryTemplateRoute;
import org.broadinstitute.dsm.route.OncHistoryUploadRoute;
import org.broadinstitute.dsm.route.ParticipantEventRoute;
import org.broadinstitute.dsm.route.ParticipantExitRoute;
import org.broadinstitute.dsm.route.ParticipantStatusRoute;
import org.broadinstitute.dsm.route.PatchRoute;
import org.broadinstitute.dsm.route.SkippedParticipantEventRoute;
import org.broadinstitute.dsm.route.TriggerSomaticResultSurveyRoute;
import org.broadinstitute.dsm.route.TriggerSurveyRoute;
import org.broadinstitute.dsm.route.UserSettingRoute;
Expand Down Expand Up @@ -135,13 +134,13 @@
import org.broadinstitute.dsm.route.tag.cohort.DeleteCohortTagRoute;
import org.broadinstitute.dsm.route.util.JacksonResponseTransformer;
import org.broadinstitute.dsm.security.Auth0Util;
import org.broadinstitute.dsm.service.EventService;
import org.broadinstitute.dsm.service.FileDownloadService;
import org.broadinstitute.dsm.service.SomaticResultUploadService;
import org.broadinstitute.dsm.statics.ApplicationConfigConstants;
import org.broadinstitute.dsm.statics.RequestParameter;
import org.broadinstitute.dsm.statics.RoutePath;
import org.broadinstitute.dsm.util.DSMConfig;
import org.broadinstitute.dsm.util.EventUtil;
import org.broadinstitute.dsm.util.JWTRouteFilter;
import org.broadinstitute.dsm.util.JavaHeapDumper;
import org.broadinstitute.dsm.util.JsonNullTransformer;
Expand Down Expand Up @@ -347,15 +346,17 @@ public static void createScheduleJob(@NonNull Scheduler scheduler, @NonNull Conf
/**
* Job to trigger ddp reminder emails and external shipper
*/
public static void createScheduleJob(@NonNull Scheduler scheduler, EventUtil eventUtil, NotificationUtil notificationUtil,
public static void createScheduleJob(@NonNull Scheduler scheduler, EventService eventService, NotificationUtil notificationUtil,
@NonNull Class<? extends Job> jobClass, @NonNull String identity, @NonNull String cronExpression,
@NonNull BasicTriggerListener basicTriggerListener) throws SchedulerException {
//create job
JobDetail job = JobBuilder.newJob(jobClass).withIdentity(identity, BasicTriggerListener.NO_CONCURRENCY_GROUP).build();

if (eventUtil != null) {
if (eventService != null) {
//pass parameters to JobDataMap for JobDetail
job.getJobDataMap().put(EVENT_UTIL, eventUtil);
job.getJobDataMap().put(EVENT_UTIL, eventService);
} else {
logger.error("EventService is null, some jobs might not work properly");
}
if (notificationUtil != null) {
//pass parameters to JobDataMap for JobDetail
Expand Down Expand Up @@ -685,8 +686,8 @@ protected void setupCustomRouting(@NonNull Config cfg) {
//no GET for USER_SETTINGS_REQUEST because UI gets them per AuthenticationRoute
patch(UI_ROOT + RoutePath.USER_SETTINGS_REQUEST, new UserSettingRoute(), new GsonResponseTransformer());

EventUtil eventUtil = new EventUtil();
scheduler = setupJobs(cfg, kitUtil, notificationUtil, eventUtil);
EventService eventService = new EventService();
scheduler = setupJobs(cfg, kitUtil, notificationUtil, eventService);

//TODO - redo with pubsub
JavaHeapDumper heapDumper = new JavaHeapDumper();
Expand Down Expand Up @@ -867,10 +868,10 @@ private void setupMiscellaneousRoutes() {
get(UI_ROOT + RoutePath.EVENT_TYPES + RoutePath.ROUTE_SEPARATOR + RequestParameter.REALM, new EventTypeRoute(),
new GsonResponseTransformer());

ParticipantEventRoute participantEventRoute = new ParticipantEventRoute();
get(UI_ROOT + RoutePath.PARTICIPANT_EVENTS + RoutePath.ROUTE_SEPARATOR + RequestParameter.REALM, participantEventRoute,
SkippedParticipantEventRoute skippedParticipantEventRoute = new SkippedParticipantEventRoute();
get(UI_ROOT + RoutePath.PARTICIPANT_EVENTS + RoutePath.ROUTE_SEPARATOR + RequestParameter.REALM, skippedParticipantEventRoute,
new GsonResponseTransformer());
post(UI_ROOT + RoutePath.SKIP_PARTICIPANT_EVENTS, participantEventRoute, new GsonResponseTransformer());
post(UI_ROOT + RoutePath.SKIP_PARTICIPANT_EVENTS, skippedParticipantEventRoute, new GsonResponseTransformer());

post(UI_ROOT + RoutePath.NDI_REQUEST, new NDIRoute(), new GsonResponseTransformer());

Expand Down Expand Up @@ -975,7 +976,7 @@ private void setupPubSubPublisherRoutes(Config config) {
}

private Scheduler setupJobs(@NonNull Config cfg, @NonNull KitUtil kitUtil, @NonNull NotificationUtil notificationUtil,
@NonNull EventUtil eventUtil) {
@NonNull EventService eventService) {
String schedulerName = null;
Scheduler scheduler = null;
if (cfg.getBoolean(ApplicationConfigConstants.QUARTZ_ENABLE_JOBS)) {
Expand All @@ -996,7 +997,7 @@ private Scheduler setupJobs(@NonNull Config cfg, @NonNull KitUtil kitUtil, @NonN
createScheduleJob(scheduler, cfg, notificationUtil, kitUtil, GPNotificationJob.class, "GP_SCHEDULE_JOB",
cfg.getString(ApplicationConfigConstants.EMAIL_CRON_EXPRESSION_FOR_GP_NOTIFICATION));

createScheduleJob(scheduler, eventUtil, notificationUtil, DDPEventJob.class, "TRIGGER_DDP_EVENT",
createScheduleJob(scheduler, eventService, notificationUtil, DDPEventJob.class, "TRIGGER_DDP_EVENT",
cfg.getString(ApplicationConfigConstants.QUARTZ_CRON_EXPRESSION_FOR_DDP_EVENT_TRIGGER),
new DDPEventTriggerListener());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ public DDPInstance(int ddpInstanceId, String name) {
public static DDPInstance getDDPInstance(@NonNull String realm) {
SimpleResult results = inTransaction((conn) -> {
SimpleResult dbVals = new SimpleResult();
try (PreparedStatement stmt = conn.prepareStatement(SQL_SELECT_ALL_ACTIVE_REALMS + QueryExtension.BY_INSTANCE_NAME)) {
try (PreparedStatement stmt = conn.prepareStatement(SQL_SELECT_ALL_ACTIVE_REALMS.concat(QueryExtension.BY_INSTANCE_NAME))) {
stmt.setString(1, realm);
try (ResultSet rs = stmt.executeQuery()) {
if (rs.next()) {
Expand All @@ -178,7 +178,7 @@ public static DDPInstance getDDPInstance(@NonNull String realm) {
public static DDPInstance getDDPInstanceByGuid(@NonNull String studyGuid) {
SimpleResult results = inTransaction(conn -> {
SimpleResult dbVals = new SimpleResult();
try (PreparedStatement stmt = conn.prepareStatement(SQL_SELECT_ALL_ACTIVE_REALMS + QueryExtension.BY_STUDY_GUID)) {
try (PreparedStatement stmt = conn.prepareStatement(SQL_SELECT_ALL_ACTIVE_REALMS.concat(QueryExtension.BY_STUDY_GUID))) {
stmt.setString(1, studyGuid);
try (ResultSet rs = stmt.executeQuery()) {
if (rs.next()) {
Expand All @@ -200,7 +200,7 @@ public static DDPInstance getDDPInstanceByGuid(@NonNull String studyGuid) {
public static DDPInstance getDDPInstanceById(@NonNull Integer ddpInstanceId) {
SimpleResult results = inTransaction((conn) -> {
SimpleResult dbVals = new SimpleResult();
try (PreparedStatement stmt = conn.prepareStatement(SQL_SELECT_ALL_ACTIVE_REALMS + QueryExtension.BY_INSTANCE_ID)) {
try (PreparedStatement stmt = conn.prepareStatement(SQL_SELECT_ALL_ACTIVE_REALMS.concat(QueryExtension.BY_INSTANCE_ID))) {
stmt.setInt(1, ddpInstanceId);
try (ResultSet rs = stmt.executeQuery()) {
if (rs.next()) {
Expand Down Expand Up @@ -258,7 +258,7 @@ public static DDPInstance getDDPInstanceWithRole(@NonNull String realm, @NonNull
// and by Covid19OrderRegistrar
public static DDPInstance getDDPInstanceWithRole(@NonNull String realm, @NonNull String role, Connection conn) {
SimpleResult dbVals = new SimpleResult();
try (PreparedStatement stmt = conn.prepareStatement(SQL_SELECT_INSTANCE_WITH_ROLE + QueryExtension.BY_INSTANCE_NAME)) {
try (PreparedStatement stmt = conn.prepareStatement(SQL_SELECT_INSTANCE_WITH_ROLE.concat(QueryExtension.BY_INSTANCE_NAME))) {
stmt.setString(1, role);
stmt.setString(2, realm);
try (ResultSet rs = stmt.executeQuery()) {
Expand All @@ -276,7 +276,7 @@ public static DDPInstance getDDPInstanceWithRole(@NonNull String realm, @NonNull
public static DDPInstance getDDPInstanceWithRoleByStudyGuid(@NonNull String studyGuid, @NonNull String role) {
SimpleResult results = inTransaction((conn) -> {
SimpleResult dbVals = new SimpleResult();
try (PreparedStatement stmt = conn.prepareStatement(SQL_SELECT_INSTANCE_WITH_ROLE + QueryExtension.BY_STUDY_GUID)) {
try (PreparedStatement stmt = conn.prepareStatement(SQL_SELECT_INSTANCE_WITH_ROLE.concat(QueryExtension.BY_STUDY_GUID))) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the concat changes are a fix for sonar marking these as "blocker" issues

stmt.setString(1, role);
stmt.setString(2, studyGuid);
try (ResultSet rs = stmt.executeQuery()) {
Expand Down Expand Up @@ -404,31 +404,6 @@ public static DDPInstance getDDPInstanceWithRoleByParticipant(@NonNull String pa
return (DDPInstance) results.resultValue;
}

public static boolean getRole(@NonNull String realm, @NonNull String role) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was not used

SimpleResult results = inTransaction((conn) -> {
SimpleResult dbVals = new SimpleResult();
try (PreparedStatement stmt = conn.prepareStatement(SQL_SELECT_INSTANCE_WITH_ROLE + QueryExtension.BY_INSTANCE_NAME)) {
stmt.setString(1, role);
stmt.setString(2, realm);
try (ResultSet rs = stmt.executeQuery()) {
if (rs.next()) {
dbVals.resultValue = rs.getBoolean(DBConstants.HAS_ROLE);
}
} catch (SQLException e) {
throw new RuntimeException("Error getting role of realm " + realm, e);
}
} catch (SQLException ex) {
dbVals.resultException = ex;
}
return dbVals;
});

if (results.resultException != null) {
throw new RuntimeException("Couldn't get role of realm " + realm, results.resultException);
}
return (boolean) results.resultValue;
}

public static DDPInstance getDDPInstanceWithRoleFormResultSet(@NonNull ResultSet rs) throws SQLException {
String notificationRecipient = rs.getString(DBConstants.NOTIFICATION_RECIPIENT);
List<String> recipients = null;
Expand Down Expand Up @@ -536,8 +511,9 @@ public static DDPInstance from(DDPInstanceDto ddpInstanceDto) {
.withCollaboratorIdPrefix(ddpInstanceDto.getCollaboratorIdPrefix())
.withDaysMrAttentionNeeded(ddpInstanceDto.getMrAttentionFlagD())
.withDaysTissueAttentionNeeded(ddpInstanceDto.getTissueAttentionFlagD())
.withHasAuth0Token(ddpInstanceDto.getAuth0Token() != null)
.withNotificationRecipient(ddpInstanceDto.getNotificationRecipients())
.withHasAuth0Token(ddpInstanceDto.getAuth0Token() != null && ddpInstanceDto.getAuth0Token())
.withNotificationRecipient(ddpInstanceDto.getNotificationRecipients().isEmpty()
? null : ddpInstanceDto.getNotificationRecipients())
.withBillingReference(ddpInstanceDto.getBillingReference())
.withParticipantIndexES(ddpInstanceDto.getEsParticipantIndex())
.withActivityDefinitionIndexES(ddpInstanceDto.getEsActivityDefinitionIndex())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ public class KitRequestShipping extends KitRequest implements HasDdpInstanceId {
private static final String ERROR = "error";
private static final String SENT = "sent";
private static final String RECEIVED = "received";
private static final String OVERVIEW = "overview";
public static final String OVERVIEW = "overview";
private static final String DEACTIVATED = "deactivated";
private static final String TRIGGERED = "triggered";
private static final String WAITING = "waiting";
Expand Down
Loading