Class ElasticsearchHttpClientFactory
java.lang.Object
org.alfresco.repo.search.impl.elasticsearch.client.ElasticsearchHttpClientFactory
Singleton factory for Elasticsearch Http Client. This class is providing an Elastic RestHighLevelClient instance, that maintains a pool of RestLowLevelClient instances.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected org.apache.hc.client5.http.config.RequestConfigBuilds and caches the RequestConfig with the configured response timeout.voiddestroy()Releases resources held by the Elasticsearch client transport, including the HTTP connection pool and IO reactor threads.protected Stringprotected org.opensearch.client.opensearch.OpenSearchClientprotected intprotected org.apache.hc.client5.http.auth.CredentialsProviderBuild CredentialsProvider instance with user and password values from properties fileorg.opensearch.client.opensearch.OpenSearchClientSingleton method returning the Elasticsearch client.protected org.opensearch.client.opensearch.OpenSearchClientgetElasticsearchClient(String protocol, int port) Creates an Elasticsearch client applying parameters from properties fileGets Elasticsearch server URLprotected StringgetHost()protected org.apache.hc.client5.http.impl.async.HttpAsyncClientBuildergetHttpAsyncClientBuilder(org.apache.hc.client5.http.impl.async.HttpAsyncClientBuilder httpClientBuilder) Apply pooling options, credentials and SSL settings to Elasticsearch clientprotected org.alfresco.encryption.KeyResourceLoaderprotected intprotected intprotected intgetPort()protected intprotected Stringprotected intprotected SSLContextBuild SSLContext instance with truststore that must include Elasticsearch server public certificate in order to be trusted for this https connection.protected org.alfresco.encryption.ssl.SSLEncryptionParametersprotected org.alfresco.encryption.AlfrescoKeyStoreprotected intprotected StringgetUser()voidinit()Initialize SSL Truststore for https connections using "encryption.ssl.truststore.*" propertiesprotected booleanvoidsetArchiveIndexName(String archiveIndexName) voidsetBaseUrl(String baseUrl) protected voidsetClient(org.opensearch.client.opensearch.OpenSearchClient client) voidsetConnectionTimeout(int connectionTimeout) voidvoidsetHostNameVerification(boolean hostNameVerification) voidsetIndexName(String indexName) voidsetKeyResourceLoader(org.alfresco.encryption.KeyResourceLoader keyResourceLoader) voidsetMaxHostConnections(int maxHostConnections) voidsetMaxTotalConnections(int maxTotalConnections) voidsetPassword(String password) voidsetPort(int port) voidsetResponseTimeout(int responseTimeout) voidsetSecureComms(String secureComms) voidsetSocketTimeout(int socketTimeout) voidsetSslEncryptionParameters(org.alfresco.encryption.ssl.SSLEncryptionParameters sslEncryptionParameters) voidsetThreadCount(int threadCount) void
-
Field Details
-
TLS
- See Also:
-
TLS_V_1_2
- See Also:
-
TLS_V_1_3
- See Also:
-
SECURE_COMMS_HTTPS
- See Also:
-
-
Constructor Details
-
ElasticsearchHttpClientFactory
public ElasticsearchHttpClientFactory()
-
-
Method Details
-
init
public void init()Initialize SSL Truststore for https connections using "encryption.ssl.truststore.*" properties -
destroy
public void destroy()Releases resources held by the Elasticsearch client transport, including the HTTP connection pool and IO reactor threads. -
getSecureComms
-
getHost
-
getBaseUrl
-
getPort
protected int getPort() -
getSslEncryptionParameters
protected org.alfresco.encryption.ssl.SSLEncryptionParameters getSslEncryptionParameters() -
getKeyResourceLoader
protected org.alfresco.encryption.KeyResourceLoader getKeyResourceLoader() -
getSslTrustStore
protected org.alfresco.encryption.AlfrescoKeyStore getSslTrustStore() -
isHostNameVerification
protected boolean isHostNameVerification() -
getUser
-
getMaxTotalConnections
protected int getMaxTotalConnections() -
getMaxHostConnections
protected int getMaxHostConnections() -
getThreadCount
protected int getThreadCount() -
getConnectionTimeout
protected int getConnectionTimeout() -
getSocketTimeout
protected int getSocketTimeout() -
getResponseTimeout
protected int getResponseTimeout() -
getClient
protected org.opensearch.client.opensearch.OpenSearchClient getClient() -
getElasticsearchClient
public org.opensearch.client.opensearch.OpenSearchClient getElasticsearchClient()Singleton method returning the Elasticsearch client. The client is only built if it's not already created.- Returns:
- Elasticsearch client
-
getElasticsearchServerUrl
Gets Elasticsearch server URL- Returns:
- Elasticsearch server URL
-
getElasticsearchClient
protected org.opensearch.client.opensearch.OpenSearchClient getElasticsearchClient(String protocol, int port) Creates an Elasticsearch client applying parameters from properties file- Parameters:
protocol- Http protocol: http or httpsport- Port number- Returns:
- Elasticsearch client ready to be used
-
buildRequestConfig
protected org.apache.hc.client5.http.config.RequestConfig buildRequestConfig()Builds and caches the RequestConfig with the configured response timeout. -
getHttpAsyncClientBuilder
protected org.apache.hc.client5.http.impl.async.HttpAsyncClientBuilder getHttpAsyncClientBuilder(org.apache.hc.client5.http.impl.async.HttpAsyncClientBuilder httpClientBuilder) Apply pooling options, credentials and SSL settings to Elasticsearch client- Parameters:
httpClientBuilder- Existing HttpClientBuilder instance- Returns:
- httpClientBuilder including required settings
-
getCredentialsProvider
protected org.apache.hc.client5.http.auth.CredentialsProvider getCredentialsProvider()Build CredentialsProvider instance with user and password values from properties file- Returns:
- CredentialsProvider instance
-
getSSLContext
Build SSLContext instance with truststore that must include Elasticsearch server public certificate in order to be trusted for this https connection.- Returns:
- SSLContext instance
-
setHost
-
setBaseUrl
-
setPort
public void setPort(int port) -
setSecureComms
-
setUser
-
setPassword
-
setMaxTotalConnections
public void setMaxTotalConnections(int maxTotalConnections) -
setMaxHostConnections
public void setMaxHostConnections(int maxHostConnections) -
setConnectionTimeout
public void setConnectionTimeout(int connectionTimeout) -
setSocketTimeout
public void setSocketTimeout(int socketTimeout) -
setResponseTimeout
public void setResponseTimeout(int responseTimeout) -
setClient
protected void setClient(org.opensearch.client.opensearch.OpenSearchClient client) -
setSslEncryptionParameters
public void setSslEncryptionParameters(org.alfresco.encryption.ssl.SSLEncryptionParameters sslEncryptionParameters) -
setKeyResourceLoader
public void setKeyResourceLoader(org.alfresco.encryption.KeyResourceLoader keyResourceLoader) -
setHostNameVerification
public void setHostNameVerification(boolean hostNameVerification) -
setIndexName
-
setArchiveIndexName
-
getArchiveIndexName
-
getIndexName
-
setThreadCount
public void setThreadCount(int threadCount)
-