|
JAFS API v2 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.openafs.jafs.Process
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"); } } ... }
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 |
public static final int SIMPLE_PROCESS
public static final int FS_PROCESS
public static final int CRON_PROCESS
public static final int STOPPED
public static final int RUNNING
public static final int STOPPING
public static final int STARTING
protected String name
protected Server server
protected int serverHandle
protected int type
protected int state
protected int goal
protected long startTime
protected long numberStarts
protected long exitTime
protected long exitErrorTime
protected long errorCode
protected long errorSignal
protected boolean stateOk
protected boolean stateTooManyErrors
protected boolean stateBadFileAccess
protected GregorianCalendar startTimeDate
protected GregorianCalendar exitTimeDate
protected GregorianCalendar exitErrorTimeDate
protected boolean cachedInfo
Constructor Detail |
public Process(String name, Server server) throws AFSException
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.
name
- the name of the server to representserver
- the server on which the process resides
AFSException
- If an error occurs in the native codepublic Process(String name, Server server, boolean preloadAllMembers) throws AFSException
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.
name
- the name of the process to representserver
- 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.
AFSException
- If an error occurs in the native coderefresh()
Process(Server server) throws AFSException
Process
given the server to which the process
belongs. This blank object can then be passed into other methods to fill
out its properties.
server
- the server to which the process belongs.
AFSException
- If an error occurs in the native codeMethod Detail |
public void refresh() throws AFSException
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.
AFSException
- If an error occurs in the native codeprotected void refresh(boolean all) throws AFSException
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.
all
- if true set or renew all object properties; otherwise renew
all set properties
AFSException
- If an error occurs in the native coderefresh()
protected void refreshInfo() throws AFSException
Process
to reflect
the current state of the AFS process, such as the start time, the state,
etc.
AFSException
- If an error occurs in the native codepublic void createSimple(String executionPath) throws AFSException
executionPath
- the path to the process's executable
AFSException
- If an error occurs in the native codepublic void createFS(String executionPath) throws AFSException
executionPath
- the path to the process's executable
AFSException
- If an error occurs in the native codepublic void createCron(String executionPath, String cronTime) throws AFSException
executionPath
- the path to the process's executablecronTime
- a String representing the time a cron process is
to be run. Acceptable formats are:AFSException
- If an error occurs in the native codepublic void delete() throws AFSException
AFSException
- If an error occurs in the native codepublic void stop() throws AFSException
AFSException
- If an error occurs in the native codepublic void start() throws AFSException
AFSException
- If an error occurs in the native codepublic void restart() throws AFSException
AFSException
- If an error occurs in the native codepublic String getName()
public Server getServer()
public int getType() throws AFSException
AFSException
- If an error occurs in the native codepublic int getGoal() throws AFSException
refresh()
method is called and a more current
value is obtained.
AFSException
- If an error occurs in the native codepublic int getState() throws AFSException
refresh()
method is called and a more current
value is obtained.
AFSException
- If an error occurs in the native codepublic long getStartTime() throws AFSException
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.
AFSException
- If an error occurs in the native codepublic GregorianCalendar getStartTimeDate() throws AFSException
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.
AFSException
- If an error occurs in the native codepublic long getNumberOfStarts() throws AFSException
refresh()
method is called and a more current
value is obtained.
AFSException
- If an error occurs in the native codepublic long getExitTime() throws AFSException
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.
AFSException
- If an error occurs in the native codepublic GregorianCalendar getExitTimeDate() throws AFSException
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.
AFSException
- If an error occurs in the native codepublic long getExitErrorTime() throws AFSException
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.
AFSException
- If an error occurs in the native codepublic GregorianCalendar getExitErrorTimeDate() throws AFSException
refresh()
method is called and a more current
value is obtained.
AFSException
- If an error occurs in the native codepublic long getErrorCode() throws AFSException
refresh()
method is called and a more current
value is obtained.
AFSException
- If an error occurs in the native codepublic long getErrorSignal() throws AFSException
refresh()
method is called and a more current
value is obtained.
AFSException
- If an error occurs in the native codepublic boolean getStateOk() throws AFSException
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.
AFSException
- If an error occurs in the native codepublic boolean getStateTooManyErrors() throws AFSException
refresh()
method is called and a more current
value is obtained.
AFSException
- If an error occurs in the native codepublic boolean getStateBadFileAccess() throws AFSException
refresh()
method is called and a more current
value is obtained.
AFSException
- If an error occurs in the native codeprotected String getInfo()
String
representation of this Process
.
Contains the information fields.
String
representation of the Process
public int compareTo(Process process)
process
- The Process object to be compared to this Process
instance
public int compareTo(Object obj)
compareTo
in interface Comparable
compareTo(Process)
public boolean equals(Process otherProcess)
Process
objects are equal, based on their
names and hosting server.
otherProcess
- the Process to test
public String toString()
Process
toString
in class Object
Process
protected static void getProcessInfo(int cellHandle, String processName, Process theProcess) throws AFSException
Process
.
cellHandle
- the handle of the cell to which the process belongsprocessName
- the instance name of the process for which to get
the informationtheProcess
- the Process
object in which to fill
in the information
AFSException
- If an error occurs in the native codeCell.getCellHandle()
protected static void create(int serverHandle, String processName, int processType, String executionPath, String cronTime, String notifier) throws AFSException
serverHandle
- the bos handle of the server to which the key will
belongprocessName
- the instance name to give the process. See AFS
documentation for a standard list of instance namesprocessType
- the type of process this will be.
Acceptable values are:executionPath
- the execution path process to createcronTime
- a String representing the time a cron process is to
be run. Acceptable formats are:null
for non-cron processes.notifier
- the execution path to a notifier program that should
be called when the process terminates. Can be
null
AFSException
- If an error occurs in the native codeServer.getBosServerHandle(int, java.lang.String)
protected static void delete(int serverHandle, String processName) throws AFSException
serverHandle
- the bos handle of the server to which the process
belongsprocessName
- the name of the process to remove
AFSException
- If an error occurs in the native codeServer.getBosServerHandle(int, java.lang.String)
protected static void start(int serverHandle, String processName) throws AFSException
serverHandle
- the bos handle of the server to which the process
belongsprocessName
- the name of the process to start
AFSException
- If an error occurs in the native codeServer.getBosServerHandle(int, java.lang.String)
protected static void restart(int serverHandle, String processName) throws AFSException
serverHandle
- the bos handle of the server to which the process
belongsprocessName
- the name of the process to restart
AFSException
- If an error occurs in the native codeServer.getBosServerHandle(int, java.lang.String)
protected static void stop(int serverHandle, String processName) throws AFSException
serverHandle
- the bos handle of the server to which the process
belongsprocessName
- the name of the process to stop
AFSException
- If an error occurs in the native codeServer.getBosServerHandle(int, java.lang.String)
protected static void reclaimProcessMemory()
Process
objects are expected to be used.
|
JAFS API v2 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |