com.sun.slamd.server
Class SLAMDServer

java.lang.Object
  extended bycom.sun.slamd.server.SLAMDServer
All Implemented Interfaces:
ConfigSubscriber

public class SLAMDServer
extends java.lang.Object
implements ConfigSubscriber

This class provides the entry point to the SLAMD server. It performs all the necessary bootstrapping, starts the scheduler, starts the client listener, and handles all necessary coordination between all other components of SLAMD.


Field Summary
static java.lang.String CONFIG_SUBSCRIBER_NAME
          The name used to register the logger as a subscriber to the configuration handler.
static java.lang.String SLAMD_SERVER_VERSION
          The version of the SLAMD server software being used.
 
Constructor Summary
SLAMDServer(AdminServlet adminServlet, boolean readOnlyMode, java.lang.String configDirectoryHost, int configDirectoryPort, java.lang.String configBindDN, java.lang.String configBindPassword, java.lang.String configBaseDN, boolean configUseSSL, boolean configDirBlindTrust, java.lang.String sslKeyStore, java.lang.String sslKeyPassword, java.lang.String sslTrustStore, java.lang.String sslTrustPassword)
          Creates a new instance of the SLAMD server.
SLAMDServer(AdminServlet adminServlet, boolean readOnlyMode, java.lang.String configDirectoryHost, int configDirectoryPort, java.lang.String configBindDN, java.lang.String configBindPassword, java.lang.String configBaseDN, boolean configUseSSL, boolean configDirBlindTrust, java.lang.String sslKeyStore, java.lang.String sslKeyPassword, java.lang.String sslTrustStore, java.lang.String sslTrustPassword, int logLevel)
          Creates a new instance of the SLAMD server.
 
Method Summary
 void addJobClass(JobClass jobClass)
          Adds the specified class as a job thread that can be used to run jobs in the SLAMD server.
 AdminServlet getAdminServlet()
          Retrieves the admin servlet used to manage the SLAMD server.
 JobClass[][] getCategorizedJobClasses()
          Retrieves the set of job classes defined for use in the configuration directory, separated into the individual job class categories.
 java.lang.String getClassPath()
          Retrieves the location of the job class files on the local filesystem.
 ClientListener getClientListener()
          Retrieves the client listener associated with this SLAMD server.
 ClientManagerListener getClientManagerListener()
          Retrieves the client manager listener associated with this SLAMD server.
 ConfigHandler getConfigHandler()
          Retrieves the configuration handler associated with this SLAMD server.
 JobCache getJobCache()
          Retreives the job cache associated with this SLAMD server.
 JobClass getJobClass(java.lang.String className)
          Retrieves the SLAMD job class with the specified name.
 java.lang.String[] getJobClassCategories()
          Retrieves the names of the job class categories defined to the SLAMD server.
 JobClass[] getJobClasses()
          Retrieves the set of job classes defined for use in the configuration directory.
 JobClass[] getJobClasses(java.lang.String categoryName)
          Retrieves the set of job classes defined for use in the configuration directory that are in the specified category name.
 SMTPMailer getMailer()
          Retrieves the mailer associated with this SLAMD server.
 ResourceMonitorClientListener getMonitorClientListener()
          Retrieves the resource monitor client listener associated with this SLAMD server.
 OptimizationAlgorithm getOptimizationAlgorithm(java.lang.String algorithmClass)
          Retrieves the optimization algorithm with the specified class name.
 OptimizationAlgorithm[] getOptimizationAlgorithms()
          Retrieves the set of optimization algorithms defined for use in the SLAMD server.
 JobClass getOrLoadJobClass(java.lang.String className)
          Retrieves a cached copy of this job class if possible.
 Scheduler getScheduler()
          Retrieves the scheduler associated with this SLAMD server.
 java.lang.String getSSLKeyStore()
          Retrieves the location of the SSL key store.
 java.lang.String getSSLKeyStorePassword()
          Retrieves the password required to access the SSL key store.
 java.lang.String getSSLTrustStore()
          Retrieves the location of the SSL trust store.
 java.lang.String getSSLTrustStorePassword()
          Retrieves the password required to access the SSL trust store.
 java.util.Date getStartupTime()
          Retrieves the time that the SLAMD server was started.
 RealTimeStatHandler getStatHandler()
          Retrieves the real-time stat handler associated with this SLAMD server.
 StatListener getStatListener()
          Retrieves the stat listener associated with this SLAMD server.
 java.lang.String getSubscriberName()
          Retrieves the name that the server uses to subscribe to the configuration handler in order to be notified of configuration changes.
 ParameterList getSubscriberParameters()
          Retrieves the set of configuration parameters associated with this configuration subscriber.
 java.lang.String getTimestamp()
          Retrieves a formatted timestamp containing the current time.
 JobClass loadJobClass(java.lang.String className)
          Loads the job class with the specified name and returns it to the caller.
 boolean loggerInitialized()
          Indicates whether the logging subsystem has been initialized.
 void logMessage(int messageLogLevel, java.lang.String logMessage)
          Writes the specified message to the SLAMD log if appropriate (based on the log level).
 void logWithoutFormatting(int messageLogLevel, java.lang.String message)
          Writes the specified message to the SLAMD log if appropriate (based on the log level).
 void refreshSubscriberConfiguration()
          Re-reads all configuration information used by the core SLAMD server.
 void refreshSubscriberConfiguration(java.lang.String parameterName)
          Re-reads the configuration information for the specified parameter.
 void reloadJobClasses()
          Refreshes the list of available job classes from the definitions stored in the configuration directory.
 void removeJobClass(JobClass jobClass)
          Removes the specified class from the list of job classes defined in the SLAMD server.
 void sendCompletedJobNotification(Job job)
          Checks to see if an e-mail message should be sent to one or more users to tell them that the specified job is complete.
 void setLoggerInitialized(boolean loggerInitialized)
          Specifies whether the logger is initialized or not.
 void stopSLAMD()
          Stops the SLAMD server and all related components.
 boolean useCustomClassLoader()
          Indicates whether a custom class loader should be used for loading job classes.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SLAMD_SERVER_VERSION

public static final java.lang.String SLAMD_SERVER_VERSION
The version of the SLAMD server software being used.

See Also:
Constant Field Values

CONFIG_SUBSCRIBER_NAME

public static final java.lang.String CONFIG_SUBSCRIBER_NAME
The name used to register the logger as a subscriber to the configuration handler.

See Also:
Constant Field Values
Constructor Detail

SLAMDServer

public SLAMDServer(AdminServlet adminServlet,
                   boolean readOnlyMode,
                   java.lang.String configDirectoryHost,
                   int configDirectoryPort,
                   java.lang.String configBindDN,
                   java.lang.String configBindPassword,
                   java.lang.String configBaseDN,
                   boolean configUseSSL,
                   boolean configDirBlindTrust,
                   java.lang.String sslKeyStore,
                   java.lang.String sslKeyPassword,
                   java.lang.String sslTrustStore,
                   java.lang.String sslTrustPassword)
            throws SLAMDServerException
Creates a new instance of the SLAMD server. All of the configuration will be retrieved from an LDAP directory server using the information provided as parameters to this function.

Parameters:
adminServlet - The admin servlet used to control the SLAMD server.
readOnlyMode - Indicates whether the server should operate in read-only mode. If so, then it should not create any listeners.
configDirectoryHost - The DNS hostname or IP address of the configuration directory server. There can be multiple hosts provided (separated by spaces) to provide failover capability.
configDirectoryPort - The port number to use to bind to the configuration directory server.
configBindDN - The DN to use when binding to the configuration directory server.
configBindPassword - The password to use for the bind DN.
configBaseDN - The location in the configuration directory under which SLAMD information will be stored.
configUseSSL - Indicates whether communication between the SLAMD server and the configuration directory should use SSL.
configDirBlindTrust - Indicates whether the SLAMD server should blindly trust any SSL certificate presented by the configuration directory.
sslKeyStore - The JSSE key store file to use for SSL connections (typically "~/.keystore").
sslKeyPassword - The password that should be used to access the contents of the JSSE key store.
sslTrustStore - The JSSE trust store file to use for SSL connections (typically "JAVA_HOME/jre/lib/security/cacerts")
sslTrustPassword - The password that should be used to access the contents of the JSSE trust store.
Throws:
SLAMDServerException - If an unrecoverable error occurs that prevents the server from operating.

