mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-07 18:14:26 +00:00
Fork off new thread to perform Discovery reindexing
This commit is contained in:
@@ -146,7 +146,7 @@ public class DatabaseUtils
|
|||||||
BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
|
BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
|
||||||
System.out.println("If you continue, ALL DATA IN YOUR DATABASE WILL BE DELETED. \n");
|
System.out.println("If you continue, ALL DATA IN YOUR DATABASE WILL BE DELETED. \n");
|
||||||
System.out.println("There is no turning back from this action. You should backup your database before continuing. \n");
|
System.out.println("There is no turning back from this action. You should backup your database before continuing. \n");
|
||||||
System.out.println("Are you ready to destroy your entire database? [y/n]: ");
|
System.out.print("Are you ready to destroy your entire database? [y/n]: ");
|
||||||
String choiceString = input.readLine();
|
String choiceString = input.readLine();
|
||||||
input.close();
|
input.close();
|
||||||
|
|
||||||
@@ -707,23 +707,54 @@ public class DatabaseUtils
|
|||||||
* The actual indexer to use to reindex Discovery, if needed
|
* The actual indexer to use to reindex Discovery, if needed
|
||||||
* @see org.dspace.discovery.SolrServiceImpl
|
* @see org.dspace.discovery.SolrServiceImpl
|
||||||
*/
|
*/
|
||||||
public static void checkReindexDiscovery(IndexingService indexer)
|
public static synchronized void checkReindexDiscovery(IndexingService indexer)
|
||||||
{
|
{
|
||||||
// We only do something if the reindexDiscovery flag has been triggered
|
// We only do something if the reindexDiscovery flag has been triggered
|
||||||
if(getReindexDiscovery())
|
if(getReindexDiscovery())
|
||||||
{
|
{
|
||||||
log.info("Post database migration, reindexing all content in Discovery search and browse engine");
|
log.info("Post database migration, reindexing all content in Discovery search and browse engine");
|
||||||
|
|
||||||
|
// Kick off a custom thread to perform the reindexing in Discovery
|
||||||
|
// (See ReindexerThread nested class below)
|
||||||
|
ReindexerThread go = new ReindexerThread(indexer);
|
||||||
|
go.start();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Internal class to actually perform re-indexing in a separate thread.
|
||||||
|
* (See checkReindexDiscovery() method)>
|
||||||
|
*/
|
||||||
|
private static class ReindexerThread extends Thread
|
||||||
|
{
|
||||||
|
IndexingService indexer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor. Pass it an existing IndexingService
|
||||||
|
* @param indexer
|
||||||
|
*/
|
||||||
|
ReindexerThread(IndexingService is)
|
||||||
|
{
|
||||||
|
this.indexer = is;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Actually perform Reindexing in Discovery/Solr
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void run()
|
||||||
|
{
|
||||||
Context context = null;
|
Context context = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
context = new Context();
|
context = new Context();
|
||||||
|
|
||||||
// Reindex Discovery (just clean & update index)
|
// Reindex Discovery (just clean & update index)
|
||||||
indexer.cleanIndex(true);
|
this.indexer.cleanIndex(true);
|
||||||
indexer.updateIndex(context, true);
|
this.indexer.updateIndex(context, true);
|
||||||
|
|
||||||
// Reset our indexing flag
|
// Reset our indexing flag. Indexing is done.
|
||||||
setReindexDiscovery(false);
|
DatabaseUtils.setReindexDiscovery(false);
|
||||||
log.info("Reindexing is complete");
|
log.info("Reindexing is complete");
|
||||||
}
|
}
|
||||||
catch(SearchServiceException sse)
|
catch(SearchServiceException sse)
|
||||||
@@ -742,5 +773,4 @@ public class DatabaseUtils
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user