Bypass ingest if server not started

This commit is contained in:
adam-m 2012-10-10 12:41:33 -04:00
parent 3f11338014
commit be021e3f14
3 changed files with 18 additions and 7 deletions

View File

@ -35,6 +35,7 @@ import org.sleuthkit.autopsy.casemodule.Case;
public class Installer extends ModuleInstall {
private static final Logger logger = Logger.getLogger(Installer.class.getName());
private final static int SERVER_START_RETRIES = 5;
@Override
public void restored() {
@ -68,7 +69,7 @@ public class Installer extends ModuleInstall {
}
//retry if needed
int retries = 5;
int retries = SERVER_START_RETRIES;
while (retries-- > 0) {
try {
Thread.sleep(1000);

View File

@ -38,6 +38,7 @@ import org.apache.solr.client.solrj.SolrServerException;
import org.netbeans.api.progress.ProgressHandle;
import org.netbeans.api.progress.ProgressHandleFactory;
import org.openide.util.Cancellable;
import org.openide.util.Exceptions;
import org.sleuthkit.autopsy.casemodule.Case;
import org.sleuthkit.autopsy.coreutils.ModuleSettings;
import org.sleuthkit.autopsy.coreutils.StopWatch;
@ -338,11 +339,20 @@ public final class KeywordSearchIngestModule implements IngestModuleAbstractFile
caseHandle = Case.getCurrentCase().getSleuthkitCase();
ingester = Server.getIngester();
//use the settings files to set values
final Server server = KeywordSearch.getServer();
try {
if (! server.isRunning()) {
String msg = "Keyword search server was not properly initialized, cannot run keyword search ingest. ";
logger.log(Level.SEVERE, msg);
String details = msg + "Please try restarting the OS and the application";
services.postMessage(IngestMessage.createErrorMessage(++messageID, instance, msg, details));
return;
}
} catch (KeywordSearchModuleException ex) {
logger.log(Level.WARNING, "Error checking if Solr server is running while initializing ingest", ex);
}
//initialize extractors

View File

@ -327,7 +327,7 @@ class Server {
// that doesn't work when there are no cores
CoreAdminRequest.getStatus(null, solrServer);
logger.log(Level.INFO, "Solr is running");
logger.log(Level.INFO, "Solr server is running");
} catch (SolrServerException ex) {
Throwable cause = ex.getRootCause();
@ -336,7 +336,7 @@ class Server {
// probably caused by starting a connection as the server finishes
// shutting down)
if (cause instanceof ConnectException || cause instanceof SocketException || cause instanceof NoHttpResponseException) {
logger.log(Level.INFO, "Solr is not running, cause: " + cause.getMessage());
logger.log(Level.INFO, "Solr server is not running, cause: " + cause.getMessage());
return false;
} else {
throw new KeywordSearchModuleException("Error checking if Solr server is running", ex);