org.rhq.core.pc.measurement
Class MeasurementManager

java.lang.Object
  extended by org.rhq.core.pc.agent.AgentService
      extended by org.rhq.core.pc.measurement.MeasurementManager
All Implemented Interfaces:
MeasurementAgentService, ContainerService, MeasurementManagerMBean

public class MeasurementManager
extends AgentService
implements MeasurementAgentService, ContainerService, MeasurementManagerMBean

Manage the scheduled process of measurement data collection, detection and sending across all plugins.

This is an agent service; its interface is made remotely accessible if this is deployed within the agent.

Author:
Greg Hinkle, John Mazzitelli

Nested Class Summary
 
Nested classes/interfaces inherited from class org.rhq.core.pc.agent.AgentService
AgentService.LifecycleState
 
Field Summary
static String OBJECT_NAME
           
 
Constructor Summary
MeasurementManager()
           
 
Method Summary
 boolean checkTrait(int scheduleId, String traitValue)
          Check if the passed trait is new or has changed
 org.rhq.core.domain.measurement.MeasurementReport getActiveReport()
           
 String getCachedTraitValue(int scheduleId)
          If you want to get a cached value of a trait, pass in its schedule ID.
 long getCurrentlyScheduleMeasurements()
           
 long getFailedCollections()
           
 long getLateCollections()
           
 Map<String,Object> getMeasurementScheduleInfoForResource(int resourceId)
           
 long getMeasurementsCollected()
           
 long getMeasurementsCollectedPerMinute()
           
 long getNextExpectedCollectionTime()
           
 Set<ScheduledMeasurementInfo> getNextScheduledSet()
          Returns the complete set of scheduled measurement collections.
 Set<org.rhq.core.domain.measurement.MeasurementData> getRealTimeMeasurementValue(int resourceId, List<org.rhq.core.domain.measurement.MeasurementDataRequest> requests)
           
 long getTotalTimeCollectingMeasurements()
           
 String getTraitValue(ResourceContainer container, String traitName)
          Given the name of a trait, this will find the value of that trait for the given resource.
 void initialize()
          Initializes the container service which will effectively tell the service to start doing its work.
 void perMinuteItizeData(org.rhq.core.domain.measurement.MeasurementReport report)
           
 void reschedule(Set<ScheduledMeasurementInfo> scheduledMeasurementInfos)
           
 void scheduleCollection(int resourceId, Set<org.rhq.core.domain.measurement.MeasurementScheduleRequest> requests)
          Used to direct reschedule resources from the persisted to disk schedules
 void scheduleCollection(Set<org.rhq.core.domain.measurement.ResourceMeasurementScheduleRequest> scheduleRequests)
          This remoted method allows the server to schedule a bunch of resources with one call.
 void sendMeasurementReport(org.rhq.core.domain.measurement.MeasurementReport report)
          Sends the given measurement report to the server, if this plugin container has server services that it can communicate with.
 void setConfiguration(PluginContainerConfiguration configuration)
          Informs the container service how it should be configured by providing the full plugin container configuration.
 void shutdown()
          Stops the container service which effectively releases all runtime resources such as running threads.
 org.rhq.core.domain.measurement.MeasurementReport swapReport()
           
 void unscheduleCollection(Set<Integer> resourceIds)
           
 void updateCollection(Set<org.rhq.core.domain.measurement.ResourceMeasurementScheduleRequest> scheduleRequests)
          This remoted method allows the server to schedule a bunch of resources with one call.
 
Methods inherited from class org.rhq.core.pc.agent.AgentService
addLifecycleListener, getClientInterface, notifyLifecycleListenersOfNewState, remoteInputStream, remoteOutputStream, removeLifecycleListener, setAgentServiceStreamRemoter
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

OBJECT_NAME

public static final String OBJECT_NAME
See Also:
Constant Field Values
Constructor Detail

MeasurementManager

public MeasurementManager()
Method Detail

initialize

public void initialize()
Description copied from interface: ContainerService
Initializes the container service which will effectively tell the service to start doing its work. Implementations of this interface can be assured that prior to this method being called, a non-null configuration will be set via a call to ContainerService.setConfiguration(PluginContainerConfiguration).

Specified by:
initialize in interface ContainerService

getActiveReport

public org.rhq.core.domain.measurement.MeasurementReport getActiveReport()

checkTrait

public boolean checkTrait(int scheduleId,
                          String traitValue)
Check if the passed trait is new or has changed

Parameters:
scheduleId -
traitValue -
Returns:
true if the value is new or changed and should be included in the report

getCachedTraitValue

public String getCachedTraitValue(int scheduleId)
If you want to get a cached value of a trait, pass in its schedule ID. This is useful if you don't care to obtain the latest-n-greated value of the trait, and you want to avoid making a live call to the managed resource to obtain its value. Note that if the trait is not yet cached, this will return null, and the caller will be forced to make a live call to obtain the trait value, but at least this can help avoid unnecessarily calling the live resource.

