public class DxlClientConfig
extends java.lang.Object
DxlClientConfig
class holds the information necessary to connect a DxlClient
to the DXL fabric.Modifier and Type | Field and Description |
---|---|
static java.lang.String |
KS_PASS
The default keystore password
|
Constructor and Description |
---|
DxlClientConfig(java.lang.String brokerCaBundlePath,
java.lang.String certFile,
java.lang.String privateKey,
java.util.List<Broker> brokers)
Constructs the configuration
|
DxlClientConfig(java.lang.String brokerCaBundlePath,
java.lang.String certFile,
java.lang.String privateKey,
java.util.List<Broker> brokers,
java.util.List<Broker> webSocketBrokers)
Constructs the configuration
|
Modifier and Type | Method and Description |
---|---|
static DxlClientConfig |
createDxlConfigFromFile(java.lang.String fileName)
This method allows creation of a
DxlClientConfig object from a specified configuration file. |
java.lang.String |
getBrokerCaBundlePath()
Returns the file name of a bundle containing the broker CA certificates in PEM format
|
java.util.List<Broker> |
getBrokerList()
Returns the list of
Broker objects representing brokers on the DXL fabric supporting standard
MQTT connections. |
int |
getConnectRetries()
Returns the maximum number of connection attempts for each
Broker specified. |
int |
getConnectTimeout()
Returns the connection timeout.
|
int |
getDisconnectTimeout()
Returns the disconnection timeout.
|
int |
getIncomingMessageQueueSize()
Returns the queue size for incoming messages (will block when queue is full)
|
int |
getIncomingMessageThreadPoolSize()
Returns the thread pool size for incoming messages
|
java.util.List<Broker> |
getInUseBrokerList()
Returns the list of
Broker objects representing brokers on the DXL fabric. |
int |
getKeepAliveInterval()
Returns the maximum period in seconds between communications with a connected
Broker . |
java.security.KeyStore |
getKeyStore()
Returns the
KeyStore associated with the client configuration |
long |
getOperationTimeToWait()
Returns the time to wait for an underlying protocol operation to complete.
|
java.lang.String |
getProxyAddress()
Returns the HTTP proxy address
|
char[] |
getProxyPassword()
Returns the the HTTP proxy password
|
int |
getProxyPort()
Returns the HTTP proxy port
|
java.lang.String |
getProxyUserName()
Returns the HTTP proxy user name
|
int |
getReconnectBackOffMultiplier()
Returns the exponential reconnect back off multiplier, defaults to
2 |
int |
getReconnectDelay()
Returns the amount of time (in ms) for the first connect retry, defaults to
1000 |
long |
getReconnectDelayMax()
Returns the maximum reconnect delay time, defaults to
60000 (one minute) |
float |
getReconnectDelayRandom()
Returns the randomness delay percentage (between
0.0 and 1.0 ). |
java.lang.String |
getUniqueId()
Returns the unique identifier of the client instance
|
java.util.List<Broker> |
getWebSocketBrokers()
Returns the list of
Broker objects representing brokers on the DXL fabric supporting DXL connections
over WebSockets. |
boolean |
isHttpsHostnameVerificationEnabled()
Returns whether the client should do SSL host name verification when connecting to a broker
|
boolean |
isInfiniteReconnectRetries()
Returns whether the client should infinitely retry to reconnect when it gets disconnected
|
boolean |
isUseWebSockets()
Returns whether the client should use WebSockets or regular MQTT over tcp when connecting to a
Broker |
void |
setConnectRetries(int retries)
Sets the maximum number of connection attempts for each
Broker specified. |
void |
setConnectTimeout(int timeout)
Sets the connection timeout.
|
void |
setDisconnectTimeout(int timeout)
Sets the disconnection timeout.
|
void |
setHttpsHostnameVerificationEnabled(boolean httpsHostnameVerificationEnabled)
Sets whether the client should do SSL host name verification when connecting to a broker.
|
void |
setIncomingMessageQueueSize(int size)
Sets the queue size for incoming messages (will block when queue is full)
|
void |
setIncomingMessageThreadPoolSize(int size)
Sets the thread pool size for incoming messages
|
void |
setInfiniteReconnectRetries(boolean infiniteReconnect)
Sets whether the client should infinitely retry to reconnect when it gets disconnected
|
void |
setKeepAliveInterval(int keepAliveInterval)
Sets the maximum period in seconds between communications with a connected
Broker . |
void |
setOperationTimeToWait(long timeToWait)
Sets the time to wait for an underlying protocol operation to complete.
|
void |
setProxyAddress(java.lang.String proxyAddress)
Sets the HTTP proxy address
|
void |
setProxyPassword(char[] proxyPassword)
Sets the the HTTP proxy password
|
void |
setProxyPort(int proxyPort)
Sets the HTTP proxy port
|
void |
setProxyUserName(java.lang.String proxyUserName)
Sets the HTTP proxy user name
|
void |
setReconnectBackOffMultiplier(int multiplier)
The exponential reconnect back off multiplier, defaults to
2 |
void |
setReconnectDelay(int delay)
The amount of time (in ms) for the first connect retry, defaults to
1000 |
void |
setReconnectDelayMax(long delayMax)
The maximum reconnect delay time, defaults to
60000 (one minute) |
void |
setReconnectDelayRandom(float percent)
Sets a randomness delay percentage (between
0.0 and 1.0 ). |
void |
setUniqueId(java.lang.String uniqueId)
Overwrites the unique identifier of the client with a new UUID.
|
void |
setUseWebSockets(boolean useWebSockets)
Sets whether the client should use WebSockets or regular MQTT over tcp when connecting to a
Broker |
void |
setWebSocketBrokers(java.util.List<Broker> webSocketBrokers)
Set the list of
Broker objects representing brokers on the DXL fabric supporting DXL connections
over WebSockets. |
void |
write(java.lang.String configFile)
Method to write out the dxlClient.config file from the DXLClientConfig object member variables
|
public static final java.lang.String KS_PASS
public DxlClientConfig(java.lang.String brokerCaBundlePath, java.lang.String certFile, java.lang.String privateKey, java.util.List<Broker> brokers)
brokerCaBundlePath
- The file name of a bundle containing the broker CA certificates in PEM formatcertFile
- The file name of the client certificate in PEM formatprivateKey
- The file name of the client private key in PEM formatbrokers
- A list of Broker
objects representing brokers comprising the DXL fabric supporting
standard MQTT connections. When invoking the DxlClient.connect()
method, the
DxlClient
will attempt to connect to the closest broker.public DxlClientConfig(java.lang.String brokerCaBundlePath, java.lang.String certFile, java.lang.String privateKey, java.util.List<Broker> brokers, java.util.List<Broker> webSocketBrokers)
brokerCaBundlePath
- The file name of a bundle containing the broker CA certificates in PEM formatcertFile
- The file name of the client certificate in PEM formatprivateKey
- The file name of the client private key in PEM formatbrokers
- A list of Broker
objects representing brokers comprising the DXL fabric supporting
standard MQTT connections. When invoking the DxlClient.connect()
method, the
DxlClient
will attempt to connect to the closest broker.webSocketBrokers
- A list Broker
objects representing brokers on the DXL fabric supporting DXL
connections over WebSockets. When invoking the DxlClient.connect()
method,
the DxlClient
will attempt to connect to the closest broker.public java.security.KeyStore getKeyStore() throws DxlException
KeyStore
associated with the client configurationKeyStore
associated with the client configurationDxlException
- If an error occurspublic java.lang.String getBrokerCaBundlePath()
public java.lang.String getUniqueId()
public void setUniqueId(java.lang.String uniqueId)
uniqueId
- The unique identifier of the client.public java.util.List<Broker> getBrokerList()
Broker
objects representing brokers on the DXL fabric supporting standard
MQTT connections. When invoking the DxlClient.connect()
method, the DxlClient
will attempt to
connect to the closest broker.Broker
objects representing brokers on the DXL fabric supporting standard
MQTT connections.public java.util.List<Broker> getInUseBrokerList()
Broker
objects representing brokers on the DXL fabric. When invoking
the DxlClient.connect()
method, the DxlClient
will attempt to
connect to the closest broker.Broker
objects representing brokers on the DXL fabricpublic java.util.List<Broker> getWebSocketBrokers()
Broker
objects representing brokers on the DXL fabric supporting DXL connections
over WebSockets. When invoking the DxlClient.connect()
method, the DxlClient
will
attempt to connect to the closest broker.Broker
objects representing brokers on the DXL fabric supporting DXL connections
over WebSockets.public void setWebSocketBrokers(java.util.List<Broker> webSocketBrokers)
Broker
objects representing brokers on the DXL fabric supporting DXL connections
over WebSockets.webSocketBrokers
- The list of Broker
objects representing brokers on the DXL fabric supporting
DXL connections over WebSockets.public boolean isUseWebSockets()
Broker
Defaults to false
Broker
public void setUseWebSockets(boolean useWebSockets)
Broker
useWebSockets
- Whether the client should use WebSockets or regular MQTT over tcp when connecting to
a Broker
public void setIncomingMessageThreadPoolSize(int size)
Defaults to 1
size
- The thread pool size for incoming messagespublic int getIncomingMessageThreadPoolSize()
Defaults to 1
public void setIncomingMessageQueueSize(int size)
Defaults to 16384
size
- The queue size for incoming messagespublic int getIncomingMessageQueueSize()
Defaults to 16384
public void setKeepAliveInterval(int keepAliveInterval) throws java.lang.IllegalArgumentException
Broker
. If no other
messages are being exchanged, this controls the rate at which the client will send ping messages to the
Broker
.
Defaults to 1800
seconds (30 minutes)
keepAliveInterval
- The maximum period in seconds between communications with a connected Broker
.java.lang.IllegalArgumentException
public int getKeepAliveInterval()
Broker
. If no other
messages are being exchanged, this controls the rate at which the client will send ping messages to the
Broker
.
Defaults to 1800
seconds (30 minutes)
Broker
.public void setConnectRetries(int retries)
Broker
specified.
A value of -1
indicates that the client will continue to retry without limit until it establishes
a connection.
Defaults to -1
retries
- The maximum number of connection attempts for each Broker
specified.public int getConnectRetries()
Broker
specified.
A value of -1
indicates that the client will continue to retry without limit until it establishes
a connection.
Defaults to -1
Broker
specified.public void setInfiniteReconnectRetries(boolean infiniteReconnect)
Defaults to true
infiniteReconnect
- Whether the client should infinitely retry to reconnect when
it gets disconnectedpublic boolean isInfiniteReconnectRetries()
Defaults to true
public boolean isHttpsHostnameVerificationEnabled()
public void setHttpsHostnameVerificationEnabled(boolean httpsHostnameVerificationEnabled)
Defaults to false
httpsHostnameVerificationEnabled
- Whether the client should do SSL host name
verification when connecting to a broker.public void setReconnectDelay(int delay)
1000
delay
- The amount of time (in ms) for the first connect retry,
defaults to 1000
public int getReconnectDelay()
1000
1000
public void setReconnectDelayMax(long delayMax)
60000
(one minute)delayMax
- The maximum reconnect delay time, defaults to 60000
(one minute)public long getReconnectDelayMax()
60000
(one minute)60000
(one minute)public void setReconnectBackOffMultiplier(int multiplier)
2
multiplier
- The exponential reconnect back off multiplier, defaults to 2
public int getReconnectBackOffMultiplier()
2
2
public void setReconnectDelayRandom(float percent)
0.0
and 1.0
). When
calculating the reconnect delay, this percentage indicates how much randomness there
should be in the current delay. For example, if the current delay is 100ms, a value of
.25 would mean that the actual delay would be between 100ms and 125ms. The default value
is 0.25
percent
- The randomness delay percentage (between 0.0
and
1.0
public java.lang.String getProxyAddress()
public void setProxyAddress(java.lang.String proxyAddress)
proxyAddress
- The HTTP proxy addresspublic int getProxyPort()
public void setProxyPort(int proxyPort)
proxyPort
- The HTTP proxy portpublic java.lang.String getProxyUserName()
public void setProxyUserName(java.lang.String proxyUserName)
proxyUserName
- The HTTP proxy user namepublic char[] getProxyPassword()
public void setProxyPassword(char[] proxyPassword)
proxyPassword
- The the HTTP proxy passwordpublic void write(java.lang.String configFile) throws java.lang.Exception
configFile
- The path to the dxlClient.config filejava.lang.Exception
- If there is an issue with writing the dxlClient.config filepublic float getReconnectDelayRandom()
0.0
and 1.0
). When
calculating the reconnect delay, this percentage indicates how much randomness there
should be in the current delay. For example, if the current delay is 100ms, a value of
.25 would mean that the actual delay would be between 100ms and 125ms. The default value
is 0.25
0.0
and 1.0
public void setOperationTimeToWait(long timeToWait)
2
minutes.timeToWait
- The time to wait for an underlying protocol operation to complete (in milliseconds)public long getOperationTimeToWait()
2
minutes.public void setConnectTimeout(int timeout)
30
seconds.timeout
- The connection timeout (in seconds)public int getConnectTimeout()
30
seconds.public void setDisconnectTimeout(int timeout)
60
seconds.timeout
- The disconnection timeout (in seconds)public int getDisconnectTimeout()
60
seconds.public static DxlClientConfig createDxlConfigFromFile(java.lang.String fileName) throws DxlException
DxlClientConfig
object from a specified configuration file. The
information contained in the file has a one-to-one correspondence with the DxlClientConfig
constructor.
[General] UseWebSockets=false [Certs] BrokerCertChain=c:\\certs\\brokercerts.crt CertFile=c:\\certs\\client.crt PrivateKey=c:\\certs\\client.key [Brokers] mybroker=mybroker;8883;mybroker.mcafee.com;192.168.1.12 mybroker2=mybroker2;8883;mybroker2.mcafee.com;192.168.1.13 [BrokersWebSockets] mybroker=mybroker;8883;mybroker.mcafee.com;192.168.1.12 mybroker2=mybroker2;8883;mybroker2.mcafee.com;192.168.1.13 [Proxy] Address=proxy.mycompany.com Port=3128 User=proxyUser Password=proxyPasswordThe configuration file can be loaded as follows:
DxlClientConfig.createDxlConfigFromFile("c:\\certs\\dxlclient.cfg");
fileName
- Path to the configuration fileDxlClientConfig
object corresponding to the specified configuration fileDxlException
- If an error occurs