org.rhq.enterprise.server.core.comm
Class ServerConfiguration

java.lang.Object
  extended by org.rhq.enterprise.server.core.comm.ServerConfiguration

public class ServerConfiguration
extends Object

Just provides some convienence methods to extract server configuration properties. The bulk of the server configuration really is just the ServiceContainerConfiguration, with some additional client-side type preferences to support remote streaming.

Author:
John Mazzitelli

Constructor Summary
ServerConfiguration(Preferences prefs)
          Wraps a preferences object in this instance.
 
Method Summary
 String getAgentFilesDirectory()
          This will return the directory name where the server stores all the files it can distribute to its agents.
 ClientCommandSenderConfiguration getClientCommandSenderConfiguration()
          This is a convienence method that returns the full client sender configuration.
 String getClientSenderCommandSpoolFileName()
          This will return the name of the command spool file (to be located in the data directory).
 long[] getClientSenderCommandSpoolFileParams()
          Returns an array of command spool file parameters.
 long getClientSenderCommandTimeout()
          Returns the default timeout that the client sender will wait for a command to be processed by the remote endpoint.
 int getClientSenderMaxConcurrent()
          Returns the maximum number of concurrent commands that the client sender will send at any one time.
 int getClientSenderMaxRetries()
          Returns the number of times a guaranteed message is retried, if it fails for a reason other than a "cannot connect" to server.
 int getClientSenderQueueSize()
          Returns the client sender queue size which determines how many commands can be queued up for sending.
 int[] getClientSenderQueueThrottling()
          Returns an array of queue throttling parameters or null if queue throttling is to be disabled.
 long getClientSenderRetryInterval()
          Returns the time in milliseconds the client sender should wait in between retries of commands that have failed.
 String getClientSenderSecurityKeystoreAlgorithm()
          Returns the algorithm used to manage the keys in the keystore.
 String getClientSenderSecurityKeystoreAlias()
          Returns the alias to the client's key in the keystore.
 String getClientSenderSecurityKeystoreFile()
          Returns the path to the keystore file.
 String getClientSenderSecurityKeystoreKeyPassword()
          Returns the password to gain access to the key in the keystore.
 String getClientSenderSecurityKeystorePassword()
          Returns the password of the keystore file itself.
 String getClientSenderSecurityKeystoreType()
          Returns the type of the keystore file.
 String getClientSenderSecuritySocketProtocol()
          Returns the protocol used over the secure socket.
 String getClientSenderSecurityTruststoreAlgorithm()
          Returns the algorithm used to manage the keys in the truststore.
 String getClientSenderSecurityTruststoreFile()
          Returns the path to the truststore file.
 String getClientSenderSecurityTruststorePassword()
          Returns the password of the truststore file itself.
 String getClientSenderSecurityTruststoreType()
          Returns the type of the truststore file.
 long[] getClientSenderSendThrottling()
          Returns an array of send throttling parameters or null if send throttling is to be disabled.
 File getDataDirectory()
          Returns the data directory where all internally persisted data can be written to.
 String getDataDirectoryIfDefined()
          This will return the data directory string as found in the preferences.
 Preferences getPreferences()
          Returns the raw preferences containing the server configuration.
 int getServerConfigurationVersion()
          Returns the version of the configuration schema.
 ServiceContainerConfiguration getServiceContainerPreferences()
          Returns the service container configuration object that provides strongly typed methods to retrieve the server-side communications preferences.
 boolean isClientSenderCommandSpoolFileCompressed()
          Returns the command spool file compression flag that, if true, indicates the data in the command spool file should be compressed.
 long[] isClientSenderCommandSpoolFileParamsValueValid(String pref_value)
          Given a command spool file parameters value, will determine if its valid or not.
 int[] isClientSenderQueueThrottlingValueValid(String pref_value)
          Given a queue throttling parameters value, will determine if its valid or not.
 boolean isClientSenderSecurityServerAuthMode()
          Returns true if the server authentication mode is enabled.
 long[] isClientSenderSendThrottlingValueValid(String pref_value)
          Given a send throttling parameters value, will determine if its valid or not.
 void tagWithServerConfigurationVersion()
          This tags the existing preferences by setting the configuration schema version preference appropriately.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ServerConfiguration

public ServerConfiguration(Preferences prefs)
Wraps a preferences object in this instance.

Parameters:
prefs - the configuration preferences
Throws:
IllegalArgumentException - if props is null
Method Detail

getPreferences

public Preferences getPreferences()
Returns the raw preferences containing the server configuration.

Returns:
the server configuration preferences

getServiceContainerPreferences

public ServiceContainerConfiguration getServiceContainerPreferences()
Returns the service container configuration object that provides strongly typed methods to retrieve the server-side communications preferences.

Returns:
server-side communications preferences

getServerConfigurationVersion

public int getServerConfigurationVersion()
Returns the version of the configuration schema.

