org.rhq.enterprise.server.core
Class AgentManagerBean

java.lang.Object
  extended by org.rhq.enterprise.server.core.AgentManagerBean
All Implemented Interfaces:
AgentManagerLocal

public class AgentManagerBean
extends Object
implements AgentManagerLocal

Manages the access to Agent objects.

Some of these methods need to execute as fast as possible. So, @ExcludeDefaultInterceptors has been added to all methods that don't explicitly need a permission check (those without Subject as the first parameter).

Author:
John Mazzitelli

Constructor Summary
AgentManagerBean()
           
 
Method Summary
 void agentIsAlive(org.rhq.core.domain.resource.Agent agent)
          This method should only be called when it is confirmed that an agent is alive.
 void agentIsShuttingDown(String agentName)
          This method is called whenever an agent is going down.
 void checkForSuspectAgents()
          Call this method to see if there are agents that we might suspect are down.
 void createAgent(org.rhq.core.domain.resource.Agent agent)
          Persists a new agent.
 void deleteAgent(org.rhq.core.domain.resource.Agent agent)
          Deletes an existing agent.
 org.rhq.core.domain.resource.Agent getAgentByAddressAndPort(String address, int port)
          Given an agent's address and port, this will look up and return the Agent associated with that address and port.
 org.rhq.core.domain.resource.Agent getAgentByAgentToken(String token)
          Given an agent token string, this will look up and return the Agent associated with that token.
 org.rhq.core.domain.resource.Agent getAgentByID(int agentId)
          Given an agent id, this will look up and return the Agent with that id.
 org.rhq.core.domain.resource.Agent getAgentByName(String agentName)
          Given an agent name, this will look up and return the Agent with that name.
 org.rhq.core.domain.resource.Agent getAgentByResourceId(org.rhq.core.domain.auth.Subject subject, int resourceId)
          Given a resource ID, this will return the agent responsible for servicing that resource.
 AgentClient getAgentClient(org.rhq.core.domain.resource.Agent agent)
          Returns an agent client that can be used to send commands to the specified JON agent.
 AgentClient getAgentClient(org.rhq.core.domain.auth.Subject subject, int resourceId)
          Returns an agent client that can be used to send commands to the JON agent that managed the specified resource.
 int getAgentCount()
          Returns the total number of agents that are in inventory.
 File getAgentDownloadDir()
          The directory on the server's file system where the agent update version file and binary file are found.
 Integer getAgentIdByName(String agentName)
          Given an agent name, this will return the agent id.
 Integer getAgentIdByResourceId(int resourceId)
          Given a resource ID, this will return the agent id responsible for servicing that resource.
 Integer getAgentIdByScheduleId(int scheduleId)
          Given a schedule ID, this will return the agent responsible for servicing that scheduleId.
 org.rhq.core.domain.util.PageList<org.rhq.core.domain.resource.Agent> getAgentsByServer(org.rhq.core.domain.auth.Subject subject, Integer serverId, org.rhq.core.domain.util.PageControl pageControl)
          Methods with page control are typically accessed by the GUI, as such apply permission check.
 File getAgentUpdateBinaryFile()
          Returns the path on the server's file system where the agent update binary is found.
 File getAgentUpdateVersionFile()
          Returns the path on the server's file system where the agent update version file is found.
 Properties getAgentUpdateVersionFileContent()
          Returns the content of the agent update version file, which simply consists of some name/value pairs.
 List<org.rhq.core.domain.resource.Agent> getAllAgents()
          Returns a collection of all agents currently in inventory.
 boolean isAgentBackfilled(int agentId)
          Returns true if the agent is "suspect" and has been backfilled.
 boolean isAgentVersionSupported(AgentVersion agentVersionInfo)
          Determines if the given agent version is supported by this server.
 Boolean pingAgentByResourceId(org.rhq.core.domain.auth.Subject subject, int resourceId)
          Returns true indicating successful ping of agent.
 void setAgentBackfilled(int agentId, boolean backfilled)
           
 org.rhq.core.domain.resource.Agent updateAgent(org.rhq.core.domain.resource.Agent agent)
          Updates an existing agent.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AgentManagerBean

public AgentManagerBean()
Method Detail

createAgent

public void createAgent(org.rhq.core.domain.resource.Agent agent)
Description copied from interface: AgentManagerLocal
Persists a new agent.

Specified by:
createAgent in interface AgentManagerLocal

deleteAgent

public void deleteAgent(org.rhq.core.domain.resource.Agent agent)
Description copied from interface: AgentManagerLocal
Deletes an existing agent.

Specified by:
deleteAgent in interface AgentManagerLocal

updateAgent

public org.rhq.core.domain.resource.Agent updateAgent(org.rhq.core.domain.resource.Agent agent)
Description copied from interface: AgentManagerLocal
Updates an existing agent.

