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

java.lang.Object
  extended by org.rhq.enterprise.server.core.comm.ServerCommunicationsService
All Implemented Interfaces:
MBeanRegistration, ServiceContainerMetricsMBean, ServerCommunicationsServiceMBean

public class ServerCommunicationsService
extends Object
implements ServerCommunicationsServiceMBean, MBeanRegistration

This is an MBean service that can be used to bootstrap the ServiceContainer. The main purpose for the existence of this class is to bootstrap the comm services for the Server so remote CLI and Agent clients can talk to the server.

Author:
John Mazzitelli

Field Summary
 
Fields inherited from interface org.rhq.enterprise.server.core.comm.ServerCommunicationsServiceMBean
OBJECT_NAME
 
Fields inherited from interface org.rhq.enterprise.communications.ServiceContainerMetricsMBean
OBJECTNAME_METRICS
 
Constructor Summary
ServerCommunicationsService()
           
 
Method Summary
 void addStartedAgent(org.rhq.core.domain.resource.Agent agent)
          Given an agent (which includes its remote endpoint and name), this will see if it is not yet a known agent and if so, will add it.
 void clear()
           
 void destroyKnownAgentClient(org.rhq.core.domain.resource.Agent agent)
          This will stop the client, remove it from the cache and clean up any resources used by the client.
 List<org.jboss.remoting.InvokerLocator> getAllKnownAgents()
          This returns a list of all known agents that the server is in communications with.
 Integer getAvailabilityReportConcurrencyLimit()
          Gets the concurrency limit for availability reports.
 long getAverageExecutionTimeReceived()
           
 Map<String,CommandProcessorMetrics.Calltime> getCallTimeDataReceived()
           
 ServerConfiguration getConfiguration()
          Returns the configuration of the server-side communication components.
 String getConfigurationFile()
          Returns the location of the configuration file where all preferences are defined for the server-side services.
 Properties getConfigurationOverrides()
          Returns a set of properties that will override the configuration preferences.
 Integer getContentDownloadConcurrencyLimit()
          Gets the concurrency limit for content downloads.
 Integer getContentReportConcurrencyLimit()
          Gets the concurrency limit for content reports.
 Integer getGlobalConcurrencyLimit()
          Gets the global concurrency limit.
 Integer getInventoryReportConcurrencyLimit()
          Gets the concurrency limit for inventory reports.
 Integer getInventorySyncConcurrencyLimit()
          Gets the concurrency limit for inventory sync requests.
 AgentClient getKnownAgentClient(org.rhq.core.domain.resource.Agent agent)
          Given an agent domain object, this will see if that agent is known by looking up its host and port from the list of all known agents and returns a client to that agent.
 Boolean getMaintenanceModeAtStartup()
          Returns true if the server should always start up in maintenance mode.
 Integer getMeasurementReportConcurrencyLimit()
          Gets the concurrency limit for measurement reports.
 Integer getMeasurementScheduleRequestConcurrencyLimit()
          Gets the concurrency limit for measurement reports.
 long getNumberDroppedCommandsReceived()
           
 long getNumberFailedCommandsReceived()
           
 long getNumberNotProcessedCommandsReceived()
           
 long getNumberSuccessfulCommandsReceived()
           
 long getNumberTotalCommandsReceived()
           
 String getPreferencesNodeName()
          Returns the preferences node name used to identify the configuration set to use.
 ServiceContainer getServiceContainer()
          Returns the service container that houses all the server-side communications services.
 String getStartedServerEndpoint()
          If the server is currently listening for requests, this will return the endpoint the agents should use to connect to it.
 Boolean isMaintenanceModeAtStartup()
          Same as ServerCommunicationsServiceMBean.getMaintenanceModeAtStartup().
 boolean isStarted()
           
 boolean pingEndpoint(String endpoint, long timeoutMillis)
          This will perform an ad-hoc, low-level ping to the given endpoint.
 void postDeregister()
          Cleans up the internal state of this service.
 void postRegister(Boolean arg0)
          This method does nothing - it is a no-op.
 void preDeregister()
          This method does nothing - it is a no-op.
 ObjectName preRegister(MBeanServer mbs, ObjectName name)
          Sets up some internal state.
 ServerConfiguration reloadConfiguration()
          This will clear any and all current configuration preferences and then reload the configuration file.
 void removeDownedAgent(String endpoint)
          Given an agent remote endpoint, this will see if it is a known agent and if so, will remove it.
 ServiceContainer safeGetServiceContainer()
          Returns the service container that houses all the server-side communications services.
 void setAvailabilityReportConcurrencyLimit(Integer maxConcurrency)
          Sets the new concurrency limit for availability reports.
 void setConfigurationFile(String location)
          Defines the location of the configuration file where all preferences are defined for the server-side services.
 void setConfigurationOverrides(Properties overrides)
          This allows you to explicitly override configuration preferences found in the configuration file.
 void setContentDownloadConcurrencyLimit(Integer maxConcurrency)
          Sets the new concurrency limit for content downloads.
 void setContentReportConcurrencyLimit(Integer maxConcurrency)
          Sets the new concurrency limit for content reports.
 void setGlobalConcurrencyLimit(Integer maxConcurrency)
          Sets the global concurrency limit.
 void setInventoryReportConcurrencyLimit(Integer maxConcurrency)
          Sets the new concurrency limit for inventory reports.
 void setInventorySyncConcurrencyLimit(Integer maxConcurrency)
          Sets the new concurrency limit for inventory sync requests.
 void setMaintenanceModeAtStartup(Boolean flag)
          Sets the flag to indicate if the server should always start up in maintenance mode.
 void setMeasurementReportConcurrencyLimit(Integer maxConcurrency)
          Sets the new concurrency limit for measurement reports.
 void setMeasurementScheduleRequestConcurrencyLimit(Integer maxConcurrency)
          Sets the new concurrency limit for measurement schedule requests.
 void setPreferencesNodeName(String node)
          Defines the preferences node name used to identify the configuration set to use.
 void startCommunicationServices()
          Actually starts the communications services.
 void stop()
          Synchronized to ensure that the stop operation completes atomically.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ServerCommunicationsService

public ServerCommunicationsService()
Method Detail

preRegister

public ObjectName preRegister(MBeanServer mbs,
                              ObjectName name)
                       throws Exception
Sets up some internal state.

Specified by:
preRegister in interface MBeanRegistration
Throws:
Exception
See Also:
MBeanRegistration.preRegister(MBeanServer, ObjectName)

postRegister

public void postRegister(Boolean arg0)
This method does nothing - it is a no-op.

Specified by:
postRegister in interface MBeanRegistration
See Also:
MBeanRegistration.postRegister(java.lang.Boolean)

startCommunicationServices

public void startCommunicationServices()
                                throws Exception
Actually starts the communications services. Once this returns, agents can communicate with the server. This method exists (as opposed to "start()") because we do not want these communications services initialized until after we are assured the EJBs are all deployed and we are ready to begin processing incoming agent messages. Synchronized to ensure that the start operation completes atomically.

Specified by:
startCommunicationServices in interface ServerCommunicationsServiceMBean
Throws:
Exception - if failed to start the server-side services successfully
See Also:
ServerCommunicationsServiceMBean.startCommunicationServices()

stop

public void stop()
Synchronized to ensure that the stop operation completes atomically.

Specified by:
stop in interface ServerCommunicationsServiceMBean
See Also:
ServerCommunicationsServiceMBean.stop()

isStarted

public boolean isStarted()
Specified by:
isStarted in interface ServerCommunicationsServiceMBean
Returns:
true if communication services have been started. False if not initialized or stopped.
See Also:
ServerCommunicationsServiceMBean.isStarted()

preDeregister

public void preDeregister()
                   throws Exception
This method does nothing - it is a no-op.

Specified by:
preDeregister in interface MBeanRegistration
Throws:
Exception
See Also:
MBeanRegistration.preDeregister()

postDeregister

public void postDeregister()
Cleans up the internal state of this service.

Specified by:
postDeregister in interface MBeanRegistration
See Also:
MBeanRegistration.postDeregister()

getConfigurationFile

