use of org.mskcc.oncotree.utils.FailedCacheRefreshException in project oncotree by cBioPortal.
the class MSKConceptCache method resetCache.
@EventListener(ApplicationReadyEvent.class)
// call every Sunday at 3am
@Scheduled(cron = "0 0 3 * * SUN")
private // the actual returned MSKConcept is not necessary for webapp deployment
void resetCache() throws Exception {
logger.info("resetCache() -- attempting to refresh Crosswalk MSKConcept cache");
HashMap<String, MSKConcept> latestOncoTreeCodesToMSKConcepts = new HashMap<String, MSKConcept>();
ArrayList<Version> oncoTreeVersions = new ArrayList<Version>();
try {
oncoTreeVersions = oncoTreePersistentCache.getOncoTreeVersionsFromPersistentCache();
} catch (RuntimeException e) {
throw new FailedCacheRefreshException("Failed to refresh MSKConceptCache, unable to load verisons...");
}
for (Version version : oncoTreeVersions) {
ArrayList<OncoTreeNode> oncoTreeNodes = new ArrayList<OncoTreeNode>();
try {
oncoTreeNodes = oncoTreePersistentCache.getOncoTreeNodesFromPersistentCache(version);
} catch (RuntimeException e) {
throw new FailedCacheRefreshException("Failed to refresh MSKConceptCache : " + e.toString());
}
for (OncoTreeNode node : oncoTreeNodes) {
// skip querying repeated nodes/MSKConcepts
if (!latestOncoTreeCodesToMSKConcepts.containsKey(node.getCode())) {
// pull from crosswalk first
oncoTreePersistentCache.updateMSKConceptInPersistentCache(node.getCode());
MSKConcept concept = oncoTreePersistentCache.getMSKConceptFromPersistentCache(node.getCode());
latestOncoTreeCodesToMSKConcepts.put(node.getCode(), concept);
}
}
}
// save all MSKConcepts at once
try {
oncoTreePersistentCache.backupMSKConceptPersistentCache(latestOncoTreeCodesToMSKConcepts);
} catch (Exception e) {
logger.error("Unable to backup MSKConcepts in EHCache");
slackUtil.sendSlackNotification("*OncoTree Error* - MSKConceptCache backup failed." + e.getMessage());
}
}
Aggregations