Returns:
configuration version; if the configuration isn't versioned, 0 is returned

tagWithServerConfigurationVersion

public void tagWithServerConfigurationVersion()
This tags the existing preferences by setting the configuration schema version preference appropriately.


getDataDirectory

public File getDataDirectory()
Returns the data directory where all internally persisted data can be written to. If the data directory does not exist, it will be created. The data directory is the one that is defined in the service container configuration. See ServiceContainerConfiguration.getDataDirectory().

Because this does alittle extra work, it may not be suitable to call if you just want to get the value of the data directory or if you just want to know if its defined or not. In those instances, use getDataDirectoryIfDefined() instead.

Returns:
the data directory

getDataDirectoryIfDefined

public String getDataDirectoryIfDefined()
This will return the data directory string as found in the preferences. If the data directory is not defined in the preferences, null is returned. The data directory is the one that is defined in the service container configuration. See ServiceContainerConfiguration.getDataDirectoryIfDefined().

Returns:
the data directory string as defined in the preferences or null if it is not defined
See Also:
getDataDirectory()

getAgentFilesDirectory

public String getAgentFilesDirectory()
This will return the directory name where the server stores all the files it can distribute to its agents. If this directory is not defined, null is returned. If null is returned, the server is not configured to distribute any files remotely.

Returns:
the directory string as defined in the preferences or null if it is not defined

getClientSenderQueueSize

public int getClientSenderQueueSize()
Returns the client sender queue size which determines how many commands can be queued up for sending. If this is 0 or less, it means the queue is unbounded.

Returns:
queue size
See Also:
getClientCommandSenderConfiguration()

getClientSenderMaxConcurrent

public int getClientSenderMaxConcurrent()
Returns the maximum number of concurrent commands that the client sender will send at any one time.

Returns:
max concurrent value
See Also:
getClientCommandSenderConfiguration()

getClientSenderCommandTimeout

public long getClientSenderCommandTimeout()
Returns the default timeout that the client sender will wait for a command to be processed by the remote endpoint. The timeout may be less than or equal to zero in which case the default will be to never timeout commands.

Returns:
timeout in milliseconds
See Also:
getClientCommandSenderConfiguration()

getClientSenderRetryInterval

public long getClientSenderRetryInterval()
Returns the time in milliseconds the client sender should wait in between retries of commands that have failed. This is a minimum but by no means is the limit before the command must be retried. The command may, in fact, be retried any amount of time after this retry interval.

Returns:
retry interval in milliseconds
See Also:
getClientCommandSenderConfiguration()

getClientSenderMaxRetries

public int getClientSenderMaxRetries()
Returns the number of times a guaranteed message is retried, if it fails for a reason other than a "cannot connect" to server.

Returns:
maximum number of retry attempts that will be made to send a guaranteed delivery message when it fails for some reason other than being unable to communicate with the server.
See Also:
getClientCommandSenderConfiguration()

getClientSenderCommandSpoolFileName

public String getClientSenderCommandSpoolFileName()
This will return the name of the command spool file (to be located in the data directory). If this is not defined, null is returned to indicate that commands should not be spooled to disk (thus implicitly disabling guaranteed delivery).

Returns:
the command spool file name or null if it is not defined

getClientSenderCommandSpoolFileParams

public long[] getClientSenderCommandSpoolFileParams()
Returns an array of command spool file parameters. The first element of the array is the maximum file size threshold. The second element is the purge percentage. See PersistentFifo for the meanings of these settings.

Because this is a weakly typed method (i.e. you have to know what the elements in the returned array represent), it is recommended that you call getClientCommandSenderConfiguration() because it will return all the configuration, including the spool file parameters, in a more strongly typed data object.

Returns:
array of command spool file parameters
See Also:
getClientCommandSenderConfiguration()

isClientSenderCommandSpoolFileParamsValueValid

public long[] isClientSenderCommandSpoolFileParamsValueValid(String pref_value)
Given a command spool file parameters value, will determine if its valid or not. If its valid, its individual parameter values are returned. If not valid, null is returned.

Parameters:
pref_value - the command spool file parameters value
Returns:
the individual parameters values or null if not valid

isClientSenderCommandSpoolFileCompressed

public boolean isClientSenderCommandSpoolFileCompressed()
Returns the command spool file compression flag that, if true, indicates the data in the command spool file should be compressed.

Returns:
true if the command spool file should compress its data; false means the data should be stored in its uncompressed format.

getClientSenderSendThrottling

public long[] getClientSenderSendThrottling()
Returns an array of send throttling parameters or null if send throttling is to be disabled. The first element of the array is the maximum number of commands that can be sent before the quiet period must start. The second element is the length of time (in milliseconds) that each quiet period lasts. Once that time period expires, commands can again be sent, up to the maximum (and the cycle repeats).

