prepatory work for switching into asynchronous reasoning mode when processing a tbox update.

This commit is contained in:
stellamit 2011-11-03 18:37:25 +00:00
parent 5559ba5fed
commit a8140fcde7
2 changed files with 31 additions and 21 deletions

View file

@ -1381,16 +1381,8 @@ public class SimpleReasoner extends StatementListener {
} }
} }
@Override protected void startBatchMode() {
public synchronized void notifyEvent(Model model, Object event) {
if (event instanceof BulkUpdateEvent) {
if (((BulkUpdateEvent) event).getBegin()) {
log.info("received BulkUpdateEvent(begin)");
if (batchMode1 || batchMode2) { if (batchMode1 || batchMode2) {
log.info("received a BulkUpdateEvent(begin) while already in batch update mode; this event will be ignored (and processing in batch mode will continue until there are no pending updates)");
return; return;
} else { } else {
batchMode1 = true; batchMode1 = true;
@ -1398,9 +1390,29 @@ public class SimpleReasoner extends StatementListener {
aBoxDeltaModeler1.getRetractions().removeAll(); aBoxDeltaModeler1.getRetractions().removeAll();
log.info("started processing retractions in batch mode"); log.info("started processing retractions in batch mode");
} }
}
protected void endBatchMode() {
if (!batchMode1 && !batchMode2) {
log.warn("SimpleReasoner received an end batch mode request when not currently in batch mode. No action was taken");
return;
}
new Thread(new DeltaComputer(),"DeltaComputer").start();
}
@Override
public synchronized void notifyEvent(Model model, Object event) {
if (event instanceof BulkUpdateEvent) {
if (((BulkUpdateEvent) event).getBegin()) {
log.info("received BulkUpdateEvent(begin)");
startBatchMode();
} else { } else {
log.info("received BulkUpdateEvent(end)"); log.info("received BulkUpdateEvent(end)");
new Thread(new DeltaComputer(),"DeltaComputer").start(); endBatchMode();
} }
} }
} }

View file

@ -1,15 +1,14 @@
/* $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.reasoner.support; package edu.cornell.mannlib.vitro.webapp.reasoner;
import com.hp.hpl.jena.rdf.listeners.StatementListener; import com.hp.hpl.jena.rdf.listeners.StatementListener;
import com.hp.hpl.jena.rdf.model.Statement; import com.hp.hpl.jena.rdf.model.Statement;
import edu.cornell.mannlib.vitro.webapp.reasoner.SimpleReasoner;
/** /**
* Route notification of changes to TBox to the incremental ABox reasoner. * Route notification of changes to TBox to the incremental ABox reasoner.
* The incremental ABox reasoner needs to handle only subclass, superclass * The incremental ABox reasoner handles only subclass, superclass
* and equivalent class axioms. * and equivalent class axioms.
* *
*/ */
@ -18,22 +17,21 @@ public class SimpleReasonerTBoxListener extends StatementListener {
private SimpleReasoner simpleReasoner = null; private SimpleReasoner simpleReasoner = null;
public SimpleReasonerTBoxListener(SimpleReasoner simpleReasoner) { public SimpleReasonerTBoxListener(SimpleReasoner simpleReasoner) {
this.simpleReasoner = simpleReasoner; this.simpleReasoner = simpleReasoner;
} }
@Override @Override
public void addedStatement(Statement stmt) { public void addedStatement(Statement stmt) {
//simpleReasoner.startBatchMode();
simpleReasoner.addedTBoxStatement(stmt); simpleReasoner.addedTBoxStatement(stmt);
//simpleReasoner.endBatchMode();
} }
@Override @Override
public void removedStatement(Statement stmt) { public void removedStatement(Statement stmt) {
//simpleReasoner.startBatchMode();
simpleReasoner.removedTBoxStatement(stmt); simpleReasoner.removedTBoxStatement(stmt);
//simpleReasoner.endBatchMode();
} }
} }