Parameters:
scheduleId - the schedule for the trait for a specific resource
Returns:
the trait's cached value, null if not available

perMinuteItizeData

public void perMinuteItizeData(org.rhq.core.domain.measurement.MeasurementReport report)

shutdown

public void shutdown()
Description copied from interface: ContainerService
Stops the container service which effectively releases all runtime resources such as running threads.

Specified by:
shutdown in interface ContainerService

setConfiguration

public void setConfiguration(PluginContainerConfiguration configuration)
Description copied from interface: ContainerService
Informs the container service how it should be configured by providing the full plugin container configuration. The plugin container will ensure it passes in a non-null configuration object so implementations of this interface should never have to worry about a null configuration parameter value.

Specified by:
setConfiguration in interface ContainerService

updateCollection

public void updateCollection(Set<org.rhq.core.domain.measurement.ResourceMeasurementScheduleRequest> scheduleRequests)
This remoted method allows the server to schedule a bunch of resources with one call. This method will update the set of MeasurementSchedules in the agent. Use scheduleCollection(Set) if you want to replace the existing ones.

Specified by:
updateCollection in interface MeasurementAgentService
Parameters:
scheduleRequests -

scheduleCollection

public void scheduleCollection(Set<org.rhq.core.domain.measurement.ResourceMeasurementScheduleRequest> scheduleRequests)
This remoted method allows the server to schedule a bunch of resources with one call. BE CAREFUL, as this will replace all existing schedules with the passed set. Use updateCollection(Set) if you want to schedule additional MeasurementSchedules

Specified by:
scheduleCollection in interface MeasurementAgentService
Parameters:
scheduleRequests -

scheduleCollection

public void scheduleCollection(int resourceId,
                               Set<org.rhq.core.domain.measurement.MeasurementScheduleRequest> requests)
Used to direct reschedule resources from the persisted to disk schedules

Parameters:
resourceId - The resource to collect on
requests - The measurements to collect

unscheduleCollection

public void unscheduleCollection(Set<Integer> resourceIds)
Specified by:
unscheduleCollection in interface MeasurementAgentService

getRealTimeMeasurementValue

public Set<org.rhq.core.domain.measurement.MeasurementData> getRealTimeMeasurementValue(int resourceId,
                                                                                        List<org.rhq.core.domain.measurement.MeasurementDataRequest> requests)
Specified by:
getRealTimeMeasurementValue in interface MeasurementAgentService

getNextExpectedCollectionTime

public long getNextExpectedCollectionTime()
Specified by:
getNextExpectedCollectionTime in interface MeasurementManagerMBean

getNextScheduledSet

public Set<ScheduledMeasurementInfo> getNextScheduledSet()
Returns the complete set of scheduled measurement collections.

Returns:
all measurement schedules

reschedule

public void reschedule(Set<ScheduledMeasurementInfo> scheduledMeasurementInfos)

sendMeasurementReport

public void sendMeasurementReport(org.rhq.core.domain.measurement.MeasurementReport report)
Sends the given measurement report to the server, if this plugin container has server services that it can communicate with.

Parameters:
report -

getMeasurementScheduleInfoForResource

public Map<String,Object> getMeasurementScheduleInfoForResource(int resourceId)
Specified by:
getMeasurementScheduleInfoForResource in interface MeasurementAgentService

getTraitValue

public String getTraitValue(ResourceContainer container,
                            String traitName)
Given the name of a trait, this will find the value of that trait for the given resource.

Parameters:
resource - the resource whose trait value is to be obtained
traitName - the name of the trait whose value is to be obtained
Returns:
the value of the trait, or null if unknown

getMeasurementsCollected

public long getMeasurementsCollected()
Specified by:
getMeasurementsCollected in interface MeasurementManagerMBean

getMeasurementsCollectedPerMinute

public long getMeasurementsCollectedPerMinute()
Specified by:
getMeasurementsCollectedPerMinute in interface MeasurementManagerMBean

getCurrentlyScheduleMeasurements

public long getCurrentlyScheduleMeasurements()
Specified by:
getCurrentlyScheduleMeasurements in interface MeasurementManagerMBean

getTotalTimeCollectingMeasurements

public long getTotalTimeCollectingMeasurements()
Specified by:
getTotalTimeCollectingMeasurements in interface MeasurementManagerMBean

getLateCollections

public long getLateCollections()
Specified by:
getLateCollections in interface MeasurementManagerMBean

swapReport

public org.rhq.core.domain.measurement.MeasurementReport swapReport()

getFailedCollections

public long getFailedCollections()
Specified by:
getFailedCollections in interface MeasurementManagerMBean


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