| java.lang.Object org.cougaar.lib.vishnu.client.VishnuComm
VishnuComm | public class VishnuComm (Code) | | Abstractions of communication for Vishnu
Hides whether we're running internally or externally from callers.
Knows about command-to-URL mapping, e.g. postCancel becomes a URL calling
the php script postcancel.php.
Uses an internalBuffer to write to when we're running internally. It holds
the same bytes as are sent to the web server when running externally.
|
Method Summary | |
public void | appendToBuffer(String data) | protected void | appendToInternalBuffer(String data, StringBuffer internalBuffer) | public void | clearBuffer() Clears internal buffer
Called by various methods in InternalMode, after having asked scheduler to parse data
in the buffer. | public void | getAnswer(DefaultHandler assignmentHandler) | public String | getBuffer() | protected String | getClusterName() | protected String | getInstancePostVar() | protected ParamMap | getMyParams() | protected String | getName() | public String | getProblem() | protected String | getProblemPostVar() | public String | getResponse(URLConnection connection) Returns response as string. | protected String | getUserPostVar() | protected String | getWaitPostVars() | protected void | localSetup() | public void | postCancel() Cancels any pending jobs. | public void | postClear() | public boolean | postData(String data) | public void | postProblem(String data) Posts problem to web site/internal buffer
URL encodes the data
Calls postToURL with URL header and data
bogus is sent first because user would not arrive
at php with value if it was sent first. | public String | postToURL(String host, String fileToExec, String data, Document doc, boolean readResponse) | public String | postToURL(URL aURL, String data, Document doc, boolean readResponse) Called from other signature
Post data to the URL
If readResponse is true, read the response back from the URL and return it. | public String | readBufferFromFile(String filename) Returns an array of Strings with each element containing a line from the given file. | protected void | readXML(URL aURL, DefaultHandler handler) | public void | sendData(URLConnection connection, String data, Document doc) Sends data on the connection. | protected void | serializeAndPost(Document doc, boolean postData, boolean runInternal, StringBuffer internalBuffer) post the Document doc to a URL. | protected void | serializeAndPost(String doc, boolean postData, boolean runInternal, StringBuffer internalBuffer)
Does most of the work of posting, the other signature does the serializing.
If running internally, just appends the data to the buffer. | public void | serializeAndPostData(Document doc) serialize document and post as data to web server or internal buffer
Just calls serializeAndPost with correct arguments. | public void | serializeAndPostProblem(Document doc) serialize document and post as problem definition to web server or internal buffer
Just calls serializeAndPost with correct arguments. | protected void | setProblemName()
sets Problem name used by Vishnu
Appends the machine name to divide the name space of problems
automatically. | protected void | showPostDataWarning() | public void | startScheduling()
Tells the scheduler to start.
bogus is sent first because user would not arrive
at php with it's value if it was sent first. | public boolean | waitTillFinished() | public void | writeBufferToFile(String suffix, String buffer) | public void | writeBufferToFile_withBackup(String suffix, String postfix, String buffer) Overloaded: postfix is pre-determined. |
assignmentsFile | protected String assignmentsFile(Code) | | php file to execute
|
clusterName | protected String clusterName(Code) | | name of the cluster
|
done | protected String done(Code) | | message from web server when problem is done
|
internalBuffer | protected StringBuffer internalBuffer(Code) | | holds data posted to URLs when running internally
|
kickoffFile | protected String kickoffFile(Code) | | php file to execute
|
maxWaitCycles | protected int maxWaitCycles(Code) | | max times to wait between polls in waitTillFinished
|
myLegalHosts | protected String myLegalHosts(Code) | | list of hosts the scheduler can run on
|
myParamTable | protected ParamMap myParamTable(Code) | | param table from plugin
|
myPassword | protected String myPassword(Code) | | web server password
|
numFilesWritten | protected int numFilesWritten(Code) | | how many files have been written out via the writeEncodedXMLToFile or writeXMLToFile flag
|
phpPath | protected String phpPath(Code) | | php path on web server host, relative to document root
|
postCancelFile | protected String postCancelFile(Code) | | php file to execute
|
postDataFile | protected String postDataFile(Code) | | php file to execute
|
postProblemFile | protected String postProblemFile(Code) | | php file to execute
|
readStatusFile | protected String readStatusFile(Code) | | php file to execute
|
runInternal | protected boolean runInternal(Code) | | parameter -- run internally (when true) or externally
|
showTiming | protected boolean showTiming(Code) | | parameter -- dump timing results to stdout
|
testing | protected boolean testing(Code) | | parameter -- write complete URL to stdout -- little used
|
waitTime | protected long waitTime(Code) | | wait between polls in waitTillFinished
|
writeEncodedXMLToFile | protected boolean writeEncodedXMLToFile(Code) | | parameter -- write encoded xml to a file
|
writeXMLToFile | protected boolean writeXMLToFile(Code) | | parameter -- write xml to a file
|
appendToBuffer | public void appendToBuffer(String data)(Code) | | adds data to internal buffer
|
appendToInternalBuffer | protected void appendToInternalBuffer(String data, StringBuffer internalBuffer)(Code) | | adds data to internal buffer, removing any xml header
|
clearBuffer | public void clearBuffer()(Code) | | Clears internal buffer
Called by various methods in InternalMode, after having asked scheduler to parse data
in the buffer.
See Also: InternalMode.prepareScheduler |
getBuffer | public String getBuffer()(Code) | | return string representation of buffer
|
getInstancePostVar | protected String getInstancePostVar()(Code) | | the problem instance post variable
|
getProblemPostVar | protected String getProblemPostVar()(Code) | | the problem post variable
|
getResponse | public String getResponse(URLConnection connection) throws IOException(Code) | | Returns response as string.
If there is an IOException on the input stream, will try two more times.
Parameters: connection - the url connection to get data from String reponse from URL |
getUserPostVar | protected String getUserPostVar()(Code) | | the user post variable
|
getWaitPostVars | protected String getWaitPostVars()(Code) | | create wait URL
|
localSetup | protected void localSetup()(Code) | | sets a variety of parameters
|
postCancel | public void postCancel()(Code) | | Cancels any pending jobs.
Should only be done once, when the plugin loads.
This is an insurance policy against the case where someone
starts a society and runs it, but never starts a scheduler, or otherwise
gets a problem into the state of "processing" but not "complete."
Once in the "processing" state, the scheduler will not accept new
jobs for this problem, effectively blocking it for all time.
bogus is sent first because user would not arrive
at php with value if it was sent first. No idea why.
Calls postToURL with URL header
See Also: VishnuComm.postToURL |
postClear | public void postClear()(Code) | |
Tells database or scheduler to forget all data associated with the problem
Calls postToURL with URL header
See Also: VishnuComm.postToURL |
postData | public boolean postData(String data)(Code) | | Posts data to web site or internal buffer, depending on mode
URL encodes the data
Calls postToURL with URL header and data
See Also: VishnuComm.postToURL Parameters: data - to send to URL |
postProblem | public void postProblem(String data)(Code) | | Posts problem to web site/internal buffer
URL encodes the data
Calls postToURL with URL header and data
bogus is sent first because user would not arrive
at php with value if it was sent first. No idea why.
See Also: VishnuComm.postToURL Parameters: data - to send to URL |
postToURL | public String postToURL(String host, String fileToExec, String data, Document doc, boolean readResponse)(Code) | | Posts data to a URL, given the host, the php file, the URL header data, the doc to send
response, if asked for one with readResponse |
postToURL | public String postToURL(URL aURL, String data, Document doc, boolean readResponse)(Code) | | Called from other signature
Post data to the URL
If readResponse is true, read the response back from the URL and return it.
|
readBufferFromFile | public String readBufferFromFile(String filename)(Code) | | Returns an array of Strings with each element containing a line from the given file.
returns null if any error
|
readXML | protected void readXML(URL aURL, DefaultHandler handler)(Code) | | Get XML back from URL and give it to a SAX Parser, running the handler
Parameters: aURL - the URL to read from Parameters: handler - will parse the XML coming from URL |
serializeAndPost | protected void serializeAndPost(Document doc, boolean postData, boolean runInternal, StringBuffer internalBuffer)(Code) | | post the Document doc to a URL.
If writeXMLToFile is set, will write a copy of what is
sent to the URL to a file named ClusterName_type_number, where type is
problem (the problem definition) or data (the tasks and resources), and
number is a counter that keeps the file names unique
What's written to the file is human readable, whereas if
writeEncodedXMLToFile is set, a different file is written,
named ClusterName_encoded_number. This file contains exactly what is
sent to the web server, after URL encoding has been performed.
Does the work of serialization here, by calling DomUtil function getDocAsArray,
and lets the other signature do actual posting.
See Also: VishnuDomUtil.getDocAsArray Parameters: doc - - DOM doc to send to URL Parameters: postData - - true if posting data |
serializeAndPost | protected void serializeAndPost(String doc, boolean postData, boolean runInternal, StringBuffer internalBuffer)(Code) | |
Does most of the work of posting, the other signature does the serializing.
If running internally, just appends the data to the buffer. Otherwise tries to
to either post data or post the problem
Only called by other serializeAndPost
See Also: VishnuComm.postProblem See Also: VishnuComm.postData |
serializeAndPostData | public void serializeAndPostData(Document doc)(Code) | | serialize document and post as data to web server or internal buffer
Just calls serializeAndPost with correct arguments.
See Also: VishnuComm.serializeAndPost |
serializeAndPostProblem | public void serializeAndPostProblem(Document doc)(Code) | | serialize document and post as problem definition to web server or internal buffer
Just calls serializeAndPost with correct arguments.
See Also: VishnuComm.serializeAndPost |
setProblemName | protected void setProblemName()(Code) | |
sets Problem name used by Vishnu
Appends the machine name to divide the name space of problems
automatically.
For example, if there were an expander in the
AsmaraTFSP cluster, run on a machine named pumpernickle,
the problem name would be
AsmaraTFSP_pumpernickle
|
showPostDataWarning | protected void showPostDataWarning()(Code) | | dumps warning to stdout when problem definition is out of sync with data format
|
startScheduling | public void startScheduling()(Code) | |
Tells the scheduler to start.
bogus is sent first because user would not arrive
at php with it's value if it was sent first. No idea why.
BOZO - Still a problem???
Calls postToURL with URL header
See Also: VishnuComm.postToURL |
waitTillFinished | public boolean waitTillFinished()(Code) | |
Polls the scheduler for it's status
Only uses in external mode
Sleeps between polls
Calls postToURL with URL header
See Also: ExternalMode.run See Also: VishnuComm.postToURL |
writeBufferToFile_withBackup | public void writeBufferToFile_withBackup(String suffix, String postfix, String buffer)(Code) | | Overloaded: postfix is pre-determined.
|
|
|