mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-17 10:17:41 +00:00
Automating solr 4 vs 8 local server
This commit is contained in:
parent
d62c000943
commit
cf50848d60
@ -69,7 +69,6 @@ import org.apache.solr.common.SolrInputDocument;
|
|||||||
import org.apache.solr.common.util.NamedList;
|
import org.apache.solr.common.util.NamedList;
|
||||||
import org.openide.modules.InstalledFileLocator;
|
import org.openide.modules.InstalledFileLocator;
|
||||||
import org.openide.modules.Places;
|
import org.openide.modules.Places;
|
||||||
import org.openide.util.Exceptions;
|
|
||||||
import org.openide.util.NbBundle;
|
import org.openide.util.NbBundle;
|
||||||
import org.openide.windows.WindowManager;
|
import org.openide.windows.WindowManager;
|
||||||
import org.sleuthkit.autopsy.casemodule.Case;
|
import org.sleuthkit.autopsy.casemodule.Case;
|
||||||
@ -229,8 +228,6 @@ public class Server {
|
|||||||
private int currentSolrServerPort = 0;
|
private int currentSolrServerPort = 0;
|
||||||
private int currentSolrStopPort = 0;
|
private int currentSolrStopPort = 0;
|
||||||
private static final boolean DEBUG = false;//(Version.getBuildType() == Version.Type.DEVELOPMENT);
|
private static final boolean DEBUG = false;//(Version.getBuildType() == Version.Type.DEVELOPMENT);
|
||||||
private static final String SOLR = "solr";
|
|
||||||
private static final String CORE_PROPERTIES = "core.properties";
|
|
||||||
private static final int NUM_COLLECTION_CREATION_RETRIES = 5;
|
private static final int NUM_COLLECTION_CREATION_RETRIES = 5;
|
||||||
|
|
||||||
public enum CORE_EVT_STATES {
|
public enum CORE_EVT_STATES {
|
||||||
@ -557,6 +554,14 @@ public class Server {
|
|||||||
startSolr(SOLR_VERSION.SOLR8);
|
startSolr(SOLR_VERSION.SOLR8);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void startLocalSolrServer(Index index) throws KeywordSearchModuleException, SolrServerNoPortException {
|
||||||
|
if (IndexFinder.getCurrentSolrVersion().equals(index.getSolrVersion())) {
|
||||||
|
startSolr(SOLR_VERSION.SOLR8);
|
||||||
|
} else {
|
||||||
|
startSolr(SOLR_VERSION.SOLR4);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tries to start a local Solr instance in a separate process. Returns
|
* Tries to start a local Solr instance in a separate process. Returns
|
||||||
* immediately (probably before the server is ready) and doesn't check
|
* immediately (probably before the server is ready) and doesn't check
|
||||||
@ -566,8 +571,15 @@ public class Server {
|
|||||||
"Server.status.failed.msg=Local Solr server did not respond to status request. This may be because the server failed to start or is taking too long to initialize.",})
|
"Server.status.failed.msg=Local Solr server did not respond to status request. This may be because the server failed to start or is taking too long to initialize.",})
|
||||||
void startSolr(SOLR_VERSION version) throws KeywordSearchModuleException, SolrServerNoPortException {
|
void startSolr(SOLR_VERSION version) throws KeywordSearchModuleException, SolrServerNoPortException {
|
||||||
|
|
||||||
// If an embedded Solr server is running, we stop it.
|
if (isEmbeddedSolrRunning()) {
|
||||||
stop();
|
if (localServerVersion == version) {
|
||||||
|
// this version of local server is already running
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
// wrong version of local server is running, stop it
|
||||||
|
stop();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// set which version of embedded server is currently running
|
// set which version of embedded server is currently running
|
||||||
localServerVersion = version;
|
localServerVersion = version;
|
||||||
@ -713,14 +725,6 @@ public class Server {
|
|||||||
*/
|
*/
|
||||||
synchronized void stop() {
|
synchronized void stop() {
|
||||||
|
|
||||||
try {
|
|
||||||
if (!isEmbeddedSolrRunning()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
} catch (KeywordSearchModuleException ex) {
|
|
||||||
logger.log(Level.WARNING, "Unable to check if embedded server is currently runing: ", ex); //NON-NLS
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Close any open core before stopping server
|
// Close any open core before stopping server
|
||||||
closeCore();
|
closeCore();
|
||||||
@ -955,8 +959,11 @@ public class Server {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
if (theCase.getCaseType() == CaseType.SINGLE_USER_CASE) {
|
if (theCase.getCaseType() == CaseType.SINGLE_USER_CASE) {
|
||||||
|
|
||||||
|
// makes sure the proper embedded Solr server is running
|
||||||
|
startLocalSolrServer(index);
|
||||||
|
|
||||||
currentSolrServer = this.localSolrServer;
|
currentSolrServer = this.localSolrServer;
|
||||||
UserPreferences.setMaxNumShards(1);
|
|
||||||
|
|
||||||
// check if the embedded Solr server is running
|
// check if the embedded Solr server is running
|
||||||
if (!this.isEmbeddedSolrRunning()) {
|
if (!this.isEmbeddedSolrRunning()) {
|
||||||
@ -1015,18 +1022,6 @@ public class Server {
|
|||||||
dataDir.mkdirs();
|
dataDir.mkdirs();
|
||||||
}
|
}
|
||||||
|
|
||||||
// In single user mode, if there is a core.properties file already,
|
|
||||||
// we've hit a solr bug. Compensate by deleting it.
|
|
||||||
// ELTODO make sure we use the proper SolrFolder, can it be a Solr 4 case?
|
|
||||||
Path corePropertiesFile = Paths.get(solr8Folder.toString(), SOLR, collectionName, CORE_PROPERTIES);
|
|
||||||
if (corePropertiesFile.toFile().exists()) {
|
|
||||||
try {
|
|
||||||
corePropertiesFile.toFile().delete();
|
|
||||||
} catch (Exception ex) {
|
|
||||||
logger.log(Level.INFO, "Could not delete pre-existing core.properties prior to opening the core."); //NON-NLS
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// for single user cases, we unload the core when we close the case. So we have to load the core again.
|
// for single user cases, we unload the core when we close the case. So we have to load the core again.
|
||||||
CoreAdminRequest.Create createCoreRequest = new CoreAdminRequest.Create();
|
CoreAdminRequest.Create createCoreRequest = new CoreAdminRequest.Create();
|
||||||
createCoreRequest.setDataDir(dataDir.getAbsolutePath());
|
createCoreRequest.setDataDir(dataDir.getAbsolutePath());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user