VIVO-870 Clean up exception handling on shutdown.
This commit is contained in:
parent
982e81aece
commit
0c477945a8
4 changed files with 42 additions and 24 deletions
|
@ -1,4 +1,5 @@
|
|||
@prefix : <http://vitro.mannlib.cornell.edu/ns/vitro/ApplicationSetup#> .
|
||||
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
|
||||
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
|
||||
|
||||
#
|
||||
|
@ -41,21 +42,6 @@
|
|||
|
||||
# ------------------------------------
|
||||
|
||||
:documentModifier_nameFields
|
||||
a <java:edu.cornell.mannlib.vitro.webapp.searchindex.documentBuilding.NameFields> ,
|
||||
<java:edu.cornell.mannlib.vitro.webapp.searchindex.documentBuilding.DocumentModifier> .
|
||||
|
||||
:documentModifier_nameBoost
|
||||
a <java:edu.cornell.mannlib.vitro.webapp.searchindex.documentBuilding.NameBoost> ,
|
||||
<java:edu.cornell.mannlib.vitro.webapp.searchindex.documentBuilding.DocumentModifier> ;
|
||||
:hasBoost "1.2"^^xsd:float .
|
||||
|
||||
:documentModifier_thumbnailImageUrl
|
||||
a <java:edu.cornell.mannlib.vitro.webapp.searchindex.documentBuilding.ThumbnailImageURL> ,
|
||||
<java:edu.cornell.mannlib.vitro.webapp.searchindex.documentBuilding.DocumentModifier> .
|
||||
|
||||
# ------------------------------------
|
||||
|
||||
:uriFinder_forDataProperties
|
||||
a <java:edu.cornell.mannlib.vitro.webapp.searchindex.indexing.IndexingUriFinder> ,
|
||||
<java:edu.cornell.mannlib.vitro.webapp.searchindex.indexing.AdditionalURIsForDataProperties> .
|
||||
|
@ -71,3 +57,18 @@
|
|||
:uriFinder_forClassGroupChange
|
||||
a <java:edu.cornell.mannlib.vitro.webapp.searchindex.indexing.IndexingUriFinder> ,
|
||||
<java:edu.cornell.mannlib.vitro.webapp.searchindex.indexing.URIsForClassGroupChange> .
|
||||
|
||||
# ------------------------------------
|
||||
|
||||
:documentModifier_nameFields
|
||||
a <java:edu.cornell.mannlib.vitro.webapp.searchindex.documentBuilding.NameFields> ,
|
||||
<java:edu.cornell.mannlib.vitro.webapp.searchindex.documentBuilding.DocumentModifier> .
|
||||
|
||||
:documentModifier_nameBoost
|
||||
a <java:edu.cornell.mannlib.vitro.webapp.searchindex.documentBuilding.NameBoost> ,
|
||||
<java:edu.cornell.mannlib.vitro.webapp.searchindex.documentBuilding.DocumentModifier> ;
|
||||
:hasBoost "1.2"^^xsd:float .
|
||||
|
||||
:documentModifier_thumbnailImageUrl
|
||||
a <java:edu.cornell.mannlib.vitro.webapp.searchindex.documentBuilding.ThumbnailImageURL> ,
|
||||
<java:edu.cornell.mannlib.vitro.webapp.searchindex.documentBuilding.DocumentModifier> .
|
||||
|
|
|
@ -334,7 +334,7 @@ public class SearchIndexerImpl implements SearchIndexer {
|
|||
try {
|
||||
queue.execute(new TaskWrapper(task));
|
||||
} catch (RejectedExecutionException e) {
|
||||
log.warn("Search Indexer task was rejected: " + e);
|
||||
log.warn("Search Indexer task was rejected: " + task);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -442,7 +442,11 @@ public class SearchIndexerImpl implements SearchIndexer {
|
|||
}
|
||||
|
||||
public void submit(Runnable workUnit, Task task) {
|
||||
try {
|
||||
pool.execute(new WorkUnitWrapper(workUnit, task));
|
||||
} catch (RejectedExecutionException e) {
|
||||
log.warn("Work unit was rejected: " + workUnit + " for " + task);
|
||||
}
|
||||
}
|
||||
|
||||
public void waitUntilIdle() {
|
||||
|
|
|
@ -70,13 +70,27 @@ public class RebuildIndexTask implements Task {
|
|||
listeners.fireEvent(new Event(START_REBUILD, status));
|
||||
|
||||
Collection<String> uris = getAllUrisInTheModel();
|
||||
|
||||
if (!isInterrupted()) {
|
||||
updateTheUris(uris);
|
||||
if (!isInterrupted()) {
|
||||
deleteOutdatedDocuments();
|
||||
}
|
||||
}
|
||||
|
||||
status = buildStatus(REBUILDING, getDocumentCount());
|
||||
listeners.fireEvent(new Event(STOP_REBUILD, status));
|
||||
}
|
||||
|
||||
private boolean isInterrupted() {
|
||||
if (Thread.interrupted()) {
|
||||
Thread.currentThread().interrupt();
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private Collection<String> getAllUrisInTheModel() {
|
||||
return indDao.getAllIndividualUris();
|
||||
}
|
||||
|
|
|
@ -21,7 +21,6 @@ import edu.cornell.mannlib.vitro.webapp.beans.Individual;
|
|||
import edu.cornell.mannlib.vitro.webapp.beans.VClass;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.IndividualDao;
|
||||
import edu.cornell.mannlib.vitro.webapp.modules.searchEngine.SearchEngine;
|
||||
import edu.cornell.mannlib.vitro.webapp.modules.searchEngine.SearchEngineException;
|
||||
import edu.cornell.mannlib.vitro.webapp.modules.searchIndexer.SearchIndexer.Event;
|
||||
import edu.cornell.mannlib.vitro.webapp.modules.searchIndexer.SearchIndexerStatus;
|
||||
import edu.cornell.mannlib.vitro.webapp.modules.searchIndexer.SearchIndexerStatus.UriCounts;
|
||||
|
@ -81,7 +80,7 @@ public class UpdateUrisTask implements Task {
|
|||
for (String uri : uris) {
|
||||
if (isInterrupted()) {
|
||||
log.info("Interrupted: " + status.getSearchIndexerStatus());
|
||||
return;
|
||||
break;
|
||||
} else {
|
||||
Individual ind = getIndividual(uri);
|
||||
if (ind == null || hasNoClass(ind) || isExcluded(ind)) {
|
||||
|
@ -103,8 +102,8 @@ public class UpdateUrisTask implements Task {
|
|||
private void commitChanges() {
|
||||
try {
|
||||
searchEngine.commit();
|
||||
} catch (SearchEngineException e) {
|
||||
log.error("Failed to commit the changes.");
|
||||
} catch (Exception e) {
|
||||
log.error("Failed to commit the changes.", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -144,7 +143,7 @@ public class UpdateUrisTask implements Task {
|
|||
searchEngine.deleteById(SearchIndexerUtils.getIdForUri(uri));
|
||||
status.incrementDeletes();
|
||||
log.debug("deleted '" + uri + "' from search index.");
|
||||
} catch (SearchEngineException e) {
|
||||
} catch (Exception e) {
|
||||
log.warn("Failed to delete '" + uri + "' from search index", e);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue