org.rhq.plugins.apache
Class ApacheServerComponent

java.lang.Object
  extended by org.rhq.plugins.apache.ApacheServerComponent
All Implemented Interfaces:
AvailabilityFacet, ConfigurationFacet, CreateChildResourceFacet, ResourceComponent<PlatformComponent>, MeasurementFacet, OperationFacet, AugeasRHQComponent

public class ApacheServerComponent
extends Object
implements AugeasRHQComponent, ResourceComponent<PlatformComponent>, MeasurementFacet, OperationFacet, ConfigurationFacet, CreateChildResourceFacet

The resource component for Apache 2.x servers.

Author:
Ian Springer, Lukas Krejci

Field Summary
static String AUGEAS_ENABLED
           
static String AUGEAS_HTTP_MODULE_NAME
           
static String AUXILIARY_INDEX_PROP
           
static String CONFIGURATION_NOT_SUPPORTED_ERROR_MESSAGE
           
static String DEFAULT_ERROR_LOG_PATH
           
static String DEFAULT_EXECUTABLE_PATH
           
static String PLUGIN_CONFIG_CUSTOM_MODULE_NAMES
           
static String PLUGIN_CONFIG_MODULE_MAPPING
           
static String PLUGIN_CONFIG_MODULE_NAME
           
static String PLUGIN_CONFIG_MODULE_SOURCE_FILE
           
static String PLUGIN_CONFIG_PROP_CONTROL_SCRIPT_PATH
           
static String PLUGIN_CONFIG_PROP_ERROR_LOG_EVENTS_ENABLED
           
static String PLUGIN_CONFIG_PROP_ERROR_LOG_FILE_PATH
           
static String PLUGIN_CONFIG_PROP_ERROR_LOG_INCLUDES_PATTERN
           
static String PLUGIN_CONFIG_PROP_ERROR_LOG_MINIMUM_SEVERITY
           
static String PLUGIN_CONFIG_PROP_EXECUTABLE_PATH
           
static String PLUGIN_CONFIG_PROP_HTTPD_CONF
           
static String PLUGIN_CONFIG_PROP_RESTART_AFTER_CONFIG_UPDATE
           
static String PLUGIN_CONFIG_PROP_SERVER_ROOT
           
static String PLUGIN_CONFIG_PROP_SNMP_AGENT_COMMUNITY
           
static String PLUGIN_CONFIG_PROP_SNMP_AGENT_HOST
           
static String PLUGIN_CONFIG_PROP_SNMP_AGENT_PORT
           
static String PLUGIN_CONFIG_PROP_URL
           
static String PLUGIN_CONFIG_PROP_VHOST_CREATION_POLICY
           
static String PLUGIN_CONFIG_PROP_VHOST_FILES_MASK
           
static String PLUGIN_CONFIG_VHOST_IN_SINGLE_FILE_PROP_VALUE
           
static String PLUGIN_CONFIG_VHOST_PER_FILE_PROP_VALUE
           
static String SERVER_BUILT_TRAIT
           
 
Constructor Summary
ApacheServerComponent()
           
 
Method Summary
 void conditionalRestart()
          Conditionally restarts the server based on the settings in the plugin configuration of the server.
 CreateResourceReport createResource(CreateResourceReport report)
           
 void deleteEmptyFile(AugeasTree tree, AugeasNode deletedNode)
          This method checks whether the supplied node that has been deleted from the tree didn't leave the file it was contained in empty.
 void finishChildResourceCreate(CreateResourceReport report)
          This method is akin to finishConfigurationUpdate(ConfigurationUpdateReport) but should be used in the createResource(CreateResourceReport) method.
 void finishConfigurationUpdate(ConfigurationUpdateReport report)
          This method is supposed to be called from updateResourceConfiguration(ConfigurationUpdateReport) of this resource and any child resources.
 HttpdAddressUtility getAddressUtility()
           
 AugeasComponent getAugeas()
           
 org.rhq.core.domain.measurement.AvailabilityType getAvailability()
           
 ConfigurationTimestamp getConfigurationTimestamp()
           
 File getControlScriptPath()
          Return the absolute path of this Apache server's control script (e.g.
 ApacheBinaryInfo getCurrentBinaryInfo()
           
 ProcessInfo getCurrentProcessInfo()
           
 File getExecutablePath()
          Return the absolute path of this Apache server's executable (e.g.
 File getHttpdConfFile()
          Returns the httpd.conf file
 Map<String,String> getModuleNames()
           
 File getServerRoot()
          Return the absolute path of this Apache server's server root (e.g.
 String getServerUrl()
           
 SNMPSession getSNMPSession()
          Returns an SNMP session that can be used to communicate with this server's SNMP agent.
static SNMPSession getSNMPSession(SNMPClient snmpClient, org.rhq.core.domain.configuration.Configuration pluginConfig)
           
 void getValues(org.rhq.core.domain.measurement.MeasurementReport report, Set<org.rhq.core.domain.measurement.MeasurementScheduleRequest> schedules)
           
 OperationResult invokeOperation(String name, org.rhq.core.domain.configuration.Configuration params)
           
 boolean isAugeasEnabled()
           
 org.rhq.core.domain.configuration.Configuration loadResourceConfiguration()
           
 ApacheDirectiveTree parseFullConfiguration()
           
 ApacheDirectiveTree parseRuntimeConfiguration(boolean suppressUnknownModuleWarnings)
           
 void start(ResourceContext<PlatformComponent> resourceContext)
           
 void stop()
           
 void updateResourceConfiguration(ConfigurationUpdateReport report)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CONFIGURATION_NOT_SUPPORTED_ERROR_MESSAGE

public static final String CONFIGURATION_NOT_SUPPORTED_ERROR_MESSAGE
See Also:
Constant Field Values

PLUGIN_CONFIG_PROP_SERVER_ROOT

public static final String PLUGIN_CONFIG_PROP_SERVER_ROOT
See Also:
Constant Field Values

PLUGIN_CONFIG_PROP_EXECUTABLE_PATH

public static final String PLUGIN_CONFIG_PROP_EXECUTABLE_PATH
See Also:
Constant Field Values

PLUGIN_CONFIG_PROP_CONTROL_SCRIPT_PATH

public static final String PLUGIN_CONFIG_PROP_CONTROL_SCRIPT_PATH
See Also:
Constant Field Values

PLUGIN_CONFIG_PROP_URL

public static final String PLUGIN_CONFIG_PROP_URL
See Also:
Constant Field Values

PLUGIN_CONFIG_PROP_HTTPD_CONF

public static final String PLUGIN_CONFIG_PROP_HTTPD_CONF
See Also:
Constant Field Values

AUGEAS_HTTP_MODULE_NAME

public static final String AUGEAS_HTTP_MODULE_NAME
See Also:
Constant Field Values

PLUGIN_CONFIG_PROP_SNMP_AGENT_HOST

public static final String PLUGIN_CONFIG_PROP_SNMP_AGENT_HOST
See Also:
Constant Field Values

PLUGIN_CONFIG_PROP_SNMP_AGENT_PORT

public static final String PLUGIN_CONFIG_PROP_SNMP_AGENT_PORT
See Also:
Constant Field Values

PLUGIN_CONFIG_PROP_SNMP_AGENT_COMMUNITY

public static final String PLUGIN_CONFIG_PROP_SNMP_AGENT_COMMUNITY
See Also:
Constant Field Values

PLUGIN_CONFIG_PROP_ERROR_LOG_FILE_PATH

public static final String PLUGIN_CONFIG_PROP_ERROR_LOG_FILE_PATH
See Also:
Constant Field Values

PLUGIN_CONFIG_PROP_ERROR_LOG_EVENTS_ENABLED

public static final String PLUGIN_CONFIG_PROP_ERROR_LOG_EVENTS_ENABLED
See Also:
Constant Field Values

PLUGIN_CONFIG_PROP_ERROR_LOG_MINIMUM_SEVERITY

public static final String PLUGIN_CONFIG_PROP_ERROR_LOG_MINIMUM_SEVERITY
See Also:
Constant Field Values

PLUGIN_CONFIG_PROP_ERROR_LOG_INCLUDES_PATTERN

public static final String PLUGIN_CONFIG_PROP_ERROR_LOG_INCLUDES_PATTERN
See Also:
Constant Field Values

PLUGIN_CONFIG_PROP_VHOST_FILES_MASK

public static final String PLUGIN_CONFIG_PROP_VHOST_FILES_MASK
See Also:
Constant Field Values

PLUGIN_CONFIG_PROP_VHOST_CREATION_POLICY

public static final String PLUGIN_CONFIG_PROP_VHOST_CREATION_POLICY
See Also:
Constant Field Values

PLUGIN_CONFIG_PROP_RESTART_AFTER_CONFIG_UPDATE

public static final String PLUGIN_CONFIG_PROP_RESTART_AFTER_CONFIG_UPDATE
See Also:
Constant Field Values

PLUGIN_CONFIG_VHOST_IN_SINGLE_FILE_PROP_VALUE

public static final String PLUGIN_CONFIG_VHOST_IN_SINGLE_FILE_PROP_VALUE
See Also:
Constant Field Values

PLUGIN_CONFIG_VHOST_PER_FILE_PROP_VALUE

public static final String PLUGIN_CONFIG_VHOST_PER_FILE_PROP_VALUE
See Also:
Constant Field Values

PLUGIN_CONFIG_CUSTOM_MODULE_NAMES

public static final String PLUGIN_CONFIG_CUSTOM_MODULE_NAMES
See Also:
Constant Field Values

PLUGIN_CONFIG_MODULE_MAPPING

public static final String PLUGIN_CONFIG_MODULE_MAPPING
See Also:
Constant Field Values

PLUGIN_CONFIG_MODULE_NAME

public static final String PLUGIN_CONFIG_MODULE_NAME
See Also:
Constant Field Values

PLUGIN_CONFIG_MODULE_SOURCE_FILE

public static final String PLUGIN_CONFIG_MODULE_SOURCE_FILE
See Also:
Constant Field Values

AUXILIARY_INDEX_PROP

public static final String AUXILIARY_INDEX_PROP
See Also:
Constant Field Values

SERVER_BUILT_TRAIT

public static final String SERVER_BUILT_TRAIT
See Also:
Constant Field Values

AUGEAS_ENABLED

public static final String AUGEAS_ENABLED
See Also:
Constant Field Values

DEFAULT_EXECUTABLE_PATH

public static final String DEFAULT_EXECUTABLE_PATH

DEFAULT_ERROR_LOG_PATH

public static final String DEFAULT_ERROR_LOG_PATH
Constructor Detail

ApacheServerComponent

public ApacheServerComponent()
Method Detail

start

public void start(ResourceContext<PlatformComponent> resourceContext)
           throws Exception
Specified by:
start in interface ResourceComponent<PlatformComponent>
Throws:
Exception

stop

public void stop()
Specified by:
stop in interface ResourceComponent<PlatformComponent>

getAvailability

public org.rhq.core.domain.measurement.AvailabilityType getAvailability()
Specified by:
getAvailability in interface AvailabilityFacet

getValues

public void getValues(org.rhq.core.domain.measurement.MeasurementReport report,
                      Set<org.rhq.core.domain.measurement.MeasurementScheduleRequest> schedules)
               throws Exception
Specified by:
getValues in interface MeasurementFacet
Throws:
Exception

invokeOperation

@Nullable
public OperationResult invokeOperation(@NotNull
                                                String name,
                                                @NotNull
                                                org.rhq.core.domain.configuration.Configuration params)
                                throws Exception
Specified by:
invokeOperation in interface OperationFacet
Throws:
Exception

loadResourceConfiguration

public org.rhq.core.domain.configuration.Configuration loadResourceConfiguration()
                                                                          throws Exception
Specified by:
loadResourceConfiguration in interface ConfigurationFacet
Throws:
Exception

updateResourceConfiguration

public void updateResourceConfiguration(ConfigurationUpdateReport report)
Specified by:
updateResourceConfiguration in interface ConfigurationFacet

getAugeas

