org.cougaar.pizza.relay
Class RSVPRelaySource

java.lang.Object
  extended byorg.cougaar.pizza.relay.RSVPRelaySource
All Implemented Interfaces:
org.cougaar.core.relay.Relay, org.cougaar.core.relay.Relay.Source, java.io.Serializable, org.cougaar.core.util.UniqueObject

public class RSVPRelaySource
extends java.lang.Object
implements org.cougaar.core.relay.Relay.Source, org.cougaar.core.util.UniqueObject

A source-side Relay for RSVPs.

As responses come back from remote agents, the infrastrusture (RelayLP) calls updateResponse(), and entries are added to the PizzaPreferences object.

See Also:
InvitePlugin, PizzaPreferences, Serialized Form

Nested Class Summary
 
Nested classes inherited from class org.cougaar.core.relay.Relay
org.cougaar.core.relay.Relay.Source, org.cougaar.core.relay.Relay.Target, org.cougaar.core.relay.Relay.TargetFactory, org.cougaar.core.relay.Relay.Token
 
Field Summary
 
Fields inherited from interface org.cougaar.core.relay.Relay
CONTENT_CHANGE, NO_CHANGE, RESPONSE_CHANGE
 
Constructor Summary
RSVPRelaySource(org.cougaar.core.util.UID uid, org.cougaar.core.mts.MessageAddress target, java.lang.Object query, PizzaPreferences pizzaPreferences)
          Create a new Relay Source whose content is the query, and which will accumulate responses in the given PizzaPreferences object.
 
Method Summary
 java.lang.Object getContent()
          The query in the relay.
 PizzaPreferences getPizzaPrefs()
           
 org.cougaar.core.relay.Relay.TargetFactory getTargetFactory()
          Get the Factory for RSVPTargets.
 java.util.Set getTargets()
          Who gets this invitation?
 org.cougaar.core.util.UID getUID()
          Implemented for UniqueObject interface.
 void setUID(org.cougaar.core.util.UID uid)
          Does nothing - not allowed to reset UID.
 java.lang.String toString()
           
 int updateResponse(org.cougaar.core.mts.MessageAddress target, java.lang.Object response)
          Record responses from remote agents as they come in on the PizzaPreferences object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

RSVPRelaySource

public RSVPRelaySource(org.cougaar.core.util.UID uid,
                       org.cougaar.core.mts.MessageAddress target,
                       java.lang.Object query,
                       PizzaPreferences pizzaPreferences)
Create a new Relay Source whose content is the query, and which will accumulate responses in the given PizzaPreferences object.

Method Detail

getTargets

public java.util.Set getTargets()
Who gets this invitation?

Specified by:
getTargets in interface org.cougaar.core.relay.Relay.Source
Returns:
set of targets (For us, just one member - the AttributeBasedAddress)

getContent

public java.lang.Object getContent()
The query in the relay.

Specified by:
getContent in interface org.cougaar.core.relay.Relay.Source
Returns:
the query in the RSVP - meat or veg?

getTargetFactory

public org.cougaar.core.relay.Relay.TargetFactory getTargetFactory()
Get the Factory for RSVPTargets.

This factory creates a stand-alone Relay.Target implementation, simply copying over the content (our query). If we implemented the Relay.Target and Relay.Source in the same Class, we'd want to ensure that the target had an empty set of target addresses, to avoid re-propagating the Relay from the target agents.

If your Relay.Target was also a Relay.Source and did include target addresses, this could lead to endless pinging in this case where the target address is an ABA broadcast to all members of the community.

Specified by:
getTargetFactory in interface org.cougaar.core.relay.Relay.Source
Returns:
target factory that makes a stand-alone Relay Target

updateResponse

public int updateResponse(org.cougaar.core.mts.MessageAddress target,
                          java.lang.Object response)
Record responses from remote agents as they come in on the PizzaPreferences object.

Note that we assume the response will be a RSVPReply.

If INFO logging is on, tells how long we had to wait until all responses came back.

Specified by:
updateResponse in interface org.cougaar.core.relay.Relay.Source
Returns:
Relay.RESPONSE_CHANGE - since every time we get a response, we want to examine it

getPizzaPrefs

public PizzaPreferences getPizzaPrefs()
Returns:
the PizzaPreferences object in which our answers are collected

getUID

public org.cougaar.core.util.UID getUID()
Implemented for UniqueObject interface.

Specified by:
getUID in interface org.cougaar.core.util.UniqueObject
Returns:
the UID of this UniqueObject.

setUID

public void setUID(org.cougaar.core.util.UID uid)
Does nothing - not allowed to reset UID. Implemented for UniqueObject interface.

Specified by:
setUID in interface org.cougaar.core.util.UniqueObject

toString

public java.lang.String toString()