JAFS API v2

org.openafs.jafs
Class Process

java.lang.Object
  |
  +--org.openafs.jafs.Process
All Implemented Interfaces:
Comparable, Serializable

public class Process
extends Object
implements Serializable, Comparable

An abstract representation of an AFS process. It holds information about the server, such as what its state is.

Constructing an instance of a Process does not mean an actual AFS process is created on a server -- usually a Process object is a representation of an already existing AFS process. If, however, the Process is constructed with the name of a process that does not exist in the server represented by the provided Server, a new process with that name can be created on that server by calling one of the createSimple(String), createFS(String), or createCron(String,String) methods. If such a process does already exist when one of these methods are called, an exception will be thrown.

The following is a simple example of how to construct and use a Process object. This example obtains the list of all Process objects on a particular server and prints out the name of each one along with its start time.

 import org.openafs.jafs.Cell;
 import org.openafs.jafs.AFSException;
 import org.openafs.jafs.Process;
 import org.openafs.jafs.Server;
 ...
 public class ...
 {
   ...
   private Cell cell;
   private Server server;
   ...
   public static void main(String[] args) throws Exception
   {
     String username   = arg[0];
     String password   = arg[1];
     String cellName   = arg[2];
     String serverName = arg[3];
 
     token = new Token(username, password, cellName);
     cell   = new Cell(token);
     server = new Server(serverName, cell);
 
     System.out.println("Processes in Server " + server.getName() + ":");
     Process[] processes = server.getProcesss();
     for (int i = 0; i < processes.length; i++) {
       System.out.print("Process " + processes[i].getName());
       System.out.print("was started: " + 
                        processes[i].getStartTimeDate().getTime() + "\n");
     }
   }
   ...
 }
 

See Also:
Serialized Form

Field Summary
protected  boolean cachedInfo
           
static int CRON_PROCESS
          A process that should be restarted at a specific time either daily or weekly.
protected  long errorCode
           
protected  long errorSignal
           
protected  long exitErrorTime
           
protected  GregorianCalendar exitErrorTimeDate
           
protected  long exitTime
           
protected  GregorianCalendar exitTimeDate
           
static int FS_PROCESS
          Combination of File Server, Volume Server, and Salvager processes
protected  int goal
           
protected  String name
           
protected  long numberStarts
           
static int RUNNING
          Process execution state running
protected  Server server
           
protected  int serverHandle
           
static int SIMPLE_PROCESS
          Any standard type of process except for fs (such as kaserver, upclientbin, etc.)
static int STARTING
          Process execution state starting
protected  long startTime
           
protected  GregorianCalendar startTimeDate
           
protected  int state
           
protected  boolean stateBadFileAccess
           
protected  boolean stateOk
           
protected  boolean stateTooManyErrors
           
static int STOPPED
          Process execution state stopped
static int STOPPING
          Process execution state stopping
protected  int type
           
 
Constructor Summary
(package private) Process(Server server)
          Creates a blank Process given the server to which the process belongs.
  Process(String name, Server server)
          Constructs a new Process object instance given the name of the AFS process and the AFS server, represented by server, to which it belongs.
  Process(String name, Server server, boolean preloadAllMembers)
          Constructs a new Process object instance given the name of the AFS process and the AFS server, represented by server, to which it belongs.
 
Method Summary
 int compareTo(Object obj)
          Comparable interface method.
 int compareTo(Process process)
          Compares two Process objects respective to their names and does not factor any other attribute.
protected static void create(int serverHandle, String processName, int processType, String executionPath, String cronTime, String notifier)
          Creates a processes on a server.
 void createCron(String executionPath, String cronTime)
          Creates this process as a cron process on the server.
 void createFS(String executionPath)
          Creates this process as a file server process on the server.
 void createSimple(String executionPath)
          Creates this process as a simple process on the server.
 void delete()
          Removes this process from the bos server
