Class OpenSearchClientFactory
java.lang.Object
org.springframework.beans.factory.config.AbstractFactoryBean<org.opensearch.client.opensearch.OpenSearchClient>
org.craftercms.search.opensearch.spring.OpenSearchClientFactory
- All Implemented Interfaces:
org.springframework.beans.factory.Aware,org.springframework.beans.factory.BeanClassLoaderAware,org.springframework.beans.factory.BeanFactoryAware,org.springframework.beans.factory.DisposableBean,org.springframework.beans.factory.FactoryBean<org.opensearch.client.opensearch.OpenSearchClient>,org.springframework.beans.factory.InitializingBean
public class OpenSearchClientFactory
extends org.springframework.beans.factory.config.AbstractFactoryBean<org.opensearch.client.opensearch.OpenSearchClient>
Implementation of
AbstractFactoryBean to create instances of OpenSearchClient- Since:
- 4.0.0
- Author:
- joseross
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected intThe connection timeout in millisecondsprotected intThe maximum number of connections per routeprotected intThe maximum number of connectionsprotected StringThe password for OpenSearchprotected final String[]List of OpenSearch urlsprotected booleanIndicates if socket keep alive should be enabledprotected intThe socket timeout in millisecondsprotected intThe number of threads to useprotected StringThe username for OpenSearchFields inherited from interface org.springframework.beans.factory.FactoryBean
OBJECT_TYPE_ATTRIBUTE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic org.opensearch.client.opensearch.OpenSearchClientcreateClient(String[] serverUrls, String username, String password, int connectTimeout, int socketTimeout, int threadCount, boolean socketKeepAlive, int maxTotalConnections, int maxConnectionsPerRoute) Creates anOpenSearchClientinstanceprotected @NonNull org.opensearch.client.opensearch.OpenSearchClientprotected voiddestroyInstance(@Nullable org.opensearch.client.opensearch.OpenSearchClient instance) Class<?> voidsetConnectTimeout(int connectTimeout) voidsetMaxConnectionsPerRoute(int maxConnectionsPerRoute) voidsetMaxTotalConnections(int maxTotalConnections) voidsetPassword(String password) voidsetSocketKeepAlive(boolean socketKeepAlive) voidsetSocketTimeout(int socketTimeout) voidsetThreadCount(int threadCount) voidsetUsername(String username) Methods inherited from class org.springframework.beans.factory.config.AbstractFactoryBean
afterPropertiesSet, destroy, getBeanFactory, getBeanTypeConverter, getEarlySingletonInterfaces, getObject, isSingleton, setBeanClassLoader, setBeanFactory, setSingleton
-
Field Details
-
serverUrls
List of OpenSearch urls -
username
The username for OpenSearch -
password
The password for OpenSearch -
connectTimeout
protected int connectTimeoutThe connection timeout in milliseconds -
socketTimeout
protected int socketTimeoutThe socket timeout in milliseconds -
threadCount
protected int threadCountThe number of threads to use -
socketKeepAlive
protected boolean socketKeepAliveIndicates if socket keep alive should be enabled -
maxTotalConnections
protected int maxTotalConnectionsThe maximum number of connections -
maxConnectionsPerRoute
protected int maxConnectionsPerRouteThe maximum number of connections per route
-
-
Constructor Details
-
OpenSearchClientFactory
-
-
Method Details
-
setUsername
-
setPassword
-
setConnectTimeout
public void setConnectTimeout(int connectTimeout) -
setSocketTimeout
public void setSocketTimeout(int socketTimeout) -
setThreadCount
public void setThreadCount(int threadCount) -
setSocketKeepAlive
public void setSocketKeepAlive(boolean socketKeepAlive) -
setMaxConnectionsPerRoute
public void setMaxConnectionsPerRoute(int maxConnectionsPerRoute) -
setMaxTotalConnections
public void setMaxTotalConnections(int maxTotalConnections) -
createClient
public static org.opensearch.client.opensearch.OpenSearchClient createClient(String[] serverUrls, String username, String password, int connectTimeout, int socketTimeout, int threadCount, boolean socketKeepAlive, int maxTotalConnections, int maxConnectionsPerRoute) throws URISyntaxException Creates anOpenSearchClientinstance- Parameters:
serverUrls- array of OpenSearch server URLsusername- the usernamepassword- the passwordconnectTimeout- connection timeoutsocketTimeout- socket timeoutthreadCount- number of threadssocketKeepAlive- indicates if socket keep alive should be enabledmaxTotalConnections- maximum total connectionsmaxConnectionsPerRoute- maximum connections per route- Returns:
- the
OpenSearchClientinstance - Throws:
URISyntaxException
-
getObjectType
- Specified by:
getObjectTypein interfaceorg.springframework.beans.factory.FactoryBean<org.opensearch.client.opensearch.OpenSearchClient>- Specified by:
getObjectTypein classorg.springframework.beans.factory.config.AbstractFactoryBean<org.opensearch.client.opensearch.OpenSearchClient>
-
createInstance
protected @NonNull org.opensearch.client.opensearch.OpenSearchClient createInstance() throws URISyntaxException- Specified by:
createInstancein classorg.springframework.beans.factory.config.AbstractFactoryBean<org.opensearch.client.opensearch.OpenSearchClient>- Throws:
URISyntaxException
-
destroyInstance
protected void destroyInstance(@Nullable org.opensearch.client.opensearch.OpenSearchClient instance) throws Exception - Overrides:
destroyInstancein classorg.springframework.beans.factory.config.AbstractFactoryBean<org.opensearch.client.opensearch.OpenSearchClient>- Throws:
Exception
-