Package org.ametys.cms.search.solr
Class DefaultSolrClientProvider
- java.lang.Object
-
- org.ametys.runtime.plugin.component.AbstractLogEnabled
-
- org.ametys.cms.search.solr.DefaultSolrClientProvider
-
- All Implemented Interfaces:
SolrClientProvider,LogEnabled,Disposable,Initializable,Component,Serviceable
public class DefaultSolrClientProvider extends AbstractLogEnabled implements SolrClientProvider, Component, Serviceable, Initializable, Disposable
Component acting as a single entry point to get access to Solr clients.
-
-
Field Summary
Fields Modifier and Type Field Description protected JackrabbitRepository_repositoryThe JCR repositoryprotected String_solrCorePrefixThe solr core prefix.protected Map<String,org.apache.solr.client.solrj.SolrClient>_solrDefaultUpdateClientsThe Solr "default" update clients, per workspaceprotected Map<String,org.apache.solr.client.solrj.SolrClient>_solrNoAutoCommitUpdateClientsThe Solr "no auto commit" update clients, per workspaceprotected org.apache.solr.client.solrj.SolrClient_solrReadClientThe Solr read client.protected Optional<Integer>_solrSocketTimeoutThe solr socket timeout (in millis).protected String_solrUrlThe solr URL.protected WorkspaceSelector_workspaceSelectorThe workspace selector.-
Fields inherited from interface org.ametys.cms.search.solr.SolrClientProvider
ROLE
-
-
Constructor Summary
Constructors Constructor Description DefaultSolrClientProvider()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voiddispose()StringgetCollectionName()Get the name of the collection to use.StringgetCollectionName(String workspaceName)Get the collection to use.org.apache.solr.client.solrj.SolrClientgetReadClient()Get the "read" mode solr client.org.apache.solr.client.solrj.SolrClientgetUpdateClient(String workspaceName, boolean autoCommit)Get a Solr client suited to update.voidinitialize()voidservice(ServiceManager serviceManager)-
Methods inherited from class org.ametys.runtime.plugin.component.AbstractLogEnabled
getLogger, setLogger
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.ametys.cms.search.solr.SolrClientProvider
getUpdateClient
-
-
-
-
Field Detail
-
_workspaceSelector
protected WorkspaceSelector _workspaceSelector
The workspace selector.
-
_repository
protected JackrabbitRepository _repository
The JCR repository
-
_solrReadClient
protected org.apache.solr.client.solrj.SolrClient _solrReadClient
The Solr read client.
-
_solrDefaultUpdateClients
protected Map<String,org.apache.solr.client.solrj.SolrClient> _solrDefaultUpdateClients
The Solr "default" update clients, per workspace
-
_solrNoAutoCommitUpdateClients
protected Map<String,org.apache.solr.client.solrj.SolrClient> _solrNoAutoCommitUpdateClients
The Solr "no auto commit" update clients, per workspace
-
_solrSocketTimeout
protected Optional<Integer> _solrSocketTimeout
The solr socket timeout (in millis).
-
_solrCorePrefix
protected String _solrCorePrefix
The solr core prefix.
-
-
Constructor Detail
-
DefaultSolrClientProvider
public DefaultSolrClientProvider()
-
-
Method Detail
-
service
public void service(ServiceManager serviceManager) throws ServiceException
- Specified by:
servicein interfaceServiceable- Throws:
ServiceException
-
initialize
public void initialize() throws Exception
- Specified by:
initializein interfaceInitializable- Throws:
Exception
-
dispose
public void dispose()
- Specified by:
disposein interfaceDisposable
-
getReadClient
public org.apache.solr.client.solrj.SolrClient getReadClient()
Description copied from interface:SolrClientProviderGet the "read" mode solr client.- Specified by:
getReadClientin interfaceSolrClientProvider- Returns:
- the "read" mode solr client.
-
getUpdateClient
public org.apache.solr.client.solrj.SolrClient getUpdateClient(String workspaceName, boolean autoCommit)
Description copied from interface:SolrClientProviderGet a Solr client suited to update.
You must call this method withfalsevalue for argument `autocommit` so as to get a client that will not trigger any autocommit on Solr side.
Otherwise, calling this method withtruevalue for argument `autocommit` is equivalent to callingSolrClientProvider.getUpdateClient(String)- Specified by:
getUpdateClientin interfaceSolrClientProvider- Parameters:
workspaceName- The name of the workspaceautoCommit-falseso as to get a client that will not trigger any autocommit on Solr side.- Returns:
- a Solr client suited to update.
-
getCollectionName
public String getCollectionName()
Description copied from interface:SolrClientProviderGet the name of the collection to use.- Specified by:
getCollectionNamein interfaceSolrClientProvider- Returns:
- The name of the collection to search in.
-
getCollectionName
public String getCollectionName(String workspaceName)
Description copied from interface:SolrClientProviderGet the collection to use.- Specified by:
getCollectionNamein interfaceSolrClientProvider- Parameters:
workspaceName- The workspace name.- Returns:
- The name of the collection to search in.
-
-