|
Java AFS Admin API v1.3 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.openafs.jafsadm.Server
An abstract representation of an AFS server. It holds information about
the server, such as what its processes are.
Constructing an instance of a Server
does not mean an actual
AFS server is created and added to a cell -- on the contrary, a
Server
object must be a representation of an already existing
AFS server. There is no way to create a new AFS server through this API.
See OpenAFS.org for information on how
to create a new AFS server.
A Server
object may represent either an AFS file server,
an AFS database server, or both if the same machine serves both
purposes.
Each Server
object has its own individual set of
Partition
s, Process
es, and Key
s.
This represents the properties and attributes of an actual AFS server.
The following is a simple example of how to construct and use a Server
object. This example constructs a Server
using the
Cell
representing teh AFS cell to which the server belongs,
and prints out the names of all the partitions residing on the server.
import org.openafs.jafsadm.Cell; import org.openafs.jafsadm.AFSAdminException; import org.openafs.jafsadm.Partition; import org.openafs.jafsadm.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]; cell = new Cell(cellName, username, password); server = new Server(serverName, cell); System.out.println("Partitions in Server " + server.getName() + ":"); if( server.isFileServer() ) { Partition[] partitions = server.getPartitions(); for (int i = 0; i < partitions.length; i++) { System.out.println(" -> " + partitions[i]); } } } ... }
Inner Class Summary | |
static class |
Server.ExecutableTime
|
Constructor Summary | |
Server(String name,
Cell cell)
Constructs a new Server object instance given the
name of the AFS server and the AFS cell, represented by
cell , to which it belongs. |
|
Server(String name,
Cell cell,
boolean preloadAllMembers)
Constructs a new Server object instance given the name
of the AFS server and the AFS cell, represented by cell ,
to which it belongs. |
Method Summary | |
void |
addAdmin(User admin)
Add a bos admin to the UserList file of this server, in order to given the AFS user represented by admin full bos
administrative privileges on this server. |
void |
close()
Unauthenticates all server-related tokens that have been obtained by this Server object, and shuts this server object down. |
int |
compareTo(Object obj)
Comparable interface method. |
int |
compareTo(Server server)
Compares two Server objects respective to their names and does not factor any other attribute. |
boolean |
equals(Server otherServer)
Tests whether two Server objects are equal, based on their
names and hosting Cell. |
int |
getAdminCount()
Returns the number of BOS administrators assigned to this server. |
String[] |
getAdminNames()
Retrieves an array containing all of the names of bos admins associated with this Server . |
User[] |
getAdmins()
Retrieves an array containing all of the admin User objects
associated with this Server , each of which are an abstract
representation of an actual bos administrator of the AFS server. |
Server.ExecutableTime |
getBinaryRestartTime()
Returns the BOS Server's binary restart time in the form of an ExecutableTime object. |
Cell |
getCell()
Returns the Cell object with which this Server
was constructed. |
Server.ExecutableTime |
getGeneralRestartTime()
Returns the BOS Server's general restart time in the form of an ExecutableTime object. |
String[] |
getIPAddresses()
Returns this server's IP address as a String. |
Key |
getKey(int keyVersion)
Retrieves the Key object (which is an abstract
representation of an actual AFS partition of this server) designated
by nkeyVersion . |
int |
getKeyCount()
Returns the number of keys on this server. |
Key[] |
getKeys()
Retrieves an array containing all of the Key objects
associated with this Server , each of which are an abstract
representation of an actual AFS key of the AFS server. |
String |
getLog(String logLocation)
Gets the contents of a log file, in one large String . |
String |
getName()
Returns the name of this server. |
Partition |
getPartition(String name)
Retrieves the Partition object (which is an abstract
representation of an actual AFS partition of this server) designated
by name (i.e. |
int |
getPartitionCount()
Returns the number of partitions on this server. |
String[] |
getPartitionNames()
Retrieves an array containing all of the names of partitions associated with this Server (i.e. |
Partition[] |
getPartitions()
Retrieves an array containing all of the Partition objects
associated with this Server , each of which are an abstract
representation of an actual AFS partition of the AFS server. |
Process |
getProcess(String name)
Retrieves the Process object (which is an abstract
representation of an actual AFS process of this server) designated
by name (i.e. |
int |
getProcessCount()
Returns the number of processes hosted by this server. |
Process[] |
getProcesses()
Retrieves an array containing all of the Process objects
associated with this Server , each of which are an abstract
representation of an actual AFS process of the AFS server. |
String[] |
getProcessNames()
Retrieves an array containing all of the names of processes associated with this Server (i.e. |
int |
getTotalFreeSpace()
Returns the total free space on this server (a sum of the free space of all the partitions associated with this server). |
int |
getTotalSpace()
Returns the total space on this server (a sum of the space of all the partitions associated with this server). |
int |
getTotalUsedSpace()
Returns the total used space on this server (a sum of the used space of all the partitions associated with this server). |
boolean |
isBadDatabase()
Returns whether or not this server is a database machine AND either it isn't in reality (e.g. |
boolean |
isBadFileServer()
Returns whether this machine thinks it's a file server AND either it isn't in reality (e.g. |
boolean |
isDatabase()
Returns whether or not this server is a database machine, meaning it runs processes such as the "kaserver" and "vlserver", and participates in elections. |
boolean |
isFileServer()
Returns whether or not this server is a file server machine, meaning it runs the "fs" process and stores AFS volumes. |
void |
refresh()
Refreshes the properties of this Server object instance with values from the AFS server it represents. |
void |
removeAdmin(User admin)
Remove a bos admin from the UserList file of this server, in order to take away from the AFS user represented by admin bos
administrative privileges on this machine. |
void |
restartAllProcesses()
Restarts all bos processes on this server. |
void |
restartBosServer()
Restarts bos server and all bos processes on this server. |
void |
salvage()
Salvages (restores consistency to) this server. |
void |
setBinaryRestartTime(Server.ExecutableTime executableTime)
Sets the BOS binary restart time. |
void |
setGeneralRestartTime(Server.ExecutableTime executableTime)
Sets the BOS general restart time. |
void |
startAllProcesses()
Starts up all bos processes on this server. |
void |
stopAllProcesses()
Stops all bos processes on this server. |
void |
syncServer()
Syncs this server to the VLDB. |
void |
syncVLDB()
Syncs the VLDB to this server. |
String |
toString()
Returns the name of this Server |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public Server(String name, Cell cell) throws AFSAdminException
Server
object instance given the
name of the AFS server and the AFS cell, represented by
cell
, to which it belongs. This does not actually
create a new AFS server, it just represents an existing one.
If name
is not an actual AFS server, exceptions
will be thrown during subsequent method invocations on this
object.name
- the name of the server to representcell
- the cell to which the server belongs.AFSAdminException
- If an error occurs in the native codepublic Server(String name, Cell cell, boolean preloadAllMembers) throws AFSAdminException
Server
object instance given the name
of the AFS server and the AFS cell, represented by cell
,
to which it belongs. This does not actually
create a new AFS server, it just represents an existing one.
If name
is not an actual AFS server, exceptions
will be thrown during subsequent method invocations on this
object.
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 server to representcell
- the cell to which the server belongs.preloadAllMembers
- true will ensure all object members are
set upon construction;
otherwise members will be set upon access,
which is the default behavior.AFSAdminException
- If an error occurs in the native coderefresh()
Method Detail |
public void refresh() throws AFSAdminException
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.
AFSAdminException
- If an error occurs in the native codepublic void addAdmin(User admin) throws AFSAdminException
admin
full bos
administrative privileges on this server.admin
- the admin to addAFSAdminException
- If an error occurs in the native codepublic void removeAdmin(User admin) throws AFSAdminException
admin
bos
administrative privileges on this machine.admin
- the admin to removeAFSAdminException
- If an error occurs in the native codepublic void syncServer() throws AFSAdminException
AFSAdminException
- If an error occurs in the native codepublic void syncVLDB() throws AFSAdminException
AFSAdminException
- If an error occurs in the native codepublic void salvage() throws AFSAdminException
AFSAdminException
- If an error occurs in the native codepublic void startAllProcesses() throws AFSAdminException
AFSAdminException
- If an error occurs in the native codepublic void stopAllProcesses() throws AFSAdminException
AFSAdminException
- If an error occurs in the native codepublic void restartAllProcesses() throws AFSAdminException
AFSAdminException
- If an error occurs in the native codepublic void restartBosServer() throws AFSAdminException
AFSAdminException
- If an error occurs in the native codepublic String getLog(String logLocation) throws AFSAdminException
String
.
The log cannot be in AFS file space.String
containing the contents of the log fileAFSAdminException
- If an error occurs in the native codepublic void close() throws AFSAdminException
Server
object, and shuts this server object down.
This method should only be called when this Server
or any
of the objects constructed using this Server
will not be
used anymore. Note that this does not effect the actual AFS server;
it merely closes the representation.AFSAdminException
- If an error occurs in the native codepublic String getName()
public Cell getCell()
Cell
object with which this Server
was constructed. It represents the actual AFS cell to which this
server belongs.public int getAdminCount() throws AFSAdminException
If the total list of admins or admin names have already been
collected (see getAdmins()
), then the returning value will
be calculated based upon the current list. Otherwise, AFS will be
explicitly queried for the information.
The product of this method is not saved, and is recalculated with every call.
AFSAdminException
- If an error occurs
in any of the associated native methodsgetAdmins()
,
getAdminNames()
public User[] getAdmins() throws AFSAdminException
User
objects
associated with this Server
, each of which are an abstract
representation of an actual bos administrator of the AFS server.
After this method is called once, it saves the array of
User
s and returns that saved array on subsequent calls,
until the refresh()
method is called and a more current list
is obtained.User
array of the admins of the server.AFSAdminException
- If an error occurs in the native coderefresh()
public String[] getAdminNames() throws AFSAdminException
Server
. After this method
is called once, it saves the array of String
s and returns
that saved array on subsequent calls, until the refresh()
method
is called and a more current list is obtained.String
array of the bos admin of the server.AFSAdminException
- If an error occurs in the native coderefresh()
public int getPartitionCount() throws AFSAdminException
If the total list of partitions or partition names have already been
collected (see getPartitions()
), then the returning value will
be calculated based upon the current list. Otherwise, AFS will be
explicitly queried for the information.
The product of this method is not saved, and is recalculated with every call.
AFSAdminException
- If an error occurs
in any of the associated native methodsgetPartitions()
,
getPartitionNames()
public Partition getPartition(String name) throws AFSAdminException
Partition
object (which is an abstract
representation of an actual AFS partition of this server) designated
by name
(i.e. "/vicepa", etc.). If a partition by
that name does not actually exist in AFS on the server
represented by this object, an AFSAdminException
will be
thrown.name
- the name of the partition to retrievePartition
designated by name
.AFSAdminException
- If an error occurs in the native codeNullPointerException
- If name
is
null
.public Partition[] getPartitions() throws AFSAdminException
Partition
objects
associated with this Server
, each of which are an abstract
representation of an actual AFS partition of the AFS server.
After this method is called once, it saves the array of
Partition
s and returns that saved array on subsequent calls,
until the refresh()
method is called and a more current list
is obtained.Partition
array of the Partition
objects of the server.AFSAdminException
- If an error occurs in the native coderefresh()
public String[] getPartitionNames() throws AFSAdminException
Server
(i.e. "vicepa", etc.).
After this method is called once, it saves the array of
String
s and returns that saved array on subsequent calls,
until the refresh()
method is called and a more current
list is obtained.String
array of the partitions of the server.AFSAdminException
- If an error occurs in the native coderefresh()
public Key getKey(int keyVersion) throws AFSAdminException
Key
object (which is an abstract
representation of an actual AFS partition of this server) designated
by nkeyVersion
. If a key with
that version does not actually exist in AFS on the server
represented by this object, null
is returned.keyVersion
- the version of the key to retrieveKey
designated by keyVersion
.AFSAdminException
- If an error occurs in the native codepublic int getKeyCount() throws AFSAdminException
If the total list of keys has already been
collected (see getKeys()
), then the returning value will
be calculated based upon the current list. Otherwise, AFS will be
explicitly queried for the information.
The product of this method is not saved, and is recalculated with every call.
AFSAdminException
- If an error occurs
in any of the associated native methodsgetKeys()
public Key[] getKeys() throws AFSAdminException
Key
objects
associated with this Server
, each of which are an abstract
representation of an actual AFS key of the AFS server.
After this method is called once, it saves the array of
Key
s and returns that saved array on subsequent calls,
until the refresh()
method is called and a more current list
is obtained.Key
array of the Key
objects
of the server.AFSAdminException
- If an error occurs in the native coderefresh()
public Process getProcess(String name) throws AFSAdminException
Process
object (which is an abstract
representation of an actual AFS process of this server) designated
by name
(i.e. "kaserver", etc.). If a process by
that name does not actually exist in AFS on the server
represented by this object, an AFSAdminException
will be
thrown.name
- the name of the process to retrieveProcess
designated by name
.AFSAdminException
- If an error occurs in the native codeNullPointerException
- If name
is
null
.public int getProcessCount() throws AFSAdminException
If the total list of processes or process names have already been
collected (see getProcesses()
), then the returning value will
be calculated based upon the current list. Otherwise, AFS will be
explicitly queried for the information.
The product of this method is not saved, and is recalculated with every call.
AFSAdminException
- If an error occurs
in any of the associated native methodsgetProcesses()
,
getProcessNames()
public Process[] getProcesses() throws AFSAdminException
Process
objects
associated with this Server
, each of which are an abstract
representation of an actual AFS process of the AFS server.
After this method is called once, it saves the array of
Process
es and returns that saved array on subsequent calls,
until the refresh()
method is called and a more current list
is obtained.Process
array of the Process
objects of the server.AFSAdminException
- If an error occurs in the native coderefresh()
public String[] getProcessNames() throws AFSAdminException
Server
(i.e. "kaserver", etc.).
After this method is called once, it saves the array of
String
s and returns that saved array on subsequent calls,
until the refresh()
method is called and a more current
list is obtained.String
array of the processes of the server.AFSAdminException
- If an error occurs in the native coderefresh()
public boolean isDatabase() throws AFSAdminException
AFSAdminException
- If an error occurs in the native coderefresh()
public boolean isFileServer() throws AFSAdminException
AFSAdminException
- If an error occurs in the native coderefresh()
public boolean isBadDatabase() throws AFSAdminException
AFSAdminException
- If an error occurs in the native coderefresh()
public boolean isBadFileServer() throws AFSAdminException
AFSAdminException
- If an error occurs in the native coderefresh()
public String[] getIPAddresses() throws AFSAdminException
AFSAdminException
- If an error occurs in the native coderefresh()
public Server.ExecutableTime getGeneralRestartTime() throws AFSAdminException
refresh()
method
is called and a more current value is obtained.AFSAdminException
- If an error occurs in the native codeServer.ExecutableTime
,
refresh()
public Server.ExecutableTime getBinaryRestartTime() throws AFSAdminException
refresh()
method
is called and a more current value is obtained.AFSAdminException
- If an error occurs in the native codeServer.ExecutableTime
,
refresh()
public int getTotalSpace() throws AFSAdminException
refresh()
method
is called and a more current value is obtained.AFSAdminException
- If an error occurs in the native coderefresh()
public int getTotalFreeSpace() throws AFSAdminException
refresh()
method
is called and a more current value is obtained.AFSAdminException
- If an error occurs in the native coderefresh()
public int getTotalUsedSpace() throws AFSAdminException
refresh()
method
is called and a more current value is obtained.AFSAdminException
- If an error occurs in the native codegetTotalSpace()
,
getTotalFreeSpace()
public void setGeneralRestartTime(Server.ExecutableTime executableTime) throws AFSAdminException
executableTime
- Executable time object that represents what
the BOS Server's general restart time should be.AFSAdminException
- If an error occurs in the native codeServer.ExecutableTime
public void setBinaryRestartTime(Server.ExecutableTime executableTime) throws AFSAdminException
executableTime
- Executable time object that represents what
the BOS Server's binary restart time should be.AFSAdminException
- If an error occurs in the native codeServer.ExecutableTime
public int compareTo(Server server)
server
- The Server object to be compared to this
Server instancepublic int compareTo(Object obj)
compareTo
in interface Comparable
compareTo(Server)
public boolean equals(Server otherServer)
Server
objects are equal, based on their
names and hosting Cell.otherServer
- the Server to testpublic String toString()
Server
toString
in class Object
Server
|
Java AFS Admin (jafsadm) API for OpenAFS | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |