VIVO-869 ABoxRecomputer should pause the SearchIndexer during a rebuild.
This commit is contained in:
parent
ccb2063aa4
commit
de5b80bf75
6 changed files with 137 additions and 11 deletions
|
@ -38,6 +38,7 @@ import com.hp.hpl.jena.vocabulary.RDFS;
|
|||
import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.jena.RDFServiceGraph;
|
||||
import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelNames;
|
||||
import edu.cornell.mannlib.vitro.webapp.modules.searchIndexer.SearchIndexer;
|
||||
import edu.cornell.mannlib.vitro.webapp.rdfservice.ChangeSet;
|
||||
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFService;
|
||||
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFServiceException;
|
||||
|
@ -46,6 +47,8 @@ import edu.cornell.mannlib.vitro.webapp.rdfservice.impl.RDFServiceUtils;
|
|||
public class ABoxRecomputer {
|
||||
|
||||
private static final Log log = LogFactory.getLog(ABoxRecomputer.class);
|
||||
|
||||
private final SearchIndexer searchIndexer;
|
||||
|
||||
private OntModel tboxModel; // asserted and inferred TBox axioms
|
||||
private OntModel aboxModel;
|
||||
|
@ -67,11 +70,13 @@ public class ABoxRecomputer {
|
|||
public ABoxRecomputer(OntModel tboxModel,
|
||||
OntModel aboxModel,
|
||||
RDFService rdfService,
|
||||
SimpleReasoner simpleReasoner) {
|
||||
SimpleReasoner simpleReasoner,
|
||||
SearchIndexer searchIndexer) {
|
||||
this.tboxModel = tboxModel;
|
||||
this.aboxModel = aboxModel;
|
||||
this.rdfService = rdfService;
|
||||
this.simpleReasoner = simpleReasoner;
|
||||
this.searchIndexer = searchIndexer;
|
||||
recomputing = false;
|
||||
stopRequested = false;
|
||||
handleSameAs = simpleReasoner.getSameAsEnabled();
|
||||
|
@ -97,8 +102,14 @@ public class ABoxRecomputer {
|
|||
}
|
||||
}
|
||||
try {
|
||||
if (searchIndexer != null) {
|
||||
searchIndexer.pause();
|
||||
}
|
||||
recomputeABox();
|
||||
} finally {
|
||||
if (searchIndexer != null) {
|
||||
searchIndexer.unpause();
|
||||
}
|
||||
synchronized (lock1) {
|
||||
recomputing = false;
|
||||
}
|
||||
|
|
|
@ -43,6 +43,7 @@ import edu.cornell.mannlib.vitro.webapp.dao.jena.DifferenceGraph;
|
|||
import edu.cornell.mannlib.vitro.webapp.dao.jena.RDFServiceGraph;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.jena.event.BulkUpdateEvent;
|
||||
import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelNames;
|
||||
import edu.cornell.mannlib.vitro.webapp.modules.searchIndexer.SearchIndexer;
|
||||
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFService;
|
||||
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFServiceException;
|
||||
import edu.cornell.mannlib.vitro.webapp.rdfservice.adapters.VitroModelFactory;
|
||||
|
@ -60,6 +61,8 @@ public class SimpleReasoner extends StatementListener {
|
|||
|
||||
private static final Log log = LogFactory.getLog(SimpleReasoner.class);
|
||||
|
||||
private final SearchIndexer searchIndexer;
|
||||
|
||||
private OntModel tboxModel; // asserted and inferred TBox axioms
|
||||
private OntModel aboxModel; // ABox assertions
|
||||
private Model inferenceModel; // ABox inferences
|
||||
|
@ -95,12 +98,17 @@ public class SimpleReasoner extends StatementListener {
|
|||
* whole ABox inference model is rebuilt
|
||||
* @param inferenceScratchpadModel - output. This the model is temporarily used when
|
||||
* the whole ABox inference model is rebuilt
|
||||
* @param searchIndexer - output. If not null, the indexer will be paused before the
|
||||
* ABox inference model is rebuilt and unpaused when the rebuild is complete.
|
||||
*/
|
||||
public SimpleReasoner(OntModel tboxModel,
|
||||
RDFService rdfService,
|
||||
Model inferenceModel,
|
||||
Model inferenceRebuildModel,
|
||||
Model scratchpadModel) {
|
||||
Model scratchpadModel,
|
||||
SearchIndexer searchIndexer) {
|
||||
|
||||
this.searchIndexer = searchIndexer;
|
||||
|
||||
this.tboxModel = tboxModel;
|
||||
|
||||
|
@ -117,7 +125,7 @@ public class SimpleReasoner extends StatementListener {
|
|||
this.batchMode = 0;
|
||||
aBoxDeltaModeler1 = new CumulativeDeltaModeler();
|
||||
aBoxDeltaModeler2 = new CumulativeDeltaModeler();
|
||||
recomputer = new ABoxRecomputer(tboxModel, aboxModel, rdfService, this);
|
||||
recomputer = new ABoxRecomputer(tboxModel, aboxModel, rdfService, this, searchIndexer);
|
||||
stopRequested = false;
|
||||
|
||||
if (rdfService == null) {
|
||||
|
@ -140,6 +148,7 @@ public class SimpleReasoner extends StatementListener {
|
|||
* ABox statements are maintained (added or retracted).
|
||||
*/
|
||||
public SimpleReasoner(OntModel tboxModel, OntModel aboxModel, Model inferenceModel) {
|
||||
this.searchIndexer = null;
|
||||
this.tboxModel = tboxModel;
|
||||
this.aboxModel = aboxModel;
|
||||
this.inferenceModel = inferenceModel;
|
||||
|
@ -155,7 +164,7 @@ public class SimpleReasoner extends StatementListener {
|
|||
ds.addNamedModel(ModelNames.TBOX_ASSERTIONS, tboxModel);
|
||||
|
||||
ds.setDefaultModel(ModelFactory.createUnion(fullModel, tboxModel));
|
||||
recomputer = new ABoxRecomputer(tboxModel, aboxModel, new RDFServiceModel(ds), this);
|
||||
recomputer = new ABoxRecomputer(tboxModel, aboxModel, new RDFServiceModel(ds), this, searchIndexer);
|
||||
}
|
||||
|
||||
public void setPluginList(List<ReasonerPlugin> pluginList) {
|
||||
|
|
|
@ -23,8 +23,10 @@ import com.hp.hpl.jena.query.Dataset;
|
|||
import com.hp.hpl.jena.rdf.model.Model;
|
||||
import com.hp.hpl.jena.rdf.model.RDFNode;
|
||||
|
||||
import edu.cornell.mannlib.vitro.webapp.application.ApplicationUtils;
|
||||
import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess;
|
||||
import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelNames;
|
||||
import edu.cornell.mannlib.vitro.webapp.modules.searchIndexer.SearchIndexer;
|
||||
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFService;
|
||||
import edu.cornell.mannlib.vitro.webapp.reasoner.ReasonerPlugin;
|
||||
import edu.cornell.mannlib.vitro.webapp.reasoner.SimpleReasoner;
|
||||
|
@ -45,6 +47,7 @@ public class SimpleReasonerSetup implements ServletContextListener {
|
|||
@Override
|
||||
public void contextInitialized(ServletContextEvent sce) {
|
||||
ServletContext ctx = sce.getServletContext();
|
||||
SearchIndexer searchIndexer = ApplicationUtils.instance().getSearchIndexer();
|
||||
|
||||
try {
|
||||
OntModel tboxAssertionsModel = ModelAccess.on(ctx).getOntModel(ModelNames.TBOX_ASSERTIONS);
|
||||
|
@ -70,7 +73,7 @@ public class SimpleReasonerSetup implements ServletContextListener {
|
|||
|
||||
// the simple reasoner will register itself as a listener to the ABox assertions
|
||||
SimpleReasoner simpleReasoner = new SimpleReasoner(
|
||||
tboxUnionModel, rdfService, inferenceModel, rebuildModel, scratchModel);
|
||||
tboxUnionModel, rdfService, inferenceModel, rebuildModel, scratchModel, searchIndexer);
|
||||
sce.getServletContext().setAttribute(SimpleReasoner.class.getName(),simpleReasoner);
|
||||
|
||||
StartupStatus ss = StartupStatus.getBean(ctx);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue