Reusing Solr4 core name for upgrdaed Solr6 cores. Code cleanup

This commit is contained in:
Eugene Livis 2017-01-31 15:24:56 -05:00
parent 92d27e0838
commit 3a546b7a4e
4 changed files with 5 additions and 33 deletions

View File

@ -26,13 +26,11 @@ class Index {
private final String indexPath; private final String indexPath;
private final String schemaVersion; private final String schemaVersion;
private final String solrVersion; private final String solrVersion;
private boolean newIndex;
Index(String indexPath, String solrVersion, String schemaVersion) { Index(String indexPath, String solrVersion, String schemaVersion) {
this.indexPath = indexPath; this.indexPath = indexPath;
this.solrVersion = solrVersion; this.solrVersion = solrVersion;
this.schemaVersion = schemaVersion; this.schemaVersion = schemaVersion;
newIndex = false;
} }
/** /**
@ -55,18 +53,4 @@ class Index {
String getSolrVersion() { String getSolrVersion() {
return solrVersion; return solrVersion;
} }
/**
* @return the newIndex
*/
boolean isNewIndex() {
return newIndex;
}
/**
* @param newIndex the newIndex to set
*/
void setNewIndex(boolean newIndex) {
this.newIndex = newIndex;
}
} }

View File

@ -105,7 +105,6 @@ class IndexUpgrader {
// create upgraded index object // create upgraded index object
upgradedIndex = new Index(newIndexDir, Integer.toString(currentSolrVersion), indexToUpgrade.getSchemaVersion()); upgradedIndex = new Index(newIndexDir, Integer.toString(currentSolrVersion), indexToUpgrade.getSchemaVersion());
upgradedIndex.setNewIndex(true);
return upgradedIndex; return upgradedIndex;
} catch (Exception ex) { } catch (Exception ex) {

View File

@ -806,8 +806,6 @@ public class Server {
} }
try { try {
String coreName = getCoreName(index, theCase);
File dataDir = new File(new File(index.getIndexPath()).getParent()); // "data dir" is the parent of the index directory File dataDir = new File(new File(index.getIndexPath()).getParent()); // "data dir" is the parent of the index directory
if (!dataDir.exists()) { if (!dataDir.exists()) {
dataDir.mkdirs(); dataDir.mkdirs();
@ -818,6 +816,7 @@ public class Server {
throw new KeywordSearchModuleException(NbBundle.getMessage(this.getClass(), "Server.openCore.exception.msg")); throw new KeywordSearchModuleException(NbBundle.getMessage(this.getClass(), "Server.openCore.exception.msg"));
} }
String coreName = getCoreName(theCase);
if (!coreIsLoaded(coreName)) { if (!coreIsLoaded(coreName)) {
/* /*
* The core either does not exist or it is not loaded. Make a * The core either does not exist or it is not loaded. Make a
@ -861,28 +860,19 @@ public class Server {
/** /**
* Get or create a sanitized Solr core name. Stores the core name if needed. * Get or create a sanitized Solr core name. Stores the core name if needed.
* *
* @param index Index object
* @param theCase Case object * @param theCase Case object
* *
* @return The sanitized Solr core name * @return The sanitized Solr core name
*/ */
private String getCoreName(Index index, Case theCase) throws CaseMetadata.CaseMetadataException { private String getCoreName(Case theCase) throws CaseMetadata.CaseMetadataException {
String coreName = "";
if (index.isNewIndex()) {
// come up with a new core name
coreName = createCoreName(theCase.getName());
// store the new core name
theCase.setTextIndexName(coreName);
} else {
// get core name // get core name
coreName = theCase.getTextIndexName(); String coreName = theCase.getTextIndexName();
if (coreName.isEmpty()) { if (coreName == null || coreName.isEmpty()) {
// come up with a new core name // come up with a new core name
coreName = createCoreName(theCase.getName()); coreName = createCoreName(theCase.getName());
// store the new core name // store the new core name
theCase.setTextIndexName(coreName); theCase.setTextIndexName(coreName);
} }
}
return coreName; return coreName;
} }

View File

@ -196,7 +196,6 @@ public class SolrSearchService implements KeywordSearchService, AutopsyService {
progressUnitsCompleted++; progressUnitsCompleted++;
progress.progress(Bundle.SolrSearch_creatingNewIndex_msg(), progressUnitsCompleted); progress.progress(Bundle.SolrSearch_creatingNewIndex_msg(), progressUnitsCompleted);
currentVersionIndex = IndexFinder.createLatestVersionIndexDir(context.getCase()); currentVersionIndex = IndexFinder.createLatestVersionIndexDir(context.getCase());
currentVersionIndex.setNewIndex(true);
} else { } else {
// check if one of the existing indexes is for latest Solr version and schema // check if one of the existing indexes is for latest Solr version and schema
progressUnitsCompleted++; progressUnitsCompleted++;