Package org.opennms.features.jest.client
Class RestClientFactory
- java.lang.Object
-
- org.opennms.features.jest.client.RestClientFactory
-
public class RestClientFactory extends Object
This factory wraps theJestClientFactoryto provide instances ofJestClient.
-
-
Constructor Summary
Constructors Constructor Description RestClientFactory(String elasticSearchURL)RestClientFactory(String elasticSearchURL, String globalElasticUser, String globalElasticPassword)Create a RestClientFactory.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description io.searchbox.client.JestClientcreateClient()voidsetConnTimeout(int timeout)voidsetCredentials(CredentialsProvider credentialsProvider)voidsetDefaultMaxTotalConnectionPerRoute(int connections)Set the default max connections per route.voidsetDiscovery(boolean discovery)Defines if discovery/sniffing of nodes in the cluster is enabled.voidsetDiscoveryFrequency(int discoveryFrequencyInSeconds)Sets the frequency to discover the nodes in the cluster.voidsetHttpCompression(boolean httpCompression)voidsetIgnoreCertificates(boolean ignoreCertificates)Allow insecure HTTPS/SSL connections.voidsetMaxConnectionIdleTime(int timeout, TimeUnit unit)voidsetMaxTotalConnection(int connections)Set the default max total connections.voidsetMultiThreaded(boolean multiThreaded)voidsetProxy(String proxy)voidsetReadTimeout(int timeout)voidsetRequestExecutorFactory(RequestExecutorFactory requestExecutorFactory)voidsetRequestExecutorSupplier(java.util.function.Supplier<RequestExecutor> requestExecutorSupplier)voidsetRetries(int retries)Set the number of times the REST operation will be retried if an exception is thrown during the operation.voidsetSocketTimeout(int timeout)Set the socket timeout (SO_TIMEOUT) for the REST connections.voidsetTimeout(int timeout)Set the connection timeout for the REST connections.
-
-
-
Constructor Detail
-
RestClientFactory
public RestClientFactory(String elasticSearchURL) throws MalformedURLException
- Throws:
MalformedURLException
-
RestClientFactory
public RestClientFactory(String elasticSearchURL, String globalElasticUser, String globalElasticPassword) throws MalformedURLException
Create a RestClientFactory.- Parameters:
elasticSearchURL- Elasticsearch URL, either a single URL or multiple URLs that are comma-separated without spacesglobalElasticUser- Optional HTTP usernameglobalElasticPassword- Optional HTTP password- Throws:
MalformedURLException
-
-
Method Detail
-
setRetries
public void setRetries(int retries)
Set the number of times the REST operation will be retried if an exception is thrown during the operation.- Parameters:
retries- Number of retries.
-
setSocketTimeout
public void setSocketTimeout(int timeout)
Set the socket timeout (SO_TIMEOUT) for the REST connections. This is the maximum period of inactivity while waiting for incoming data. A default value of 3000 is specified inio.searchbox.client.config.ClientConfig.AbstractBuilder.- Parameters:
timeout- Timeout in milliseconds.
-
setTimeout
public void setTimeout(int timeout)
Set the connection timeout for the REST connections. A default value of 3000 is specified inio.searchbox.client.config.ClientConfig.AbstractBuilder. This is also used as the minimum interval between successive retries if the connection is refused in a shorter amount of time.- Parameters:
timeout- Timeout in milliseconds.
-
setConnTimeout
public void setConnTimeout(int timeout)
-
setReadTimeout
public void setReadTimeout(int timeout)
-
setMultiThreaded
public void setMultiThreaded(boolean multiThreaded)
-
setDefaultMaxTotalConnectionPerRoute
public void setDefaultMaxTotalConnectionPerRoute(int connections)
Set the default max connections per route. By default, we use the number of available processors * 2. If a negative value is given, the set is ignored. This allows us to use -1 as the default in the Blueprint in order to avoid having to caculate the default again there.- Parameters:
connections- default max connections per route
-
setMaxTotalConnection
public void setMaxTotalConnection(int connections)
Set the default max total connections. By default, we use the default max connections per route * 3. If a negative value is given, the set is ignored. This allows us to use -1 as the default in the Blueprint in order to avoid having to caculate the default again there.- Parameters:
connections- default max connections per route
-
setDiscovery
public void setDiscovery(boolean discovery)
Defines if discovery/sniffing of nodes in the cluster is enabled.- Parameters:
discovery- true if discovery should be enabled, false otherwise
-
setDiscoveryFrequency
public void setDiscoveryFrequency(int discoveryFrequencyInSeconds)
Sets the frequency to discover the nodes in the cluster. Note: This only works if discovery is enabled.- Parameters:
discoveryFrequencyInSeconds- frequency in seconds
-
setMaxConnectionIdleTime
public void setMaxConnectionIdleTime(int timeout, TimeUnit unit)
-
setCredentials
public void setCredentials(CredentialsProvider credentialsProvider) throws IOException
- Throws:
IOException
-
setProxy
public void setProxy(String proxy) throws MalformedURLException
- Throws:
MalformedURLException
-
setHttpCompression
public void setHttpCompression(boolean httpCompression)
-
setRequestExecutorFactory
public void setRequestExecutorFactory(RequestExecutorFactory requestExecutorFactory)
-
setRequestExecutorSupplier
public void setRequestExecutorSupplier(java.util.function.Supplier<RequestExecutor> requestExecutorSupplier)
-
createClient
public io.searchbox.client.JestClient createClient()
-
setIgnoreCertificates
public void setIgnoreCertificates(boolean ignoreCertificates)
Allow insecure HTTPS/SSL connections.- Parameters:
ignoreCertificates-
-
-