org.rhq.core.domain.resource
Class Agent

java.lang.Object
  extended by org.rhq.core.domain.resource.Agent
All Implemented Interfaces:
Serializable

public class Agent
extends Object
implements Serializable

A JON agent.

See Also:
Serialized Form

Nested Class Summary
static class Agent.Status
           
 
Field Summary
static String QUERY_COUNT_ALL
           
static String QUERY_FIND_AGENT_ID_BY_NAME
           
static String QUERY_FIND_AGENT_ID_BY_RESOURCE_ID
           
static String QUERY_FIND_AGENT_ID_BY_SCHEDULE_ID
           
static String QUERY_FIND_ALL
           
static String QUERY_FIND_ALL_SUSPECT_AGENTS
           
static String QUERY_FIND_ALL_WITH_STATUS
           
static String QUERY_FIND_ALL_WITH_STATUS_BY_SERVER
           
static String QUERY_FIND_BY_ADDRESS_AND_PORT
           
static String QUERY_FIND_BY_AFFINITY_GROUP
           
static String QUERY_FIND_BY_AGENT_TOKEN
           
static String QUERY_FIND_BY_NAME
           
static String QUERY_FIND_BY_RESOURCE_ID
           
static String QUERY_FIND_BY_SERVER
           
static String QUERY_FIND_RESOURCE_IDS_FOR_AGENT
           
static String QUERY_FIND_WITHOUT_AFFINITY_GROUP
           
static String QUERY_IS_AGENT_BACKFILLED
           
static String QUERY_REMOVE_SERVER_REFERENCE
           
static String QUERY_SET_AGENT_BACKFILLED
           
static String QUERY_UPDATE_CLEAR_STATUS_BY_IDS
           
static String QUERY_UPDATE_STATUS_BY_AGENT
           
static String QUERY_UPDATE_STATUS_BY_ALERT_DEFINITION
           
static String QUERY_UPDATE_STATUS_BY_MEASUREMENT_BASELINE
           
static String QUERY_UPDATE_STATUS_BY_RESOURCE
           
static String QUERY_UPDATE_STATUS_FOR_ALL
           
static long serialVersionUID
           
 
Constructor Summary
protected Agent()
          Creates a new instance of Agent
  Agent(String name, String address, int port, String remoteEndpoint, String agentToken)
          Constructor for Agent.
 
Method Summary
 void addStatus(Agent.Status newStatus)
          If some subsystem makes a change to some data that this agent cares about (as summarized by the various Agent.Status elements), then that change should be added via this method.
 void clearStatus()
          If this status was non-zero, some scheduled job would have had to come along to perform some work on behalf of this agent.
 boolean equals(Object obj)
           
 String getAddress()
          Returns the machine address that is used to connect to the agent.
 AffinityGroup getAffinityGroup()
          Returns the AffinityGroup this agent currently belongs to.
 String getAgentToken()
          Returns the token string that allows the agent to talk back to the server.
 long getCreatedTime()
          Returns when this agent object was initially created.
 int getId()
           
 Long getLastAvailabilityReport()
          Returns the timestamp when this agent last returned an availability report.
 long getModifiedTime()
          Returns when this agent object was modified - usually when it receives a new security token.
 String getName()
          The agent's name will usually, but is not required to, be the fully qualified domain name of the machine where the agent is running.
 int getPort()
          Returns the port number that the agent is listening to when accepting messages from the server.
 String getRemoteEndpoint()
          The remote endpoint is the full connection string that is to be used to connect to the agent.
 Server getServer()
          Returns the Server this agent is currently communicating to.
 int getStatus()
          Returns 0 if this agent is current.
 List<String> getStatusMessages()
           
 int hashCode()
           
 boolean isBackFilled()
           
 void setAddress(String address)
           
 void setAffinityGroup(AffinityGroup affinityGroup)
          Sets the AffinityGroup this agent should belong to.
 void setAgentToken(String agentToken)
           
 void setBackFilled(boolean backFilled)
           
 void setId(int id)
           
 void setLastAvailabilityReport(Long lastAvailabilityReport)
          Sets the timestamp when this agent last returned an availability report.
 void setName(String name)
           
 void setPort(int port)
           
 void setRemoteEndpoint(String locatorUri)
           
 void setServer(Server server)
          Sets the Server this agent should communicate with.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

serialVersionUID

public static final long serialVersionUID
See Also:
Constant Field Values

QUERY_FIND_BY_NAME

public static final String QUERY_FIND_BY_NAME
See Also:
Constant Field Values

QUERY_FIND_BY_ADDRESS_AND_PORT

public static final String QUERY_FIND_BY_ADDRESS_AND_PORT
See Also:
Constant Field Values

QUERY_FIND_BY_AGENT_TOKEN

public static final String QUERY_FIND_BY_AGENT_TOKEN
See Also:
Constant Field Values

QUERY_FIND_BY_RESOURCE_ID

public static final String QUERY_FIND_BY_RESOURCE_ID
See Also:
Constant Field Values

QUERY_FIND_AGENT_ID_BY_RESOURCE_ID

public static final String QUERY_FIND_AGENT_ID_BY_RESOURCE_ID
See Also:
Constant Field Values

QUERY_FIND_AGENT_ID_BY_NAME

public static final String QUERY_FIND_AGENT_ID_BY_NAME
See Also:
Constant Field Values

QUERY_FIND_AGENT_ID_BY_SCHEDULE_ID

public static final String QUERY_FIND_AGENT_ID_BY_SCHEDULE_ID
See Also:
Constant Field Values

QUERY_FIND_ALL

public static final String QUERY_FIND_ALL
See Also:
Constant Field Values

QUERY_FIND_BY_SERVER

public static final String QUERY_FIND_BY_SERVER
See Also:
Constant Field Values

QUERY_COUNT_ALL

public static final String QUERY_COUNT_ALL
See Also:
Constant Field Values

QUERY_FIND_RESOURCE_IDS_FOR_AGENT

public static final String QUERY_FIND_RESOURCE_IDS_FOR_AGENT
See Also:
Constant Field Values

QUERY_FIND_ALL_SUSPECT_AGENTS

public static final String QUERY_FIND_ALL_SUSPECT_AGENTS
See Also:
Constant Field Values

QUERY_FIND_BY_AFFINITY_GROUP

public static final String QUERY_FIND_BY_AFFINITY_GROUP
See Also:
Constant Field Values

QUERY_FIND_WITHOUT_AFFINITY_GROUP

public static final String QUERY_FIND_WITHOUT_AFFINITY_GROUP
See Also:
Constant Field Values

QUERY_SET_AGENT_BACKFILLED

public static final String QUERY_SET_AGENT_BACKFILLED
See Also:
Constant Field Values

QUERY_IS_AGENT_BACKFILLED

public static final String QUERY_IS_AGENT_BACKFILLED
See Also:
Constant Field Values

QUERY_FIND_ALL_WITH_STATUS_BY_SERVER

public static final String QUERY_FIND_ALL_WITH_STATUS_BY_SERVER
See Also:
Constant Field Values

QUERY_FIND_ALL_WITH_STATUS

public static final String QUERY_FIND_ALL_WITH_STATUS
See Also:
Constant Field Values

QUERY_UPDATE_CLEAR_STATUS_BY_IDS

public static final String QUERY_UPDATE_CLEAR_STATUS_BY_IDS
See Also:
Constant Field Values

QUERY_REMOVE_SERVER_REFERENCE

public static final String QUERY_REMOVE_SERVER_REFERENCE
See Also:
Constant Field Values

QUERY_UPDATE_STATUS_BY_RESOURCE

public static final String QUERY_UPDATE_STATUS_BY_RESOURCE
See Also:
Constant Field Values

QUERY_UPDATE_STATUS_BY_ALERT_DEFINITION

public static final String QUERY_UPDATE_STATUS_BY_ALERT_DEFINITION
See Also:
Constant Field Values

QUERY_UPDATE_STATUS_BY_MEASUREMENT_BASELINE

public static final String QUERY_UPDATE_STATUS_BY_MEASUREMENT_BASELINE
See Also:
Constant Field Values

QUERY_UPDATE_STATUS_BY_AGENT

public static final String QUERY_UPDATE_STATUS_BY_AGENT
See Also:
Constant Field Values

QUERY_UPDATE_STATUS_FOR_ALL

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

Agent

protected Agent()
Creates a new instance of Agent


Agent

public Agent(@NotNull
             String name,
             String address,
             int port,
             String remoteEndpoint,
             String agentToken)