Specified by:
updateAgent in interface AgentManagerLocal
Parameters:
agent - the agent to be updated, with the new data in it
Returns:
an updated (attached) copy of the passed-in agent

getAgentClient

public AgentClient getAgentClient(org.rhq.core.domain.resource.Agent agent)
Description copied from interface: AgentManagerLocal
Returns an agent client that can be used to send commands to the specified JON agent.

Specified by:
getAgentClient in interface AgentManagerLocal
Parameters:
agent - a JON agent
Returns:
an agent client that can be used to send commands to the specified JON agent

getAgentClient

public AgentClient getAgentClient(org.rhq.core.domain.auth.Subject subject,
                                  int resourceId)
Description copied from interface: AgentManagerLocal
Returns an agent client that can be used to send commands to the JON agent that managed the specified resource.

Specified by:
getAgentClient in interface AgentManagerLocal
resourceId - the ID of the resource whose agent is to be returned
Returns:
an agent client that can be used to send commands to the JON agent that manages the resource

agentIsShuttingDown

public void agentIsShuttingDown(String agentName)
Description copied from interface: AgentManagerLocal
This method is called whenever an agent is going down.

This will usually be triggered when an agent explicitly tells us that it is shutting down. See CoreServerService.agentIsShuttingDown(String).

Specified by:
agentIsShuttingDown in interface AgentManagerLocal
Parameters:
agentName - the name of the agent that is going down

agentIsAlive

public void agentIsAlive(org.rhq.core.domain.resource.Agent agent)
Description copied from interface: AgentManagerLocal
This method should only be called when it is confirmed that an agent is alive. This can perform some tasks that can only be done when it is known that the agent is up.

Specified by:
agentIsAlive in interface AgentManagerLocal
Parameters:
agent - the agent that is confirmed alive and well

checkForSuspectAgents

public void checkForSuspectAgents()
Description copied from interface: AgentManagerLocal
Call this method to see if there are agents that we might suspect are down. This is periodically called via our scheduled job CheckForSuspectedAgentsJob.

Specified by:
checkForSuspectAgents in interface AgentManagerLocal

getAllAgents

public List<org.rhq.core.domain.resource.Agent> getAllAgents()
Description copied from interface: AgentManagerLocal
Returns a collection of all agents currently in inventory.

Specified by:
getAllAgents in interface AgentManagerLocal
Returns:
list of all known agents in inventory

getAgentsByServer

public org.rhq.core.domain.util.PageList<org.rhq.core.domain.resource.Agent> getAgentsByServer(org.rhq.core.domain.auth.Subject subject,
                                                                                               Integer serverId,
                                                                                               org.rhq.core.domain.util.PageControl pageControl)
Methods with page control are typically accessed by the GUI, as such apply permission check.

Specified by:
getAgentsByServer in interface AgentManagerLocal
serverId - the server to filter the agent list by. pass null to view unfiltered results.
Returns:
list of all known agents in inventory

getAgentCount

public int getAgentCount()
Description copied from interface: AgentManagerLocal
Returns the total number of agents that are in inventory.

Specified by:
getAgentCount in interface AgentManagerLocal
Returns:
total agent count

getAgentByAgentToken

public org.rhq.core.domain.resource.Agent getAgentByAgentToken(String token)
Description copied from interface: AgentManagerLocal
Given an agent token string, this will look up and return the Agent associated with that token. If the given token is invalid, null is returned.

Specified by:
getAgentByAgentToken in interface AgentManagerLocal
Parameters:
token - the agent token
Returns:
the agent whose agent token matches the given token; null if there is no agent with the given token

getAgentByName

public org.rhq.core.domain.resource.Agent getAgentByName(String agentName)
Description copied from interface: AgentManagerLocal
Given an agent name, this will look up and return the Agent with that name. If no agent with the given name exists, null is returned.

Specified by:
getAgentByName in interface AgentManagerLocal
Returns:
the agent whose name matches the given name; null if there is no agent with the given name

getAgentByID

public org.rhq.core.domain.resource.Agent getAgentByID(int agentId)
Description copied from interface: AgentManagerLocal
Given an agent id, this will look up and return the Agent with that id. If no agent with the given name exists, null is returned.

Specified by:
getAgentByID in interface AgentManagerLocal
Returns:
the agent whose id matches the given id; null if there is no agent with the given id

getAgentByAddressAndPort

public org.rhq.core.domain.resource.Agent getAgentByAddressAndPort(String address,
                                                                   int port)
Description copied from interface: AgentManagerLocal
Given an agent's address and port, this will look up and return the Agent associated with that address and port. If no agent is found, null is returned.

Specified by:
getAgentByAddressAndPort in interface AgentManagerLocal
Parameters:
address - the address that the agent is bound to
port - the port at the given address that the agent is listening on
Returns:
the agent to be known at the given address and port; null if there is no agent with the given token

