Hyperic HQ Plugin API v. 4.4.0.2

org.hyperic.hq.measurement.server.session
Class MeasurementManagerEJBImpl

java.lang.Object
  extended by org.hyperic.hq.measurement.server.session.SessionEJB
      extended by org.hyperic.hq.measurement.server.session.MeasurementManagerEJBImpl
All Implemented Interfaces:
java.io.Serializable, javax.ejb.EnterpriseBean, javax.ejb.SessionBean

public class MeasurementManagerEJBImpl
extends SessionEJB
implements javax.ejb.SessionBean

The MeasurementManager provides APIs to deal with Measurement objects.

See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.hyperic.hq.measurement.server.session.SessionEJB
_mpm, DATASOURCE_NAME
 
Constructor Summary
MeasurementManagerEJBImpl()
           
 
Method Summary
 void buildMeasurementEvent(MeasurementEvent event)
          Initializes the units and resource properties of a measurement event
 void checkConfiguration(AuthzSubject subject, AppdefEntityID entity, ConfigResponse config)
          Check a configuration to see if it returns DSNs which the agent can use to successfully monitor an entity.
 java.util.List createMeasurements(AppdefEntityID id, java.lang.Integer[] templates, long[] intervals, ConfigResponse props)
          Create Measurement objects based their templates
 java.util.List createMeasurements(AuthzSubject subject, AppdefEntityID id, java.lang.Integer[] templates, ConfigResponse props)
          Create Measurement objects based their templates and default intervals
 java.util.List createMeasurements(AuthzSubject subject, AppdefEntityID id, java.lang.Integer[] templates, long[] intervals, ConfigResponse props)
          Create Measurements and enqueue for scheduling after commit
 void disableMeasurements(AuthzSubject subject, Agent agent, AppdefEntityID[] ids, boolean isAsyncDelete)
          Disable all measurements for the given resources.
 void disableMeasurements(AuthzSubject subject, AppdefEntityID id)
          Disable all Measurements for a resource
 void disableMeasurements(AuthzSubject subject, AppdefEntityID agentId, AppdefEntityID[] ids)
          Disable all measurements for the given resources.
 void disableMeasurements(AuthzSubject subject, AppdefEntityID id, java.lang.Integer[] tids)
          Disable measurements for an instance Enqueues reschedule events after commit
 void disableMeasurements(AuthzSubject subject, Resource res)
          Disable all Measurements for a resource
 void disableMeasurements(AuthzSubject subject, Resource res, boolean isAsyncDelete)
          Disable all Measurements for a resource
 void ejbActivate()
           
 void ejbCreate()
           
 void ejbPassivate()
           
 void ejbPostCreate()
           
 void ejbRemove()
           
 void enableDefaultMeasurements(AuthzSubject subj, Resource r)
          Enable the default on metrics for a given resource, enqueue for scheduling after commit
 void enableMeasurement(AuthzSubject subject, java.lang.Integer mId, long interval)
          Enable the Measurement and enqueue for scheduling after commit
 void enableMeasurements(AuthzSubject subject, AppdefEntityID[] aeids, java.lang.Integer[] mtids, long interval)
          Set the interval of Measurements based their template ID's Enable Measurements and enqueue for scheduling after commit
 void enableMeasurements(AuthzSubject subject, java.lang.Integer[] mids)
          Enable a collection of metrics, enqueue for scheduling after commit
 java.util.List findAgentOffsetTuples()
          Find a list of tuples (of size 4) consisting of the Agent the Platform it manages the Server representing the Agent the Measurement that contains the Server Offset value
 java.util.List findAllEnabledMeasurementsAndTemplates()
           
 java.util.List findDesignatedMeasurements(AppdefEntityID id)
          Look up a List of designated Measurements for an entity
 java.util.Map findDesignatedMeasurements(AuthzSubject subject, AppdefEntityID[] ids, java.lang.String cat)
          Look up a Map of Measurements for a Category XXX: This method needs to be re-thought.
 java.util.List findDesignatedMeasurements(AuthzSubject subject, AppdefEntityID id, java.lang.String cat)
          Look up a list of designated Measurements for an entity for a category
 java.util.List findDesignatedMeasurements(AuthzSubject subject, ResourceGroup g, java.lang.String cat)
          Look up a list of designated Measurements for an group for a category
 java.util.List findEnabledMeasurements(AuthzSubject subject, AppdefEntityID id, java.lang.String cat)
          Look up a list of enabled Measurements for a category
 java.util.Map findEnabledMeasurements(java.util.Collection aeids)
           
 Measurement findMeasurement(AuthzSubject subject, java.lang.Integer tid, AppdefEntityID aeid)
          Find the Measurement corresponding to the given MeasurementTemplate id and instance id.
 Measurement findMeasurement(AuthzSubject subject, java.lang.Integer tid, java.lang.Integer iid, boolean allowStale)
          Look up a Measurement, allowing for the query to return a stale copy of the Measurement (for efficiency reasons).
 Measurement findMeasurementById(java.lang.Integer mid)
           
 java.lang.Integer[] findMeasurementIds(AuthzSubject subject, java.lang.Integer tid, java.lang.Integer[] ids)
          Look up a list of Measurements for a template and instances
 java.util.List findMeasurements(AuthzSubject subject, AppdefEntityID id, java.lang.String cat, PageControl pc)
          Look up a list of Measurements for a category XXX: Why is this method called findMeasurements() but only returns enabled measurements if cat == null??
 java.util.List findMeasurements(AuthzSubject subject, java.lang.Integer tid, AppdefEntityID[] aeids)
          Look up a list of Measurements for a template and instances
 java.util.Map findMeasurements(AuthzSubject subject, java.util.Map resIdsToTemplIds)
           
 java.util.List findMeasurements(AuthzSubject subject, Resource res)
          XXX: not sure why all the findMeasurements require an authz if they do not check the viewPermissions??
 java.util.List findMeasurementsByCategory(java.lang.String cat)
          Look up a list of Measurement objects by category
 java.util.List findMetricCountSummaries()
          Gets a summary of the metrics which are scheduled for collection, across all resource types and metrics.
 java.util.Map findMetricIntervals(AuthzSubject subject, AppdefEntityID[] aeids, java.lang.Integer[] tids)
          Look up a list of Measurement intervals for template IDs.
 java.util.Map findNumMetricsPerAgent()
          Get the # of metrics that each agent is collecting.
 Measurement getAvailabilityMeasurement(AuthzSubject subject, AppdefEntityID id)
          Deprecated. Use getAvailabilityMeasurement(Resource) instead.
 Measurement getAvailabilityMeasurement(Resource r)
          Get an Availability Measurement by Resource.
 java.util.Map getAvailMeasurements(java.util.Collection resources)
          TODO: scottmf, need to do some more work to handle other authz resource types other than platform, server, service, and group
 java.util.Map getEnabledMeasurements(java.util.List resources)
           
 int getEnabledMetricsCount(AuthzSubject subject, AppdefEntityID id)
          Count of metrics enabled for a particular entity
 void getLiveMeasurementValues(AuthzSubject subject, AppdefEntityID id)
          Get the live measurement values for a given resource.
 Measurement getMeasurement(AuthzSubject s, Resource r, java.lang.String alias)
          Look up a Measurement for a Resource and Measurement alias
 Measurement getMeasurement(java.lang.Integer mid)
          Get a Measurement by Id.
 java.util.List getMeasurements(java.lang.Integer[] tids, java.lang.Integer[] aeids)
           
static org.hyperic.hq.measurement.shared.MeasurementManagerLocal getOne()
           
 void handleCreateRefreshEvents(java.util.List events)
          Handle events from the MeasurementEnabler.
 void handleResourceDelete(Resource r)
          Resource to be deleted, dissociate metrics from resource
 int removeOrphanedMeasurements()
          Remove all measurements no longer associated with a resource.
 void setSessionContext(javax.ejb.SessionContext ctx)
           
 void syncPluginMetrics(java.lang.String plugin)
           
 void updateMeasurementInterval(AuthzSubject subject, java.lang.Integer mId, long interval)
           
 
Methods inherited from class org.hyperic.hq.measurement.server.session.SessionEJB
checkDeletePermission, checkModifyPermission, checkTimeArguments, deleteMetricProblems, getAgent, getAgent, getAgentMan, getAuthzSubjectManager, getAvailabilityDataDAO, getBaselineDAO, getCategoryDAO, getDataMan, getInitialContext, getMeasurementDAO, getMeasurementTemplateDAO, getMetricProblemDAO, getMonitorableTypeDAO, getMPM, getProductMan, getResource, getScheduleRevNumDAO, getSRNManager, getTemplateMan
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MeasurementManagerEJBImpl

public MeasurementManagerEJBImpl()
Method Detail

createMeasurements

public java.util.List createMeasurements(AppdefEntityID id,
                                         java.lang.Integer[] templates,
                                         long[] intervals,
                                         ConfigResponse props)
                                  throws MeasurementCreateException,
                                         TemplateNotFoundException
Create Measurement objects based their templates

Parameters:
templates - List of Integer template IDs to add
id - instance ID (appdef resource) the templates are for
intervals - Millisecond interval that the measurement is polled
props - Configuration data for the instance
Returns:
a List of the associated Measurement objects
Throws:
MeasurementCreateException
TemplateNotFoundException

createMeasurements

public java.util.List createMeasurements(AuthzSubject subject,
                                         AppdefEntityID id,
                                         java.lang.Integer[] templates,
                                         long[] intervals,
                                         ConfigResponse props)
                                  throws PermissionException,
                                         MeasurementCreateException,
                                         TemplateNotFoundException
Create Measurements and enqueue for scheduling after commit

Returns:
List of Measurements
Throws:
PermissionException
MeasurementCreateException
TemplateNotFoundException

createMeasurements

public java.util.List createMeasurements(AuthzSubject subject,
                                         AppdefEntityID id,
                                         java.lang.Integer[] templates,
                                         ConfigResponse props)
                                  throws PermissionException,
                                         MeasurementCreateException,
                                         TemplateNotFoundException
Create Measurement objects based their templates and default intervals

Parameters:
templates - List of Integer template IDs to add
id - instance ID (appdef resource) the templates are for
props - Configuration data for the instance
Returns:
List of Measurements
Throws:
PermissionException
MeasurementCreateException
TemplateNotFoundException

findMeasurementById

public Measurement findMeasurementById(java.lang.Integer mid)

removeOrphanedMeasurements

public int removeOrphanedMeasurements()
Remove all measurements no longer associated with a resource.

Returns:
The number of Measurement objects removed.

getMeasurement

public Measurement getMeasurement(AuthzSubject s,
                                  Resource r,
                                  java.lang.String alias)
                           throws MeasurementNotFoundException
Look up a Measurement for a Resource and Measurement alias

Returns:
a The Measurement for the Resource of the given alias.
Throws:
MeasurementNotFoundException

getMeasurement

public Measurement getMeasurement(java.lang.Integer mid)
Get a Measurement by Id.


getLiveMeasurementValues

public void getLiveMeasurementValues(AuthzSubject subject,
                                     AppdefEntityID id)
                              throws PermissionException,
                                     LiveMeasurementException,
                                     MeasurementNotFoundException
Get the live measurement values for a given resource.

Parameters:
id - The id of the resource
Throws:
PermissionException
LiveMeasurementException
MeasurementNotFoundException

getEnabledMetricsCount

public int getEnabledMetricsCount(AuthzSubject subject,
                                  AppdefEntityID id)
Count of metrics enabled for a particular entity

Returns:
a The number of metrics enabled for the given entity

findMeasurements

public java.util.Map findMeasurements(AuthzSubject subject,
                                      java.util.Map resIdsToTemplIds)
                               throws PermissionException
Parameters:
subject - AuthzSubject
resIdsToTemplIds - Map of Integer of resourceIds to List of templateIds
Returns:
Map of Resource to List of Measurements
Throws:
PermissionException

findMeasurement

public Measurement findMeasurement(AuthzSubject subject,
                                   java.lang.Integer tid,
                                   AppdefEntityID aeid)
                            throws MeasurementNotFoundException
Find the Measurement corresponding to the given MeasurementTemplate id and instance id.

Parameters:
tid - The MeasurementTemplate id
aeid - The entity id.
Returns:
a Measurement value
Throws:
MeasurementNotFoundException

findMeasurement

public Measurement findMeasurement(AuthzSubject subject,
                                   java.lang.Integer tid,
                                   java.lang.Integer iid,
                                   boolean allowStale)
                            throws MeasurementNotFoundException
Look up a Measurement, allowing for the query to return a stale copy of the Measurement (for efficiency reasons).

Parameters:
subject - The subject.
tid - The template Id.
iid - The instance Id.
allowStale - true to allow stale copies of an alert definition in the query results; false to never allow stale copies, potentially always forcing a sync with the database.
Returns:
The Measurement
Throws:
MeasurementNotFoundException

findMeasurements

public java.util.List findMeasurements(AuthzSubject subject,
                                       java.lang.Integer tid,
                                       AppdefEntityID[] aeids)
Look up a list of Measurements for a template and instances

Returns:
a list of Measurement's

findMeasurementIds

public java.lang.Integer[] findMeasurementIds(AuthzSubject subject,
                                              java.lang.Integer tid,
                                              java.lang.Integer[] ids)
Look up a list of Measurements for a template and instances

Returns:
An array of Measurement ids.

findMeasurements

public java.util.List findMeasurements(AuthzSubject subject,
                                       AppdefEntityID id,
                                       java.lang.String cat,
                                       PageControl pc)
Look up a list of Measurements for a category XXX: Why is this method called findMeasurements() but only returns enabled measurements if cat == null??

Returns:
a List of Measurement objects.

getEnabledMeasurements

public java.util.Map getEnabledMeasurements(java.util.List resources)
Parameters:
aeids - List of Resources
Returns:
Map of Integer representing resourceId to List of Measurements

findEnabledMeasurements

public java.util.Map findEnabledMeasurements(java.util.Collection aeids)
Parameters:
aeids - List of AppdefEntityIDs
Returns:
Map of Integer representing resourceId to List of Measurements

findEnabledMeasurements

public java.util.List findEnabledMeasurements(AuthzSubject subject,
                                              AppdefEntityID id,
                                              java.lang.String cat)
Look up a list of enabled Measurements for a category

Returns:
a list of Measurement

findDesignatedMeasurements

public java.util.List findDesignatedMeasurements(AppdefEntityID id)
Look up a List of designated Measurements for an entity

Returns:
A List of Measurements

findDesignatedMeasurements

public java.util.List findDesignatedMeasurements(AuthzSubject subject,
                                                 AppdefEntityID id,
                                                 java.lang.String cat)
Look up a list of designated Measurements for an entity for a category

Returns:
A List of Measurements

findDesignatedMeasurements

public java.util.List findDesignatedMeasurements(AuthzSubject subject,
                                                 ResourceGroup g,
                                                 java.lang.String cat)
Look up a list of designated Measurements for an group for a category

Returns:
A List of Measurements

getAvailabilityMeasurement

public Measurement getAvailabilityMeasurement(AuthzSubject subject,
                                              AppdefEntityID id)
Deprecated. Use getAvailabilityMeasurement(Resource) instead.

Get an Availabilty Measurement by AppdefEntityId


getAvailabilityMeasurement

public Measurement getAvailabilityMeasurement(Resource r)
Get an Availability Measurement by Resource. May return null.


findMeasurementsByCategory

public java.util.List findMeasurementsByCategory(java.lang.String cat)
Look up a list of Measurement objects by category


findDesignatedMeasurements

public java.util.Map findDesignatedMeasurements(AuthzSubject subject,
                                                AppdefEntityID[] ids,
                                                java.lang.String cat)
                                         throws MeasurementNotFoundException
Look up a Map of Measurements for a Category XXX: This method needs to be re-thought. It only returns a single designated metric per category even though HQ supports multiple designates per category.

Returns:
A List of designated Measurements keyed by AppdefEntityID
Throws:
MeasurementNotFoundException

getAvailMeasurements

public java.util.Map getAvailMeasurements(java.util.Collection resources)
TODO: scottmf, need to do some more work to handle other authz resource types other than platform, server, service, and group

Returns:
Map of Integer to List of Measurements, Integer => Resource.getId(),

findMetricIntervals

public java.util.Map findMetricIntervals(AuthzSubject subject,
                                         AppdefEntityID[] aeids,
                                         java.lang.Integer[] tids)
Look up a list of Measurement intervals for template IDs.

Returns:
a map keyed by template ID and values of metric intervals There is no entry if a metric is disabled or does not exist for the given entity or entities. However, if there are multiple entities, and the intervals differ or some enabled/not enabled, then the value will be "0" to denote varying intervals.

findAllEnabledMeasurementsAndTemplates

public java.util.List findAllEnabledMeasurementsAndTemplates()
Returns:
List - [0] = Measurement, [1] MeasurementTemplate

enableMeasurements

public void enableMeasurements(AuthzSubject subject,
                               AppdefEntityID[] aeids,
                               java.lang.Integer[] mtids,
                               long interval)
                        throws MeasurementNotFoundException,
                               MeasurementCreateException,
                               TemplateNotFoundException,
                               PermissionException
Set the interval of Measurements based their template ID's Enable Measurements and enqueue for scheduling after commit

Throws:
MeasurementNotFoundException
MeasurementCreateException
TemplateNotFoundException
PermissionException

enableMeasurements

public void enableMeasurements(AuthzSubject subject,
                               java.lang.Integer[] mids)
                        throws PermissionException
Enable a collection of metrics, enqueue for scheduling after commit

Throws:
PermissionException

enableMeasurement

public void enableMeasurement(AuthzSubject subject,
                              java.lang.Integer mId,
                              long interval)
                       throws PermissionException
Enable the Measurement and enqueue for scheduling after commit

Throws:
PermissionException

enableDefaultMeasurements

public void enableDefaultMeasurements(AuthzSubject subj,
                                      Resource r)
                               throws PermissionException
Enable the default on metrics for a given resource, enqueue for scheduling after commit

Throws:
PermissionException

updateMeasurementInterval

public void updateMeasurementInterval(AuthzSubject subject,
                                      java.lang.Integer mId,
                                      long interval)
                               throws PermissionException
Throws:
PermissionException

disableMeasurements

public void disableMeasurements(AuthzSubject subject,
                                AppdefEntityID agentId,
                                AppdefEntityID[] ids)
                         throws PermissionException,
                                AgentNotFoundException
Disable all measurements for the given resources.

Parameters:
agentId - The entity id to use to look up the agent connection
ids - The list of entitys to unschedule
Throws:
PermissionException
AgentNotFoundException

disableMeasurements

public void disableMeasurements(AuthzSubject subject,
                                Agent agent,
                                AppdefEntityID[] ids,
                                boolean isAsyncDelete)
                         throws PermissionException
Disable all measurements for the given resources.

Parameters:
agent - The agent for the given resources
ids - The list of entitys to unschedule
isAsyncDelete - Indicates whether it is for async delete
Throws:
PermissionException

disableMeasurements

public void disableMeasurements(AuthzSubject subject,
                                AppdefEntityID id)
                         throws PermissionException
Disable all Measurements for a resource

Throws:
PermissionException

disableMeasurements

public void disableMeasurements(AuthzSubject subject,
                                Resource res)
                         throws PermissionException
Disable all Measurements for a resource

Throws:
PermissionException

disableMeasurements

public void disableMeasurements(AuthzSubject subject,
                                Resource res,
                                boolean isAsyncDelete)
                         throws PermissionException
Disable all Measurements for a resource

Throws:
PermissionException

findMeasurements

public java.util.List findMeasurements(AuthzSubject subject,
                                       Resource res)
XXX: not sure why all the findMeasurements require an authz if they do not check the viewPermissions??


disableMeasurements

public void disableMeasurements(AuthzSubject subject,
                                AppdefEntityID id,
                                java.lang.Integer[] tids)
                         throws PermissionException
Disable measurements for an instance Enqueues reschedule events after commit

Throws:
PermissionException

syncPluginMetrics

public void syncPluginMetrics(java.lang.String plugin)

findMetricCountSummaries

public java.util.List findMetricCountSummaries()
Gets a summary of the metrics which are scheduled for collection, across all resource types and metrics.

Returns:
a list of CollectionSummary beans

findAgentOffsetTuples

public java.util.List findAgentOffsetTuples()
Find a list of tuples (of size 4) consisting of the Agent the Platform it manages the Server representing the Agent the Measurement that contains the Server Offset value


findNumMetricsPerAgent

public java.util.Map findNumMetricsPerAgent()
Get the # of metrics that each agent is collecting.

Returns:
a map of Agent onto Longs indicating how many metrics that agent is collecting.

handleCreateRefreshEvents

public void handleCreateRefreshEvents(java.util.List events)
Handle events from the MeasurementEnabler. This method is required to place the operation within a transaction (and session)


checkConfiguration

public void checkConfiguration(AuthzSubject subject,
                               AppdefEntityID entity,
                               ConfigResponse config)
                        throws PermissionException,
                               InvalidConfigException,
                               AppdefEntityNotFoundException
Check a configuration to see if it returns DSNs which the agent can use to successfully monitor an entity. This routine will attempt to get live DSN values from the entity.

Parameters:
entity - Entity to check the configuration for
config - Configuration to check
Throws:
PermissionException
InvalidConfigException
AppdefEntityNotFoundException

getMeasurements

public java.util.List getMeasurements(java.lang.Integer[] tids,
                                      java.lang.Integer[] aeids)
Returns:
List Measurement of MeasurementIds

handleResourceDelete

public void handleResourceDelete(Resource r)
Resource to be deleted, dissociate metrics from resource


buildMeasurementEvent

public void buildMeasurementEvent(MeasurementEvent event)
Initializes the units and resource properties of a measurement event


getOne

public static org.hyperic.hq.measurement.shared.MeasurementManagerLocal getOne()

ejbCreate

public void ejbCreate()
               throws javax.ejb.CreateException
Throws:
javax.ejb.CreateException

ejbPostCreate

public void ejbPostCreate()

ejbActivate

public void ejbActivate()
Specified by:
ejbActivate in interface javax.ejb.SessionBean

ejbPassivate

public void ejbPassivate()
Specified by:
ejbPassivate in interface javax.ejb.SessionBean

ejbRemove

public void ejbRemove()
Specified by:
ejbRemove in interface javax.ejb.SessionBean

setSessionContext

public void setSessionContext(javax.ejb.SessionContext ctx)
Specified by:
setSessionContext in interface javax.ejb.SessionBean

Hyperic HQ Plugin API v. 4.4.0.2

Copyright © 2004-2006 Hyperic, Inc. support@hyperic.net, All Rights Reserved.