| org.cougaar.lib.filter.UTILBufferingPluginAdapter org.cougaar.lib.vishnu.client.VishnuPlugin
All known Subclasses: org.cougaar.lib.vishnu.client.VishnuAllocatorPlugin, org.cougaar.lib.vishnu.client.VishnuAggregatorPlugin, org.cougaar.lib.vishnu.client.VishnuExpanderPlugin,
VishnuPlugin | abstract public class VishnuPlugin extends UTILBufferingPluginAdapter implements UTILAssetListener,DirectModeListener,ResultListener(Code) | |
ALP-Vishnu bridge.
Base class for interacting with the Vishnu scheduler.
There are 3 main dimensions of behavior for this plugin:
- SchedulerMode (External, Internal, or Direct)
- Job type (Batch or Incremental)
- Translation (Automatic or Custom)
Supports three main scheduler modes : External, Internal, and Direct. These
are classes which implement the SchedulerLifecycle interface. They
orchestrate the steps to use the Vishnu Scheduler. The VishnuPlugin
is a ModeListener and its as a mode listener that the modes communicate
with the plugin.
External mode uses the web server and expects the scheduling to be
done by a separate Vishnu Scheduler process. All communication is done with
XML.
Internal mode uses an internal Vishnu Scheduler process, but
communicates exclusively through XML.
Direct mode extends internal mode, but directly translates between
Cougaar objects and Vishnu scheduling objects.
The results of a scheduling job are handled by a ResultHandler, which
can be either an XMLResultHandler, or a DirectResultHandler. Each mode is a
ResultListener and communicates with its result handler.
Orthogonal to the scheduling modes, the scheduling jobs can be either
batch or incremental. Batch starts from scratch every time, but
incremental mode maintains scheduler state from previous batches.
Further, XML translation can either be automatic or custom. Automatic
mode uses introspection to determine the object format of the problem,
whereas custom forces the developer to define it and participate in
the translation process.
Abstract because it does not define :
- createThreadCallback
each of which is defined in the allocator, aggregator, and expander
subclasses.
See Also: org.cougaar.lib.filter.UTILBufferingPluginAdapter.createThreadCallback See Also: org.cougaar.lib.vishnu.client.VishnuAggregatorPlugin.createThreadCallback See Also: org.cougaar.lib.vishnu.client.VishnuAllocatorPlugin.createThreadCallback See Also: org.cougaar.lib.vishnu.client.VishnuExpanderPlugin.createThreadCallback See Also: |
Method Summary | |
protected void | appendGlobalDataFormat(Document problemFormatDoc) Talks to VishnuConfig to find out if there is an other data format file. | protected void | attachAssociatedFiles(Document problemFormatDoc) Attaches various files to format document. | public void | clearChangedAssets() Implemented for ModeListener interface
After the scheduler is informed of the changed assets, forget about them. | protected void | clearTasks() | protected UTILAssetCallback | createAssetCallback() | protected SchedulerLifecycle | createDirectMode() | protected DirectResultHandler | createDirectResultHandler() | protected SchedulerLifecycle | createExternalMode() | protected SchedulerLifecycle | createInternalMode() | protected Task | createMainTask(Task task, Asset asset, Date start, Date end, Date setupStart, Date wrapupEnd) | protected Task | createSetupTask(Task task, Asset asset, Date start, Date end, Date setupStart, Date wrapupEnd) | protected VishnuComm | createVishnuComm() | protected VishnuConfig | createVishnuConfig() | protected VishnuDomUtil | createVishnuDomUtil() | protected Task | createWrapupTask(Task task, Asset asset, Date start, Date end, Date setupStart, Date wrapupEnd) | protected XMLProcessor | createXMLProcessor() | protected XMLResultHandler | createXMLResultHandler() | protected Collection | getAllAssets() If you're not in incremental mode, send all assets. | protected UTILAssetCallback | getAssetCallback() | public Asset | getAssetForKey(StringKey key) | public Collection | getChangedAssets() | public XMLizer | getDataXMLizer() | public int | getNumAssets() | public int | getNumTasks() | protected Vector | getPreferences(Task parentTask, Date readyAt, Date earliest, Date best, Date latest)
Adjust preferences so that the start time preference is the assigned
start time, and the end time preference has a best date that is the
assigned end time. | protected Vector | getPrepPhrases(Task parentTask, Asset a) Defines how the task holds the asset for the task->asset association. | public boolean | getRunDirectly() | public Task | getTaskForKey(StringKey key) | public String | getTaskName() | public Collection | getTasks() | public void | handleAssignment(org.cougaar.planning.ldm.plan.Task task, Asset asset, Date start, Date end, Date setupStart, Date wrapupEnd, String contribs, String taskText)
Should define in subclass -- create an allocation
The parameters are what got returned from the vishnu scheduler. | public void | handleChangedAssets(Enumeration changedAssets) Place to handle changed assets. | public void | handleIllFormedTask(Task t) Implemented for UTILTaskChecker interface. | protected void | handleImpossibleTasks(Collection impossibleTasks) Given a collection of impossible tasks, make failed disposition for each. | public void | handleMultiAssignment(Vector tasks, Asset asset, Date start, Date end, Date setupStart, Date wrapupEnd, boolean assetWasUsedBefore)
Should define in subclass -- create an aggregation
The parameters are what got returned from the vishnu scheduler. | public void | handleNewAssets(Enumeration newAssets) Collect new assets into a set to eventually give to scheduler (after translation). | protected void | handleRemovedTasks(Enumeration removedTasks) Place to handle rescinded tasks. | protected void | initializeWithStoredFormat() little helper method called by processTasks, if using a stored object format
Reads object format if hasn't been yet. | public boolean | interestingAsset(Asset a) Implemented for UTILAssetListener
OVERRIDE to see which assets you think are interesting. | public boolean | interestingTask(Task t) Is the task interesting to the plugin? This is the inner-most part of
the predicate. | public void | localSetup() Here all the various runtime parameters get set. | protected List | makeSetupWrapupExpansion(Task task, Asset asset, Date start, Date end, Date setupStart, Date wrapupEnd) Make expansion of mptask that attached between one and three subtasks
May attach setup and wrapup tasks, if there are specs defined for them and
if the makeSetupAndWrapupTasks boolean parameter is set. | protected void | prepareData(List stuffToSend, Document objectFormatDoc) Tasks a list of tasks and the object format document and sends the data
to the scheduler. | protected void | prepareObjectFormat(List tasks) Automatically generate object format from Cougaar input tasks (and assets). | protected Document | prepareStoredObjectFormat() Like VishnuPlugin.prepareObjectFormat
Send the file called .dff.xml as the default object format
for the problem. | public void | prepareVishnuObjects(List tasksAndResources, Collection changedAssets, List vishnuTasks, List vishnuResources, List changedVishnuResources, Document objectFormat, SchedulingData schedData) Creates lists of Vishnu objects. | public void | processTasks(List tasks)
Heart of the plugin. | protected void | publishAddWithCheck(Object obj) | public void | publishSubtasks(boolean wantConfidence, Task t, List subtasks) This method Expands the given Task. | public void | removeTask(StringKey key) | protected Map | sendFormat(Collection templates, String assetClassName) Send the dataformat section of the problem to the postdata
URL. | protected void | setUIDToObjectMap(Collection objects, Map UIDtoObject) Utility for setting up UID to object map. | public void | setupFilters() | protected void | unfreezeTasks(Collection tasks) | protected void | waitForAnswer() Ask the mode to run, which includes handling the assignments. |
comm | protected VishnuComm comm(Code) | | manages communication with URLs or internally
|
config | protected VishnuConfig config(Code) | | config files, gets representative tasks and assets for automatic translation
|
firstTemplateTasks | protected int firstTemplateTasks(Code) | | how many tasks to examine to automatically determine format in automatic translation mode
|
incrementalScheduling | protected boolean incrementalScheduling(Code) | | incremental or batch mode
|
localDidRehydrate | protected boolean localDidRehydrate(Code) | | |
makeSetupAndWrapupTasks | protected boolean makeSetupAndWrapupTasks(Code) | | option : create setup and wrapup tasks, in addition to assignment task
|
myAssetUIDtoObject | protected Map myAssetUIDtoObject(Code) | | memory of which assets are available -- used when assignments are returned
|
myChangedAssets | protected Set myChangedAssets(Code) | | changed assets to tell the scheduler about
|
myNewAssets | protected Set myNewAssets(Code) | | recently received assets to tell the scheduler about
|
myTaskUIDtoObject | protected Map myTaskUIDtoObject(Code) | | memory for which tasks are being processed in this batch -- used when assignments are returned
|
objectFormatDoc | protected Document objectFormatDoc(Code) | | object format doc, either generated or from a file
|
resultHandler | protected ResultHandler resultHandler(Code) | | handles results, calls methods in plugin to create plan elements
|
runDirectly | protected boolean runDirectly(Code) | | determines whether to do XML or direct translation of Cougaar objects
|
runInternal | protected boolean runInternal(Code) | | determines whether to run in internal or external (with web server) mode
|
sentFormatAlready | protected boolean sentFormatAlready(Code) | | sent the format already? Send it only once unless in batch mode
|
showTiming | protected boolean showTiming(Code) | | report debug output showing timing info
|
skipTransitARA | protected AllocationResultAggregator skipTransitARA(Code) | | Must use a special allocation result aggregator that does NOT include the transit (setup, wrapup) tasks
in it's time calculations.
|
stopOnFailure | protected boolean stopOnFailure(Code) | | controls whether to do exit on failure, sometimes useful for debugging
|
total | protected int total(Code) | | |
useStoredFormat | protected boolean useStoredFormat(Code) | | controls whether to use custom translation
|
wantMediumConfidenceOnExpansion | protected boolean wantMediumConfidenceOnExpansion(Code) | | |
appendGlobalDataFormat | protected void appendGlobalDataFormat(Document problemFormatDoc)(Code) | | Talks to VishnuConfig to find out if there is an other data format file.
If there is, appends it to problem format doc. Adds it beneath DATAFORMAT tag.
Parameters: problemFormatDoc - document to add other data format to |
attachAssociatedFiles | protected void attachAssociatedFiles(Document problemFormatDoc)(Code) | | Attaches various files to format document.
- attach global object format file
- attach specs file
- attach ga parameters file
Parameters: problemFormatDoc - - document to add to |
clearChangedAssets | public void clearChangedAssets()(Code) | | Implemented for ModeListener interface
After the scheduler is informed of the changed assets, forget about them.
|
clearTasks | protected void clearTasks()(Code) | | called by waitForAnswer -- we don't have to remember taskUID-to-object mappings after answer is returned
|
createAssetCallback | protected UTILAssetCallback createAssetCallback()(Code) | | Create the standard Asset callback
UTILAssetCallback that was created and has this plugin as a listener |
createMainTask | protected Task createMainTask(Task task, Asset asset, Date start, Date end, Date setupStart, Date wrapupEnd)(Code) | |
create first and possibly only subtask of MPTask
Time preferences have
1) the start time = earliest arrival = start of main task
2) the best arrival time = latest arrival = end of main task
Attaches WITH prep that shows which asset was used
|
createSetupTask | protected Task createSetupTask(Task task, Asset asset, Date start, Date end, Date setupStart, Date wrapupEnd)(Code) | |
create setup task that goes before main subtask
Time preferences have
1) the start time = earliest arrival = setup start
2) the best arrival time = latest arrival = start of main task
Attaches WITH prep that shows which asset was used
|
createWrapupTask | protected Task createWrapupTask(Task task, Asset asset, Date start, Date end, Date setupStart, Date wrapupEnd)(Code) | |
create wrapup task that goes after main subtask
Time preferences have
1) the start time = earliest arrival = end of main task
2) the best arrival time = latest arrival = end of wrapup
Attaches WITH prep that shows which asset was used
|
getAllAssets | protected Collection getAllAssets()(Code) | | If you're not in incremental mode, send all assets.
Otherwise, only send those that have come in on the subscription add list.
Collection of assets to send to Vishnu |
getAssetCallback | protected UTILAssetCallback getAssetCallback()(Code) | | UTILAssetCallback that was previously created and has this plugin as a listener |
getAssetForKey | public Asset getAssetForKey(StringKey key)(Code) | | Used when XML assignment information is returned to find matching resource asset
implemented for ResultListener interface
|
getChangedAssets | public Collection getChangedAssets()(Code) | | Implemented for ModeListener interface
Which assets were changed since they were added as new assets?
myChangedAssets set of assets on the changed list |
getNumAssets | public int getNumAssets()(Code) | | implemented for ModeListener interface
|
getNumTasks | public int getNumTasks()(Code) | | implemented for ModeListener interface
|
getPreferences | protected Vector getPreferences(Task parentTask, Date readyAt, Date earliest, Date best, Date latest)(Code) | |
Adjust preferences so that the start time preference is the assigned
start time, and the end time preference has a best date that is the
assigned end time. The early and late dates of the end time preference
are the same as the first parent task. (This isn't very important, as the
downstream allocator should just allocate to the start and best times.)
Parameters: parentTask - - parent task Parameters: readyAt - - the date for the START_TIME preference Parameters: best - - the best date for the END_TIME preference Vector - list of preferences for the MPTask |
getPrepPhrases | protected Vector getPrepPhrases(Task parentTask, Asset a)(Code) | | Defines how the task holds the asset for the task->asset association.
Critical, because the allocator downstream will probably look for this prep and
pluck the asset off to make the allocation or use it in some way.
Parameters: a - - asset to attach to task Parameters: parentTask - - parent task the original set of prep phrases from the first parent task PLUS the WITHprep with the asset |
getRunDirectly | public boolean getRunDirectly()(Code) | | anything you added with register, you will be informed about here upon rehydration
|
getTaskForKey | public Task getTaskForKey(StringKey key)(Code) | | Used when XML assignment information is returned to find matching resource asset
implemented for ResultListener interface
|
getTaskName | public String getTaskName()(Code) | | implemented for ModeListener interface
|
getTasks | public Collection getTasks()(Code) | | implemented for ModeListener interface
|
handleAssignment | public void handleAssignment(org.cougaar.planning.ldm.plan.Task task, Asset asset, Date start, Date end, Date setupStart, Date wrapupEnd, String contribs, String taskText)(Code) | |
Should define in subclass -- create an allocation
The parameters are what got returned from the vishnu scheduler.
implemented for ResultListener interface
See Also: VishnuAllocatorPlugin.handleAssignment Parameters: task - task that was assigned to asset Parameters: asset - asset handling task Parameters: start - of main task Parameters: end - of main task Parameters: setupStart - start of setup task Parameters: wrapupEnd - end of wrapup task |
handleChangedAssets | public void handleChangedAssets(Enumeration changedAssets)(Code) | | Place to handle changed assets.
Does nothing by default - reports changed assets when isInfoEnabled() set.
Parameters: changedAssets - changed assets found in the container |
handleImpossibleTasks | protected void handleImpossibleTasks(Collection impossibleTasks)(Code) | | Given a collection of impossible tasks, make failed disposition for each.
If stopOnFailure is true, exits.
Parameters: impossibleTasks - -- tasks that the scheduler couldn't figure out what to do with |
handleMultiAssignment | public void handleMultiAssignment(Vector tasks, Asset asset, Date start, Date end, Date setupStart, Date wrapupEnd, boolean assetWasUsedBefore)(Code) | |
Should define in subclass -- create an aggregation
The parameters are what got returned from the vishnu scheduler.
implemented for ResultListener interface
See Also: VishnuAggregatorPlugin.handleMultiAssignment Parameters: tasks - tasks to be aggregated together and assigned to asset Parameters: asset - asset handling task Parameters: start - of main task Parameters: end - of main task Parameters: setupStart - start of setup task Parameters: wrapupEnd - end of wrapup task |
handleNewAssets | public void handleNewAssets(Enumeration newAssets)(Code) | | Collect new assets into a set to eventually give to scheduler (after translation).
Parameters: newAssets - new assets found in the container |
initializeWithStoredFormat | protected void initializeWithStoredFormat()(Code) | | little helper method called by processTasks, if using a stored object format
Reads object format if hasn't been yet. Sends format if it hasn't been sent yet.
|
interestingAsset | public boolean interestingAsset(Asset a)(Code) | | Implemented for UTILAssetListener
OVERRIDE to see which assets you think are interesting.
For instance, if you are scheduling trucks/ships/planes,
you'd want to check like this :
return (GLMAsset).hasContainPG ();
Parameters: a - asset to check boolean true if asset is interesting |
interestingTask | public boolean interestingTask(Task t)(Code) | | Is the task interesting to the plugin? This is the inner-most part of
the predicate.
By default, it ignores tasks produced from this plugin
If you redefine this, it's good to call this using super.
Parameters: t - - the task begin checked See Also: org.cougaar.lib.callback.UTILGenericListener.interestingTask |
localSetup | public void localSetup()(Code) | | Here all the various runtime parameters get set. See documentation for details.
|
makeSetupWrapupExpansion | protected List makeSetupWrapupExpansion(Task task, Asset asset, Date start, Date end, Date setupStart, Date wrapupEnd)(Code) | | Make expansion of mptask that attached between one and three subtasks
May attach setup and wrapup tasks, if there are specs defined for them and
if the makeSetupAndWrapupTasks boolean parameter is set.
The parameters are what got returned from the vishnu scheduler.
Parameters: task - task that was assigned to asset Parameters: asset - asset handling task Parameters: start - of main task Parameters: end - of main task Parameters: setupStart - start of setup task Parameters: wrapupEnd - end of wrapup task List of subtasks created |
prepareObjectFormat | protected void prepareObjectFormat(List tasks)(Code) | | Automatically generate object format from Cougaar input tasks (and assets).
Calls VishnuConfig to get representative sample of input tasks and assets to
use as the base for automatic translation. Also gets the class name of the
resource asset.
Sends the object format and creates a data xmlizer, if needed.
Parameters: tasks - - tasks to examine |
prepareStoredObjectFormat | protected Document prepareStoredObjectFormat()(Code) | | Like VishnuPlugin.prepareObjectFormat
Send the file called .dff.xml as the default object format
for the problem.
Does NOT discover the object format from sampling the tasks.
This file can also be indicated by setting the parameter defaultFormat .
|
prepareVishnuObjects | public void prepareVishnuObjects(List tasksAndResources, Collection changedAssets, List vishnuTasks, List vishnuResources, List changedVishnuResources, Document objectFormat, SchedulingData schedData)(Code) | | Creates lists of Vishnu objects.
Complains that you need to define this method by default.
Implemented for DirectResultListener interface.
Parameters: tasksAndResources - - Cougaar tasks and resources to translate Parameters: changedAssets - - list of changed Cougaar assets Parameters: vishnuTasks - - list to add Vishnu tasks to Parameters: vishnuResources - - list to add Vishnu resources to Parameters: changedVishnuResources - - list of changed Vishnu resources |
processTasks | public void processTasks(List tasks)(Code) | |
Heart of the plugin.
Deal with the tasks that we have accumulated.
Does:
1) Sets up the scheduler
2) Sends the problem's object format, if it hasn't already been sent.
- generated introspectively or from a file
- will keep sending the object format if running in batch mode
3) Prepares and sends the data (obtained from tasks and assets)
- ask the mode to translate the tasks and assets
4) Waits for a result (all in the mode)
- start the scheduler
- wait for a result
- call handleAssignment on each returned assignment
- deal with un-assigned tasks
- clear tasks, ready to start on a new batch
Parameters: tasks - the tasks to handle |
publishAddWithCheck | protected void publishAddWithCheck(Object obj)(Code) | | |
publishSubtasks | public void publishSubtasks(boolean wantConfidence, Task t, List subtasks)(Code) | | This method Expands the given Task.
Parameters: wantConfidence - set the confidence to 100% on expansion Parameters: t - the task to be expanded. Parameters: subtasks - the expanded subtasks |
removeTask | public void removeTask(StringKey key)(Code) | | implemented for ResultListener interface
|
sendFormat | protected Map sendFormat(Collection templates, String assetClassName)(Code) | | Send the dataformat section of the problem to the postdata
URL.
This will define the structure of input tasks and resources,
as well as the scheduling specs and the ga parameters.
Each of the items in the template collection will be translated
into an xml OBJECTFORMAT tag.
Attaches associated files.
Parameters: templates - -- a collection of all the template resources and a template task. Parameters: assetClassName - - used to figure out which asset is to be the Vishnu resource map of the object types to their object descriptions |
setUIDToObjectMap | protected void setUIDToObjectMap(Collection objects, Map UIDtoObject)(Code) | | Utility for setting up UID to object map. Uses StringKeys for speed.
Parameters: objects - to add to map Parameters: UIDtoObject - map to populate |
setupFilters | public void setupFilters()(Code) | | filter for assets
|
|
|