public String getConfigurationFile()
Description copied from interface: ServerCommunicationsServiceMBean
Returns the location of the configuration file where all preferences are defined for the server-side services. The file location can be either a URL, a local file system path or a path within this service's classloader.

Specified by:
getConfigurationFile in interface ServerCommunicationsServiceMBean
Returns:
configuration file location

setConfigurationFile

public void setConfigurationFile(String location)
Description copied from interface: ServerCommunicationsServiceMBean
Defines the location of the configuration file where all preferences are defined for the server-side services. The file location can be either a URL, a local file system path or a path within this service's classloader.

Specified by:
setConfigurationFile in interface ServerCommunicationsServiceMBean

getPreferencesNodeName

public String getPreferencesNodeName()
Description copied from interface: ServerCommunicationsServiceMBean
Returns the preferences node name used to identify the configuration set to use. See the Java Preferences API for the definition of a preference node name.

Specified by:
getPreferencesNodeName in interface ServerCommunicationsServiceMBean
Returns:
the name of the Java Preferences node where the server's configuration lives

setPreferencesNodeName

public void setPreferencesNodeName(String node)
Description copied from interface: ServerCommunicationsServiceMBean
Defines the preferences node name used to identify the configuration set to use. See the Java Preferences API for the definition of a preference node name.

If this isn't specified, a suitable default will be used.

Specified by:
setPreferencesNodeName in interface ServerCommunicationsServiceMBean
Parameters:
node - the name of the Java Preferences node where the server's configuration will or already lives

getConfigurationOverrides

public Properties getConfigurationOverrides()
Description copied from interface: ServerCommunicationsServiceMBean
Returns a set of properties that will override the configuration preferences. If this returns null, then the configuration preferences takes effect as-is.

Specified by:
getConfigurationOverrides in interface ServerCommunicationsServiceMBean
Returns:
configuration setting overrides (may be null)

setConfigurationOverrides

public void setConfigurationOverrides(Properties overrides)
Description copied from interface: ServerCommunicationsServiceMBean
This allows you to explicitly override configuration preferences found in the configuration file. If this isn't set, then the settings specified by the configuration preferences file take effect as-is. These overrides can be set in the bootstrap deployment file (and thus allow you to be able to use any app-server specific settings, like ${jboss.server.data.dir}, in the configuration preference values).

Specified by:
setConfigurationOverrides in interface ServerCommunicationsServiceMBean
Parameters:
overrides - configuration settings that override the configuration preferences (may benull)

reloadConfiguration

public ServerConfiguration reloadConfiguration()
                                        throws Exception
Description copied from interface: ServerCommunicationsServiceMBean
This will clear any and all current configuration preferences and then reload the configuration file.

Specified by:
reloadConfiguration in interface ServerCommunicationsServiceMBean
Returns:
the new server configuration
Throws:
Exception - if failed to clear and reload the configuration

getConfiguration

public ServerConfiguration getConfiguration()
Description copied from interface: ServerCommunicationsServiceMBean
Returns the configuration of the server-side communication components. If the configuration has not yet been loaded, this will return null.

Specified by:
getConfiguration in interface ServerCommunicationsServiceMBean
Returns:
the server configuration

safeGetServiceContainer

public ServiceContainer safeGetServiceContainer()
Description copied from interface: ServerCommunicationsServiceMBean
Returns the service container that houses all the server-side communications services. Will create a service container for the comm services if one has not yet been created. This is typically only called to add or remove listeners prior to comm service startup. Use isStarted() as necessary.

Specified by:
safeGetServiceContainer in interface ServerCommunicationsServiceMBean
Returns:
service container object

getServiceContainer

public ServiceContainer getServiceContainer()
Description copied from interface: ServerCommunicationsServiceMBean
Returns the service container that houses all the server-side communications services. Will return null if the serviceContainer has not been initialized. It is possible for this to be non-null prior to server-side comm services initialization. Use isStarted() as necessary.

Specified by:
getServiceContainer in interface ServerCommunicationsServiceMBean
Returns:
service container object

getStartedServerEndpoint

public String getStartedServerEndpoint()
Description copied from interface: ServerCommunicationsServiceMBean
If the server is currently listening for requests, this will return the endpoint the agents should use to connect to it. If the server's underlying communications services are not deployed and running, this returns null.

Specified by:
getStartedServerEndpoint in interface ServerCommunicationsServiceMBean
Returns:
the server's remote endpoint that agents use to connect to the server

getKnownAgentClient

public AgentClient getKnownAgentClient(org.rhq.core.domain.resource.Agent agent)
Description copied from interface: ServerCommunicationsServiceMBean
Given an agent domain object, this will see if that agent is known by looking up its host and port from the list of all known agents and returns a client to that agent. An agent can become known if it has been auto discovered.

Specified by:
getKnownAgentClient in interface ServerCommunicationsServiceMBean
Parameters:
agent - the agent whose client is to be returned
Returns:
the agent client; will be null if that agent is not known

destroyKnownAgentClient

public void destroyKnownAgentClient(org.rhq.core.domain.resource.Agent agent)
Description copied from interface: ServerCommunicationsServiceMBean
This will stop the client, remove it from the cache and clean up any resources used by the client. This is normally called when an agent has been completely removed from inventory.

Specified by:
destroyKnownAgentClient in interface ServerCommunicationsServiceMBean
Parameters:
agent - the agent whose client is to be destroyed

getAllKnownAgents

public List<org.jboss.remoting.InvokerLocator> getAllKnownAgents()
Description copied from interface: ServerCommunicationsServiceMBean
This returns a list of all known agents that the server is in communications with.

Specified by:
getAllKnownAgents in interface ServerCommunicationsServiceMBean
Returns:
the list of agents (which may or may not be empty)

addStartedAgent

public void addStartedAgent(org.rhq.core.domain.resource.Agent agent)
Description copied from interface: ServerCommunicationsServiceMBean
Given an agent (which includes its remote endpoint and name), this will see if it is not yet a known agent and if so, will add it. This should be called only when you know an agent has started.

Specified by:
addStartedAgent in interface ServerCommunicationsServiceMBean
Parameters:
agent - the agent (which has the endpoint of the agent that has started and its name)

removeDownedAgent

public void removeDownedAgent(String endpoint)
Description copied from interface: ServerCommunicationsServiceMBean
Given an agent remote endpoint, this will see if it is a known agent and if so, will remove it. This should be called only when you know an agent has gone down.

Specified by:
removeDownedAgent in interface ServerCommunicationsServiceMBean
Parameters:
endpoint - the endpoint of the agent that has gone down

pingEndpoint

public boolean pingEndpoint(String endpoint,
                            long timeoutMillis)
Description copied from interface: ServerCommunicationsServiceMBean
This will perform an ad-hoc, low-level ping to the given endpoint. This is usually reserved for those callers that need to confirm that an endpoint exists and can be communicated with, before being added as an official agent endpoint.

Specified by:
pingEndpoint in interface ServerCommunicationsServiceMBean
Parameters:
endpoint - the endpoint to ping
timeoutMillis - the timeout, in milliseconds, to wait for the ping to return
Returns:
true if connectivity to the given endpoint was verified; false if for some reason the endpoint could not be pinged

getGlobalConcurrencyLimit

public Integer getGlobalConcurrencyLimit()
Description copied from interface: ServerCommunicationsServiceMBean
Gets the global concurrency limit. This is the amount of messages that the server will allow to be processed concurrently - the type of message doesn't matter, this is the global maximum of any and all messages that are allowed to be concurrently accepted.

Specified by:
getGlobalConcurrencyLimit in interface ServerCommunicationsServiceMBean
Returns:
number of concurrent calls allowed

setGlobalConcurrencyLimit

public void setGlobalConcurrencyLimit(Integer maxConcurrency)
Description copied from interface: ServerCommunicationsServiceMBean
Sets the global concurrency limit. This is the amount of messages that the server will allow to be processed concurrently - the type of message doesn't matter, this is the global maximum of any and all messages that are allowed to be concurrently accepted.

Specified by:
setGlobalConcurrencyLimit in interface ServerCommunicationsServiceMBean

getInventoryReportConcurrencyLimit

public Integer getInventoryReportConcurrencyLimit()
Description copied from interface: ServerCommunicationsServiceMBean
Gets the concurrency limit for inventory reports. This is the amount of inventory reports that the server will allow to be processed concurrently.

Specified by:
getInventoryReportConcurrencyLimit in interface ServerCommunicationsServiceMBean
Returns:
number of concurrent calls allowed

setInventoryReportConcurrencyLimit

public void setInventoryReportConcurrencyLimit(Integer maxConcurrency)
Description copied from interface: ServerCommunicationsServiceMBean
Sets the new concurrency limit for inventory reports. This new number is the amount of inventory reports that the server will allow to be processed concurrently.

Specified by:
setInventoryReportConcurrencyLimit in interface ServerCommunicationsServiceMBean

getAvailabilityReportConcurrencyLimit

public Integer getAvailabilityReportConcurrencyLimit()
Description copied from interface: ServerCommunicationsServiceMBean
Gets the concurrency limit for availability reports. This is the amount of availability reports that the server will allow to be processed concurrently.

Specified by:
getAvailabilityReportConcurrencyLimit in interface ServerCommunicationsServiceMBean
Returns:
number of concurrent calls allowed

setAvailabilityReportConcurrencyLimit

public void setAvailabilityReportConcurrencyLimit(Integer maxConcurrency)
Description copied from interface: ServerCommunicationsServiceMBean
Sets the new concurrency limit for availability reports. This new number is the amount of availability reports that the server will allow to be processed concurrently.

Specified by:
setAvailabilityReportConcurrencyLimit in interface ServerCommunicationsServiceMBean

getInventorySyncConcurrencyLimit

public Integer getInventorySyncConcurrencyLimit()
Description copied from interface: ServerCommunicationsServiceMBean
Gets the concurrency limit for inventory sync requests. This is the amount of inventory sync requests that the server will allow to be processed concurrently.

Specified by:
getInventorySyncConcurrencyLimit in interface ServerCommunicationsServiceMBean
Returns:
number of concurrent calls allowed

setInventorySyncConcurrencyLimit

public void setInventorySyncConcurrencyLimit(Integer maxConcurrency)
Description copied from interface: ServerCommunicationsServiceMBean
Sets the new concurrency limit for inventory sync requests. This new number is the amount of inventory sync requests that the server will allow to be processed concurrently.

Specified by:
setInventorySyncConcurrencyLimit in interface ServerCommunicationsServiceMBean

getContentReportConcurrencyLimit

public Integer getContentReportConcurrencyLimit()
Description copied from interface: ServerCommunicationsServiceMBean
Gets the concurrency limit for content reports. This is the amount of content reports that the server will allow to be processed concurrently.

Specified by:
getContentReportConcurrencyLimit in interface ServerCommunicationsServiceMBean
Returns:
number of concurrent calls allowed

setContentReportConcurrencyLimit

public void setContentReportConcurrencyLimit(Integer maxConcurrency)
Description copied from interface: ServerCommunicationsServiceMBean
Sets the new concurrency limit for content reports. This new number is the amount of content reports that the server will allow to be processed concurrently.

Specified by:
setContentReportConcurrencyLimit in interface ServerCommunicationsServiceMBean

getContentDownloadConcurrencyLimit

public Integer getContentDownloadConcurrencyLimit()
Description copied from interface: ServerCommunicationsServiceMBean
Gets the concurrency limit for content downloads. This is the amount of downloads that the server will allow to be processed concurrently.

Specified by:
getContentDownloadConcurrencyLimit in interface ServerCommunicationsServiceMBean
Returns:
number of concurrent calls allowed

setContentDownloadConcurrencyLimit

public void setContentDownloadConcurrencyLimit(Integer maxConcurrency)
Description copied from interface: ServerCommunicationsServiceMBean
Sets the new concurrency limit for content downloads. This new number is the amount of downloads that the server will allow to be processed concurrently.

Specified by:
setContentDownloadConcurrencyLimit in interface ServerCommunicationsServiceMBean

getMeasurementReportConcurrencyLimit

public Integer getMeasurementReportConcurrencyLimit()
Description copied from interface: ServerCommunicationsServiceMBean
Gets the concurrency limit for measurement reports. This is the amount of measurement reports that the server will allow to be processed concurrently.