public AugeasComponent getAugeas()
                          throws AugeasTreeException
Specified by:
getAugeas in interface AugeasRHQComponent
Throws:
AugeasTreeException

createResource

public CreateResourceReport createResource(CreateResourceReport report)
Specified by:
createResource in interface CreateChildResourceFacet

getSNMPSession

@NotNull
public SNMPSession getSNMPSession()
                           throws Exception
Returns an SNMP session that can be used to communicate with this server's SNMP agent.

Returns:
an SNMP session that can be used to communicate with this server's SNMP agent
Throws:
Exception - on failure to initialize the SNMP session

getSNMPSession

@NotNull
public static SNMPSession getSNMPSession(SNMPClient snmpClient,
                                                 org.rhq.core.domain.configuration.Configuration pluginConfig)
                                  throws Exception
Throws:
Exception

getServerRoot

@NotNull
public File getServerRoot()
Return the absolute path of this Apache server's server root (e.g. "C:\Program Files\Apache Group\Apache2").

Returns:
the absolute path of this Apache server's server root (e.g. "C:\Program Files\Apache Group\Apache2")

getExecutablePath

@NotNull
public File getExecutablePath()
Return the absolute path of this Apache server's executable (e.g. "C:\Program Files\Apache Group\Apache2\bin\Apache.exe").

Returns:
the absolute path of this Apache server's executable (e.g. "C:\Program Files\Apache Group\Apache2\bin\Apache.exe")

getServerUrl

@Nullable
public String getServerUrl()
Returns:
The url the server is pinged for availability or null if the url is not set.

getHttpdConfFile

public File getHttpdConfFile()
Returns the httpd.conf file

Returns:
A File object that represents the httpd.conf file or null in case of error

getControlScriptPath

@NotNull
public File getControlScriptPath()
Return the absolute path of this Apache server's control script (e.g. "C:\Program Files\Apache Group\Apache2\bin\Apache.exe"). On Unix we need to try various locations, as some unixes have bin/ conf/ .. all within one root and on others those are separated.

Returns:
the absolute path of this Apache server's control script (e.g. "C:\Program Files\Apache Group\Apache2\bin\Apache.exe")

getConfigurationTimestamp

@NotNull
public ConfigurationTimestamp getConfigurationTimestamp()

finishConfigurationUpdate

public void finishConfigurationUpdate(ConfigurationUpdateReport report)
This method is supposed to be called from updateResourceConfiguration(ConfigurationUpdateReport) of this resource and any child resources. Based on the plugin configuration of this resource, the Apache instance is either restarted or left as is.

Parameters:
report - the report is updated with the error message and status is set to failure if the restart fails.

finishChildResourceCreate

public void finishChildResourceCreate(CreateResourceReport report)
This method is akin to finishConfigurationUpdate(ConfigurationUpdateReport) but should be used in the createResource(CreateResourceReport) method.

Parameters:
report - the report is updated with the error message and status is set to failure if the restart fails.

conditionalRestart

public void conditionalRestart()
                        throws Exception
Conditionally restarts the server based on the settings in the plugin configuration of the server.

Throws:
Exception - if the restart fails.

deleteEmptyFile

public void deleteEmptyFile(AugeasTree tree,
                            AugeasNode deletedNode)
This method checks whether the supplied node that has been deleted from the tree didn't leave the file it was contained in empty. If the file is empty after deleting the node, the file is automatically deleted.

Parameters:
tree - TODO
deletedNode - the node that has been deleted from the tree.

getModuleNames

public Map<String,String> getModuleNames()

getCurrentProcessInfo

public ProcessInfo getCurrentProcessInfo()

getCurrentBinaryInfo

public ApacheBinaryInfo getCurrentBinaryInfo()

getAddressUtility

public HttpdAddressUtility getAddressUtility()

parseFullConfiguration

public ApacheDirectiveTree parseFullConfiguration()

parseRuntimeConfiguration

public ApacheDirectiveTree parseRuntimeConfiguration(boolean suppressUnknownModuleWarnings)

isAugeasEnabled

public boolean isAugeasEnabled()


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