SLAMDServer

public SLAMDServer(AdminServlet adminServlet,
                   boolean readOnlyMode,
                   java.lang.String configDirectoryHost,
                   int configDirectoryPort,
                   java.lang.String configBindDN,
                   java.lang.String configBindPassword,
                   java.lang.String configBaseDN,
                   boolean configUseSSL,
                   boolean configDirBlindTrust,
                   java.lang.String sslKeyStore,
                   java.lang.String sslKeyPassword,
                   java.lang.String sslTrustStore,
                   java.lang.String sslTrustPassword,
                   int logLevel)
            throws SLAMDServerException
Creates a new instance of the SLAMD server. All of the configuration will be retrieved from an LDAP directory server using the information provided as parameters to this function.

Parameters:
adminServlet - The admin servlet used to control the SLAMD server.
readOnlyMode - Indicates whether the server should operate in read-only mode. If so, then it should not create any listeners.
configDirectoryHost - The DNS hostname or IP address of the configuration directory server. There can be multiple hosts provided (separated by spaces) to provide failover capability.
configDirectoryPort - The port number to use to bind to the configuration directory server.
configBindDN - The DN to use when binding to the configuration directory server.
configBindPassword - The password to use for the bind DN.
configBaseDN - The location in the configuration directory under which SLAMD information will be stored.
configUseSSL - Indicates whether communication between the SLAMD server and the configuration directory should use SSL.
configDirBlindTrust - Indicates whether the SLAMD server should blindly trust any SSL certificate presented by the configuration directory.
sslKeyStore - The JSSE key store file to use for SSL connections (typically "~/.keystore").
sslKeyPassword - The password to access the JSSE key store.
sslTrustStore - The JSSE trust store file to use for SSL connections (typically "JAVA_HOME/jre/lib/security/cacerts")
sslTrustPassword - The password to access the JSSE trust store.
logLevel - The loglevel that should be used by the server. If it is a valid loglevel, then it will override whatever loglevel may be specified in the configuration.
Throws:
SLAMDServerException - If an unrecoverable error occurs that prevents the server from operating.
Method Detail

stopSLAMD

public void stopSLAMD()
Stops the SLAMD server and all related components. This method will not return until the shutdown has completed.


getAdminServlet

public AdminServlet getAdminServlet()
Retrieves the admin servlet used to manage the SLAMD server.

Returns:
The admin servlet used to manage the SLAMD server.

getClassPath

public java.lang.String getClassPath()
Retrieves the location of the job class files on the local filesystem.

Returns:
The path to the job class files on the local filesystem.

getJobClasses

public JobClass[] getJobClasses()
Retrieves the set of job classes defined for use in the configuration directory.

Returns:
The set of job classes defined for use in the configuration directory.

getJobClasses

public JobClass[] getJobClasses(java.lang.String categoryName)
Retrieves the set of job classes defined for use in the configuration directory that are in the specified category name.

Parameters:
categoryName - The name of the category for which to retrieve the job classes.
Returns:
The job classes in the specified category.

getJobClassCategories

public java.lang.String[] getJobClassCategories()
Retrieves the names of the job class categories defined to the SLAMD server.

Returns:
The names of the job class categories defined to the SLAMD server.

getCategorizedJobClasses

public JobClass[][] getCategorizedJobClasses()
Retrieves the set of job classes defined for use in the configuration directory, separated into the individual job class categories.

Returns:
The set of job classes defined for use in the configuration directory, separated into the individual job class categories.

getJobClass

public JobClass getJobClass(java.lang.String className)
Retrieves the SLAMD job class with the specified name.

Parameters:
className - The Java class name for the class to retrieve.
Returns:
The SLAMD job class with the specified name, or null if the specified job class is not known to the SLAMD server.

useCustomClassLoader

public boolean useCustomClassLoader()
Indicates whether a custom class loader should be used for loading job classes.

Returns:
true if a custom class loader should be used for loading job classes, or false if not.

loadJobClass

public JobClass loadJobClass(java.lang.String className)
                      throws SLAMDException
Loads the job class with the specified name and returns it to the caller.

Parameters:
className - The name of the job class to be loaded.
Returns:
The requested job class.
Throws:
SLAMDException - If a problem occurs while trying to load the requested class.

getOrLoadJobClass

public JobClass getOrLoadJobClass(java.lang.String className)
                           throws SLAMDException
Retrieves a cached copy of this job class if possible. Otherwise, attempts to load the job class using the appropriate class loader.

Parameters:
className - The name of the Java class to be returned.
Returns:
The requested job class.
Throws:
SLAMDException - If it is necessary to load the job class and a problem occurs while doing so.

reloadJobClasses

public void reloadJobClasses()
                      throws SLAMDServerException
Refreshes the list of available job classes from the definitions stored in the configuration directory.

Throws:
SLAMDServerException - If a problem is encountered while reading from the configuration directory.

addJobClass

public void addJobClass(JobClass jobClass)
                 throws SLAMDServerException
Adds the specified class as a job thread that can be used to run jobs in the SLAMD server.

Parameters:
jobClass - The job thread class that will be used to perform the work for this job.
Throws:
SLAMDServerException - If a problem is encountered while adding the job class.

removeJobClass

public void removeJobClass(JobClass jobClass)
                    throws SLAMDServerException
Removes the specified class from the list of job classes defined in the SLAMD server.

Parameters:
jobClass - The class to remove from the set of defined job classes.
Throws:
SLAMDServerException - If a problem is encountered while removing the job class.

getOptimizationAlgorithms

public OptimizationAlgorithm[] getOptimizationAlgorithms()
Retrieves the set of optimization algorithms defined for use in the SLAMD server.

Returns:
The set of optimization algorithms defined for use in the SLAMD server.

getOptimizationAlgorithm

public OptimizationAlgorithm getOptimizationAlgorithm(java.lang.String algorithmClass)
Retrieves the optimization algorithm with the specified class name.

Parameters:
algorithmClass - The fully-qualified name of the Java class that provides the optimization algorithm.
Returns:
The optimization algorithm with the specified class name, or null if no such algorithm is defined.

getStartupTime

public java.util.Date getStartupTime()
Retrieves the time that the SLAMD server was started.

Returns:
The time that the SLAMD server was started.

logMessage

public void logMessage(int messageLogLevel,
                       java.lang.String logMessage)
Writes the specified message to the SLAMD log if appropriate (based on the log level). The message will be formatted so that it contains a timestamp and a log level indicator. If the logging system has not been initialized, then the message will be logged to standard error.

Parameters:
messageLogLevel - The log level to use when determining whether to actually write the message to the SLAMD log.
logMessage - The message to be logged.

logWithoutFormatting

public void logWithoutFormatting(int messageLogLevel,
                                 java.lang.String message)
Writes the specified message to the SLAMD log if appropriate (based on the log level). The message will be logged as-is with no formatting applied, so the timestamp and log level should be already included in the message. If the logging system has not been initialized, then the message will be logged to standard error.

Parameters:
messageLogLevel - The log level to use when determining whether to actually write the message to the SLAMD log.
message - The message to be logged.

getTimestamp

public java.lang.String getTimestamp()
Retrieves a formatted timestamp containing the current time.

Returns:
A formatted timestamp containing the current time.

getConfigHandler

public ConfigHandler getConfigHandler()
Retrieves the configuration handler associated with this SLAMD server.

Returns:
The configuration handler associated with this SLAMD server.

getJobCache

public JobCache getJobCache()
Retreives the job cache associated with this SLAMD server.

Returns:
The job cache associated with this SLAMD server.

getClientListener

public ClientListener getClientListener()
Retrieves the client listener associated with this SLAMD server.

Returns:
The client listener associated with this SLAMD server.

getClientManagerListener

public ClientManagerListener getClientManagerListener()
Retrieves the client manager listener associated with this SLAMD server.

Returns:
The client manager listener associated with this SLAMD server.

getMonitorClientListener

public ResourceMonitorClientListener getMonitorClientListener()
Retrieves the resource monitor client listener associated with this SLAMD server.

Returns:
The resource monitor client listener associated with this SLAMD server.

getStatListener

public StatListener getStatListener()
Retrieves the stat listener associated with this SLAMD server.

Returns:
The stat listener associated with this SLAMD server.

getStatHandler

public RealTimeStatHandler getStatHandler()
Retrieves the real-time stat handler associated with this SLAMD server.

Returns:
The real-time stat handler associated with this SLAMD server.

getMailer

public SMTPMailer getMailer()
Retrieves the mailer associated with this SLAMD server.

Returns:
The mailer associated with this SLAMD server.

sendCompletedJobNotification

public void sendCompletedJobNotification(Job job)
Checks to see if an e-mail message should be sent to one or more users to tell them that the specified job is complete.

Parameters:
job - The job for which to provide notification.

loggerInitialized

public boolean loggerInitialized()
Indicates whether the logging subsystem has been initialized.

Returns:
true if the logging system has been initialized, or false if not.

setLoggerInitialized

public void setLoggerInitialized(boolean loggerInitialized)
Specifies whether the logger is initialized or not.

Parameters:
loggerInitialized - Used to indicate whether the logger has been initialized or not.

getScheduler

public Scheduler getScheduler()
Retrieves the scheduler associated with this SLAMD server.

Returns:
The scheduler associated with this SLAMD server.

getSSLKeyStore

public java.lang.String getSSLKeyStore()
Retrieves the location of the SSL key store.

Returns:
The location of the SSL key store.

getSSLKeyStorePassword

public java.lang.String getSSLKeyStorePassword()
Retrieves the password required to access the SSL key store.

Returns:
The password required to access the SSL key store.

getSSLTrustStore

public java.lang.String getSSLTrustStore()
Retrieves the location of the SSL trust store.

Returns:
The location of the SSL trust store.

getSSLTrustStorePassword

public java.lang.String getSSLTrustStorePassword()
Retrieves the password required to access the SSL trust store.

Returns:
The password required to access the SSL trust store.

getSubscriberName

public java.lang.String getSubscriberName()
Retrieves the name that the server uses to subscribe to the configuration handler in order to be notified of configuration changes.

Specified by:
getSubscriberName in interface ConfigSubscriber
Returns:
The name that the server uses to subscribe to the configuration handler in order to be notified of configuration changes.

getSubscriberParameters

public ParameterList getSubscriberParameters()
Retrieves the set of configuration parameters associated with this configuration subscriber.

Specified by:
getSubscriberParameters in interface ConfigSubscriber
Returns:
The set of configuration parameters associated with this configuration subscriber.

refreshSubscriberConfiguration

public void refreshSubscriberConfiguration()
Re-reads all configuration information used by the core SLAMD server. In this case, the only option is the log level to determine which messages are written to the log file. If a specific log level was specified in a constructor, then that will always be used, regardless of the loglevel specified in the configuration.

Specified by:
refreshSubscriberConfiguration in interface ConfigSubscriber

refreshSubscriberConfiguration

public void refreshSubscriberConfiguration(java.lang.String parameterName)
Re-reads the configuration information for the specified parameter. In this case, the only option is the log level to determine which messages are written to the log file. If a specific log level was specified in a constructor, then that will always be used, regardless of the loglevel specified in the configuration.

Specified by:
refreshSubscriberConfiguration in interface ConfigSubscriber
Parameters:
parameterName - The name of the parameter to be re-read from the configuration.