Skip to content

Commit

Permalink
Cleanup unused request logger (#59)
Browse files Browse the repository at this point in the history
Signed-off-by: Angelica Ochoa <[email protected]>
  • Loading branch information
ao508 authored Jul 23, 2024
1 parent 4749375 commit 5e5c7eb
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 148 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import org.mskcc.cmo.messaging.MessageConsumer;
import org.mskcc.smile.service.PromotedRequestMsgHandlingService;
import org.mskcc.smile.service.ValidRequestChecker;
import org.mskcc.smile.service.util.RequestStatusLogger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
Expand All @@ -45,9 +44,6 @@ public class PromotedRequestMsgHandlingServiceImpl implements PromotedRequestMsg
@Autowired
private ValidRequestChecker validRequestChecker;

@Autowired
private RequestStatusLogger requestStatusLogger;

private final ObjectMapper mapper = new ObjectMapper();
private static boolean initialized = false;
private static volatile boolean shutdownInitiated;
Expand Down Expand Up @@ -162,12 +158,6 @@ public void onMessage(Message msg, Object message) {
} catch (Exception e) {
LOG.error("Exception during processing of request on topic: "
+ VALIDATE_PROMOTED_REQUEST_TOPIC, e);
try {
requestStatusLogger.logRequestStatus(message.toString(),
RequestStatusLogger.StatusType.REQUEST_PARSING_ERROR);
} catch (IOException ex) {
LOG.error("Error during attempt to write request status to logger file", ex);
}
}
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import org.mskcc.cmo.messaging.MessageConsumer;
import org.mskcc.smile.service.RequestFilterMessageHandlingService;
import org.mskcc.smile.service.ValidRequestChecker;
import org.mskcc.smile.service.util.RequestStatusLogger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
Expand All @@ -44,9 +43,6 @@ public class RequestFilterMsgHandlingServiceIml implements RequestFilterMessageH
@Autowired
private ValidRequestChecker validRequestChecker;

@Autowired
private RequestStatusLogger requestStatusLogger;

private final ObjectMapper mapper = new ObjectMapper();
private static boolean initialized = false;
private static volatile boolean shutdownInitiated;
Expand Down Expand Up @@ -183,12 +179,6 @@ public void onMessage(Message msg, Object message) {
} catch (Exception e) {
LOG.error("Exception during processing of request on topic: "
+ IGO_REQUEST_FILTER_TOPIC, e);
try {
requestStatusLogger.logRequestStatus(message.toString(),
RequestStatusLogger.StatusType.REQUEST_PARSING_ERROR);
} catch (IOException ex) {
LOG.error("Error during attempt to write request status to logger file", ex);
}
}
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,13 @@
import org.mskcc.smile.commons.enums.SampleType;
import org.mskcc.smile.commons.enums.SpecimenType;
import org.mskcc.smile.service.ValidRequestChecker;
import org.mskcc.smile.service.util.RequestStatusLogger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

@Component
public class ValidRequestCheckerImpl implements ValidRequestChecker {

@Autowired
private RequestStatusLogger requestStatusLogger;

@Value("${igo.cmo_request_filter:false}")
private Boolean igoCmoRequestFilter;

Expand Down Expand Up @@ -136,11 +132,11 @@ public Map<String, Object> generatePromotedRequestValidationMap(String requestJs
}
}
if (validPromotedSampleCount < sampleList.length) {
String requestId = getRequestId(requestJson);
LOG.warn("One or more sample(s) is missing one or a combination of the following: igoId or "
+ "primaryId, cmoPatientId or cmoSampleIdFields --> normalizedPatientId - this "
+ "information must be added for promoted requests & samples");
requestStatusLogger.logRequestStatus(requestJson,
RequestStatusLogger.StatusType.PROMOTED_SAMPLES_MISSING_IDS);
+ "information must be added for promoted requests & samples: requestId = "
+ requestId + ", " + requestJson);
}
if (validPromotedSampleCount == 0) {
requestStatus.put("validationStatus", Boolean.FALSE);
Expand Down Expand Up @@ -206,19 +202,15 @@ public Map<String, Object> generateRequestStatusValidationMap(String requestJson

// if requestId is blank then nothing to do, return null
if (!hasRequestId) {
LOG.warn("CMO request failed sanity checking - missing requestId...");
requestStatusLogger.logRequestStatus(requestJson,
RequestStatusLogger.StatusType.REQUEST_MISSING_REQUEST_ID);
LOG.warn("CMO request failed sanity checking - missing requestId. " + requestJson);
validationReport.put("requestId", "IGO Request ID is missing from the request JSON received.");
validationStatus = Boolean.FALSE;
}

// if cmo filter is enabled then skip request if it is non-cmo
if (igoCmoRequestFilter && !isCmoRequest) {
LOG.warn("CMO request filter enabled - skipping non-CMO request: "
+ getRequestId(requestJsonMap));
requestStatusLogger.logRequestStatus(requestJson,
RequestStatusLogger.StatusType.CMO_REQUEST_FILTER_SKIPPED_REQUEST);
+ getRequestId(requestJsonMap) + ", " + requestJson);
validationReport.put("isCmo", "SMILE CMO request filter is enabled and request JSON received has"
+ " 'cmoRequest': false. This value must be set to true for import into SMILE.");
validationStatus = Boolean.FALSE;
Expand Down Expand Up @@ -599,21 +591,20 @@ private Boolean hasNormalizedPatientId(Map<String, Object> sampleMap)
}

private Boolean requestHasSamples(String requestJson) throws JsonProcessingException, IOException {
String requestId = getRequestId(requestJson);
Map<String, Object> requestJsonMap = mapper.readValue(requestJson, Map.class);
if (!requestJsonMap.containsKey("samples")) {
LOG.warn("Skipping request that is missing 'samples' in JSON");
requestStatusLogger.logRequestStatus(requestJson,
RequestStatusLogger.StatusType.REQUEST_WITH_MISSING_SAMPLES);
LOG.warn("Skipping request that is missing 'samples' in JSON for request ID: "
+ requestId + ", " + requestJson);
return Boolean.FALSE;
}

// extract sample list from request json and check size is non-zero
Object[] sampleList = mapper.convertValue(requestJsonMap.get("samples"),
Object[].class);
if (sampleList.length == 0) {
LOG.warn("Skipping request without any sample data in 'samples' JSON field");
requestStatusLogger.logRequestStatus(requestJson,
RequestStatusLogger.StatusType.REQUEST_WITH_MISSING_SAMPLES);
LOG.warn("Skipping request without any sample data in 'samples' JSON field: "
+ requestId + ", " + requestJson);
return Boolean.FALSE;
}
return Boolean.TRUE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import org.mskcc.cmo.messaging.MessageConsumer;
import org.mskcc.smile.service.ValidRequestChecker;
import org.mskcc.smile.service.ValidateUpdatesMessageHandlingService;
import org.mskcc.smile.service.util.RequestStatusLogger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
Expand Down Expand Up @@ -45,9 +44,6 @@ public class ValidateUpdatesMsgHandlingServiceImpl implements ValidateUpdatesMes
@Autowired
private ValidRequestChecker validRequestChecker;

@Autowired
private RequestStatusLogger requestStatusLogger;

private static boolean initialized = false;
private static Gateway messagingGateway;
private static final Log LOG = LogFactory.getLog(RequestFilterMsgHandlingServiceIml.class);
Expand Down Expand Up @@ -123,8 +119,6 @@ public void run() {
} else {
LOG.error("Sanity check failed on Request updates: "
+ validRequestChecker.getRequestId(requestJson));
requestStatusLogger.logRequestStatus(requestJson,
RequestStatusLogger.StatusType.REQUEST_UPDATE_FAILED_SANITY_CHECK);
}
}
if (interrupted && requestUpdateFilterQueue.isEmpty()) {
Expand Down Expand Up @@ -158,9 +152,8 @@ public void run() {
Map<String, Object> sampleMap = mapper.readValue(sampleJson, Map.class);
Boolean hasRequestId = validRequestChecker.hasRequestId(sampleJson);
if (!hasRequestId) {
LOG.warn("Cannot extract request ID information from sample update message");
requestStatusLogger.logRequestStatus(sampleJson,
RequestStatusLogger.StatusType.SAMPLE_UPDATE_FAILED_SANITY_CHECK);
LOG.warn("Cannot extract request ID information from sample update message: "
+ sampleJson);
continue;
}

Expand All @@ -175,9 +168,7 @@ public void run() {
messagingGateway.publish(CMO_LABEL_UPDATE_TOPIC,
sampleJson);
} else {
LOG.error("Sanity check failed on CMO sample updates ");
requestStatusLogger.logRequestStatus(sampleJson,
RequestStatusLogger.StatusType.SAMPLE_UPDATE_FAILED_SANITY_CHECK);
LOG.error("Sanity check failed on CMO sample updates: " + sampleJson);
}
} else {
Map<String, Object> sampleStatus =
Expand All @@ -190,9 +181,8 @@ public void run() {
SERVER_SAMPLE_UPDATE_TOPIC,
sampleJson);
} else {
LOG.error("Sanity check failed on non-CMO sample update received.");
requestStatusLogger.logRequestStatus(sampleJson,
RequestStatusLogger.StatusType.SAMPLE_UPDATE_FAILED_SANITY_CHECK);
LOG.error("Sanity check failed on non-CMO sample update received: "
+ sampleJson);
}
}
}
Expand Down