Constructor for Agent.

Parameters:
name -
address -
port -
remoteEndpoint -
agentToken -
Method Detail

getId

public int getId()

setId

public void setId(int id)

getName

@NotNull
public String getName()
The agent's name will usually, but is not required to, be the fully qualified domain name of the machine where the agent is running. In other words, the address. However, there is no technical reason why you cannot have an agent with a name such as "foo". In fact, there are use-cases where the agent name is not the same as the address (e.g. perhaps you expect the machine to periodically change hostnames due to DNS name changes and so you want to name it something more permanent).

Agent names must be unique - no two agents can have the same name.

Returns:
the agent's unique name

setName

public void setName(@NotNull
                    String name)

getAddress

@NotNull
public String getAddress()
Returns the machine address that is used to connect to the agent. This can be either an IP address or a fully qualified host name.

Returns:
the name of the host where the agent is located

setAddress

public void setAddress(@NotNull
                       String address)

getPort

public int getPort()
Returns the port number that the agent is listening to when accepting messages from the server.

Returns:
server socket port being listened to by the agent

setPort

public void setPort(int port)

getAgentToken

@NotNull
public String getAgentToken()
Returns the token string that allows the agent to talk back to the server. If the agent provides an agent token different that this, the server will ignore the agent's messages. The agent gets a new token whenever it registers with the server.

Returns:
agent token string

setAgentToken

public void setAgentToken(@NotNull
                          String agentToken)

getRemoteEndpoint

public String getRemoteEndpoint()
The remote endpoint is the full connection string that is to be used to connect to the agent. If null, a default protocol mechanism will be used. The remote endpoint will usually have both the address and port encoded in it.

Returns:
the endpoint describing where and how to communicate with the agent

setRemoteEndpoint

public void setRemoteEndpoint(String locatorUri)

getCreatedTime

public long getCreatedTime()
Returns when this agent object was initially created.

Returns:
creation time

getModifiedTime

public long getModifiedTime()
Returns when this agent object was modified - usually when it receives a new security token. Other times an agent will be modified is when it registers a new remote endpoint (in the case when the agent changes the port it is listening to, for example).

Returns:
modified time

getLastAvailabilityReport

public Long getLastAvailabilityReport()
Returns the timestamp when this agent last returned an availability report. If null, then this agent has yet to send its very first availability report.

Returns:
timestamp when the last availability report was received from this agent

setLastAvailabilityReport

public void setLastAvailabilityReport(Long lastAvailabilityReport)
Sets the timestamp when this agent last returned an availability report.

Parameters:
lastAvailabilityReport - when the last availability report was received from this agent

getAffinityGroup

public AffinityGroup getAffinityGroup()
Returns the AffinityGroup this agent currently belongs to.

Returns:
the AffinityGroup this agent currently belongs to

setAffinityGroup

public void setAffinityGroup(AffinityGroup affinityGroup)
Sets the AffinityGroup this agent should belong to.

Parameters:
affinityGroup - the AffinityGroup this agent should belong to

getServer

public Server getServer()
Returns the Server this agent is currently communicating to.

Returns:
the Server this agent is currently communicating to

setServer

public void setServer(Server server)
Sets the Server this agent should communicate with.

Parameters:
server - the Server this agent should communicate with

getStatus

public int getStatus()
Returns 0 if this agent is current. Otherwise, returns a mask of Agent.Status elements corresponding to the updates that have occurred that are related to this agent.

Returns:
0 if this agent is current. Otherwise, returns a mask of Agent.Status elements corresponding to the updates that have occurred that are related to this agent.

clearStatus

public void clearStatus()
If this status was non-zero, some scheduled job would have had to come along to perform some work on behalf of this agent. After that work is complete, the status can be reset (set to 0) signifying that no further work needs to be done on this agent (as long as the status remains 0).


addStatus

public void addStatus(Agent.Status newStatus)
If some subsystem makes a change to some data that this agent cares about (as summarized by the various Agent.Status elements), then that change should be added via this method. Periodically, a background job will come along, check the status, and possibly perform work on behalf of this agent based on the type of change.


getStatusMessages

public List<String> getStatusMessages()

isBackFilled

public boolean isBackFilled()

setBackFilled

public void setBackFilled(boolean backFilled)

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

toString

public String toString()
Overrides:
toString in class Object


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