protected static void delete(int serverHandle, String processName)
          Removes a process from a server.
 boolean equals(Process otherProcess)
          Tests whether two Process objects are equal, based on their names and hosting server.
 long getErrorCode()
          Returns the error code of the process.
 long getErrorSignal()
          Returns the error signal of the process.
 long getExitErrorTime()
          Returns the most recent time this process exited with an error.
 GregorianCalendar getExitErrorTimeDate()
          Returns the most recent time this process exited with an error.
 long getExitTime()
          Returns the most recent exit time of this process.
 GregorianCalendar getExitTimeDate()
          Returns the most recent exit time of this process.
 int getGoal()
          Returns the process goal.
protected  String getInfo()
          Returns a String representation of this Process.
 String getName()
          Returns the name of this process.
 long getNumberOfStarts()
          Returns the number of starts of the process.
protected static void getProcessInfo(int cellHandle, String processName, Process theProcess)
          Fills in the information fields of the provided Process.
 Server getServer()
          Returns the server hosting this process.
 long getStartTime()
          Returns the most recent start time of this process.
 GregorianCalendar getStartTimeDate()
          Returns the most recent start time of this process.
 int getState()
          Returns the process execution state.
 boolean getStateBadFileAccess()
          Returns whether or not the state of the process indicates bad file access.
 boolean getStateOk()
          Returns whether or not the state of the process is ok.
 boolean getStateTooManyErrors()
          Returns whether or not the state of the process indicates too many errors.
 int getType()
          Returns the process type.
protected static void reclaimProcessMemory()
          Reclaims all memory being saved by the process portion of the native library.
 void refresh()
          Refreshes the properties of this Process object instance with values from the AFS process it represents.
protected  void refresh(boolean all)
          Refreshes the properties of this Process object instance with values from the AFS process it represents.
protected  void refreshInfo()
          Refreshes the information fields of this Process to reflect the current state of the AFS process, such as the start time, the state, etc.
 void restart()
          Restarts this process
protected static void restart(int serverHandle, String processName)
          Retart this process.
 void start()
          Starts this process
protected static void start(int serverHandle, String processName)
          Start this process.
 void stop()
          Stops this process.
protected static void stop(int serverHandle, String processName)
          Stop this process.
 String toString()
          Returns the name of this Process
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

SIMPLE_PROCESS

public static final int SIMPLE_PROCESS
Any standard type of process except for fs (such as kaserver, upclientbin, etc.)

See Also:
Constant Field Values

FS_PROCESS

public static final int FS_PROCESS
Combination of File Server, Volume Server, and Salvager processes

See Also:
Constant Field Values

CRON_PROCESS

public static final int CRON_PROCESS
A process that should be restarted at a specific time either daily or weekly.

See Also:
Constant Field Values

STOPPED

public static final int STOPPED
Process execution state stopped

See Also:
Constant Field Values

RUNNING

public static final int RUNNING
Process execution state running

See Also:
Constant Field Values

STOPPING

public static final int STOPPING
Process execution state stopping

See Also:
Constant Field Values

STARTING

public static final int STARTING
Process execution state starting

See Also:
Constant Field Values

name

protected String name

server

protected Server server

serverHandle

protected int serverHandle

type

protected int type

state

protected int state

goal

protected int goal

startTime

protected long startTime

numberStarts

protected long numberStarts

exitTime

protected long exitTime

exitErrorTime

protected long exitErrorTime

errorCode

protected long errorCode

errorSignal

protected long errorSignal

stateOk

protected boolean stateOk

stateTooManyErrors

protected boolean stateTooManyErrors

stateBadFileAccess

protected boolean stateBadFileAccess

startTimeDate

protected GregorianCalendar startTimeDate

exitTimeDate

protected GregorianCalendar exitTimeDate

exitErrorTimeDate

protected GregorianCalendar exitErrorTimeDate

cachedInfo

protected boolean cachedInfo
Constructor Detail

Process

public Process(String name,
               Server server)
        throws AFSException
Constructs a new Process object instance given the name of the AFS process and the AFS server, represented by server, to which it belongs. This does not actually create a new AFS process, it just represents one. If name is not an actual AFS process, exceptions will be thrown during subsequent method invocations on this object, unless one of the createSimple(String), createFS(String), or createCron(String,String) methods are explicitly called to create it.

Parameters:
name - the name of the server to represent
server - the server on which the process resides
Throws:
AFSException - If an error occurs in the native code

Process

public Process(String name,
               Server server,
               boolean preloadAllMembers)
        throws AFSException
Constructs a new Process object instance given the name of the AFS process and the AFS server, represented by server, to which it belongs. This does not actually create a new AFS process, it just represents one. If name is not an actual AFS process, exceptions will be thrown during subsequent method invocations on this object, unless one of the createSimple(String), createFS(String), or createCron(String,String) methods are explicitly called to create it. Note that if he process doesn't exist and preloadAllMembers is true, an exception will be thrown.

This constructor is ideal for point-in-time representation and transient applications. It ensures all data member values are set and available without calling back to the filesystem at the first request for them. Use the refresh() method to address any coherency concerns.

Parameters:
name - the name of the process to represent
server - the server to which the process belongs.
preloadAllMembers - true will ensure all object members are set upon construction; otherwise members will be set upon access, which is the default behavior.
Throws:
AFSException - If an error occurs in the native code
See Also:
refresh()

Process

Process(Server server)
  throws AFSException
Creates a blank Process given the server to which the process belongs. This blank object can then be passed into other methods to fill out its properties.

Parameters:
server - the server to which the process belongs.
Throws:
AFSException - If an error occurs in the native code
Method Detail

refresh

public void refresh()
             throws AFSException
Refreshes the properties of this Process object instance with values from the AFS process it represents. All properties that have been initialized and/or accessed will be renewed according to the values of the AFS process this Process object instance represents.

Since in most environments administrative changes can be administered from an AFS command-line program or an alternate GUI application, this method provides a means to refresh the Java object representation and thereby ascertain any possible modifications that may have been made from such alternate administrative programs. Using this method before an associated instance accessor will ensure the highest level of representative accuracy, accommodating changes made external to the Java application space. If administrative changes to the underlying AFS system are only allowed via this API, then the use of this method is unnecessary.

Throws:
AFSException - If an error occurs in the native code

refresh

protected void refresh(boolean all)
                throws AFSException
Refreshes the properties of this Process object instance with values from the AFS process it represents. If all is true then all of the properties of this Process object instance will be set, or renewed, according to the values of the AFS process it represents, disregarding any previously set properties.

Thus, if all is false then properties that are currently set will be refreshed and properties that are not set will remain uninitialized. See refresh() for more information.

Parameters:
all - if true set or renew all object properties; otherwise renew all set properties
Throws:
AFSException - If an error occurs in the native code
See Also:
refresh()

refreshInfo

protected void refreshInfo()
                    throws AFSException
Refreshes the information fields of this Process to reflect the current state of the AFS process, such as the start time, the state, etc.

Throws:
AFSException - If an error occurs in the native code

createSimple

public void createSimple(String executionPath)
                  throws AFSException
Creates this process as a simple process on the server.

Parameters:
executionPath - the path to the process's executable
Throws:
AFSException - If an error occurs in the native code

createFS

public void createFS(String executionPath)
              throws AFSException
Creates this process as a file server process on the server.

Parameters:
executionPath - the path to the process's executable
Throws:
AFSException - If an error occurs in the native code

createCron

public void createCron(String executionPath,
                       String cronTime)
                throws AFSException
Creates this process as a cron process on the server.

Parameters:
executionPath - the path to the process's executable
cronTime - a String representing the time a cron process is to be run. Acceptable formats are:
  • for daily restarts: "23:10" or "11:10 pm"
  • for weekly restarts: "sunday 11:10pm" or "sun 11:10pm"
Throws:
AFSException - If an error occurs in the native code

delete

public void delete()
            throws AFSException
Removes this process from the bos server

Throws:
AFSException - If an error occurs in the native code

stop

public void stop()
          throws AFSException
Stops this process.

Throws:
AFSException - If an error occurs in the native code

start

public void start()
           throws AFSException
Starts this process

Throws:
AFSException - If an error occurs in the native code

restart

public void restart()
             throws AFSException
Restarts this process

Throws:
AFSException - If an error occurs in the native code

getName

public String getName()
Returns the name of this process.

Returns:
the name of this process

getServer

public Server getServer()
Returns the server hosting this process.

Returns:
this process' server

getType

public int getType()
            throws AFSException
Returns the process type. Possible values are:

Returns:
the process type
Throws:
AFSException - If an error occurs in the native code

getGoal

public int getGoal()
            throws AFSException
Returns the process goal. Possible values are: After this method is called once, it saves the value and returns that value on subsequent calls, until the refresh() method is called and a more current value is obtained.

Returns:
the process goal
Throws:
AFSException - If an error occurs in the native code

getState

public int getState()
             throws AFSException
Returns the process execution state. Possible values are: After this method is called once, it saves the value and returns that value on subsequent calls, until the refresh() method is called and a more current value is obtained.

Returns:
the process execution state
Throws:
AFSException - If an error occurs in the native code

getStartTime

public long getStartTime()
                  throws AFSException
Returns the most recent start time of this process. A null value indicates no start time. After this method is called once, it saves the value and returns that value on subsequent calls, until the refresh() method is called and a more current value is obtained.

Returns:
the start time
Throws:
AFSException - If an error occurs in the native code

getStartTimeDate

public GregorianCalendar getStartTimeDate()
                                   throws AFSException
Returns the most recent start time of this process. A null value indicates no start time. After this method is called once, it saves the value and returns that value on subsequent calls, until the refresh() method is called and a more current value is obtained.

Returns:
the start time
Throws:
AFSException - If an error occurs in the native code

getNumberOfStarts

public long getNumberOfStarts()
                       throws AFSException
Returns the number of starts of the process. After this method is called once, it saves the value and returns that value on subsequent calls, until the refresh() method is called and a more current value is obtained.

Returns:
the number of starts
Throws:
AFSException - If an error occurs in the native code

getExitTime

public long getExitTime()
                 throws AFSException
Returns the most recent exit time of this process. A null value indicates no exit time. After this method is called once, it saves the value and returns that value on subsequent calls, until the refresh() method is called and a more current value is obtained.

Returns:
the exit time
Throws:
AFSException - If an error occurs in the native code

getExitTimeDate

public GregorianCalendar getExitTimeDate()
                                  throws AFSException
Returns the most recent exit time of this process. A null value indicates no exit time After this method is called once, it saves the value and returns that value on subsequent calls, until the refresh() method is called and a more current value is obtained.

Returns:
the exit time
Throws:
AFSException - If an error occurs in the native code

getExitErrorTime

public long getExitErrorTime()
                      throws AFSException
Returns the most recent time this process exited with an error. A null value indicates no exit w/ error time. After this method is called once, it saves the value and returns that value on subsequent calls, until the refresh() method is called and a more current value is obtained.

Returns:
the exit w/ error time
Throws:
AFSException - If an error occurs in the native code

getExitErrorTimeDate

public GregorianCalendar getExitErrorTimeDate()
                                       throws AFSException
Returns the most recent time this process exited with an error. A < code>null value indicates no exit w/ error time. After this method is called once, it saves the value and returns that value on subsequent calls, until the refresh() method is called and a more current value is obtained.

Returns:
the exit w/ error time
Throws:
AFSException - If an error occurs in the native code

getErrorCode

public long getErrorCode()
                  throws AFSException
Returns the error code of the process. A value of 0 indicates no error code. After this method is called once, it saves the value and returns that value on subsequent calls, until the refresh() method is called and a more current value is obtained.

Returns:
the error code
Throws:
AFSException - If an error occurs in the native code

getErrorSignal

public long getErrorSignal()
                    throws AFSException
Returns the error signal of the process. A value of 0 indicates no error signal. After this method is called once, it saves the value and returns that value on subsequent calls, until the refresh() method is called and a more current value is obtained.

Returns:
the error signal
Throws:
AFSException - If an error occurs in the native code

getStateOk

public boolean getStateOk()
                   throws AFSException
Returns whether or not the state of the process is ok. A value of false indicates there has been a core dump. After this method is called once, it saves the value and returns that value on subsequent calls, until the refresh() method is called and a more current value is obtained.

Returns:
whether or not the state is ok
Throws:
AFSException - If an error occurs in the native code

getStateTooManyErrors

public boolean getStateTooManyErrors()
                              throws AFSException
Returns whether or not the state of the process indicates too many errors. After this method is called once, it saves the value and returns that value on subsequent calls, until the refresh() method is called and a more current value is obtained.

Returns:
whether or not the state indicates too many errors
Throws:
AFSException - If an error occurs in the native code

getStateBadFileAccess

public boolean getStateBadFileAccess()
                              throws AFSException
Returns whether or not the state of the process indicates bad file access. After this method is called once, it saves the value and returns that value on subsequent calls, until the refresh() method is called and a more current value is obtained.

Returns:
whether or not the state indicates bad file access
Throws:
AFSException - If an error occurs in the native code

getInfo

protected String getInfo()
Returns a String representation of this Process. Contains the information fields.

Returns:
a String representation of the Process

compareTo

public int compareTo(Process process)
Compares two Process objects respective to their names and does not factor any other attribute. Alphabetic case is significant in comparing names.

Parameters:
process - The Process object to be compared to this Process instance
Returns:
Zero if the argument is equal to this Process' name, a value less than zero if this Process' name is lexicographically less than the argument, or a value greater than zero if this Process' name is lexicographically greater than the argument

compareTo

public int compareTo(Object obj)
Comparable interface method.

Specified by:
compareTo in interface Comparable
See Also:
compareTo(Process)

equals

public boolean equals(Process otherProcess)
Tests whether two Process objects are equal, based on their names and hosting server.

Parameters:
otherProcess - the Process to test
Returns:
whether the specifed Process is the same as this Process

toString

public String toString()
Returns the name of this Process

Overrides:
toString in class Object
Returns:
the name of this Process

getProcessInfo

protected static void getProcessInfo(int cellHandle,
                                     String processName,
                                     Process theProcess)
                              throws AFSException
Fills in the information fields of the provided Process.

Parameters:
cellHandle - the handle of the cell to which the process belongs
processName - the instance name of the process for which to get the information
theProcess - the Process object in which to fill in the information
Throws:
AFSException - If an error occurs in the native code
See Also:
Cell.getCellHandle()

create

protected static void create(int serverHandle,
                             String processName,
                             int processType,
                             String executionPath,
                             String cronTime,
                             String notifier)
                      throws AFSException
Creates a processes on a server.

Parameters:
serverHandle - the bos handle of the server to which the key will belong
processName - the instance name to give the process. See AFS documentation for a standard list of instance names
processType - the type of process this will be. Acceptable values are:
executionPath - the execution path process to create
cronTime - a String representing the time a cron process is to be run. Acceptable formats are:
  • for daily restarts: "23:10" or "11:10 pm"
  • for weekly restarts: "sunday 11:10pm" or "sun 11:10pm"
Can be null for non-cron processes.
notifier - the execution path to a notifier program that should be called when the process terminates. Can be null
Throws:
AFSException - If an error occurs in the native code
See Also:
Server.getBosServerHandle(int, java.lang.String)

delete

protected static void delete(int serverHandle,
                             String processName)
                      throws AFSException
Removes a process from a server.

Parameters:
serverHandle - the bos handle of the server to which the process belongs
processName - the name of the process to remove
Throws:
AFSException - If an error occurs in the native code
See Also:
Server.getBosServerHandle(int, java.lang.String)

start

protected static void start(int serverHandle,
                            String processName)
                     throws AFSException
Start this process.

Parameters:
serverHandle - the bos handle of the server to which the process belongs
processName - the name of the process to start
Throws:
AFSException - If an error occurs in the native code
See Also:
Server.getBosServerHandle(int, java.lang.String)

restart

protected static void restart(int serverHandle,
                              String processName)
                       throws AFSException
Retart this process.

Parameters:
serverHandle - the bos handle of the server to which the process belongs
processName - the name of the process to restart
Throws:
AFSException - If an error occurs in the native code
See Also:
Server.getBosServerHandle(int, java.lang.String)

stop

protected static void stop(int serverHandle,
                           String processName)
                    throws AFSException
Stop this process.

Parameters:
serverHandle - the bos handle of the server to which the process belongs
processName - the name of the process to stop
Throws:
AFSException - If an error occurs in the native code
See Also:
Server.getBosServerHandle(int, java.lang.String)

reclaimProcessMemory

protected static void reclaimProcessMemory()
Reclaims all memory being saved by the process portion of the native library. This method should be called when no more Process objects are expected to be used.


JAFS API v2