Because this is a weakly typed method (i.e. you have to know what the elements in the returned array represent), it is recommended that you call getClientCommandSenderConfiguration() because it will return all the configuration, including the throttling configuration, in a more strongly typed data object.

Returns:
array of send throttling parameters, null if send throttling is disabled
See Also:
getClientCommandSenderConfiguration()

isClientSenderSendThrottlingValueValid

public long[] isClientSenderSendThrottlingValueValid(String pref_value)
Given a send throttling parameters value, will determine if its valid or not. If its valid, its individual parameter values are returned. If not valid, null is returned. Note that if pref_value is null, then null will be immediately returned.

Parameters:
pref_value - the send throttling parameters value
Returns:
the individual parameters values or null if not valid or the preference value was null

getClientSenderQueueThrottling

public int[] getClientSenderQueueThrottling()
Returns an array of queue throttling parameters or null if queue throttling is to be disabled. The first element of the array is the maximum number of commands that can be dequeued in a burst period before the client sender must pause (i.e. cannot dequeue any more commands). The second element is the length of time (in milliseconds) that each burst period lasts. Once that time period expires, commands can again be dequeued, up to the maximum (and the cycle repeats).

Because this is a weakly typed method (i.e. you have to know what the elements in the returned array represent), it is recommended that you call getClientCommandSenderConfiguration() because it will return all the configuration, including the throttling configuration, in a more strongly typed data object.

Returns:
array of queue throttling parameters, null if queue throttling is disabled
See Also:
getClientCommandSenderConfiguration()

isClientSenderQueueThrottlingValueValid

public int[] isClientSenderQueueThrottlingValueValid(String pref_value)
Given a queue throttling parameters value, will determine if its valid or not. If its valid, its individual parameter values are returned. If not valid, null is returned. Note that if pref_value is null, then null will be immediately returned.

Parameters:
pref_value - the queue throttling parameters value
Returns:
the individual parameters values or null if not valid or the preference value was null

getClientCommandSenderConfiguration

public ClientCommandSenderConfiguration getClientCommandSenderConfiguration()
This is a convienence method that returns the full client sender configuration. It combines all the getClientSenderXXX methods and puts all the data in the returned data object.

Returns:
the full client sender configuration

getClientSenderSecuritySocketProtocol

public String getClientSenderSecuritySocketProtocol()
Returns the protocol used over the secure socket.

Returns:
protocol name

getClientSenderSecurityKeystoreAlias

public String getClientSenderSecurityKeystoreAlias()
Returns the alias to the client's key in the keystore.

Returns:
alias name

getClientSenderSecurityKeystoreFile

public String getClientSenderSecurityKeystoreFile()
Returns the path to the keystore file. This returns a String as opposed to File since some underlying remoting code may allow for this filepath to be relative to a jar inside the classloader.

Returns:
keystore file path

getClientSenderSecurityKeystoreAlgorithm

public String getClientSenderSecurityKeystoreAlgorithm()
Returns the algorithm used to manage the keys in the keystore.

Returns:
algorithm name

getClientSenderSecurityKeystoreType

public String getClientSenderSecurityKeystoreType()
Returns the type of the keystore file.

Returns:
keystore file type

getClientSenderSecurityKeystorePassword

public String getClientSenderSecurityKeystorePassword()
Returns the password of the keystore file itself.

Returns:
keystore file password

getClientSenderSecurityKeystoreKeyPassword

public String getClientSenderSecurityKeystoreKeyPassword()
Returns the password to gain access to the key in the keystore. If no key password is configured, this returns the keystore password.

Returns:
password to the key

getClientSenderSecurityTruststoreFile

public String getClientSenderSecurityTruststoreFile()
Returns the path to the truststore file. This returns a String as opposed to File since some underlying remoting code may allow for this filepath to be relative to a jar inside the classloader.

Returns:
truststore file path

getClientSenderSecurityTruststoreAlgorithm

public String getClientSenderSecurityTruststoreAlgorithm()
Returns the algorithm used to manage the keys in the truststore.

Returns:
algorithm name

getClientSenderSecurityTruststoreType

public String getClientSenderSecurityTruststoreType()
Returns the type of the truststore file.

Returns:
truststore file type

getClientSenderSecurityTruststorePassword

public String getClientSenderSecurityTruststorePassword()
Returns the password of the truststore file itself.

Returns:
truststore file password

isClientSenderSecurityServerAuthMode

public boolean isClientSenderSecurityServerAuthMode()
Returns true if the server authentication mode is enabled. If this is enabled, it means when using secure communications, the agents' certificates will be authenticated with the certificates found in the server's truststore. If this is false, the agents do not have to authenticate themselves with a trusted certificate; the server will trust any remote agent (in other words, the secure communications repo will only be used for encryption and not authentication).

Returns:
server authenticate mode

toString

public String toString()
Overrides:
toString in class Object
See Also:
Object.toString()


Copyright © 2008-2012 Red Hat, Inc.. All Rights Reserved.