Package com.iizix.test.client
Class ClientManager
java.lang.Object
com.iizix.test.client.ClientManager
Class to manage clients connections.
- Author:
- Christopher Mindus
- Method SummaryModifier and TypeMethodDescription- createDefaultClient- (DestinationServer... destinations) Creates a new DefaultClient.- int- dispose- (long timeout) Disposes of the client manager.- intGets the count for the write cache.- intGets the maximum length for string caching.- intGets the minimum length for string caching.Gets all the clients.- static ClientManagerGets the client manager singleton instance.- intGets the maximum queued transactions to keep.Gets the property factory.- booleanChecks if client manager is disposed of.- booleanGets the verbose flag.- void- setMaxTransactionQueueSize- (int size) Sets the maximum queued transaction to keep.- void- setRequestedApp- (String appID, String language, String userID, String password) Sets the Application ID to run, the User ID and Password to use for the connection.- void- setVerbose- (boolean isVerbose) Sets the verbose flag, also used for new clients.- void- setWriteCacheParams- (int minLength, int maxLength, int cacheCount) Sets the parameters for the write cache: minLength, maxLength, cacheCount.
- Method Details- getInstanceGets the client manager singleton instance.- Returns:
- The client manager instance.
 
- getPropFactoryGets the property factory.- Returns:
- The PropFactory instance initialized as CLIENT.
 
- isVerbosepublic boolean isVerbose()Gets the verbose flag.- Returns:
- The verbose output flag on console.
 
- setVerbosepublic void setVerbose- (boolean isVerbose) Sets the verbose flag, also used for new clients.- Parameters:
- isVerbose- The verbose output flag on console.
 
- setWriteCacheParamspublic void setWriteCacheParams- (int minLength, int maxLength, int cacheCount) Sets the parameters for the write cache: minLength, maxLength, cacheCount. This call must be done creating a new client.- Parameters:
- minLength- The minimum length for caching, 7 is the smallest value.
- maxLength- The maximum length for caching, normally 80 or so (maximum 1024).
- cacheCount- The count should normally be larger than 200 and smaller than 1000 (range is 10 to 2048), if zero, cache is disabled.
- Throws:
- IllegalArgumentException- If arguments are not valid.
 
- getCacheMinLengthpublic int getCacheMinLength()Gets the minimum length for string caching.- Returns:
- The minimum length.
 
- getCacheMaxLengthpublic int getCacheMaxLength()Gets the maximum length for string caching.- Returns:
- The maximum length.
 
- getCacheCountpublic int getCacheCount()Gets the count for the write cache.- Returns:
- The count of cached strings in the write cache.
 
- setMaxTransactionQueueSizepublic void setMaxTransactionQueueSize- (int size) Sets the maximum queued transaction to keep. This method must be called prior to creating a client.- Parameters:
- size- The size, default is 10.
- Throws:
- IllegalArgumentException- If less than 2 and more than 100.
 
- getMaxTransactionQueueSizepublic int getMaxTransactionQueueSize()Gets the maximum queued transactions to keep.- Returns:
- The size, range between 2 and 100, default is 10.
 
- setRequestedAppSets the Application ID to run, the User ID and Password to use for the connection.- Parameters:
- appID- The application ID (leading and trailing whitespaces are removed).
- language- The language code (or null for none). Must be a valid language code. Please note that the language code used for the client session is changed using- Locale.forLanguageTag(language).getDisplayLanguage().replace('_','-').
- userID- The user ID (leading and trailing whitespaces are removed).
- password- The password.
- Throws:
- NullPointerException- If any parameter is null.
- IllegalArgumentException- If any string is empty.
 
- createDefaultClientCreates a new DefaultClient.- Parameters:
- destinations- The destinations.
- Throws:
- IOException- If the worker cannot be created.
- IllegalStateException- If client manager is disposed of.
 
- getClientsGets all the clients.- Returns:
- The clients array.
 
- isDisposedpublic boolean isDisposed()Checks if client manager is disposed of.- Returns:
- true if disposed of, false otherwise.
 
- disposepublic int dispose- (long timeout) Disposes of the client manager. Calling this method will cause all client connections to be disposed of.- Parameters:
- timeout- The maximum time to wait for clients to complete,- -1Lfor indefinite timeout. The timeout wait can be interrupted if you call the thread's- interrupt()method.
- Returns:
- zero for success, otherwise the remaining disposed but still not terminated client sessions. If called when already disposed of, -1is returned.