mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-08 10:34:25 +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.setAction(CoreAdminParams.CoreAdminAction.SWAP);
|
||||||
swapRequest.process(adminSolr);
|
swapRequest.process(adminSolr);
|
||||||
|
|
||||||
// export all docs from now-temp core...
|
// export all docs from now-temp core into a temporary directory...
|
||||||
exportIndex(tempIndexName, exportDir, tempSolrUrl, timeField);
|
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
|
// ...and import them into the now-again-actual core *without* clearing
|
||||||
importIndex(tempIndexName, exportDir, false, origSolrUrl);
|
importIndex(tempIndexName, tempExportDirName, false, origSolrUrl);
|
||||||
|
|
||||||
// commit changes
|
// commit changes
|
||||||
origSolr.commit();
|
origSolr.commit();
|
||||||
|
|
||||||
|
// delete temporary export dir
|
||||||
|
FileUtils.deleteDirectory(new File(tempExportDirName));
|
||||||
|
|
||||||
// unload now-temp core (temp core name)
|
// unload now-temp core (temp core name)
|
||||||
CoreAdminRequest.unloadCore(tempIndexName, false, false, adminSolr);
|
CoreAdminRequest.unloadCore(tempIndexName, false, false, adminSolr);
|
||||||
|
|
||||||
@@ -331,6 +335,8 @@ public class SolrImportExport
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Arrays.sort(files);
|
||||||
|
|
||||||
for (File file : files)
|
for (File file : files)
|
||||||
{
|
{
|
||||||
log.info("Importing file " + file.getCanonicalPath());
|
log.info("Importing file " + file.getCanonicalPath());
|
||||||
@@ -443,8 +449,18 @@ public class SolrImportExport
|
|||||||
query.setRows(0);
|
query.setRows(0);
|
||||||
query.setGetFieldStatistics(timeField);
|
query.setGetFieldStatistics(timeField);
|
||||||
Map<String, FieldStatsInfo> fieldInfo = solr.query(query).getFieldStatsInfo();
|
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.clearSorts();
|
||||||
query.setRows(0);
|
query.setRows(0);
|
||||||
query.setFacet(true);
|
query.setFacet(true);
|
||||||
|
Reference in New Issue
Block a user