NIHVIVO-1054 Convert the Thread instances to VitroBackgroundThread instances, so we can track when the system becomes idle.
This commit is contained in:
parent
b4796c649a
commit
8c12deacec
3 changed files with 15 additions and 3 deletions
|
@ -1,6 +1,8 @@
|
||||||
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
||||||
package edu.cornell.mannlib.vitro.webapp.controller.freemarker;
|
package edu.cornell.mannlib.vitro.webapp.controller.freemarker;
|
||||||
|
|
||||||
|
import static edu.cornell.mannlib.vitro.webapp.utils.threads.VitroBackgroundThread.WorkLevel.WORKING;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
@ -14,6 +16,7 @@ import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.Exc
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.ResponseValues;
|
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.ResponseValues;
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.TemplateResponseValues;
|
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.TemplateResponseValues;
|
||||||
import edu.cornell.mannlib.vitro.webapp.reasoner.SimpleReasoner;
|
import edu.cornell.mannlib.vitro.webapp.reasoner.SimpleReasoner;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.utils.threads.VitroBackgroundThread;
|
||||||
|
|
||||||
public class SimpleReasonerRecomputeController extends FreemarkerHttpServlet {
|
public class SimpleReasonerRecomputeController extends FreemarkerHttpServlet {
|
||||||
|
|
||||||
|
@ -49,7 +52,10 @@ public class SimpleReasonerRecomputeController extends FreemarkerHttpServlet {
|
||||||
} else {
|
} else {
|
||||||
String submit = (String)vreq.getParameter("submit");
|
String submit = (String)vreq.getParameter("submit");
|
||||||
if (submit != null) {
|
if (submit != null) {
|
||||||
new Thread(new Recomputer((simpleReasoner))).start();
|
VitroBackgroundThread thread = new VitroBackgroundThread(new Recomputer((simpleReasoner)),
|
||||||
|
"SimpleReasonerRecomputController.Recomputer");
|
||||||
|
thread.setWorkLevel(WORKING);
|
||||||
|
thread.start();
|
||||||
messageStr = "Recompute of inferences started. See vivo log for further details.";
|
messageStr = "Recompute of inferences started. See vivo log for further details.";
|
||||||
} else {
|
} else {
|
||||||
body.put("formAction", UrlBuilder.getUrl("/RecomputeInferences"));
|
body.put("formAction", UrlBuilder.getUrl("/RecomputeInferences"));
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
|
|
||||||
package edu.cornell.mannlib.vitro.webapp.reasoner;
|
package edu.cornell.mannlib.vitro.webapp.reasoner;
|
||||||
|
|
||||||
|
import static edu.cornell.mannlib.vitro.webapp.utils.threads.VitroBackgroundThread.WorkLevel.WORKING;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
@ -42,6 +44,7 @@ import edu.cornell.mannlib.vitro.webapp.dao.jena.event.BulkUpdateEvent;
|
||||||
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFService;
|
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFService;
|
||||||
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFServiceException;
|
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFServiceException;
|
||||||
import edu.cornell.mannlib.vitro.webapp.rdfservice.impl.jena.model.RDFServiceModel;
|
import edu.cornell.mannlib.vitro.webapp.rdfservice.impl.jena.model.RDFServiceModel;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.utils.threads.VitroBackgroundThread;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Allows for real-time incremental materialization or retraction of RDFS-
|
* Allows for real-time incremental materialization or retraction of RDFS-
|
||||||
|
@ -1536,7 +1539,10 @@ public class SimpleReasoner extends StatementListener {
|
||||||
log.info("received a bulk update end event");
|
log.info("received a bulk update end event");
|
||||||
if (!deltaComputerProcessing) {
|
if (!deltaComputerProcessing) {
|
||||||
deltaComputerProcessing = true;
|
deltaComputerProcessing = true;
|
||||||
new Thread(new DeltaComputer(),"DeltaComputer").start();
|
VitroBackgroundThread thread = new VitroBackgroundThread(new DeltaComputer(),
|
||||||
|
"SimpleReasoner.DeltaComputer");
|
||||||
|
thread.setWorkLevel(WORKING);
|
||||||
|
thread.start();
|
||||||
} else {
|
} else {
|
||||||
eventCount--;
|
eventCount--;
|
||||||
log.info("received a bulk update end event while currently processing in aynchronous mode. Event count = " + eventCount);
|
log.info("received a bulk update end event while currently processing in aynchronous mode. Event count = " + eventCount);
|
||||||
|
|
|
@ -66,7 +66,7 @@ public class VitroBackgroundThread extends Thread {
|
||||||
allThreads.add(new WeakReference<VitroBackgroundThread>(this));
|
allThreads.add(new WeakReference<VitroBackgroundThread>(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void setWorkLevel(WorkLevel level, String... flags) {
|
public void setWorkLevel(WorkLevel level, String... flags) {
|
||||||
log.debug("Set work level on '" + this.getName() + "' to " + level
|
log.debug("Set work level on '" + this.getName() + "' to " + level
|
||||||
+ ", flags=" + flags);
|
+ ", flags=" + flags);
|
||||||
stamp = new WorkLevelStamp(level, flags);
|
stamp = new WorkLevelStamp(level, flags);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue