| org.cougaar.pizza.plugin.PlaceOrderPlugin org.cougaar.pizza.plugin.SDPlaceOrderPlugin
SDPlaceOrderPlugin | public class SDPlaceOrderPlugin extends PlaceOrderPlugin (Code) | | The SDPlaceOrderPlugin extends the
PlaceOrderPlugin to use Service Discovery
to find pizza providers dynamically. Once the plugin receives the
PizzaPreferences object, it publishes a
org.cougaar.pizza.Constants.Verbs.FIND_PROVIDERS task with a Role of
org.cougaar.pizza.Constants.Roles.PIZZAPROVIDER . This task
will be handled by Service Discovery. The plugin then creates and expands the
org.cougaar.pizza.Constants.Verbs.ORDER Task as done in the super class. However, unlike the super class, this plugin waits
until Service Discovery has finished finding a pizza provider and has added a
Disposition on the FindProviders task before it can allocate the pizza subtasks.
ServiceDiscovery will find a provider, creating a PizzaProvider relationship. Then
the plugin continues as in the PlaceOrderPlugin.
If the Expansion on the order task fails, i.e., the provider could not complete the
pizza order, then the plugin will remove the Allocations on the subtasks of the Expansion and
request a new provider from Service Discovery. To exclude the provider that
previously failed, the plugin adds a prepositional phrase of
org.cougaar.pizza.Constants.Prepositions.NOT with the name of the
provider as the indirect object on the FindProviders task. Once a new provider is
found the tasks will be reallocated -- hopefully more succesfully!
|
Method Summary | |
protected void | execute() When we get the PizzaPreferences object (that subscription is changed), ask ServiceDiscovery to find a provider.
Meanwhile, create the root order Task and its expansions - but not yet allocated.
When the FindProviders task is Disposed (a different subscription change),
we have a provider. | protected Entity | getProvider(Disposition disposition) Find a PizzaProvider to try using, avoiding the provider on the given
Disposition if any.
First, retrieve the excluded provider from the
FindProviders task of the Disposition. | protected void | setupSubscriptions() Overrides the super class method. |
execute | protected void execute()(Code) | | When we get the PizzaPreferences object (that subscription is changed), ask ServiceDiscovery to find a provider.
Meanwhile, create the root order Task and its expansions - but not yet allocated.
When the FindProviders task is Disposed (a different subscription change),
we have a provider. Allocate the Order sub-tasks to that provider.
As in the base class, update the AllocationResults as they come in from our provider.
Finally, when the Expansion of the root Order Task changes, see if we got all
our pizza. If not, remove the old Allocations to the old provider, and ask
ServiceDiscovery to find another (different) provider. When that FindProviders
is disposed, we'll try again...
|
getProvider | protected Entity getProvider(Disposition disposition)(Code) | | Find a PizzaProvider to try using, avoiding the provider on the given
Disposition if any.
First, retrieve the excluded provider from the
FindProviders task of the Disposition. Get all relationships that match the Role
of PizzaProvider from the RelationshipSchedule. Return the first provider found that
is not the excluded provider. Returns null if a provider is not found.
Note that only one failed provider can be avoided with this implementation.
Parameters: disposition - whose previous Provider to avoid a pizza provider Entity to try |
setupSubscriptions | protected void setupSubscriptions()(Code) | | Overrides the super class method. Adds additional subscriptions
to Dispositions of the FindProviders Task and our original Order Tasks.
|
|
|