Added JARs and logic to execute Solr 5 to 6 upgrade

This commit is contained in:
Eugene Livis 2017-01-13 09:43:50 -05:00
parent b53db96aeb
commit f66db79cfa
3 changed files with 52 additions and 38 deletions

View File

@ -295,7 +295,7 @@ class IndexHandling {
}
static boolean upgradeSolrIndex4to5(String solr4path, String tempResultsDir) {
static boolean upgradeSolrIndex4to5(String solr4IndexPath, String tempResultsDir) {
boolean success = true;
String outputFileName = "output.txt";
@ -313,49 +313,48 @@ class IndexHandling {
commandLine.add(JAVA_PATH);
commandLine.add("-jar");
commandLine.add(upgradeJarPath);
commandLine.add(solr4path);
ProcessBuilder processBuilder = new ProcessBuilder(commandLine);
//processBuilder.directory(upgradeToolFolder);
processBuilder.redirectOutput(new File(outputFileFullPath));
processBuilder.redirectError(new File(errFileFullPath));
ExecUtil.execute(processBuilder);
} catch (Exception ex) {
success = false;
}
// execute lucene upgrade command
/* java -classpath ".;lucene-core-5.5.1.jar;lucene-backward-codecs-5.5.1.jar;lucene-codecs-5.5.1.jar;lucene-analyzers-common-5.5.1.jar" org.apache.lucene.index.IndexUpgrader "C:\Users\elivis\TEMP\xp new test - orig\ingest1\ModuleOutput\keywordsearch\data\index"
try {
final String outputFileFullPath = Paths.get(tempResultsDir, outputFileName).toString();
final String errFileFullPath = Paths.get(tempResultsDir, outputFileName + ".err").toString(); //NON-NLS
List<String> commandLine = new ArrayList<>();
commandLine.add(JAVA_PATH);
commandLine.add("-cp"); //NON-NLS
commandLine.add(".;lucene-core-5.5.1.jar;lucene-backward-codecs-5.5.1.jar;lucene-codecs-5.5.1.jar;lucene-analyzers-common-5.5.1.jar"); //NON-NLS
// ELTODO commandLine.add("-delete-prior-commits"); //NON-NLS
commandLine.add("-verbose"); //NON-NLS
commandLine.add(solr4path);
commandLine.add(solr4IndexPath);
ProcessBuilder processBuilder = new ProcessBuilder(commandLine);
processBuilder.redirectOutput(new File(outputFileFullPath));
processBuilder.redirectError(new File(errFileFullPath));
ExecUtil.execute(processBuilder);
// @@@ Investigate use of history versus cache as type.
} catch (Exception ex) {
success = false;
}*/
return success;
}
static boolean upgradeSolrIndex5to6(String solr4path) {
boolean success = true;
try {
// execute lucene upgrade command
// java -classpath ".;lucene-core-6.2.1.jar;lucene-backward-codecs-6.2.1.jar;lucene-codecs-6.2.1.jar;lucene-analyzers-common-6.2.1.jar" org.apache.lucene.index.IndexUpgrader "C:\Users\elivis\TEMP\xp new test - orig\ingest1\ModuleOutput\keywordsearch\data\index"
} catch (Exception ex) {
success = false;
}
// alternatively can execute lucene upgrade command from the folder where lucene jars are located
// java -cp ".;lucene-core-5.5.1.jar;lucene-backward-codecs-5.5.1.jar;lucene-codecs-5.5.1.jar;lucene-analyzers-common-5.5.1.jar" org.apache.lucene.index.IndexUpgrader \path\to\index
return success;
}
static boolean upgradeSolrIndex5to6(String solr5IndexPath, String tempResultsDir) {
boolean success = true;
String outputFileName = "output.txt";
try {
final File upgradeToolFolder = InstalledFileLocator.getDefault().locate("Solr5to6IndexUpgrade", IndexHandling.class.getPackage().getName(), false); //NON-NLS
if (upgradeToolFolder == null) {
return false;
}
String upgradeJarPath = Paths.get(upgradeToolFolder.getAbsolutePath(), "Solr5IndexUpgrade.jar").toString();
final String outputFileFullPath = Paths.get(tempResultsDir, outputFileName).toString();
final String errFileFullPath = Paths.get(tempResultsDir, outputFileName + ".err").toString(); //NON-NLS
List<String> commandLine = new ArrayList<>();
commandLine.add(JAVA_PATH);
commandLine.add("-jar");
commandLine.add(upgradeJarPath);
commandLine.add(solr5IndexPath);
ProcessBuilder processBuilder = new ProcessBuilder(commandLine);
processBuilder.redirectOutput(new File(outputFileFullPath));
processBuilder.redirectError(new File(errFileFullPath));
ExecUtil.execute(processBuilder);
} catch (Exception ex) {
success = false;
}
// alternatively can execute lucene upgrade command from the folder where lucene jars are located
// java -cp ".;lucene-core-6.2.1.jar;lucene-backward-codecs-6.2.1.jar;lucene-codecs-6.2.1.jar;lucene-analyzers-common-6.2.1.jar" org.apache.lucene.index.IndexUpgrader \path\to\index
return success;
}
}

View File

@ -185,13 +185,26 @@ public class SolrSearchService implements KeywordSearchService, AutopsyService
// Run the upgrade tools on the contents (core) in ModuleOutput/keywordsearch/data/solr6_schema_2.0/index
File tmpDir = Paths.get(context.getCase().getTempDirectory(), "IndexUpgrade").toFile(); //NON-NLS
tmpDir.mkdirs();
// upgrade from Solr 4 to 5. If index is newer than Solr 4 then the upgrade script will simply exit right away.
boolean success = IndexHandling.upgradeSolrIndex4to5(newIndexDir, tmpDir.getAbsolutePath());
// upgrade from Solr 5 to 6. This one must complete successfully in order to produce a valid Solr 6 index.
success = IndexHandling.upgradeSolrIndex5to6(newIndexDir, tmpDir.getAbsolutePath());
success = true; // ELTODO remove
if (!success) {
// delete the new directories
// close the upgraded index?
throw new AutopsyServiceException("ELTODO");
}
// Open the upgraded index
// execute a test query
success = true;
success = true; // ELTODO remove
if (!success) {
// delete the new directories
@ -201,6 +214,8 @@ public class SolrSearchService implements KeywordSearchService, AutopsyService
// currentVersionIndexDir = upgraded index dir
}
// open currentVersionIndexDir index
}
/**