Java AFS API v1.4

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
static int CRON_PROCESS
          A process that should be restarted at a specific time either daily or weekly.
static int FS_PROCESS
          Combination of File Server, Volume Server, and Salvager processes
static int RUNNING
          Process execution state running
static int SIMPLE_PROCESS
          Any standard type of process except for fs (such as kaserver, upclientbin, etc.)
static int STARTING
          Process execution state starting
static int STOPPED
          Process execution state stopped
static int STOPPING
          Process execution state stopping
 
Constructor Summary
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.
 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
 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.
 String getName()
          Returns the name of this process.
 long getNumberOfStarts()
          Returns the number of starts of the 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.
 void refresh()
          Refreshes the properties of this Process object instance with values from the AFS process it represents.
 void restart()
          Restarts this process
 void start()
          Starts this process
 void stop()
          Stops this process.
 String toString()
          Returns the name of this Process
 
Methods inherited from class java.lang.Object
equals, 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
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()
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

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

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

Java AFS API (jafs) for OpenAFS

Copyright (c) 2001-2002 International Business Machines Corp.
All rights reserved.
See copyright statement.