org.rhq.enterprise.server.core.comm
Class KnownAgents

java.lang.Object
  extended by org.rhq.enterprise.server.core.comm.KnownAgents
All Implemented Interfaces:
Serializable

public class KnownAgents
extends Object
implements Serializable

Maintains a list of agents by holding string representations of their remote endpoints. This class implementation is thread safe. Note that this class does not know agents by their name - only by their remote endpoints!

Author:
John Mazzitelli
See Also:
Serialized Form

Constructor Summary
KnownAgents()
          Constructor for KnownAgents.
 
Method Summary
 boolean addAgent(org.jboss.remoting.InvokerLocator endpoint)
          Adds the given remote endpoint to the list of known agents.
 boolean addAgent(String endpoint)
          Adds the given remote endpoint to the list of known agents.
 org.jboss.remoting.InvokerLocator getAgent(String host, int port)
          Given a specific host and port, this will return the associated agent.
 List<org.jboss.remoting.InvokerLocator> getAllAgents()
          Returns a list of all the known agents.
 boolean removeAgent(org.jboss.remoting.InvokerLocator endpoint)
          Removes the given remote endpoint from the list of known agents.
 boolean removeAgent(String endpoint)
          Removes the given remote endpoint from the list of known agents.
 void removeAllAgents()
          Empties the internal list of agents.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

KnownAgents

public KnownAgents()
Constructor for KnownAgents.

Method Detail

addAgent

public boolean addAgent(org.jboss.remoting.InvokerLocator endpoint)
Adds the given remote endpoint to the list of known agents. If the given endpoint does not represent an agent, this method does nothing and simply returns.

Parameters:
endpoint - the endpoint to add if it refers to an agent
Returns:
true if the endpoint was an agent and it was added; false if the endpoint was not an agent and nothing was added to the internal list of known agents

addAgent

public boolean addAgent(String endpoint)
Adds the given remote endpoint to the list of known agents. If the given endpoint does not represent an agent, this method does nothing and simply returns. The given endpoint is a String so you can call this method by directly using a value from Agent.getRemoteEndpoint().

Parameters:
endpoint - the endpoint to add if it refers to an agent
Returns:
true if the endpoint was an agent and it was added; false if the endpoint was not an agent and nothing was added to the internal list of known agents
Throws:
RuntimeException - if the endpoint was malformed and invalid

removeAgent

public boolean removeAgent(org.jboss.remoting.InvokerLocator endpoint)
Removes the given remote endpoint from the list of known agents. If the given endpoint does not already exist, this method does nothing and simply returns false.

Parameters:
endpoint - the endpoint to remove
Returns:
true if the agent existed and was removed; false otherwise

removeAgent

public boolean removeAgent(String endpoint)
Removes the given remote endpoint from the list of known agents. If the given endpoint does not already exist, this method does nothing and simply returns false. The given endpoint is a String so you can call this method by directly using a value from Agent.getRemoteEndpoint().

Parameters:
endpoint - the endpoint to remove
Returns:
true if the agent existed and was removed; false otherwise
Throws:
RuntimeException - if the endpoint was malformed and invalid

getAgent

public org.jboss.remoting.InvokerLocator getAgent(String host,
                                                  int port)
Given a specific host and port, this will return the associated agent. Note that the host must match exactly (no reverse DNS or virtual host IP matching is done with the given host and the known hosts names).

Parameters:
host - the host of the agent to retrieve
port - the port of the agent to retrieve
Returns:
the agent listening on the port on the given host; null if no known agent exists in the list

getAllAgents

public List<org.jboss.remoting.InvokerLocator> getAllAgents()
Returns a list of all the known agents.

Returns:
list of all known agents' endpoints

removeAllAgents

public void removeAllAgents()
Empties the internal list of agents.



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