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
|
@ -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) {
|
||||
pool.execute(new WorkUnitWrapper(workUnit, 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();
|
||||
updateTheUris(uris);
|
||||
deleteOutdatedDocuments();
|
||||
|
||||
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
Add a link
Reference in a new issue