org.rhq.enterprise.server.measurement
Class MeasurementScheduleManagerBean

java.lang.Object
  extended by org.rhq.enterprise.server.measurement.MeasurementScheduleManagerBean
All Implemented Interfaces:
MeasurementScheduleManagerLocal, MeasurementScheduleManagerRemote

public class MeasurementScheduleManagerBean
extends java.lang.Object
implements MeasurementScheduleManagerLocal, MeasurementScheduleManagerRemote

A manager for MeasurementSchedules.

Author:
Heiko W. Rupp, Ian Springer, Joseph Marques

Constructor Summary
MeasurementScheduleManagerBean()
           
 
Method Summary
 void createSchedulesForExistingResources(ResourceType type, MeasurementDefinition newDefinition)
          Create MeasurementSchedules for existing resources hanging on newType.
 void disableAllDefaultCollections(Subject subject)
          Disables all collection schedules for all measurement definitions.
 void disableAllSchedules(Subject subject)
          Disables all collection schedules attached to all resources.
 void disableDefaultCollectionForMeasurementDefinitions(Subject subject, int[] measurementDefinitionIds, boolean updateSchedules)
          Disables all collection schedules in the given measurement definition IDs.
 void disableMeasurementTemplates(Subject subject, int[] measurementDefinitionIds)
           
 void disableSchedulesForAutoGroup(Subject subject, int parentResourceId, int childResourceType, int[] measurementDefinitionIds)
          Disable the measurement schedules for the passed definitions of the rsource ot the passed auto group.
 void disableSchedulesForCompatibleGroup(Subject subject, int groupId, int[] measurementDefinitionIds)
          Disable the measurement schedules for the passed definitions for the resources of the passed compatible group.
 void disableSchedulesForResource(Subject subject, int resourceId, int[] measurementDefinitionIds)
          Disables all collection schedules attached to the given resource whose schedules are based off the given definitions.
 void enableMeasurementTemplates(Subject subject, int[] measurementDefinitionIds)
           
 void enableSchedulesForAutoGroup(Subject subject, int parentResourceId, int childResourceType, int[] measurementDefinitionIds)
          Enable the measurement schedules for the passed definitions of the rsource ot the passed auto group.
 void enableSchedulesForCompatibleGroup(Subject subject, int groupId, int[] measurementDefinitionIds)
          Enable the measurement schedules for the passed definitions for the resources of the passed compatible group.
 void enableSchedulesForResource(Subject subject, int resourceId, int[] measurementDefinitionIds)
          Enable the schedules for the provided definitions and resource
 void errorCorrectSchedules()
          This method should be called when it is determined that the data in the measurement schedule table might be corrupt.
 PageList<MeasurementScheduleComposite> findScheduleCompositesForResource(Subject subject, int resourceId, DataType dataType, PageControl pageControl)
          Retrieves the metric collection schedules for the given resource.
 PageList<MeasurementSchedule> findSchedulesByCriteria(Subject subject, MeasurementScheduleCriteria criteria)
           
 java.util.List<MeasurementSchedule> findSchedulesByIds(int[] scheduleIds)
          Return a list of MeasurementSchedules for the given ids
 java.util.List<MeasurementSchedule> findSchedulesByResourceIdAndDefinitionIds(Subject subject, int resourceId, int[] definitionIds)
          Return a list of MeasurementSchedules for the given definition ids and resource id.
 java.util.List<MeasurementSchedule> findSchedulesByResourceIdsAndDefinitionId(Subject subject, int[] resourceIds, int definitionId)
          Find MeasurementSchedules that are attached to a certain definition and some resources
 PageList<MeasurementScheduleComposite> findSchedulesForAutoGroup(Subject subject, int parentId, int childType, PageControl pageControl)
          Get the MeasurementSchedule composits for an autogroup
 PageList<MeasurementScheduleComposite> findSchedulesForCompatibleGroup(Subject subject, int groupId, PageControl pageControl)
          Get the MeasurementSchedule composites for a compatible group.
 PageList<MeasurementScheduleComposite> findSchedulesForResource(Subject subject, int resourceId, PageControl pageControl)
          Retrieves the metric collection schedules for the given resource.
 java.util.Set<ResourceMeasurementScheduleRequest> findSchedulesForResourceAndItsDescendants(int[] resourceIds, boolean getDescendents)
          Given a resource ID, this will return all schedule collections for all of the resource's measurements, including all measurements for the resource's children.
 java.util.List<MeasurementSchedule> findSchedulesForResourceAndType(Subject subject, int resourceId, DataType dataType, DisplayType displayType, boolean enabledOnly)
          Determine the Schedules for a Resource and DataType.
 AgentClient getAgentClientForSchedule(MeasurementSchedule sched)
          Get the AgentClient (the connection to the agent) for a certain Schedule
 MeasurementSchedule getSchedule(Subject subject, int resourceId, int definitionId, boolean attachBaseline)
          Find MeasurementSchedules that are attached to a certain definition and a resource
 MeasurementSchedule getScheduleById(int scheduleId)
          Returns a MeasurementSchedule by its primary key or null.
 MeasurementSchedule getScheduleById(Subject subject, int scheduleId)
          Obtain a MeasurementSchedule by its Id after a check for a valid session
 int getScheduledMeasurementsPerMinute()
           
 int insertSchedulesFor(int[] batchIds)
           
 int returnSchedulesFor(int[] batchIds, java.util.Set<ResourceMeasurementScheduleRequest> allSchedules)
           
 void updateDefaultCollectionIntervalForMeasurementDefinitions(Subject subject, int[] measurementDefinitionIds, long collectionInterval, boolean updateExistingSchedules)
          (Re-)Enables all collection schedules in the given measurement definition IDs and sets their collection intervals.
 void updateMeasurementTemplates(Subject subject, int[] measurementDefinitionIds, long collectionInterval)
           
 void updateSchedule(Subject subject, MeasurementSchedule schedule)
          Reattach a Schedule to a PersitenceContext after a successful check for a valid session
 void updateSchedules(Subject subject, int resourceId, int[] measurementDefinitionIds, long collectionInterval)
           
 void updateSchedulesForAutoGroup(Subject subject, int parentResourceId, int childResourceType, int[] measurementDefinitionIds, long collectionInterval)
          Enables all collection schedules attached to the given auto group whose schedules are based off the given definitions.
 void updateSchedulesForCompatibleGroup(Subject subject, int groupId, int[] measurementDefinitionIds, long collectionInterval)
          Enables all collection schedules attached to the given compatible group whose schedules are based off the given definitions.
 void updateSchedulesForResource(Subject subject, int resourceId, int[] measurementDefinitionIds, long collectionInterval)
          Enables all collection schedules attached to the given resource whose schedules are based off the given definitions.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MeasurementScheduleManagerBean

public MeasurementScheduleManagerBean()
Method Detail

findSchedulesForResourceAndItsDescendants

public java.util.Set<ResourceMeasurementScheduleRequest> findSchedulesForResourceAndItsDescendants(int[] resourceIds,
                                                                                                   boolean getDescendents)
Description copied from interface: MeasurementScheduleManagerLocal
Given a resource ID, this will return all schedule collections for all of the resource's measurements, including all measurements for the resource's children. This will also create schedules for resources if they do not already exist.

Specified by:
findSchedulesForResourceAndItsDescendants in interface MeasurementScheduleManagerLocal
Parameters:
resourceIds - IDs of the resources whose measurements are to be returned
getDescendents - if true, descendents will be loaded as well
Returns:
the set of resource schedule requests for a subtree or a single resource

getAgentClientForSchedule

public AgentClient getAgentClientForSchedule(MeasurementSchedule sched)
Get the AgentClient (the connection to the agent) for a certain Schedule

Specified by:
getAgentClientForSchedule in interface MeasurementScheduleManagerLocal
Parameters:
sched - A MeasurementSchedule for which we need a connection to the Agent
Returns:
an AgentClient to communicate with the Agent

getScheduleById

public MeasurementSchedule getScheduleById(int scheduleId)
Returns a MeasurementSchedule by its primary key or null.

Parameters:
scheduleId - the id of the desired schedule
Returns:
The MeasurementSchedule or null if not found

findSchedulesByIds

public java.util.List<MeasurementSchedule> findSchedulesByIds(int[] scheduleIds)
Return a list of MeasurementSchedules for the given ids

Specified by:
findSchedulesByIds in interface MeasurementScheduleManagerLocal
Parameters:
ids - PrimaryKeys of the schedules searched
Returns:
a list of Schedules

getScheduleById

public MeasurementSchedule getScheduleById(Subject subject,
                                           int scheduleId)
Obtain a MeasurementSchedule by its Id after a check for a valid session

Specified by:
getScheduleById in interface MeasurementScheduleManagerLocal
Parameters:
subject - a session id that must be valid
scheduleId - The primary key of the Schedule
Returns:
a MeasurementSchedule or null, if there is

findSchedulesByResourceIdsAndDefinitionId

public java.util.List<MeasurementSchedule> findSchedulesByResourceIdsAndDefinitionId(Subject subject,
                                                                                     int[] resourceIds,
                                                                                     int definitionId)
Find MeasurementSchedules that are attached to a certain definition and some resources

Specified by:
findSchedulesByResourceIdsAndDefinitionId in interface MeasurementScheduleManagerLocal
Parameters:
subject - A subject that must be valid
definitionId - The primary key of a MeasurementDefinition
resourceIds - primary of Resources wanted
Returns:
a List of MeasurementSchedules

getSchedule

public MeasurementSchedule getSchedule(Subject subject,
                                       int resourceId,
                                       int definitionId,
                                       boolean attachBaseline)
                                throws MeasurementNotFoundException
Find MeasurementSchedules that are attached to a certain definition and a resource

Specified by:
getSchedule in interface MeasurementScheduleManagerLocal
Parameters:
subject -
definitionId - The primary key of a MeasurementDefinition
resourceId - the id of the resource
attachBaseline - baseline won't be attached to the schedule by default do to LAZY annotation on the managed relationship. attachBaseline, if true, will eagerly load it for the caller
Returns:
the MeasurementSchedule of the given definition for the given resource
Throws:
MeasurementNotFoundException

findSchedulesForAutoGroup

public PageList<MeasurementScheduleComposite> findSchedulesForAutoGroup(Subject subject,
                                                                        int parentId,
                                                                        int childType,
                                                                        PageControl pageControl)
Get the MeasurementSchedule composits for an autogroup

Specified by:
findSchedulesForAutoGroup in interface MeasurementScheduleManagerLocal
Parameters:
subject -
parentId -
childType -
pageControl -
Returns:

findSchedulesForCompatibleGroup

public PageList<MeasurementScheduleComposite> findSchedulesForCompatibleGroup(Subject subject,
                                                                              int groupId,
                                                                              PageControl pageControl)
Get the MeasurementSchedule composites for a compatible group.

Specified by:
findSchedulesForCompatibleGroup in interface MeasurementScheduleManagerLocal

findScheduleCompositesForResource

public PageList<MeasurementScheduleComposite> findScheduleCompositesForResource(Subject subject,
                                                                                int resourceId,
                                                                                @Nullable
                                                                                DataType dataType,
                                                                                PageControl pageControl)
Description copied from interface: MeasurementScheduleManagerLocal
Retrieves the metric collection schedules for the given resource.

Specified by:
findScheduleCompositesForResource in interface MeasurementScheduleManagerLocal
Parameters:
subject - the current user
resourceId - a Resource id
dataType - the data type to limit results to, or null to not limit results to a particular data type
pageControl - the page control for the results
Returns:
the metric collection schedules for the given resource

findSchedulesForResource

public PageList<MeasurementScheduleComposite> findSchedulesForResource(Subject subject,
                                                                       int resourceId,
                                                                       PageControl pageControl)
Description copied from interface: MeasurementScheduleManagerLocal
Retrieves the metric collection schedules for the given resource.

Specified by:
findSchedulesForResource in interface MeasurementScheduleManagerLocal
Parameters:
subject - the current user
resourceId - a Resource id
pageControl - the page control for the results
Returns:
the metric collection schedules for the given resource

disableDefaultCollectionForMeasurementDefinitions

public void disableDefaultCollectionForMeasurementDefinitions(Subject subject,
                                                              int[] measurementDefinitionIds,
                                                              boolean updateSchedules)
Description copied from interface: MeasurementScheduleManagerLocal
Disables all collection schedules in the given measurement definition IDs. This only disables the "templates", it does not disable actual schedules. For that capability, see #disableSchedules(Subject, int[], int).

Specified by:
disableDefaultCollectionForMeasurementDefinitions in interface MeasurementScheduleManagerLocal
updateSchedules - TODO

disableAllDefaultCollections

public void disableAllDefaultCollections(Subject subject)
Description copied from interface: MeasurementScheduleManagerLocal
Disables all collection schedules for all measurement definitions. This only disables the "templates", it does not disable actual schedules. For that capability, see #disableAllMeasurementSchedules(Subject).

This is a highly disruptive method - it turns off monitoring for future resources. The user making this call must have global inventory and setting permissions to execute this.

Specified by:
disableAllDefaultCollections in interface MeasurementScheduleManagerLocal
Parameters:
subject - user that must have global inventory and setting rights

disableAllSchedules

public void disableAllSchedules(Subject subject)
Description copied from interface: MeasurementScheduleManagerLocal
Disables all collection schedules attached to all resources. This only disables the currently existing schedules, it does not disable the templates for future resources. For that capability, see MeasurementScheduleManagerLocal.disableAllDefaultCollections(Subject).

This is a highly disruptive method - it turns off monitoring for existing resources. The user making this call must have global inventory and setting permissions to execute this.

Specified by:
disableAllSchedules in interface MeasurementScheduleManagerLocal
Parameters:
subject - user that must have global inventory and setting rights

createSchedulesForExistingResources

public void createSchedulesForExistingResources(ResourceType type,
                                                MeasurementDefinition newDefinition)
Description copied from interface: MeasurementScheduleManagerLocal
Create MeasurementSchedules for existing resources hanging on newType.

Specified by:
createSchedulesForExistingResources in interface MeasurementScheduleManagerLocal
Parameters:
type - The ResourceType for which we want to add schedules
newDefinition - The MeasurementDefinition where we derive the schedules from

updateDefaultCollectionIntervalForMeasurementDefinitions

public void updateDefaultCollectionIntervalForMeasurementDefinitions(Subject subject,
                                                                     int[] measurementDefinitionIds,
                                                                     long collectionInterval,
                                                                     boolean updateExistingSchedules)
(Re-)Enables all collection schedules in the given measurement definition IDs and sets their collection intervals. This only enables the "templates", it does not enable actual schedules unless updateExistingSchedules is set to true.

Specified by:
updateDefaultCollectionIntervalForMeasurementDefinitions in interface MeasurementScheduleManagerLocal
Parameters:
subject - a valid subject that has Permission.MANAGE_SETTINGS
measurementDefinitionIds - The primary keys for the definitions
collectionInterval - the new interval in millisconds for collection
updateExistingSchedules - If true, then existing schedules for this definition will also be updated.

updateSchedules

public void updateSchedules(Subject subject,
                            int resourceId,
                            int[] measurementDefinitionIds,
                            long collectionInterval)

updateSchedulesForAutoGroup

public void updateSchedulesForAutoGroup(Subject subject,
                                        int parentResourceId,
                                        int childResourceType,
                                        int[] measurementDefinitionIds,
                                        long collectionInterval)
Enables all collection schedules attached to the given auto group whose schedules are based off the given definitions. This does not enable the "templates" (aka definitions). If the passed group does not exist an Exception is thrown.

Specified by:
updateSchedulesForAutoGroup in interface MeasurementScheduleManagerLocal
Parameters:
subject - Subject of the caller
measurementDefinitionIds - the definitions on which the schedules to update are based
parentResourceId - the Id of the parent resource
childResourceType - the ID of the ResourceType of the children that form the autogroup
collectionInterval - the new interval
See Also:
org.rhq.enterprise.server.measurement.MeasurementScheduleManagerLocal#updateSchedulesForAutoGroup(org.rhq.core.domain.auth.Subject, int[], int, int, long)

disableSchedulesForAutoGroup

public void disableSchedulesForAutoGroup(Subject subject,
                                         int parentResourceId,
                                         int childResourceType,
                                         int[] measurementDefinitionIds)
Disable the measurement schedules for the passed definitions of the rsource ot the passed auto group.

Specified by:
disableSchedulesForAutoGroup in interface MeasurementScheduleManagerLocal
Parameters:
subject -
measurementDefinitionIds -
parentResourceId -
childResourceType -

enableSchedulesForAutoGroup

public void enableSchedulesForAutoGroup(Subject subject,
                                        int parentResourceId,
                                        int childResourceType,
                                        int[] measurementDefinitionIds)
Enable the measurement schedules for the passed definitions of the rsource ot the passed auto group.

Specified by:
enableSchedulesForAutoGroup in interface MeasurementScheduleManagerLocal
Parameters:
subject -
measurementDefinitionIds -
parentResourceId -
childResourceType -

findSchedulesForResourceAndType

public java.util.List<MeasurementSchedule> findSchedulesForResourceAndType(Subject subject,
                                                                           int resourceId,
                                                                           DataType dataType,
                                                                           DisplayType displayType,
                                                                           boolean enabledOnly)
Determine the Schedules for a Resource and DataType. The data type is used to filter out (numerical) measurement and / or traits. If it is null, then we don't filter by DataType

Specified by:
findSchedulesForResourceAndType in interface MeasurementScheduleManagerLocal
Parameters:
subject - Subject of the caller
resourceId - PK of the resource we're interested in
dataType - DataType of the desired results use null for no filtering
displayType - the display type of the property or null for no filtering
enabledOnly - should we restrict the query to certain enablement state? null means "don't care".
Returns:
List of MeasuremenSchedules for the given resource

findSchedulesByResourceIdAndDefinitionIds

public java.util.List<MeasurementSchedule> findSchedulesByResourceIdAndDefinitionIds(Subject subject,
                                                                                     int resourceId,
                                                                                     int[] definitionIds)
Return a list of MeasurementSchedules for the given definition ids and resource id.

Specified by:
findSchedulesByResourceIdAndDefinitionIds in interface MeasurementScheduleManagerLocal
Parameters:
definitionIds -
resourceId -
Returns:
a list of Schedules

insertSchedulesFor

public int insertSchedulesFor(int[] batchIds)
                       throws java.lang.Exception
Specified by:
insertSchedulesFor in interface MeasurementScheduleManagerLocal
Throws:
java.lang.Exception

returnSchedulesFor

public int returnSchedulesFor(int[] batchIds,
                              java.util.Set<ResourceMeasurementScheduleRequest> allSchedules)
                       throws java.lang.Exception
Specified by:
returnSchedulesFor in interface MeasurementScheduleManagerLocal
Throws:
java.lang.Exception

getScheduledMeasurementsPerMinute

public int getScheduledMeasurementsPerMinute()
Specified by:
getScheduledMeasurementsPerMinute in interface MeasurementScheduleManagerLocal
Returns:
a rounded count of the average number of metrics that are scheduled per minute

errorCorrectSchedules

public void errorCorrectSchedules()
Description copied from interface: MeasurementScheduleManagerLocal
This method should be called when it is determined that the data in the measurement schedule table might be corrupt. This happens when the schedules get a collection interval of less than 30 seconds. Execution of this method will automatically correct that situation, and update the mtime's of the corresponding resources whose schedules were corrupt, to cause the agent to synchronize those schedules.

Specified by:
errorCorrectSchedules in interface MeasurementScheduleManagerLocal

disableSchedulesForResource

public void disableSchedulesForResource(Subject subject,
                                        int resourceId,
                                        int[] measurementDefinitionIds)
Description copied from interface: MeasurementScheduleManagerLocal
Disables all collection schedules attached to the given resource whose schedules are based off the given definitions. This does not disable the "templates" (aka definitions).

Specified by:
disableSchedulesForResource in interface MeasurementScheduleManagerLocal
Specified by:
disableSchedulesForResource in interface MeasurementScheduleManagerRemote

disableSchedulesForCompatibleGroup

public void disableSchedulesForCompatibleGroup(Subject subject,
                                               int groupId,
                                               int[] measurementDefinitionIds)
Disable the measurement schedules for the passed definitions for the resources of the passed compatible group.

Specified by:
disableSchedulesForCompatibleGroup in interface MeasurementScheduleManagerLocal
Specified by:
disableSchedulesForCompatibleGroup in interface MeasurementScheduleManagerRemote

