Skip to content
Snippets Groups Projects
Commit 3f2e9a72 authored by tmortagne's avatar tmortagne
Browse files

XWIKI-10455: Allow disabling SOLR startup synchronization

parent df4e0248
No related branches found
No related tags found
No related merge requests found
......@@ -114,6 +114,16 @@ public class DefaultSolrConfiguration implements SolrConfiguration
*/
public static final int SOLR_INDEXER_QUEUE_CAPACITY_DEFAULT = 100000;
/**
* The name of the configuration property indicating if a synchronization should be run at startup.
*/
public static final String SOLR_SYNCHRONIZE_AT_STARTUP = "solr.synchronizeAtStartup";
/**
* Indicate if a synchronization should be run at startup by default.
*/
public static final boolean SOLR_SYNCHRONIZE_AT_STARTUP_DEFAULT = true;
/**
* The Solr configuration source.
*/
......@@ -180,4 +190,10 @@ public int getIndexerQueueCapacity()
return this.configuration
.getProperty(SOLR_INDEXER_QUEUE_CAPACITY_PROPERTY, SOLR_INDEXER_QUEUE_CAPACITY_DEFAULT);
}
@Override
public boolean synchronizeAtStartup()
{
return this.configuration.getProperty(SOLR_SYNCHRONIZE_AT_STARTUP, SOLR_SYNCHRONIZE_AT_STARTUP_DEFAULT);
}
}
......@@ -32,6 +32,7 @@
import org.xwiki.component.annotation.Component;
import org.xwiki.observation.EventListener;
import org.xwiki.observation.event.Event;
import org.xwiki.search.solr.internal.api.SolrConfiguration;
import org.xwiki.search.solr.internal.api.SolrIndexer;
import org.xwiki.search.solr.internal.api.SolrIndexerException;
import org.xwiki.search.solr.internal.job.IndexerRequest;
......@@ -66,6 +67,9 @@ public class SolrIndexInitializeListener implements EventListener
@Inject
private Provider<SolrIndexer> solrIndexer;
@Inject
private SolrConfiguration configuration;
@Override
public List<Event> getEvents()
{
......@@ -81,14 +85,16 @@ public String getName()
@Override
public void onEvent(Event event, Object source, Object data)
{
// Start synchronization
IndexerRequest request = new IndexerRequest();
request.setId(Arrays.asList("solr", "indexer"));
if (this.configuration.synchronizeAtStartup()) {
// Start synchronization
IndexerRequest request = new IndexerRequest();
request.setId(Arrays.asList("solr", "indexer"));
try {
this.solrIndexer.get().startIndex(request);
} catch (SolrIndexerException e) {
this.logger.error("Failed to start initial Solr index synchronization", e);
try {
this.solrIndexer.get().startIndex(request);
} catch (SolrIndexerException e) {
this.logger.error("Failed to start initial Solr index synchronization", e);
}
}
}
}
......@@ -73,4 +73,10 @@ public interface SolrConfiguration
* @since 5.1M2
*/
int getIndexerQueueCapacity();
/**
* @return true if a full synchronization job between the database and SOLR index should be run when XWiki starts
* @since 6.1M1
*/
boolean synchronizeAtStartup();
}
......@@ -513,6 +513,12 @@ rendering.transformations = $xwikiRenderingTransformations
#-# The default is 10000.
# solr.indexer.queue.capacity=100000
#-# [Since 6.1M2]
#-# Indicating if a synchronization between SOLR index and XWiki database should be run at startup.
#-# Synchronization can be started from search administration.
#-# The default is true.
# solr.synchronizeAtStartup=false
#-------------------------------------------------------------------------------------
# Security
#-------------------------------------------------------------------------------------
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment