org.rhq.enterprise.server.resource
Class ResourceAvailabilityManagerBean

java.lang.Object
  extended by org.rhq.enterprise.server.resource.ResourceAvailabilityManagerBean
All Implemented Interfaces:
ResourceAvailabilityManagerLocal

public class ResourceAvailabilityManagerBean
extends Object
implements ResourceAvailabilityManagerLocal

A manager that provides methods for manipulating and querying the cached current availability for Resources.

Author:
Joseph Marques

Constructor Summary
ResourceAvailabilityManagerBean()
           
 
Method Summary
 org.rhq.core.domain.measurement.ResourceAvailability getLatestAvailability(int resourceId)
          Returns the latest availability for the given Resource
 org.rhq.core.domain.measurement.AvailabilityType getLatestAvailabilityType(org.rhq.core.domain.auth.Subject whoami, int resourceId)
          Returns the latest availability type for the given resource.
 void init()
           
 void insertNeededAvailabilityForImportedResources(List<Integer> resourceIds)
          The first time an agent is started and its platform and top-level servers are discovered, the DiscoveryBossBean.mergeInventoryReport(InventoryReport) will use the EntityManager to persist the resource.
 void updateAllResourcesAvailabilitiesForAgent(int agentId, org.rhq.core.domain.measurement.AvailabilityType availabilityType)
          Marks all resources managed by the specified agent as down
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ResourceAvailabilityManagerBean

public ResourceAvailabilityManagerBean()
Method Detail

init

@PostConstruct
public void init()

insertNeededAvailabilityForImportedResources

public void insertNeededAvailabilityForImportedResources(List<Integer> resourceIds)
Description copied from interface: ResourceAvailabilityManagerLocal
The first time an agent is started and its platform and top-level servers are discovered, the DiscoveryBossBean.mergeInventoryReport(InventoryReport) will use the EntityManager to persist the resource. A PostPersist hook exists on the Resource entity to create a corresponding default ResourceAvailability entity. However, when a platform or top-level server is removed from inventory, the agent might rediscover the resource so quickly that InventoryReport merges the resource instead of persisting new ones, bypassing the PostPersist hook. As a result, this method should be called when resources are imported from the auto-discovery portlet (the InventoryStatus is changed from NEW to COMMITTED, which will add the necessary default ResourceAvailability objects to those resources missing them.

Specified by:
insertNeededAvailabilityForImportedResources in interface ResourceAvailabilityManagerLocal
Parameters:
resourceIds - a list of resource ids which should have default ResourceAvailability objects created for them, only if the corresponding data doesn't already exist.

getLatestAvailabilityType

public org.rhq.core.domain.measurement.AvailabilityType getLatestAvailabilityType(org.rhq.core.domain.auth.Subject whoami,
                                                                                  int resourceId)
Description copied from interface: ResourceAvailabilityManagerLocal
Returns the latest availability type for the given resource. This tells you the currently known state of a resource - whether it is UP or DOWN.

Specified by:
getLatestAvailabilityType in interface ResourceAvailabilityManagerLocal
Parameters:
whoami - the user asking for the data
resourceId - the id of the resource
Returns:
the latest availability type for the given resource, null if not known

getLatestAvailability

public org.rhq.core.domain.measurement.ResourceAvailability getLatestAvailability(int resourceId)
Description copied from interface: ResourceAvailabilityManagerLocal
Returns the latest availability for the given Resource

Specified by:
getLatestAvailability in interface ResourceAvailabilityManagerLocal
Parameters:
resourceId - the id of the resource
Returns:
the latest availability for the given Resource

updateAllResourcesAvailabilitiesForAgent

public void updateAllResourcesAvailabilitiesForAgent(int agentId,
                                                     org.rhq.core.domain.measurement.AvailabilityType availabilityType)
Description copied from interface: ResourceAvailabilityManagerLocal
Marks all resources managed by the specified agent as down

Specified by:
updateAllResourcesAvailabilitiesForAgent in interface ResourceAvailabilityManagerLocal
Parameters:
agentId - the id of the agent


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