mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-07 18:14:26 +00:00
Make import/export of temporary core more robust
This commit is contained in:

committed by
Hardy Pottinger

parent
ca1803ae93
commit
3d79fa76ab
@@ -247,14 +247,18 @@ public class SolrImportExport
|
||||
swapRequest.setAction(CoreAdminParams.CoreAdminAction.SWAP);
|
||||
swapRequest.process(adminSolr);
|
||||
|
||||
// export all docs from now-temp core...
|
||||
exportIndex(tempIndexName, exportDir, tempSolrUrl, timeField);
|
||||
// export all docs from now-temp core into a temporary directory...
|
||||
String tempExportDirName = ConfigurationManager.getProperty("dspace.dir") + File.separator + "temp" + File.separator + "solr-data-tmp";
|
||||
exportIndex(tempIndexName, tempExportDirName, tempSolrUrl, timeField);
|
||||
// ...and import them into the now-again-actual core *without* clearing
|
||||
importIndex(tempIndexName, exportDir, false, origSolrUrl);
|
||||
importIndex(tempIndexName, tempExportDirName, false, origSolrUrl);
|
||||
|
||||
// commit changes
|
||||
origSolr.commit();
|
||||
|
||||
// delete temporary export dir
|
||||
FileUtils.deleteDirectory(new File(tempExportDirName));
|
||||
|
||||
// unload now-temp core (temp core name)
|
||||
CoreAdminRequest.unloadCore(tempIndexName, false, false, adminSolr);
|
||||
|
||||
@@ -331,6 +335,8 @@ public class SolrImportExport
|
||||
return;
|
||||
}
|
||||
|
||||
Arrays.sort(files);
|
||||
|
||||
for (File file : files)
|
||||
{
|
||||
log.info("Importing file " + file.getCanonicalPath());
|
||||
@@ -443,8 +449,18 @@ public class SolrImportExport
|
||||
query.setRows(0);
|
||||
query.setGetFieldStatistics(timeField);
|
||||
Map<String, FieldStatsInfo> fieldInfo = solr.query(query).getFieldStatsInfo();
|
||||
Date earliestTimestamp = (Date) fieldInfo.get(timeField).getMin();
|
||||
if (fieldInfo == null || !fieldInfo.containsKey(timeField)) {
|
||||
log.warn("Cannot get earliest date, not exporting index " + indexName + ", time field " + timeField + ", from " + fromWhen);
|
||||
return;
|
||||
}
|
||||
FieldStatsInfo timeFieldInfo = fieldInfo.get(timeField);
|
||||
if (timeFieldInfo == null || timeFieldInfo.getMin() == null) {
|
||||
log.warn("Cannot get earliest date, not exporting index " + indexName + ", time field " + timeField + ", from " + fromWhen);
|
||||
return;
|
||||
}
|
||||
Date earliestTimestamp = (Date) timeFieldInfo.getMin();
|
||||
|
||||
query.setGetFieldStatistics(false);
|
||||
query.clearSorts();
|
||||
query.setRows(0);
|
||||
query.setFacet(true);
|
||||
|
Reference in New Issue
Block a user