This file was deleted.

2 changes: 0 additions & 2 deletions src/main/resources/application.properties.EXAMPLE
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,3 @@ num.promoted_request_handler_threads=
# publishing failures filepath
smile.publishing_failures_filepath=

# detailed consistency checking logger filepath
req_filter.request_logger_filepath=
8 changes: 1 addition & 7 deletions src/test/java/org/mskcc/smile/config/MockDataConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import org.mskcc.smile.commons.FileUtil;
import org.mskcc.smile.model.MockJsonTestData;
import org.mskcc.smile.service.impl.ValidRequestCheckerImpl;
import org.mskcc.smile.service.util.RequestStatusLogger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
Expand Down Expand Up @@ -48,17 +47,12 @@ public ValidRequestCheckerImpl validRequestCheckerImpl() {
return new ValidRequestCheckerImpl();
}

@Bean
public RequestStatusLogger requestStatusLogger() {
return Mockito.mock(RequestStatusLogger.class);
}

private Map<String, MockJsonTestData> mockedRequestJsonDataMap;

/**
* Generates the mocked request json data map;
* @return Map
* @throws IOException
* @throws IOException
*/
@Bean(name = "mockedRequestJsonDataMap")
public Map<String, MockJsonTestData> mockedRequestJsonDataMap() throws IOException {
Expand Down

0 comments on commit 5e5c7eb

Please sign in to comment.