mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-17 18:17:43 +00:00
More work
This commit is contained in:
parent
aa028edd6c
commit
30e8655e79
@ -24,6 +24,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.logging.Level;
|
||||||
import org.apache.commons.lang.math.NumberUtils;
|
import org.apache.commons.lang.math.NumberUtils;
|
||||||
import org.sleuthkit.autopsy.casemodule.Case;
|
import org.sleuthkit.autopsy.casemodule.Case;
|
||||||
import org.sleuthkit.autopsy.coreutils.Logger;
|
import org.sleuthkit.autopsy.coreutils.Logger;
|
||||||
@ -63,6 +64,7 @@ class IndexFinder {
|
|||||||
// new index should be stored in "\ModuleOutput\keywordsearch\data\solrX_schemaY\index"
|
// new index should be stored in "\ModuleOutput\keywordsearch\data\solrX_schemaY\index"
|
||||||
File targetDirPath = Paths.get(theCase.getModuleDirectory(), KWS_OUTPUT_FOLDER_NAME, KWS_DATA_FOLDER_NAME, indexFolderName, INDEX_FOLDER_NAME).toFile(); //NON-NLS
|
File targetDirPath = Paths.get(theCase.getModuleDirectory(), KWS_OUTPUT_FOLDER_NAME, KWS_DATA_FOLDER_NAME, indexFolderName, INDEX_FOLDER_NAME).toFile(); //NON-NLS
|
||||||
if (!targetDirPath.mkdirs()) {
|
if (!targetDirPath.mkdirs()) {
|
||||||
|
logger.log(Level.SEVERE, "Unable to create index directory: {0}", targetDirPath.toString());
|
||||||
throw new AutopsyService.AutopsyServiceException("Unable to create text index directory " + targetDirPath.getAbsolutePath());
|
throw new AutopsyService.AutopsyServiceException("Unable to create text index directory " + targetDirPath.getAbsolutePath());
|
||||||
}
|
}
|
||||||
return new Index(targetDirPath.getAbsolutePath(), CURRENT_SOLR_VERSION, CURRENT_SOLR_SCHEMA_VERSION, "", theCase.getName());
|
return new Index(targetDirPath.getAbsolutePath(), CURRENT_SOLR_VERSION, CURRENT_SOLR_SCHEMA_VERSION, "", theCase.getName());
|
||||||
|
@ -59,6 +59,7 @@ import org.apache.solr.client.solrj.request.CollectionAdminRequest;
|
|||||||
import org.apache.solr.client.solrj.response.CollectionAdminResponse;
|
import org.apache.solr.client.solrj.response.CollectionAdminResponse;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import org.apache.solr.client.solrj.impl.BaseHttpSolrClient.RemoteSolrException;
|
||||||
import org.apache.solr.client.solrj.response.QueryResponse;
|
import org.apache.solr.client.solrj.response.QueryResponse;
|
||||||
import org.apache.solr.client.solrj.response.TermsResponse;
|
import org.apache.solr.client.solrj.response.TermsResponse;
|
||||||
import org.apache.solr.common.SolrDocument;
|
import org.apache.solr.common.SolrDocument;
|
||||||
@ -518,7 +519,7 @@ public class Server {
|
|||||||
"-Dbootstrap_confdir=../solr/configsets/AutopsyConfig/conf", //NON-NLS
|
"-Dbootstrap_confdir=../solr/configsets/AutopsyConfig/conf", //NON-NLS
|
||||||
"-Dcollection.configName=AutopsyConfig"))); //NON-NLS
|
"-Dcollection.configName=AutopsyConfig"))); //NON-NLS
|
||||||
|
|
||||||
// Wait for the Solr server to start and respond to a status request.
|
// Wait for the Solr server to start and respond to a statusRequest request.
|
||||||
for (int numRetries = 0; numRetries < 6; numRetries++) {
|
for (int numRetries = 0; numRetries < 6; numRetries++) {
|
||||||
if (isRunning()) {
|
if (isRunning()) {
|
||||||
final List<Long> pids = this.getSolrPIDs();
|
final List<Long> pids = this.getSolrPIDs();
|
||||||
@ -658,8 +659,8 @@ public class Server {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests if there's a local Solr server running by sending it a core-status
|
* Tests if there's a local Solr server running by sending it a core-statusRequest
|
||||||
* request.
|
request.
|
||||||
*
|
*
|
||||||
* @return false if the request failed with a connection error, otherwise
|
* @return false if the request failed with a connection error, otherwise
|
||||||
* true
|
* true
|
||||||
@ -669,11 +670,11 @@ public class Server {
|
|||||||
|
|
||||||
if (isPortAvailable(currentSolrServerPort)) {
|
if (isPortAvailable(currentSolrServerPort)) {
|
||||||
// ELTODO WHY FALSE?? return false;
|
// ELTODO WHY FALSE?? return false;
|
||||||
//return false;
|
return false;
|
||||||
return true;
|
//return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// making a status request here instead of just doing solrServer.ping(), because
|
// making a statusRequest request here instead of just doing solrServer.ping(), because
|
||||||
// that doesn't work when there are no cores
|
// that doesn't work when there are no cores
|
||||||
//TODO handle timeout in cases when some other type of server on that port
|
//TODO handle timeout in cases when some other type of server on that port
|
||||||
connectToSolrServer(localSolrServer);
|
connectToSolrServer(localSolrServer);
|
||||||
@ -847,6 +848,12 @@ public class Server {
|
|||||||
try {
|
try {
|
||||||
if (theCase.getCaseType() == CaseType.SINGLE_USER_CASE) {
|
if (theCase.getCaseType() == CaseType.SINGLE_USER_CASE) {
|
||||||
currentSolrServer = this.localSolrServer;
|
currentSolrServer = this.localSolrServer;
|
||||||
|
|
||||||
|
// check if the embedded Solr server is running
|
||||||
|
if (!this.isRunning()) {
|
||||||
|
logger.log(Level.SEVERE, "Core create/open requested, but server not yet running"); //NON-NLS
|
||||||
|
throw new KeywordSearchModuleException(NbBundle.getMessage(this.getClass(), "Server.openCore.exception.msg"));
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
IndexingServerProperties properties = getMultiUserServerProperties(theCase.getCaseDirectory());
|
IndexingServerProperties properties = getMultiUserServerProperties(theCase.getCaseDirectory());
|
||||||
currentSolrServer = new HttpSolrClient.Builder("http://" + properties.getHost() + ":" + properties.getPort() + "/solr").build(); //NON-NLS
|
currentSolrServer = new HttpSolrClient.Builder("http://" + properties.getHost() + ":" + properties.getPort() + "/solr").build(); //NON-NLS
|
||||||
@ -865,11 +872,6 @@ public class Server {
|
|||||||
dataDir.mkdirs();
|
dataDir.mkdirs();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!this.isRunning()) {
|
|
||||||
logger.log(Level.SEVERE, "Core create/open requested, but server not yet running"); //NON-NLS
|
|
||||||
throw new KeywordSearchModuleException(NbBundle.getMessage(this.getClass(), "Server.openCore.exception.msg"));
|
|
||||||
}
|
|
||||||
|
|
||||||
String collectionNameName = index.getIndexName();
|
String collectionNameName = index.getIndexName();
|
||||||
String existingCoreName = collectionExists(collectionNameName);
|
String existingCoreName = collectionExists(collectionNameName);
|
||||||
if (existingCoreName.isEmpty()) {
|
if (existingCoreName.isEmpty()) {
|
||||||
@ -1447,24 +1449,53 @@ public class Server {
|
|||||||
|
|
||||||
private String collectionExists(String collectionName) throws SolrServerException, IOException {
|
private String collectionExists(String collectionName) throws SolrServerException, IOException {
|
||||||
|
|
||||||
CollectionAdminRequest.ColStatus status = CollectionAdminRequest.CollectionProp.collectionStatus(collectionName);
|
CollectionAdminRequest.ClusterStatus statusRequest = CollectionAdminRequest.getClusterStatus().setCollectionName(collectionName);
|
||||||
SolrParams params = status.getParams();
|
CollectionAdminResponse statusResponse;
|
||||||
CollectionAdminResponse statusResponse = status.process(currentSolrServer);
|
try {
|
||||||
|
statusResponse = statusRequest.process(currentSolrServer);
|
||||||
|
} catch (RemoteSolrException ex) {
|
||||||
|
// collection doesn't exist
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (statusResponse == null) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
NamedList error = (NamedList) statusResponse.getResponse().get("error");
|
||||||
|
if (error != null) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// For some reason this returns info about all collections even though it's supposed to only return about the one we are requesting
|
// For some reason this returns info about all collections even though it's supposed to only return about the one we are requesting
|
||||||
NamedList collectionData = (NamedList) statusResponse.getResponse().get(collectionName);
|
NamedList cluster = (NamedList) statusResponse.getResponse().get("cluster");
|
||||||
|
NamedList collections = (NamedList) cluster.get("collections");
|
||||||
|
if (collections != null) {
|
||||||
|
return collectionName + "_shard1_replica_n1";
|
||||||
|
} else {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
/*NamedList currectCollection = (NamedList) collections.get(collectionName);
|
||||||
|
NamedList shards = (NamedList) currectCollection.get("shards");
|
||||||
|
NamedList replicas = (NamedList) shards.get("replicas");
|
||||||
|
String coreName = (String) replicas.get("core");*/
|
||||||
|
|
||||||
|
/* ELTODO for some reason using collectionStatus(collectionName) returns info about all collections
|
||||||
|
CollectionAdminRequest.ColStatus statusRequest = CollectionAdminRequest.collectionStatus(collectionName).setWithSegments(false).setWithSizeInfo(false).setWithRawSizeSummary(false)
|
||||||
|
.setWithRawSizeInfo(false).setWithRawSizeDetails(false).setWithFieldInfo(false).setWithCoreInfo(true);
|
||||||
|
SolrParams params = statusRequest.getParams();
|
||||||
|
NamedList collectionData = (NamedList) statusResponse.get(collectionName);
|
||||||
if (collectionData == null) {
|
if (collectionData == null) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
/* ELTODO it might be worth keeping these for debugging, at least until
|
NamedList collectionData = (NamedList) statusResponse.getResponse().get(collectionName);
|
||||||
we are sure that we can always get core name this way.*/
|
|
||||||
NamedList shards = (NamedList) collectionData.get("shards");
|
NamedList shards = (NamedList) collectionData.get("shards");
|
||||||
NamedList shard1 = (NamedList) shards.get("shard1");
|
NamedList shard1 = (NamedList) shards.get("shard1");
|
||||||
NamedList leader = (NamedList) shard1.get("leader");
|
NamedList leader = (NamedList) shard1.get("leader");
|
||||||
String coreName = (String) leader.get("core");
|
String coreName = (String) leader.get("core");
|
||||||
|
|
||||||
String coreName2 = (String)((NamedList)((NamedList)((NamedList) collectionData.get("shards")).get("shard1")).get("leader")).get("core");
|
String coreName2 = (String)((NamedList)((NamedList)((NamedList) collectionData.get("shards")).get("shard1")).get("leader")).get("core");
|
||||||
return coreName;
|
return coreName;*/
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user