getAgentByResourceId

public org.rhq.core.domain.resource.Agent getAgentByResourceId(org.rhq.core.domain.auth.Subject subject,
                                                               int resourceId)
Description copied from interface: AgentManagerLocal
Given a resource ID, this will return the agent responsible for servicing that resource.

Specified by:
getAgentByResourceId in interface AgentManagerLocal
Returns:
the agent that services the resource, or null if the resource ID was invalid

getAgentIdByResourceId

public Integer getAgentIdByResourceId(int resourceId)
Description copied from interface: AgentManagerLocal
Given a resource ID, this will return the agent id responsible for servicing that resource.

Specified by:
getAgentIdByResourceId in interface AgentManagerLocal
Returns:
the agentId that services the resource, or null if the resource ID was invalid

getAgentIdByName

public Integer getAgentIdByName(String agentName)
Description copied from interface: AgentManagerLocal
Given an agent name, this will return the agent id.

Specified by:
getAgentIdByName in interface AgentManagerLocal
Returns:
the agent ID or null if there is no agent with the given name

getAgentIdByScheduleId

public Integer getAgentIdByScheduleId(int scheduleId)
Description copied from interface: AgentManagerLocal
Given a schedule ID, this will return the agent responsible for servicing that scheduleId.

Specified by:
getAgentIdByScheduleId in interface AgentManagerLocal
Returns:
the agentId that services the resource, or null if the schedule ID was invalid

isAgentVersionSupported

public boolean isAgentVersionSupported(AgentVersion agentVersionInfo)
Description copied from interface: AgentManagerLocal
Determines if the given agent version is supported by this server. In other words, this will return true if this server can talk to any agent of the given version.

Specified by:
isAgentVersionSupported in interface AgentManagerLocal
Parameters:
agentVersionInfo - the version of the agent to verify
Returns:
true if this server can support an agent with the given version; if the server knows it cannot communicate successfully with an agent of that version, false will be returned

getAgentUpdateVersionFile

public File getAgentUpdateVersionFile()
                               throws Exception
Description copied from interface: AgentManagerLocal
Returns the path on the server's file system where the agent update version file is found. The agent update version file contains information about the agent update binary, such as what version it is.

Specified by:
getAgentUpdateVersionFile in interface AgentManagerLocal
Returns:
agent update version file location
Throws:
Exception - if the file could not be created or found

getAgentUpdateVersionFileContent

public Properties getAgentUpdateVersionFileContent()
                                            throws Exception
Description copied from interface: AgentManagerLocal
Returns the content of the agent update version file, which simply consists of some name/value pairs. The agent update version file contains information about the agent update binary, such as what version it is.

Specified by:
getAgentUpdateVersionFileContent in interface AgentManagerLocal
Returns:
version properties found in the agent update version file.
Throws:
Exception - if cannot read the agent update version file

getAgentUpdateBinaryFile

public File getAgentUpdateBinaryFile()
                              throws Exception
Description copied from interface: AgentManagerLocal
Returns the path on the server's file system where the agent update binary is found. This is the actual agent distribution that can be installed on the agent machines.

Specified by:
getAgentUpdateBinaryFile in interface AgentManagerLocal
Returns:
agent update binary location
Throws:
Exception - if the binary file does not exist

getAgentDownloadDir

public File getAgentDownloadDir()
                         throws Exception
Description copied from interface: AgentManagerLocal
The directory on the server's file system where the agent update version file and binary file are found.

Specified by:
getAgentDownloadDir in interface AgentManagerLocal
Returns:
directory where the agent downloads are found
Throws:
Exception - if could not determine the location or it does not exist

setAgentBackfilled

public void setAgentBackfilled(int agentId,
                               boolean backfilled)
Specified by:
setAgentBackfilled in interface AgentManagerLocal

isAgentBackfilled

public boolean isAgentBackfilled(int agentId)
Description copied from interface: AgentManagerLocal
Returns true if the agent is "suspect" and has been backfilled. A "suspect agent" means one that the server suspects is down. When an agent is suspect, all of its resources, including the platform, will be backfilled with DOWN availabilities.

Specified by:
isAgentBackfilled in interface AgentManagerLocal
Parameters:
agentId - the id of the agent
Returns:
true if the agent is a suspect agent and has been backfilled

pingAgentByResourceId

public Boolean pingAgentByResourceId(org.rhq.core.domain.auth.Subject subject,
                                     int resourceId)
Description copied from interface: AgentManagerLocal
Returns true indicating successful ping of agent. Exposed so server could initiate N requests so gwt clients wont face Single Origin Policy issues.

Specified by:
pingAgentByResourceId in interface AgentManagerLocal
Returns:
true if the agent was successfully pinged.


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