Skip to content
Snippets Groups Projects
Commit 839d8622 authored by Richard Cordovano's avatar Richard Cordovano
Browse files

Merge pull request #1685 from rcordovano/extend_kws_core_check_to_multi-user

Extend kws core check to multi user
parents 718e13d3 d006fb3a
No related branches found
No related tags found
No related merge requests found
...@@ -223,7 +223,7 @@ Server.query2.exception.msg=Error running query\: {0} ...@@ -223,7 +223,7 @@ Server.query2.exception.msg=Error running query\: {0}
Server.queryTerms.exception.msg=Error running terms query\: {0} Server.queryTerms.exception.msg=Error running terms query\: {0}
Server.connect.exception.msg=Failed to connect to Solr server\: Server.connect.exception.msg=Failed to connect to Solr server\:
Server.openCore.exception.msg=Keyword search service not yet running Server.openCore.exception.msg=Keyword search service not yet running
Server.openCore.exception.cantOpen.msg=Could not open index Server.openCore.exception.cantOpen.msg=Could not create or open index
Server.openCore.exception.noIndexDir.msg=Index directory could not be created or is missing Server.openCore.exception.noIndexDir.msg=Index directory could not be created or is missing
Server.request.exception.exception.msg=Could not issue Solr request Server.request.exception.exception.msg=Could not issue Solr request
Server.commit.exception.msg=Could not commit index Server.commit.exception.msg=Could not commit index
......
...@@ -223,7 +223,7 @@ public void propertyChange(PropertyChangeEvent evt) { ...@@ -223,7 +223,7 @@ public void propertyChange(PropertyChangeEvent evt) {
String changed = evt.getPropertyName(); String changed = evt.getPropertyName();
if (changed.equals(Case.Events.CURRENT_CASE.toString())) { if (changed.equals(Case.Events.CURRENT_CASE.toString())) {
dropPanel.resetSearchBox(); dropPanel.resetSearchBox();
setFields(null != evt.getNewValue() && RuntimeProperties.coreComponentsAreActive() && KeywordSearch.getServer().coreIsOpen()); setFields(null != evt.getNewValue() && RuntimeProperties.coreComponentsAreActive());
} else if (changed.equals(Server.CORE_EVT)) { } else if (changed.equals(Server.CORE_EVT)) {
final Server.CORE_EVT_STATES state = (Server.CORE_EVT_STATES) evt.getNewValue(); final Server.CORE_EVT_STATES state = (Server.CORE_EVT_STATES) evt.getNewValue();
switch (state) { switch (state) {
......
...@@ -126,7 +126,7 @@ public void propertyChange(PropertyChangeEvent evt) { ...@@ -126,7 +126,7 @@ public void propertyChange(PropertyChangeEvent evt) {
} catch (Exception ex) { } catch (Exception ex) {
String caseName = closedCase.getName(); String caseName = closedCase.getName();
logger.log(Level.SEVERE, String.format("Failed to close core for %s", caseName), ex); logger.log(Level.SEVERE, String.format("Failed to close core for %s", caseName), ex);
MessageNotifyUtil.Notify.error(NbBundle.getMessage(KeywordSearch.class, "KeywordSearch.closeCore.notification..msg"), ex.getCause().getMessage()); MessageNotifyUtil.Notify.error(NbBundle.getMessage(KeywordSearch.class, "KeywordSearch.closeCore.notification.msg"), ex.getMessage());
} }
} }
if (null != evt.getNewValue()) { if (null != evt.getNewValue()) {
...@@ -136,7 +136,7 @@ public void propertyChange(PropertyChangeEvent evt) { ...@@ -136,7 +136,7 @@ public void propertyChange(PropertyChangeEvent evt) {
} catch (Exception ex) { } catch (Exception ex) {
String caseName = openedCase.getName(); String caseName = openedCase.getName();
logger.log(Level.SEVERE, String.format("Failed to open or create core for %s", caseName), ex); logger.log(Level.SEVERE, String.format("Failed to open or create core for %s", caseName), ex);
MessageNotifyUtil.Notify.error(NbBundle.getMessage(KeywordSearch.class, "KeywordSearch.openCore.notification.msg"), ex.getCause().getMessage()); MessageNotifyUtil.Notify.error(NbBundle.getMessage(KeywordSearch.class, "KeywordSearch.openCore.notification.msg"), ex.getMessage());
} }
} }
} }
......
...@@ -169,7 +169,6 @@ public String toString() { ...@@ -169,7 +169,6 @@ public String toString() {
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 final UNCPathUtilities uncPathUtilities = new UNCPathUtilities(); private final UNCPathUtilities uncPathUtilities = new UNCPathUtilities();
private static final String INDEX_DIR_NAME = "index";
public enum CORE_EVT_STATES { public enum CORE_EVT_STATES {
...@@ -684,13 +683,11 @@ private Core openCore(Case theCase) throws KeywordSearchModuleException { ...@@ -684,13 +683,11 @@ private Core openCore(Case theCase) throws KeywordSearchModuleException {
} else { } else {
String host = UserPreferences.getIndexingServerHost(); String host = UserPreferences.getIndexingServerHost();
String port = UserPreferences.getIndexingServerPort(); String port = UserPreferences.getIndexingServerPort();
currentSolrServer = new HttpSolrServer("http://" + host + ":" + port + "/solr"); //NON-NLS currentSolrServer = new HttpSolrServer("http://" + host + ":" + port + "/solr"); //NON-NLS
} }
connectToSolrServer(currentSolrServer); connectToSolrServer(currentSolrServer);
} catch (SolrServerException | IOException ex) { } catch (SolrServerException | IOException ex) {
MessageNotifyUtil.Notify.error(NbBundle.getMessage(Server.class, "Server.connect.exception.msg"), ex.getCause().getMessage()); throw new KeywordSearchModuleException(NbBundle.getMessage(Server.class, "Server.connect.exception.msg"), ex);
throw new KeywordSearchModuleException(NbBundle.getMessage(Server.class, "Server.connect.exception.msg"));
} }
String dataDir = getIndexDirPath(theCase); String dataDir = getIndexDirPath(theCase);
...@@ -1068,7 +1065,7 @@ private Core openCore(String coreName, File dataDir, CaseType caseType) throws K ...@@ -1068,7 +1065,7 @@ private Core openCore(String coreName, File dataDir, CaseType caseType) throws K
NbBundle.getMessage(this.getClass(), "Server.openCore.exception.msg")); NbBundle.getMessage(this.getClass(), "Server.openCore.exception.msg"));
} }
if (!isCoreLoaded(coreName)) { if (!coreExistsOnServer(coreName)) {
CoreAdminRequest.Create createCoreRequest = new CoreAdminRequest.Create(); CoreAdminRequest.Create createCoreRequest = new CoreAdminRequest.Create();
createCoreRequest.setDataDir(dataDir.getAbsolutePath()); createCoreRequest.setDataDir(dataDir.getAbsolutePath());
createCoreRequest.setCoreName(coreName); createCoreRequest.setCoreName(coreName);
...@@ -1078,12 +1075,9 @@ private Core openCore(String coreName, File dataDir, CaseType caseType) throws K ...@@ -1078,12 +1075,9 @@ private Core openCore(String coreName, File dataDir, CaseType caseType) throws K
currentSolrServer.request(createCoreRequest); currentSolrServer.request(createCoreRequest);
} }
// TODO (RC): This check only works for single-user cases. For multi-user cases if (!coreIndexFolderExists(coreName)) {
// the path from the case metadata file needs to be checked. throw new KeywordSearchModuleException(NbBundle.getMessage(this.getClass(), "Server.openCore.exception.noIndexDir.msg"));
// File indexDir = Paths.get(dataDir.getAbsolutePath(), INDEX_DIR_NAME).toFile(); }
// if (!indexDir.exists()) {
// throw new IOException(NbBundle.getMessage(this.getClass(), "Server.openCore.exception.noIndexDir.msg"));
// }
return new Core(coreName, caseType); return new Core(coreName, caseType);
...@@ -1106,20 +1100,42 @@ void connectToSolrServer(HttpSolrServer solrServer) throws SolrServerException, ...@@ -1106,20 +1100,42 @@ void connectToSolrServer(HttpSolrServer solrServer) throws SolrServerException,
} }
/** /**
* Determines whether the Solr core with the given name already exists. * Determines whether or not a Solr core instance exists on the current Solr
* server.
* *
* @param coreName * @param coreName the name of the core.
* *
* @return true if core exists, otherwise false. * @return true or false.
* *
* @throws SolrServerException * @throws SolrServerException
* @throws IOException * @throws IOException
*/ */
private boolean isCoreLoaded(String coreName) throws SolrServerException, IOException { private boolean coreExistsOnServer(String coreName) throws SolrServerException, IOException {
CoreAdminResponse response = CoreAdminRequest.getStatus(coreName, currentSolrServer); CoreAdminResponse response = CoreAdminRequest.getStatus(coreName, currentSolrServer);
return response.getCoreStatus(coreName).get("instanceDir") != null; //NON-NLS return response.getCoreStatus(coreName).get("instanceDir") != null; //NON-NLS
} }
/**
* Determines whether or not the index files folder for a Solr core exists.
*
* @param coreName the name of the core.
*
* @return true or false
*
* @throws SolrServerException
* @throws IOException
*/
private boolean coreIndexFolderExists(String coreName) throws SolrServerException, IOException {
CoreAdminResponse response = CoreAdminRequest.getStatus(coreName, currentSolrServer);
Object dataDirPath = response.getCoreStatus(coreName).get("dataDir"); //NON-NLS
if (null != dataDirPath) {
File indexDir = Paths.get((String)dataDirPath, "index").toFile(); //NON-NLS
return indexDir.exists();
} else {
return false;
}
}
class Core { class Core {
// handle to the core in Solr // handle to the core in Solr
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment