org.rhq.enterprise.installer
Class ServerInformation

java.lang.Object
  extended by org.rhq.enterprise.installer.ServerInformation

public class ServerInformation
extends Object

Finds out information about the RHQ Server and the JBossAS server it is running in. It can also be used to modify things about the RHQ Server, such as the names of the deployment artifacts.

Author:
John Mazzitelli

Nested Class Summary
static class ServerInformation.Product
           
static class ServerInformation.Server
           
 
Constructor Summary
ServerInformation()
           
 
Method Summary
 void cleanJmsTables(Properties props)
          Clean up messages in the JMS message table.
 void createKeystore(ServerInformation.Server haServer)
           
 void createNewDatabaseSchema(Properties props)
          This will create the database schema in the database.
 void ensureDatabaseIsSupported(Properties props)
          Call this when you need to confirm that the database is supported.
 String getAffinityGroupForServer(Properties props, String serverName)
           
 Connection getDatabaseConnection(Properties props)
          Returns a database connection with the given set of properties providing the settings that allow for a successful database connection.
 File getDataDirectory()
           
 ServerInformation.Product getProduct()
           
 ServerInformation.Server getServerDetail(Properties props, String serverName)
           
 List<String> getServerNames(Properties props)
          Get the list of existing servers from an existing RHQ schema.
 Properties getServerProperties()
          Gets the current set of properties currently configured for the RHQ Server.
 boolean isDatabaseConnectionValid(Properties props)
          Returns true if the given set of properties provides settings that allow for a successful database connection.
 boolean isDatabaseSchemaExist(Properties props)
          Returns true if the database already has the database schema created for it.
 boolean isFullyDeployed()
          Returns true if the RHQ Server deployment artifacts are fully deployed.
 boolean isUnsupportedJonFeaturesEnabled()
           
 void moveDeploymentArtifacts(boolean deploy)
          This will move the RHQ Server deployment artifacts such that they either get hot-deployed or hot-undeployed in the JBossAS server.
 void restartLoginConfig()
           
 void setServerProperties(Properties props)
          Writes the given properties to the RHQ Server properties file and also sets them as system properties.
 void storeServer(Properties props, ServerInformation.Server server)
           
 void upgradeExistingDatabaseSchema(Properties props)
          This will update an existing database schema so it can be upgraded to the latest schema version.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ServerInformation

public ServerInformation()
Method Detail

isDatabaseConnectionValid

public boolean isDatabaseConnectionValid(Properties props)
Returns true if the given set of properties provides settings that allow for a successful database connection. If props is null, it will use the server properties from getServerProperties().

Parameters:
props - set of properties where the connection information is found
Returns:
true if the database can be connected to

ensureDatabaseIsSupported

public void ensureDatabaseIsSupported(Properties props)
                               throws Exception
Call this when you need to confirm that the database is supported.

Parameters:
props - set of properties where the connection information is found
Throws:
Exception - if the database is not supported

isDatabaseSchemaExist

public boolean isDatabaseSchemaExist(Properties props)
                              throws Exception
Returns true if the database already has the database schema created for it. It will not be known what version of schema or if its the latest, all this method tells you is that some RHQ database schema exists.

The given set of properties provides settings that allow for a successful database connection. If props is null, it will use the server properties from getServerProperties().

Do not call this method unless isDatabaseConnectionValid(Properties) is true.

Parameters:
props - set of properties where the connection information is found
Returns:
true if the database can be connected to
Throws:
Exception - if failed to communicate with the database

createNewDatabaseSchema

public void createNewDatabaseSchema(Properties props)
                             throws Exception
This will create the database schema in the database. props define the connection to the database - see isDatabaseConnectionValid(Properties).

Note that if the schema already exists, it will be purged of all data/tables and recreated.

Parameters:
props -
Throws:
Exception - if failed to create the new schema for some reason

upgradeExistingDatabaseSchema

public void upgradeExistingDatabaseSchema(Properties props)
                                   throws Exception
This will update an existing database schema so it can be upgraded to the latest schema version. props define the connection to the database - see isDatabaseConnectionValid(Properties).

Note that if the schema does not already exist, errors will occur.

Parameters:
props -
Throws:
Exception - if the upgrade failed for some reason

getServerProperties

public Properties getServerProperties()
Gets the current set of properties currently configured for the RHQ Server.

Returns:
current configuration properties
Throws:
RuntimeException - if failed to read the properties file

setServerProperties

public void setServerProperties(Properties props)
Writes the given properties to the RHQ Server properties file and also sets them as system properties.

Parameters:
props - the new properties
Throws:
RuntimeException - if failed to write the file

moveDeploymentArtifacts

public void moveDeploymentArtifacts(boolean deploy)
This will move the RHQ Server deployment artifacts such that they either get hot-deployed or hot-undeployed in the JBossAS server. If deploy is true, this ensures the RHQ Server deployment artifacts (e.g. the EAR and its data source) are deployed so they can run. If deploy is false, the caller is saying he wants the RHQ Server to be undeployed so it doesn't run anymore.

Parameters:
deploy - true means the RHQ Server should be deployed; otherwise, its deployment artifacts should be undeployed
Throws:
RuntimeException - if failed to move one or more artifacts

isFullyDeployed

public boolean isFullyDeployed()
Returns true if the RHQ Server deployment artifacts are fully deployed. false if the installer needs to perform some work to finish the installation.

Returns:
installation status of RHQ Server

getDataDirectory

public File getDataDirectory()

getDatabaseConnection

public Connection getDatabaseConnection(Properties props)
                                 throws SQLException
Returns a database connection with the given set of properties providing the settings that allow for a successful database connection. If props is null, it will use the server properties from getServerProperties().

Parameters:
props - set of properties where the connection information is found
Returns:
the database connection
Throws:
SQLException - if cannot successfully connect to the database

cleanJmsTables

public void cleanJmsTables(Properties props)
Clean up messages in the JMS message table. Make sure you call this when no other Servers are communicating with the database, otherwise, its possible in-flight messages will get lost or go into a bad state.

Parameters:
props -

restartLoginConfig

public void restartLoginConfig()
                        throws Exception
Throws:
Exception

getServerNames

public List<String> getServerNames(Properties props)
                            throws Exception
Get the list of existing servers from an existing RHQ schema.

The given set of properties provides settings that allow for a successful database connection. If props is null, it will use the server properties from getServerProperties().

Do not call this method unless isDatabaseConnectionValid(Properties) is true.

Parameters:
props - set of properties where the connection information is found
Returns:
List of server names registered in the database. Empty list if the table does not exist or there are no entries in the table.
Throws:
Exception - if failed to communicate with the database

getProduct

public ServerInformation.Product getProduct()

isUnsupportedJonFeaturesEnabled

public boolean isUnsupportedJonFeaturesEnabled()

getAffinityGroupForServer

public String getAffinityGroupForServer(Properties props,
                                        String serverName)

getServerDetail

public ServerInformation.Server getServerDetail(Properties props,
                                                String serverName)

storeServer

public void storeServer(Properties props,
                        ServerInformation.Server server)
                 throws Exception
Throws:
Exception

createKeystore

public void createKeystore(ServerInformation.Server haServer)


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