disableMeasurementTemplates

public void disableMeasurementTemplates(Subject subject,
                                        int[] measurementDefinitionIds)
Specified by:
disableMeasurementTemplates in interface MeasurementScheduleManagerLocal
Specified by:
disableMeasurementTemplates in interface MeasurementScheduleManagerRemote

enableSchedulesForResource

public void enableSchedulesForResource(Subject subject,
                                       int resourceId,
                                       int[] measurementDefinitionIds)
Description copied from interface: MeasurementScheduleManagerLocal
Enable the schedules for the provided definitions and resource

Specified by:
enableSchedulesForResource in interface MeasurementScheduleManagerLocal
Specified by:
enableSchedulesForResource in interface MeasurementScheduleManagerRemote

enableSchedulesForCompatibleGroup

public void enableSchedulesForCompatibleGroup(Subject subject,
                                              int groupId,
                                              int[] measurementDefinitionIds)
Enable the measurement schedules for the passed definitions for the resources of the passed compatible group.

Specified by:
enableSchedulesForCompatibleGroup in interface MeasurementScheduleManagerLocal
Specified by:
enableSchedulesForCompatibleGroup in interface MeasurementScheduleManagerRemote

enableMeasurementTemplates

public void enableMeasurementTemplates(Subject subject,
                                       int[] measurementDefinitionIds)
Specified by:
enableMeasurementTemplates in interface MeasurementScheduleManagerLocal
Specified by:
enableMeasurementTemplates in interface MeasurementScheduleManagerRemote

updateSchedule

public void updateSchedule(Subject subject,
                           MeasurementSchedule schedule)
Description copied from interface: MeasurementScheduleManagerLocal
Reattach a Schedule to a PersitenceContext after a successful check for a valid session

Specified by:
updateSchedule in interface MeasurementScheduleManagerLocal
Specified by:
updateSchedule in interface MeasurementScheduleManagerRemote
Parameters:
subject - A subject that must be valid
schedule - A MeasurementSchedule to persist.

updateSchedulesForResource

public void updateSchedulesForResource(Subject subject,
                                       int resourceId,
                                       int[] measurementDefinitionIds,
                                       long collectionInterval)
Description copied from interface: MeasurementScheduleManagerLocal
Enables all collection schedules attached to the given resource whose schedules are based off the given definitions. This does not enable the "templates" (aka definitions).

Specified by:
updateSchedulesForResource in interface MeasurementScheduleManagerLocal
Specified by:
updateSchedulesForResource in interface MeasurementScheduleManagerRemote

updateSchedulesForCompatibleGroup

public void updateSchedulesForCompatibleGroup(Subject subject,
                                              int groupId,
                                              int[] measurementDefinitionIds,
                                              long collectionInterval)
Enables all collection schedules attached to the given compatible group whose schedules are based off the given definitions. This does not enable the "templates" (aka definitions). If the passed group is not compatible or does not exist an Exception is thrown.

Specified by:
updateSchedulesForCompatibleGroup in interface MeasurementScheduleManagerLocal
Specified by:
updateSchedulesForCompatibleGroup in interface MeasurementScheduleManagerRemote
Parameters:
subject - Subject of the caller
measurementDefinitionIds - the definitions on which the schedules to update are based
groupId - ID of the group
collectionInterval - the new interval
See Also:
org.rhq.enterprise.server.measurement.MeasurementScheduleManagerLocal#updateSchedulesForCompatibleGroup(org.rhq.core.domain.auth.Subject, int[], int, long)

updateMeasurementTemplates

public void updateMeasurementTemplates(Subject subject,
                                       int[] measurementDefinitionIds,
                                       long collectionInterval)
Specified by:
updateMeasurementTemplates in interface MeasurementScheduleManagerLocal
Specified by:
updateMeasurementTemplates in interface MeasurementScheduleManagerRemote

findSchedulesByCriteria

public PageList<MeasurementSchedule> findSchedulesByCriteria(Subject subject,
                                                             MeasurementScheduleCriteria criteria)
Specified by:
findSchedulesByCriteria in interface MeasurementScheduleManagerLocal
Specified by:
findSchedulesByCriteria in interface MeasurementScheduleManagerRemote


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