Specified by:
getMeasurementReportConcurrencyLimit in interface ServerCommunicationsServiceMBean
Returns:
number of concurrent calls allowed

setMeasurementReportConcurrencyLimit

public void setMeasurementReportConcurrencyLimit(Integer maxConcurrency)
Description copied from interface: ServerCommunicationsServiceMBean
Sets the new concurrency limit for measurement reports. This new number is the amount of measurement reports that the server will allow to be processed concurrently.

Specified by:
setMeasurementReportConcurrencyLimit in interface ServerCommunicationsServiceMBean

getMeasurementScheduleRequestConcurrencyLimit

public Integer getMeasurementScheduleRequestConcurrencyLimit()
Description copied from interface: ServerCommunicationsServiceMBean
Gets the concurrency limit for measurement reports. This is the amount of measurement reports that the server will allow to be processed concurrently.

Specified by:
getMeasurementScheduleRequestConcurrencyLimit in interface ServerCommunicationsServiceMBean
Returns:
number of concurrent calls allowed

setMeasurementScheduleRequestConcurrencyLimit

public void setMeasurementScheduleRequestConcurrencyLimit(Integer maxConcurrency)
Description copied from interface: ServerCommunicationsServiceMBean
Sets the new concurrency limit for measurement schedule requests. This new number is the amount of measurement schedule requests that the server will allow to be processed concurrently.

Specified by:
setMeasurementScheduleRequestConcurrencyLimit in interface ServerCommunicationsServiceMBean

getMaintenanceModeAtStartup

public Boolean getMaintenanceModeAtStartup()
Description copied from interface: ServerCommunicationsServiceMBean
Returns true if the server should always start up in maintenance mode. If false, the server will startup in the same state it was in when it was shutdown.

Specified by:
getMaintenanceModeAtStartup in interface ServerCommunicationsServiceMBean
Returns:
true if the server should always start up in MM

isMaintenanceModeAtStartup

public Boolean isMaintenanceModeAtStartup()
Description copied from interface: ServerCommunicationsServiceMBean
Same as ServerCommunicationsServiceMBean.getMaintenanceModeAtStartup().

Specified by:
isMaintenanceModeAtStartup in interface ServerCommunicationsServiceMBean
Returns:
true if server starts up in MM

setMaintenanceModeAtStartup

public void setMaintenanceModeAtStartup(Boolean flag)
Description copied from interface: ServerCommunicationsServiceMBean
Sets the flag to indicate if the server should always start up in maintenance mode. See ServerCommunicationsServiceMBean.getMaintenanceModeAtStartup() for more.

Specified by:
setMaintenanceModeAtStartup in interface ServerCommunicationsServiceMBean

clear

public void clear()
Specified by:
clear in interface ServiceContainerMetricsMBean

getNumberDroppedCommandsReceived

public long getNumberDroppedCommandsReceived()
Specified by:
getNumberDroppedCommandsReceived in interface ServiceContainerMetricsMBean

getNumberNotProcessedCommandsReceived

public long getNumberNotProcessedCommandsReceived()
Specified by:
getNumberNotProcessedCommandsReceived in interface ServiceContainerMetricsMBean

getNumberFailedCommandsReceived

public long getNumberFailedCommandsReceived()
Specified by:
getNumberFailedCommandsReceived in interface ServiceContainerMetricsMBean

getNumberSuccessfulCommandsReceived

public long getNumberSuccessfulCommandsReceived()
Specified by:
getNumberSuccessfulCommandsReceived in interface ServiceContainerMetricsMBean

getNumberTotalCommandsReceived

public long getNumberTotalCommandsReceived()
Specified by:
getNumberTotalCommandsReceived in interface ServiceContainerMetricsMBean

getAverageExecutionTimeReceived

public long getAverageExecutionTimeReceived()
Specified by:
getAverageExecutionTimeReceived in interface ServiceContainerMetricsMBean

getCallTimeDataReceived

public Map<String,CommandProcessorMetrics.Calltime> getCallTimeDataReceived()
Specified by:
getCallTimeDataReceived in interface ServiceContainerMetricsMBean


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