Java Doc for VishnuComm.java in  » Science » Cougaar12_4 » org » cougaar » lib » vishnu » client » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Science » Cougaar12_4 » org.cougaar.lib.vishnu.client 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


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.



Field Summary
protected  StringPHP_SUFFIX
    
protected  StringURL
    
protected  StringassignmentsFile
    
protected  StringclusterName
    
protected  VishnuDomUtildomUtil
    
protected  Stringdone
    
protected  StringhostName
    
protected  StringBufferinternalBuffer
    
protected  StringkickoffFile
    
protected  Loggerlogger
    
protected  intmaxWaitCycles
    
protected  StringmyInstance
     not used...
protected  StringmyLegalHosts
    
protected  ParamMapmyParamTable
    
protected  StringmyPassword
    
protected  StringmyProblem
    
protected  StringmyUser
    
protected  Stringname
    
protected  intnumFilesWritten
    
protected  StringphpPath
    
protected  StringpostCancelFile
    
protected  StringpostDataFile
    
protected  StringpostProblemFile
    
protected  StringreadStatusFile
    
protected  booleanrunInternal
    
protected  booleanshowTiming
    
protected  booleantesting
    
protected  longwaitTime
    
protected  booleanwriteEncodedXMLToFile
    
protected  booleanwriteXMLToFile
    

Constructor Summary
public  VishnuComm(ParamMap myParamTable, String name, String clusterName, VishnuDomUtil domUtil, boolean runInternal, Logger logger)
    

Method Summary
public  voidappendToBuffer(String data)
    
protected  voidappendToInternalBuffer(String data, StringBuffer internalBuffer)
    
public  voidclearBuffer()
     Clears internal buffer

Called by various methods in InternalMode, after having asked scheduler to parse data in the buffer.

public  voidgetAnswer(DefaultHandler assignmentHandler)
    
public  StringgetBuffer()
    
protected  StringgetClusterName()
    
protected  StringgetInstancePostVar()
    
protected  ParamMapgetMyParams()
    
protected  StringgetName()
    
public  StringgetProblem()
    
protected  StringgetProblemPostVar()
    
public  StringgetResponse(URLConnection connection)
     Returns response as string.
protected  StringgetUserPostVar()
    
protected  StringgetWaitPostVars()
    
protected  voidlocalSetup()
    
public  voidpostCancel()
     Cancels any pending jobs.
public  voidpostClear()
    
public  booleanpostData(String data)
    
public  voidpostProblem(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  StringpostToURL(String host, String fileToExec, String data, Document doc, boolean readResponse)
    
public  StringpostToURL(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  StringreadBufferFromFile(String filename)
     Returns an array of Strings with each element containing a line from the given file.
protected  voidreadXML(URL aURL, DefaultHandler handler)
    
public  voidsendData(URLConnection connection, String data, Document doc)
     Sends data on the connection.
protected  voidserializeAndPost(Document doc, boolean postData, boolean runInternal, StringBuffer internalBuffer)
     post the Document doc to a URL.
protected  voidserializeAndPost(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  voidserializeAndPostData(Document doc)
     serialize document and post as data to web server or internal buffer Just calls serializeAndPost with correct arguments.
public  voidserializeAndPostProblem(Document doc)
     serialize document and post as problem definition to web server or internal buffer Just calls serializeAndPost with correct arguments.
protected  voidsetProblemName()
    
 sets Problem name used by Vishnu
 Appends the machine name to divide the name space of problems 
 automatically.
protected  voidshowPostDataWarning()
    
public  voidstartScheduling()
    
 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  booleanwaitTillFinished()
    
public  voidwriteBufferToFile(String suffix, String buffer)
    
public  voidwriteBufferToFile_withBackup(String suffix, String postfix, String buffer)
     Overloaded: postfix is pre-determined.

Field Detail
PHP_SUFFIX
protected String PHP_SUFFIX(Code)



URL
protected String URL(Code)
root of the URL, set above



assignmentsFile
protected String assignmentsFile(Code)
php file to execute



clusterName
protected String clusterName(Code)
name of the cluster



domUtil
protected VishnuDomUtil domUtil(Code)
dom helper



done
protected String done(Code)
message from web server when problem is done



hostName
protected String hostName(Code)
web server host



internalBuffer
protected StringBuffer internalBuffer(Code)
holds data posted to URLs when running internally



kickoffFile
protected String kickoffFile(Code)
php file to execute



logger
protected Logger logger(Code)



maxWaitCycles
protected int maxWaitCycles(Code)
max times to wait between polls in waitTillFinished



myInstance
protected String myInstance(Code)
not used...



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



myProblem
protected String myProblem(Code)
problem name



myUser
protected String myUser(Code)
web server user



name
protected String name(Code)
name of the cluster+plugin



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




Constructor Detail
VishnuComm
public VishnuComm(ParamMap myParamTable, String name, String clusterName, VishnuDomUtil domUtil, boolean runInternal, Logger logger)(Code)
Sets the problem name

calls postCancel and postClear if running externally





Method Detail
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




getAnswer
public void getAnswer(DefaultHandler assignmentHandler)(Code)
 Get the answer back from the web site/scheduler 
 Called by XMLResultHandler
 Calls readXML with the assignment handler
 

See Also:   XMLResultHandler.parseAnswer
See Also:   VishnuComm.readXML



getBuffer
public String getBuffer()(Code)
return string representation of buffer



getClusterName
protected String getClusterName()(Code)



getInstancePostVar
protected String getInstancePostVar()(Code)
the problem instance post variable



getMyParams
protected ParamMap getMyParams()(Code)



getName
protected String getName()(Code)



getProblem
public String getProblem()(Code)



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



sendData
public void sendData(URLConnection connection, String data, Document doc) throws IOException(Code)
Sends data on the connection. Writes to buffered stream that wraps the URL output stream.
Calls VishnuDomUtil.writeDocToStream to do most of work.
Optionally writes encoded XML to a file.
See Also:   VishnuDomUtil.writeDocToStream



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
public void writeBufferToFile(String suffix, String buffer)(Code)



writeBufferToFile_withBackup
public void writeBufferToFile_withBackup(String suffix, String postfix, String buffer)(Code)
Overloaded: postfix is pre-determined.



Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.