jpl.mipl.uplink.tour
Class ConstraintCheck

java.lang.Object
  |
  +--jpl.mipl.uplink.tour.ConstraintCheck

public class ConstraintCheck
extends Object

The ConstraintCheck class is the client program of the Remote Constraint Checker capability. The Remote Constraint Checker is a tool that allows Instrument Teams outside of JPL to constraint check their Interface files (IOI). This class takes a list of Interface files and submits them to the server for checking. The communication between the client and the server is accomplished using the FEI client. The input to this class is a list of Interface files, and the output is a log file that contains the results of constraint checking. The way this class works is basically like so. It attempts to add a lockfile to one of the available filetypes. The lockfile is a file with a special name that designates to all other clients that this filetype is in use. Then this class add the Interface files to the filetype and waits for the server to constraint check them. When the server is done constraint checking, it puts the results in a log file back on the filetype. This client then retieves the log file. To use this class first call the processArgs() method to pass in the list of Interface files and the log file name. Then call process() to perform the constraint checking. Because this class uses FEI commands for communication, the user must obtain a kerberos ticket prior to running this program. Also, the user must have permission to run the following FEI commands: feiadd, feireplace, feilist, feiget, and feimakeclean on the list of available filetypes. History: 11-27-02 Elias Sayfi - Ver 1.0, Initial delivery 03-03-03 Elias Sayfi - Ver 2.0, Modified for delivery to team. Removed filetypes 3 thru 10 04-11-03 Elias Sayfi - Ver 2.1, Added the timeout flag Modified to add server_down file and delete lock file on exit instead of deleting all the files in the filetype. This keeps other clients from connecting while the server is busy. The server will delete the server_down file when it is ready to process another client.

Version:
2.1 04-11-2003
Author:
Elias Sayfi
See Also:
VimsRemoteCC, IssRemoteCC, ExitRoutine, RunCommand

Constructor Summary
ConstraintCheck()
          Default constructor.
ConstraintCheck(Vector args)
          Constructor.
 
Method Summary
 boolean allServersDown()
          This method compares the list of available filetypes (FILETYPES_LIST) with the list of filetypes that it found have a SERVER_DOWN file on them designating that the server is not running.
 boolean connectToServer()
          This method calls the getFiletype method to find an open filetype.
 void createTempFiles(boolean createLock, boolean createGo, boolean createUsing)
          This method creates 4 temporary files.
 boolean getFiletype()
          This method attempts to locate a filetype that is not currently in use.
 void printDebug(String st)
          Print out debug message.
 void printError(int n, String st)
          Print out an error message.
 void process()
          This is the principal method of this class.
 boolean processArgs(Vector args)
          Examine the elements of the args Vector and get the Interface filenames and the name to assign to the log file if it's there.
 boolean sendGoFile()
          Attempt to add the go file to the filetype that has been established for communication to the server.
 boolean sendInputFiles()
          Send the Interface files to the server, by using the REPLACE command to add them to the reserved filetype.
 void sleep(int msec)
          Pause for the specified number of milliseconds.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ConstraintCheck

public ConstraintCheck()
Default constructor.


ConstraintCheck

public ConstraintCheck(Vector args)
Constructor.

Parameters:
args - - a list of ioi filenames and possibly "-log" followed by the log filename
Method Detail

printError

public void printError(int n,
                       String st)
Print out an error message.

Parameters:
n - - the number of new lines to print before the message
st - - the error message

printDebug

public void printDebug(String st)
Print out debug message.

Parameters:
st - - the error message

createTempFiles

public void createTempFiles(boolean createLock,
                            boolean createGo,
                            boolean createUsing)
This method creates 4 temporary files. The "lock" file, the "go" file, the "using" file, and the "server down" file. The lock file designates to other clients that this file is in use now. The go file is sent to the server to tell it that the client is finished adding files and to start processing. The using file is used by feidelete to delete the lock file from the filetype when the client terminates. The server_down file is placed on the filetype when the client terminates, successfully or unsuccessfully. This tells the server that the client is done and to reset itself. The name of the desired log file is placed in the lock file. This was the server will know what to name the log file when it returns it. The name of the team is place in the go file, this tells the server what kind of ioi's it has and how to process them. The server down file should always be created if it doesn't exist.

Parameters:
createLock - - designates whether or not to create the lock file
createGo - - designates whether or not to create the go file
createUsing - - designates whether or not to create the using file

getFiletype

public boolean getFiletype()
This method attempts to locate a filetype that is not currently in use. If a lock file exists on the filetype then it means that another client is currently using it. If the SERVER_DOWN file exists on the server then it means that the server is currently not running. The way that clients reserve a filetype is by putting the lock file on the filetype, if that's successful then the filetype is reserved. Otherwise try again and see if you can get another filetype from the list of available filetypes (FILETYPES_LIST)

Returns:
true if a filetype was reserved, else false

allServersDown

public boolean allServersDown()
This method compares the list of available filetypes (FILETYPES_LIST) with the list of filetypes that it found have a SERVER_DOWN file on them designating that the server is not running. If all the servers for all the available filetypes are down then this returns true.

Returns:
true if all the servers are down, otherwise false

processArgs

public boolean processArgs(Vector args)
Examine the elements of the args Vector and get the Interface filenames and the name to assign to the log file if it's there. Errors such as invalid filenames are expected to be handled by the program that passed the args Vector to this class. In our case, it is the Iss/VimsRemoteCC class.

Returns:
true - If at least one IOI filename was found and the log filename was parsed correctly if it was specified, otherwise false

sleep

public void sleep(int msec)
Pause for the specified number of milliseconds.

Parameters:
msec - - the number of millisecs to pause

connectToServer

public boolean connectToServer()
This method calls the getFiletype method to find an open filetype. If an open filetype is located ("open" means that neither the SERVER_DOWN file or the lock file was found on the filetype) then a lock file is placed on the server.

Returns:
true - If an open filetype was found and reserved, false otherwise

sendInputFiles

public boolean sendInputFiles()
Send the Interface files to the server, by using the REPLACE command to add them to the reserved filetype.

Returns:
- true if the files were added successfully, false otherwise

sendGoFile

public boolean sendGoFile()
Attempt to add the go file to the filetype that has been established for communication to the server. The go file is the way this client tells the server that all the input files have been added and that it should start processing.

Returns:
true - if the go file was added successfully, false otherwise

process

public void process()
This is the principal method of this class. This method and the processArgs method are what other classes call to start this class on it's merry way. The way it works, first create a lock file on the local system and try to connect to the server by adding the lock file to one of the available filetypes. If the lock file already exists on the filetype then it means that the filetype is in use by another client, so try another. Once an open filetype is found, add the Interface files to the filetype. Then, add the go file to the filetype. The go file tells the server that all the IOI files have been added to the server and that it should start processing. After the go file has been added, try to retrieve the log file from the filetype. When the server finishes processing, it will create a log file and put it on the filetype. The normal case is that the log file was created by the server and retieved properly from the filetype. If the log file cannot be retrieved from the filetype then most likely the server is down and proper error messages will have been printed.