[VIVO-1261] Allow for caches to always be used without pauses in time critical situations.
This commit is contained in:
parent
906a905275
commit
3bafa451f2
2 changed files with 25 additions and 5 deletions
|
@ -50,10 +50,10 @@ public class CapabilityMapRequestHandler implements VisualizationRequestHandler
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object generateAjaxVisualization(VitroRequest vitroRequest, Log log, Dataset dataSource) throws MalformedQueryParametersException {
|
public Object generateAjaxVisualization(VitroRequest vitroRequest, Log log, Dataset dataSource) throws MalformedQueryParametersException {
|
||||||
ConceptLabelMap conceptLabelMap = VisualizationCaches.conceptToLabel.get(vitroRequest.getRDFService());
|
ConceptLabelMap conceptLabelMap = VisualizationCaches.conceptToLabel.getNoWait(vitroRequest.getRDFService());
|
||||||
ConceptPeopleMap conceptPeopleMap = VisualizationCaches.conceptToPeopleMap.get(vitroRequest.getRDFService());
|
ConceptPeopleMap conceptPeopleMap = VisualizationCaches.conceptToPeopleMap.getNoWait(vitroRequest.getRDFService());
|
||||||
OrganizationPeopleMap organizationPeopleMap = VisualizationCaches.organisationToPeopleMap.get(vitroRequest.getRDFService());
|
OrganizationPeopleMap organizationPeopleMap = VisualizationCaches.organisationToPeopleMap.getNoWait(vitroRequest.getRDFService());
|
||||||
Map<String, String> organizationLabels = VisualizationCaches.organizationLabels.get(vitroRequest.getRDFService());
|
Map<String, String> organizationLabels = VisualizationCaches.organizationLabels.getNoWait(vitroRequest.getRDFService());
|
||||||
|
|
||||||
String data = vitroRequest.getParameter("data");
|
String data = vitroRequest.getParameter("data");
|
||||||
if (!StringUtils.isEmpty(data)) {
|
if (!StringUtils.isEmpty(data)) {
|
||||||
|
|
|
@ -61,6 +61,26 @@ public class CachingRDFServiceExecutor<T> {
|
||||||
* @param rdfService an RDF service to use, in foreground mode, if the background service is missing
|
* @param rdfService an RDF service to use, in foreground mode, if the background service is missing
|
||||||
*/
|
*/
|
||||||
public synchronized T get(RDFService rdfService) {
|
public synchronized T get(RDFService rdfService) {
|
||||||
|
return get(rdfService, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the cached results if present, or start the task.
|
||||||
|
* Will wait for completion if the cache is not already populated, otherwise the refresh will happen in the background.
|
||||||
|
*
|
||||||
|
* @param rdfService an RDF service to use, in foreground mode, if the background service is missing
|
||||||
|
*/
|
||||||
|
public synchronized T getNoWait(RDFService rdfService) {
|
||||||
|
return get(rdfService, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the cached results if present, or start the task.
|
||||||
|
* Will wait for completion if the cache is not already populated, otherwise the refresh will happen in the background.
|
||||||
|
*
|
||||||
|
* @param rdfService an RDF service to use, in foreground mode, if the background service is missing
|
||||||
|
*/
|
||||||
|
public synchronized T get(RDFService rdfService, boolean allowWaits) {
|
||||||
// First, check if there are results from the previous background task, and update the cache
|
// First, check if there are results from the previous background task, and update the cache
|
||||||
if (backgroundTask != null && backgroundTask.isDone()) {
|
if (backgroundTask != null && backgroundTask.isDone()) {
|
||||||
completeBackgroundTask();
|
completeBackgroundTask();
|
||||||
|
@ -77,7 +97,7 @@ public class CachingRDFServiceExecutor<T> {
|
||||||
startBackgroundTask(rdfService);
|
startBackgroundTask(rdfService);
|
||||||
|
|
||||||
// See if we expect it to complete in time, and if so, wait for it
|
// See if we expect it to complete in time, and if so, wait for it
|
||||||
if (isExpectedToCompleteIn(waitFor)) {
|
if (allowWaits && isExpectedToCompleteIn(waitFor)) {
|
||||||
completeBackgroundTask(waitFor);
|
completeBackgroundTask(waitFor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue