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 private static String
__SOLR_CORE_PREFIX_CONFIG
private static String
__SOLR_SOCKET_TIMEOUT_CONFIG
private static String
__SOLR_URL_CONFIG
protected String
_solrCorePrefix
The solr core prefix.protected Map<String,org.apache.solr.client.solrj.SolrClient>
_solrDefaultUpdateClients
The Solr "default" update clients, per workspaceprotected Map<String,org.apache.solr.client.solrj.SolrClient>
_solrNoAutoCommitUpdateClients
The Solr "no auto commit" update clients, per workspaceprotected org.apache.solr.client.solrj.SolrClient
_solrReadClient
The Solr read client.protected Optional<Integer>
_solrSocketTimeout
The solr socket timeout (in millis).protected String
_solrUrl
The solr URL.protected WorkspaceSelector
_workspaceSelector
The 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 private org.apache.solr.client.solrj.SolrClient
_createDefaultUpdateClient(String workspaceName)
private org.apache.solr.client.solrj.SolrClient
_createNoAutoCommitUpdateClient(String workspaceName)
private String
_nonNullWorkspaceName(String workspaceName)
void
dispose()
String
getCollectionName()
Get the name of the collection to use.String
getCollectionName(String workspaceName)
Get the collection to use.org.apache.solr.client.solrj.SolrClient
getReadClient()
Get the "read" mode solr client.org.apache.solr.client.solrj.SolrClient
getUpdateClient(String workspaceName, boolean autoCommit)
Get a Solr client suited to update.void
initialize()
void
service(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
-
__SOLR_URL_CONFIG
private static final String __SOLR_URL_CONFIG
- See Also:
- Constant Field Values
-
__SOLR_SOCKET_TIMEOUT_CONFIG
private static final String __SOLR_SOCKET_TIMEOUT_CONFIG
- See Also:
- Constant Field Values
-
__SOLR_CORE_PREFIX_CONFIG
private static final String __SOLR_CORE_PREFIX_CONFIG
- See Also:
- Constant Field Values
-
_workspaceSelector
protected WorkspaceSelector _workspaceSelector
The workspace selector.
-
_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:
service
in interfaceServiceable
- Throws:
ServiceException
-
initialize
public void initialize() throws Exception
- Specified by:
initialize
in interfaceInitializable
- Throws:
Exception
-
_createDefaultUpdateClient
private org.apache.solr.client.solrj.SolrClient _createDefaultUpdateClient(String workspaceName)
-
_createNoAutoCommitUpdateClient
private org.apache.solr.client.solrj.SolrClient _createNoAutoCommitUpdateClient(String workspaceName)
-
dispose
public void dispose()
- Specified by:
dispose
in interfaceDisposable
-
getReadClient
public org.apache.solr.client.solrj.SolrClient getReadClient()
Description copied from interface:SolrClientProvider
Get the "read" mode solr client.- Specified by:
getReadClient
in interfaceSolrClientProvider
- Returns:
- the "read" mode solr client.
-
getUpdateClient
public org.apache.solr.client.solrj.SolrClient getUpdateClient(String workspaceName, boolean autoCommit)
Description copied from interface:SolrClientProvider
Get a Solr client suited to update.
You must call this method withfalse
value for argument `autocommit` so as to get a client that will not trigger any autocommit on Solr side.
Otherwise, calling this method withtrue
value for argument `autocommit` is equivalent to callingSolrClientProvider.getUpdateClient(String)
- Specified by:
getUpdateClient
in interfaceSolrClientProvider
- Parameters:
workspaceName
- The name of the workspaceautoCommit
-false
so 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:SolrClientProvider
Get the name of the collection to use.- Specified by:
getCollectionName
in interfaceSolrClientProvider
- Returns:
- The name of the collection to search in.
-
getCollectionName
public String getCollectionName(String workspaceName)
Description copied from interface:SolrClientProvider
Get the collection to use.- Specified by:
getCollectionName
in interfaceSolrClientProvider
- Parameters:
workspaceName
- The workspace name.- Returns:
- The name of the collection to search in.
-
_nonNullWorkspaceName
private String _nonNullWorkspaceName(String workspaceName)
-
-