JAFS API v2

org.openafs.jafs
Class Server

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

public class Server
extends Object
implements Serializable, Comparable

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 Partitions, Processes, and Keys. 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.jafs.Cell;
 import org.openafs.jafs.AFSException;
 import org.openafs.jafs.Partition;
 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("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]);
       }
     }
   }
   ...
 }
 

See Also:
Serialized Form

Nested Class Summary
static class Server.ExecutableTime
           
 
Field Summary
protected  ArrayList adminNames
           
protected  ArrayList admins
           
protected  boolean badDatabase
           
protected  boolean badFileServer
           
protected  Server.ExecutableTime binRestartTime
           
protected  int bosHandle
           
protected  boolean cachedInfo
           
protected  Cell cell
           
protected  boolean database
           
protected  boolean fileServer
           
protected  Server.ExecutableTime genRestartTime
           
protected  String[] ipAddresses
           
protected  ArrayList keys
           
protected  String name
           
protected  ArrayList partitionNames
           
protected  ArrayList partitions
           
protected  ArrayList processes
           
protected  ArrayList processNames
           
protected  int totalFreeSpace
           
protected  int totalQuota
           
protected  int totalSpace
           
protected  int totalUsedSpace
           
protected  int vosHandle
           
 
Constructor Summary
(package private) Server(Cell cell)
          Constructs a blank Server object instance given the cell to which the server belongs.
  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.
protected static void addBosAdmin(int serverHandle, String adminName)
          Adds the given to name to the list of bos administrators on that server.
 void close()
          Unauthenticates all server-related tokens that have been obtained by this Server object, and shuts this server object down.
protected static void closeBosServerHandle(int bosHandle)
          Closes the given currently open bos server handle.
protected static void closeVosServerHandle(int vosHandle)
          Closes the given currently open vos server handle.
 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.
protected static int getBosAdminCount(int serverHandle)
          Returns the total number of BOS administrators associated with the server denoted by serverHandle.
protected static int getBosAdminsBegin(int serverHandle)
          Begin the process of getting the bos amdinistrators on a server.
protected static void getBosAdminsDone(int iterationId)
          Signals that the iteration is complete and will not be accessed anymore.
protected static int getBosAdminsNext(int cellHandle, int iterationId, User theUser)
          Returns the next bos admin of the server.
protected static String getBosAdminsNextString(int iterationId)
          Returns the next bos admin of the server.
protected  int getBosHandle()
          Returns this server's bos handle.
protected static int getBosServerHandle(int cellHandle, String serverName)
          Opens a server for administrative bos use, based on the cell handle provided.
 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.
protected  String getInfo()
          Returns a String representation of this Server.
protected  String getInfoKeys()
          Returns a String containing the String representations of all the keys of this Server.
protected  String getInfoPartitions()
          Returns a String containing the String representations of all the partitions of this Server.
protected  String getInfoProcesses()
          Returns a String containing the String representations of all the processes of this Server.
 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.
protected static int getKeyCount(int serverHandle)
          Returns the total number of keys hosted by the server denoted by serverHandle.
 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.
protected static int getKeysBegin(int serverHandle)
          Begin the process of getting the keys of a server.
protected static void getKeysDone(int iterationId)
          Signals that the iteration is complete and will not be accessed anymore.
protected static int getKeysNext(int iterationId, Key theKey)
          Returns the next key of the server.
protected static String getLog(int serverHandle, String logLocation)
          Retrieves a specified bos log from a 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.
protected static int getPartitionCount(int cellHandle, int serverHandle)
          Returns the total number of partitions hosted by the server denoted by serverHandle, if the server is a fileserver.
 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.
protected static int getPartitionsBegin(int cellHandle, int serverHandle)
          Begin the process of getting the partitions on a server.
protected static void getPartitionsDone(int iterationId)
          Signals that the iteration is complete and will not be accessed anymore.
protected static int getPartitionsNext(int iterationId, Partition thePartition)
          Fills the next partition object of the server.
protected static String getPartitionsNextString(int iterationId)
          Returns the next partition of the 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.
protected static int getProcessCount(int serverHandle)
          Returns the total number of processes hosted by the server denoted by serverHandle.
 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.
protected static int getProcessesBegin(int serverHandle)
          Begin the process of getting the processes on a server.
protected static void getProcessesDone(int iterationId)
          Signals that the iteration is complete and will not be accessed anymore.
protected static int getProcessesNext(int serverHandle, int iterationId, Process theProcess)
          Fills the next process object of the server.
protected static String getProcessesNextString(int iterationId)
          Returns the next process of the server.
 String[] getProcessNames()
          Retrieves an array containing all of the names of processes associated with this Server (i.e.
protected static void getServerInfo(int cellHandle, String name, Server server)
          Fills in the information fields of the provided Server.
 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).
protected  int getVosHandle()
          Returns this server's vos handle.
protected static int getVosServerHandle(int cellHandle, String serverName)
          Opens a server for administrative vos use, based on the cell handle provided.
 boolean isBadDatabase()
          Returns whether or not this server is a database machine AND either it isn't in reality (e.g. it's incorrectly configured) or it's currently down.
 boolean isBadFileServer()
          Returns whether this machine thinks it's a file server AND either it isn't in reality (e.g. it's incorrectly configured) or it's currently down.
 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.
protected static void reclaimServerMemory()
          Reclaims all memory being saved by the server portion of the native library.
 void refresh()
          Refreshes the properties of this Server object instance with values from the AFS server it represents.
protected  void refresh(boolean all)
          Refreshes the properties of this Server object instance with values from the AFS server it represents.
protected  void refreshAdminNames()
          Obtains the most current list of bos admin names of this server.
protected  void refreshAdmins()
          Obtains the most current list of admin User objects of this server.
protected  void refreshBinaryRestart()
          Refreshes the binary restart time fields of this Server to reflect the current state of the AFS server.
protected  void refreshGeneralRestart()
          Refreshes the general restart time fields of this Server to reflect the current state of the AFS server.
protected  void refreshInfo()
          Refreshes the information fields of this Server to reflect the current state of the AFS server.
protected  void refreshKeys()
          Obtains the most current list of Key objects of this server.
protected  void refreshPartitionNames()
          Obtains the most current list of partition names of this server.
protected  void refreshPartitions()
          Obtains the most current list of Partition objects of this server.
protected  void refreshPartitions(boolean refreshVolumes)
          Obtains the most current list of Partition objects of this server.
protected  void refreshProcesses()
          Obtains the most current list of Process objects of this server.
protected  void refreshProcessNames()
          Obtains the most current list of process names of this server.
 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.
protected static void removeBosAdmin(int serverHandle, String adminName)
          Removes the given to name from the list of bos administrators on that server.
 void restartAllProcesses()
          Restarts all bos processes on this server.
protected static void restartAllProcesses(int serverHandle, boolean restartBosServer)
          Restart all server processes.
 void restartBosServer()
          Restarts bos server and all bos processes on this server.
 void salvage()
          Salvages (restores consistency to) this server.
protected static void salvage(int cellHandle, int serverHandle, String partitionName, String volName, int numSalvagers, String tempDir, String logFile, boolean inspectAllVolumes, boolean removeBadlyDamaged, boolean writeInodes, boolean writeRootInodes, boolean forceDirectory, boolean forceBlockReads)
          Salvages (restores consistency to) a volume, partition, or 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.
protected static void startAllProcesses(int serverHandle)
          Start all server processes.
 void stopAllProcesses()
          Stops all bos processes on this server.
protected static void stopAllProcesses(int serverHandle)
          Stop all server processes.
 void syncServer()
          Syncs this server to the VLDB.
protected static void syncServerWithVLDB(int cellHandle, int serverHandle, int partition)
          Synchronizes a particular server with the volume location database.
 void syncVLDB()
          Syncs the VLDB to this server.
protected static void syncVLDBWithServer(int cellHandle, int serverHandle, int partition, boolean forceDeletion)
          Synchronizes the volume location database with a particular server.
 String toString()
          Returns the name of this Server
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

name

protected String name

cell

protected Cell cell

vosHandle

protected int vosHandle

bosHandle

protected int bosHandle

database

protected boolean database

fileServer

protected boolean fileServer

badFileServer

protected boolean badFileServer

badDatabase

protected boolean badDatabase

ipAddresses

protected String[] ipAddresses

partitionNames

protected ArrayList partitionNames

partitions

protected ArrayList partitions

adminNames

protected ArrayList adminNames

admins

protected ArrayList admins

keys

protected ArrayList keys

processNames

protected ArrayList processNames

processes

protected ArrayList processes

totalSpace

protected int totalSpace

totalQuota

protected int totalQuota

totalFreeSpace

protected int totalFreeSpace

totalUsedSpace

protected int totalUsedSpace

genRestartTime

protected Server.ExecutableTime genRestartTime

binRestartTime

protected Server.ExecutableTime binRestartTime

cachedInfo

protected boolean cachedInfo
Constructor Detail

Server

public Server(String name,
              Cell cell)
       throws AFSException
Constructs a new 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.

Parameters:
name - the name of the server to represent
cell - the cell to which the server belongs.
Throws:
AFSException - If an error occurs in the native code

Server

public Server(String name,
              Cell cell,
              boolean preloadAllMembers)
       throws AFSException
Constructs a new 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.

Parameters:
name - the name of the server to represent
cell - 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.
Throws:
AFSException - If an error occurs in the native code
See Also:
refresh()

Server

Server(Cell cell)
 throws AFSException
Constructs a blank Server object instance given the cell to which the server belongs. This blank object can then be passed into other methods to fill out its properties.

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

refresh

public void refresh()
             throws AFSException
Refreshes the properties of this Server object instance with values from the AFS server it represents. All properties that have been initialized and/or accessed will be renewed according to the values of the AFS server this Server 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 Server object instance with values from the AFS server it represents. If all is true then all of the properties of this Server object instance will be set, or renewed, according to the values of the AFS server 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 Server to reflect the current state of the AFS server. These fields include the IP addresses and the fileserver types.

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

refreshGeneralRestart

protected void refreshGeneralRestart()
                              throws AFSException
Refreshes the general restart time fields of this Server to reflect the current state of the AFS server.

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

refreshBinaryRestart

protected void refreshBinaryRestart()
                             throws AFSException
Refreshes the binary restart time fields of this Server to reflect the current state of the AFS server.

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

refreshPartitions

protected void refreshPartitions()
                          throws AFSException
Obtains the most current list of Partition objects of this server.

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

refreshPartitions

protected void refreshPartitions(boolean refreshVolumes)
                          throws AFSException
Obtains the most current list of Partition objects of this server.

Parameters:
refreshVolumes - force all volumes contained in each partition to be refreshed.
Throws:
AFSException - If an error occurs in the native code

refreshPartitionNames

protected void refreshPartitionNames()
                              throws AFSException
Obtains the most current list of partition names of this server.

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

refreshAdminNames

protected void refreshAdminNames()
                          throws AFSException
Obtains the most current list of bos admin names of this server.

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

refreshAdmins

protected void refreshAdmins()
                      throws AFSException
Obtains the most current list of admin User objects of this server.

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

refreshKeys

protected void refreshKeys()
                    throws AFSException
Obtains the most current list of Key objects of this server.

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

refreshProcessNames

protected void refreshProcessNames()
                            throws AFSException
Obtains the most current list of process names of this server.

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

refreshProcesses

protected void refreshProcesses()
                         throws AFSException
Obtains the most current list of Process objects of this server.

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

addAdmin

public void addAdmin(User admin)
              throws AFSException
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.

Parameters:
admin - the admin to add
Throws:
AFSException - If an error occurs in the native code

removeAdmin

public void removeAdmin(User admin)
                 throws AFSException
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.

Parameters:
admin - the admin to remove
Throws:
AFSException - If an error occurs in the native code

syncServer

public void syncServer()
                throws AFSException
Syncs this server to the VLDB.

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

syncVLDB

public void syncVLDB()
              throws AFSException
Syncs the VLDB to this server.

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

salvage

public void salvage()
             throws AFSException
Salvages (restores consistency to) this server. Uses default values for most salvager options in order to simplify the API.

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

startAllProcesses

public void startAllProcesses()
                       throws AFSException
Starts up all bos processes on this server.

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

stopAllProcesses

public void stopAllProcesses()
                      throws AFSException
Stops all bos processes on this server.

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

restartAllProcesses

public void restartAllProcesses()
                         throws AFSException
Restarts all bos processes on this server.

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

restartBosServer

public void restartBosServer()
                      throws AFSException
Restarts bos server and all bos processes on this server.

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

getLog

public String getLog(String logLocation)
              throws AFSException
Gets the contents of a log file, in one large String. The log cannot be in AFS file space.

Returns:
a String containing the contents of the log file
Throws:
AFSException - If an error occurs in the native code

close

public void close()
           throws AFSException
Unauthenticates all server-related tokens that have been obtained by this 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.

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

getName

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

Returns:
the name of this server

getCell

public Cell getCell()
Returns the Cell object with which this Server was constructed. It represents the actual AFS cell to which this server belongs.

Returns:
this server's cell

getAdminCount

public int getAdminCount()
                  throws AFSException
Returns the number of BOS administrators assigned to this server.

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.

Returns:
the number of admins on this server.
Throws:
AFSException - If an error occurs in any of the associated native methods
See Also:
getAdmins(), getAdminNames()

getAdmins

public User[] getAdmins()
                 throws AFSException
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. After this method is called once, it saves the array of Users and returns that saved array on subsequent calls, until the refresh() method is called and a more current list is obtained.

Returns:
a User array of the admins of the server.
Throws:
AFSException - If an error occurs in the native code
See Also:
refresh()

getAdminNames

public String[] getAdminNames()
                       throws AFSException
Retrieves an array containing all of the names of bos admins associated with this Server. After this method is called once, it saves the array of Strings and returns that saved array on subsequent calls, until the refresh() method is called and a more current list is obtained.

Returns:
a String array of the bos admin of the server.
Throws:
AFSException - If an error occurs in the native code
See Also:
refresh()

getPartitionCount

public int getPartitionCount()
                      throws AFSException
Returns the number of partitions on this server.

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.

Returns:
the number of partitions on this server.
Throws:
AFSException - If an error occurs in any of the associated native methods
See Also:
getPartitions(), getPartitionNames()

getPartition

public Partition getPartition(String name)
                       throws AFSException
Retrieves the 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 AFSException will be thrown.

Parameters:
name - the name of the partition to retrieve
Returns:
Partition designated by name.
Throws:
AFSException - If an error occurs in the native code
NullPointerException - If name is null.

getPartitions

public Partition[] getPartitions()
                          throws AFSException
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. After this method is called once, it saves the array of Partitions and returns that saved array on subsequent calls, until the refresh() method is called and a more current list is obtained.

Returns:
a Partition array of the Partition objects of the server.
Throws:
AFSException - If an error occurs in the native code
See Also:
refresh()

getPartitionNames

public String[] getPartitionNames()
                           throws AFSException
Retrieves an array containing all of the names of partitions associated with this Server (i.e. "vicepa", etc.). After this method is called once, it saves the array of Strings and returns that saved array on subsequent calls, until the refresh() method is called and a more current list is obtained.

Returns:
a String array of the partitions of the server.
Throws:
AFSException - If an error occurs in the native code
See Also:
refresh()

getKey

public Key getKey(int keyVersion)
           throws AFSException
Retrieves the 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.

Parameters:
keyVersion - the version of the key to retrieve
Returns:
Key designated by keyVersion.
Throws:
AFSException - If an error occurs in the native code

getKeyCount

public int getKeyCount()
                throws AFSException
Returns the number of keys on this server.

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.

Returns:
the number of keys on this server.
Throws:
AFSException - If an error occurs in any of the associated native methods
See Also:
getKeys()

getKeys

public Key[] getKeys()
              throws AFSException
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. After this method is called once, it saves the array of Keys and returns that saved array on subsequent calls, until the refresh() method is called and a more current list is obtained.

Returns:
a Key array of the Key objects of the server.
Throws:
AFSException - If an error occurs in the native code
See Also:
refresh()

getProcess

public Process getProcess(String name)
                   throws AFSException
Retrieves the 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 AFSException will be thrown.

Parameters:
name - the name of the process to retrieve
Returns:
Process designated by name.
Throws:
AFSException - If an error occurs in the native code
NullPointerException - If name is null.

getProcessCount

public int getProcessCount()
                    throws AFSException
Returns the number of processes hosted by this server.

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.

Returns:
the number of processes on this server.
Throws:
AFSException - If an error occurs in any of the associated native methods
See Also:
getProcesses(), getProcessNames()

getProcesses

public Process[] getProcesses()
                       throws AFSException
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. After this method is called once, it saves the array of Processes and returns that saved array on subsequent calls, until the refresh() method is called and a more current list is obtained.

Returns:
a Process array of the Process objects of the server.
Throws:
AFSException - If an error occurs in the native code
See Also:
refresh()

getProcessNames

public String[] getProcessNames()
                         throws AFSException
Retrieves an array containing all of the names of processes associated with this Server (i.e. "kaserver", etc.). After this method is called once, it saves the array of Strings and returns that saved array on subsequent calls, until the refresh() method is called and a more current list is obtained.

Returns:
a String array of the processes of the server.
Throws:
AFSException - If an error occurs in the native code
See Also:
refresh()

isDatabase

public boolean isDatabase()
                   throws AFSException
Returns whether or not this server is a database machine, meaning it runs processes such as the "kaserver" and "vlserver", and participates in elections.

Returns:
whether or not this user this server is a database machine.
Throws:
AFSException - If an error occurs in the native code
See Also:
refresh()

isFileServer

public boolean isFileServer()
                     throws AFSException
Returns whether or not this server is a file server machine, meaning it runs the "fs" process and stores AFS volumes.

Returns:
whether or not this user this server is a file server machine.
Throws:
AFSException - If an error occurs in the native code
See Also:
refresh()

isBadDatabase

public boolean isBadDatabase()
                      throws AFSException
Returns whether or not this server is a database machine AND either it isn't in reality (e.g. it's incorrectly configured) or it's currently down.

Returns:
whether or not this server is a database machine AND either it isn't in reality or it's currently down
Throws:
AFSException - If an error occurs in the native code
See Also:
refresh()

isBadFileServer

public boolean isBadFileServer()
                        throws AFSException
Returns whether this machine thinks it's a file server AND either it isn't in reality (e.g. it's incorrectly configured) or it's currently down.

Returns:
whether or not this server is a file server machine AND either it isn't in reality or it's currently down
Throws:
AFSException - If an error occurs in the native code
See Also:
refresh()

getIPAddresses

public String[] getIPAddresses()
                        throws AFSException
Returns this server's IP address as a String. It returns it in dotted quad notation (i.e. 123.123.123.123).

Returns:
this server's IP address as a String
Throws:
AFSException - If an error occurs in the native code
See Also:
refresh()

getGeneralRestartTime

public Server.ExecutableTime getGeneralRestartTime()
                                            throws AFSException
Returns the BOS Server's general restart time in the form of an ExecutableTime object. This is the time at which the bos server restarts itself and all running processes. After this method is called once, it saves the time and returns that value on subsequent calls, until the refresh() method is called and a more current value is obtained.

Returns:
the general restart time
Throws:
AFSException - If an error occurs in the native code
See Also:
Server.ExecutableTime, refresh()

getBinaryRestartTime

public Server.ExecutableTime getBinaryRestartTime()
                                           throws AFSException
Returns the BOS Server's binary restart time in the form of an ExecutableTime object. This is the time at which all new or newly modified AFS binaries are restarted. After this method is called once, it saves the time and returns that value on subsequent calls, until the refresh() method is called and a more current value is obtained.

Returns:
the binary restart time
Throws:
AFSException - If an error occurs in the native code
See Also:
Server.ExecutableTime, refresh()

getTotalSpace

public int getTotalSpace()
                  throws AFSException
Returns the total space on this server (a sum of the space of all the partitions associated with this server). If this server is not a file server, zero will be returned. After this method is called once, it saves the total space and returns that value on subsequent calls, until the refresh() method is called and a more current value is obtained.

Returns:
the total space on this server
Throws:
AFSException - If an error occurs in the native code
See Also:
refresh()

getTotalFreeSpace

public int getTotalFreeSpace()
                      throws AFSException
Returns the total free space on this server (a sum of the free space of all the partitions associated with this server). If this server is not a file server, zero will be returned. After this method is called once, it saves the total free space and returns that value on subsequent calls, until the refresh() method is called and a more current value is obtained.

Returns:
the total free space on this server
Throws:
AFSException - If an error occurs in the native code
See Also:
refresh()

getTotalUsedSpace

public int getTotalUsedSpace()
                      throws AFSException
Returns the total used space on this server (a sum of the used space of all the partitions associated with this server). If this server is not a file server, zero will be returned. After this method is called once, it saves the total used space and returns that value on subsequent calls, until the refresh() method is called and a more current value is obtained.

Returns:
the total space on this partition
Throws:
AFSException - If an error occurs in the native code
See Also:
getTotalSpace(), getTotalFreeSpace()

getVosHandle

protected int getVosHandle()
                    throws AFSException
Returns this server's vos handle.

Returns:
this server's vos handle
Throws:
AFSException - If an error occurs in the native code

getBosHandle

protected int getBosHandle()
                    throws AFSException
Returns this server's bos handle.

Returns:
this server's bos handle
Throws:
AFSException - If an error occurs in the native code

setGeneralRestartTime

public void setGeneralRestartTime(Server.ExecutableTime executableTime)
                           throws AFSException
Sets the BOS general restart time. This is the time at which the bos server restarts itself and all running processes.

Parameters:
executableTime - Executable time object that represents what the BOS Server's general restart time should be.
Throws:
AFSException - If an error occurs in the native code
See Also:
Server.ExecutableTime

setBinaryRestartTime

public void setBinaryRestartTime(Server.ExecutableTime executableTime)
                          throws AFSException
Sets the BOS binary restart time. This is the time at which all new or newly modified AFS binaries are restarted.

Parameters:
executableTime - Executable time object that represents what the BOS Server's binary restart time should be.
Throws:
AFSException - If an error occurs in the native code
See Also:
Server.ExecutableTime

getInfo

protected String getInfo()
Returns a String representation of this Server. Contains the information fields and a list of partitions, admin, and processes.

Returns:
a String representation of the Server

getInfoPartitions

protected String getInfoPartitions()
                            throws AFSException
Returns a String containing the String representations of all the partitions of this Server.

Returns:
a String representation of the partitions
AFSException
See Also:
Partition.getInfo()

getInfoKeys

protected String getInfoKeys()
                      throws AFSException
Returns a String containing the String representations of all the keys of this Server.

Returns:
a String representation of the keys
AFSException
See Also:
Key.getInfo()

getInfoProcesses

protected String getInfoProcesses()
                           throws AFSException
Returns a String containing the String representations of all the processes of this Server.

Returns:
a String representation of the processes
AFSException
See Also:
Process.getInfo()

compareTo

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

Parameters:
server - The Server object to be compared to this Server instance
Returns:
Zero if the argument is equal to this Server's name, a value less than zero if this Server's name is lexicographically less than the argument, or a value greater than zero if this Server's 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(Server)

equals

public boolean equals(Server otherServer)
Tests whether two Server objects are equal, based on their names and hosting Cell.

Parameters:
otherServer - the Server to test
Returns:
whether the specifed Server is the same as this Server

toString

public String toString()
Returns the name of this Server

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

getVosServerHandle

protected static int getVosServerHandle(int cellHandle,
                                        String serverName)
                                 throws AFSException
Opens a server for administrative vos use, based on the cell handle provided. Returns a vos server handle to be used by other methods as a means of identification.

Parameters:
cellHandle - a cell handle previously returned by a call to Cell.getCellHandle()
serverName - the name of the server for which to retrieve a vos handle
Returns:
a vos handle to the server
Throws:
AFSException - If an error occurs in the native code
See Also:
Cell.getCellHandle()

closeVosServerHandle

protected static void closeVosServerHandle(int vosHandle)
                                    throws AFSException
Closes the given currently open vos server handle.

Parameters:
vosHandle - the vos server handle to close
Throws:
AFSException - If an error occurs in the native code

getBosServerHandle

protected static int getBosServerHandle(int cellHandle,
                                        String serverName)
                                 throws AFSException
Opens a server for administrative bos use, based on the cell handle provided. Returns a bos server handle to be used by other methods as a means of identification.

Parameters:
cellHandle - a cell handle previously returned by a call to Cell.getCellHandle()
serverName - the name of the server for which to retrieve a bos handle
Returns:
a bos handle to the server
Throws:
AFSException - If an error occurs in the native code
See Also:
Cell.getCellHandle()

closeBosServerHandle

protected static void closeBosServerHandle(int bosHandle)
                                    throws AFSException
Closes the given currently open bos server handle.

Parameters:
bosHandle - the bos server handle to close
Throws:
AFSException - If an error occurs in the native code

getServerInfo

protected static void getServerInfo(int cellHandle,
                                    String name,
                                    Server server)
                             throws AFSException
Fills in the information fields of the provided Server.

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

getPartitionCount

protected static int getPartitionCount(int cellHandle,
                                       int serverHandle)
                                throws AFSException
Returns the total number of partitions hosted by the server denoted by serverHandle, if the server is a fileserver.

Parameters:
cellHandle - the handle of the cell to which the server belongs
serverHandle - the vos handle of the server to which the partitions belong
Returns:
total number of partitions
Throws:
AFSException - If an error occurs in the native code
See Also:
Cell.getCellHandle(), getVosServerHandle(int, java.lang.String)

getPartitionsBegin

protected static int getPartitionsBegin(int cellHandle,
                                        int serverHandle)
                                 throws AFSException
Begin the process of getting the partitions on a server. Returns an iteration ID to be used by subsequent calls to getPartitionsNext and getPartitionsDone.

Parameters:
cellHandle - the handle of the cell to which the server belongs
serverHandle - the vos handle of the server to which the partitions belong
Returns:
an iteration ID
Throws:
AFSException - If an error occurs in the native code
See Also:
Cell.getCellHandle(), getVosServerHandle(int, java.lang.String)

getPartitionsNextString

protected static String getPartitionsNextString(int iterationId)
                                         throws AFSException
Returns the next partition of the server. Returns null if there are no more partitions.

Parameters:
iterationId - the iteration ID of this iteration
Returns:
the name of the next partition of the server
Throws:
AFSException - If an error occurs in the native code
See Also:
getPartitionsBegin(int, int)

getPartitionsNext

protected static int getPartitionsNext(int iterationId,
                                       Partition thePartition)
                                throws AFSException
Fills the next partition object of the server. Returns 0 if there are no more partitions, != 0 otherwise

Parameters:
iterationId - the iteration ID of this iteration
thePartition - the Partition object in which to fill the values of the next partition
Returns:
0 if there are no more servers, != 0 otherwise
Throws:
AFSException - If an error occurs in the native code
See Also:
getPartitionsBegin(int, int)

getPartitionsDone

protected static void getPartitionsDone(int iterationId)
                                 throws AFSException
Signals that the iteration is complete and will not be accessed anymore.

Parameters:
iterationId - the iteration ID of this iteration
Throws:
AFSException - If an error occurs in the native code
See Also:
getPartitionsBegin(int, int)

getProcessCount

protected static int getProcessCount(int serverHandle)
                              throws AFSException
Returns the total number of processes hosted by the server denoted by serverHandle.

Parameters:
serverHandle - the vos handle of the server to which the processes belong
Returns:
total number of processes
Throws:
AFSException - If an error occurs in the native code
See Also:
getVosServerHandle(int, java.lang.String)

getProcessesBegin

protected static int getProcessesBegin(int serverHandle)
                                throws AFSException
Begin the process of getting the processes on a server. Returns an iteration ID to be used by subsequent calls to getProcessesNext and getProcessesDone.

Parameters:
serverHandle - the bos handle of the server to which the processes belong
Returns:
an iteration ID
Throws:
AFSException - If an error occurs in the native code
See Also:
getBosServerHandle(int, java.lang.String)

getProcessesNextString

protected static String getProcessesNextString(int iterationId)
                                        throws AFSException
Returns the next process of the server. Returns null if there are no more processes.

Parameters:
iterationId - the iteration ID of this iteration
Returns:
the name of the next process of the cell
Throws:
AFSException - If an error occurs in the native code
See Also:
getProcessesBegin(int)

getProcessesNext

protected static int getProcessesNext(int serverHandle,
                                      int iterationId,
                                      Process theProcess)
                               throws AFSException
Fills the next process object of the server. Returns 0 if there are no more processes, != 0 otherwise.

Parameters:
serverHandle - the handle of the BOS server that hosts the process
iterationId - the iteration ID of this iteration
theProcess - the Process object in which to fill the values of the next process
Returns:
0 if there are no more processes, != otherwise
Throws:
AFSException - If an error occurs in the native code
See Also:
getBosHandle(), getProcessesBegin(int)

getProcessesDone

protected static void getProcessesDone(int iterationId)
                                throws AFSException
Signals that the iteration is complete and will not be accessed anymore.

Parameters:
iterationId - the iteration ID of this iteration
Throws:
AFSException - If an error occurs in the native code
See Also:
getProcessesBegin(int)

getKeyCount

protected static int getKeyCount(int serverHandle)
                          throws AFSException
Returns the total number of keys hosted by the server denoted by serverHandle.

Parameters:
serverHandle - the vos handle of the server to which the keys belong
Returns:
total number of keys
Throws:
AFSException - If an error occurs in the native code
See Also:
getVosServerHandle(int, java.lang.String)

getKeysBegin

protected static int getKeysBegin(int serverHandle)
                           throws AFSException
Begin the process of getting the keys of a server. Returns an iteration ID to be used by subsequent calls to getKeysNext and getKeysDone.

Parameters:
serverHandle - the bos handle of the server to which the keys belong
Returns:
an iteration ID
Throws:
AFSException - If an error occurs in the native code
See Also:
getBosServerHandle(int, java.lang.String)

getKeysNext

protected static int getKeysNext(int iterationId,
                                 Key theKey)
                          throws AFSException
Returns the next key of the server. Returns 0 if there are no more keys, != 0 otherwise.

Parameters:
iterationId - the iteration ID of this iteration
theKey - a Key object, in which to fill in the properties of the next key.
Returns:
0 if there are no more keys, != 0 otherwise
Throws:
AFSException - If an error occurs in the native code
See Also:
getKeysBegin(int)

getKeysDone

protected static void getKeysDone(int iterationId)
                           throws AFSException
Signals that the iteration is complete and will not be accessed anymore.

Parameters:
iterationId - the iteration ID of this iteration
Throws:
AFSException - If an error occurs in the native code
See Also:
getKeysBegin(int)

getBosAdminCount

protected static int getBosAdminCount(int serverHandle)
                               throws AFSException
Returns the total number of BOS administrators associated with the server denoted by serverHandle.

Parameters:
serverHandle - the vos handle of the server to which the BOS admins belong
Returns:
total number of BOS administrators
Throws:
AFSException - If an error occurs in the native code
See Also:
getVosServerHandle(int, java.lang.String)

getBosAdminsBegin

protected static int getBosAdminsBegin(int serverHandle)
                                throws AFSException
Begin the process of getting the bos amdinistrators on a server. Returns an iteration ID to be used by subsequent calls to getBosAdminsNext and getBosAdminsDone.

Parameters:
serverHandle - the bos handle of the server to which the partitions belong
Returns:
an iteration ID
Throws:
AFSException - If an error occurs in the native code
See Also:
getBosServerHandle(int, java.lang.String)

getBosAdminsNextString

protected static String getBosAdminsNextString(int iterationId)
                                        throws AFSException
Returns the next bos admin of the server. Returns null if there are no more admins.

Parameters:
iterationId - the iteration ID of this iteration
Returns:
the name of the next admin of the server
Throws:
AFSException - If an error occurs in the native code
See Also:
getBosAdminsBegin(int)

getBosAdminsNext

protected static int getBosAdminsNext(int cellHandle,
                                      int iterationId,
                                      User theUser)
                               throws AFSException
Returns the next bos admin of the server. Returns 0 if there are no more admins, != 0 otherwise.

Parameters:
cellHandle - the handle of the cell to which these admins belong
iterationId - the iteration ID of this iteration
theUser - the user object in which to fill the values of this admin
Returns:
0 if no more admins, != 0 otherwise
Throws:
AFSException - If an error occurs in the native code
See Also:
Cell.getCellHandle(), getBosAdminsBegin(int)

getBosAdminsDone

protected static void getBosAdminsDone(int iterationId)
                                throws AFSException
Signals that the iteration is complete and will not be accessed anymore.

Parameters:
iterationId - the iteration ID of this iteration
Throws:
AFSException - If an error occurs in the native code
See Also:
getBosAdminsBegin(int)

addBosAdmin

protected static void addBosAdmin(int serverHandle,
                                  String adminName)
                           throws AFSException
Adds the given to name to the list of bos administrators on that server.

Parameters:
serverHandle - the bos handle of the server to which the partitions belong
adminName - the name of the admin to add to the list
Throws:
AFSException - If an error occurs in the native code
See Also:
getBosServerHandle(int, java.lang.String)

removeBosAdmin

protected static void removeBosAdmin(int serverHandle,
                                     String adminName)
                              throws AFSException
Removes the given to name from the list of bos administrators on that server.

Parameters:
serverHandle - the bos handle of the server to which the partitions belong
adminName - the name of the admin to remove from the list
Throws:
AFSException - If an error occurs in the native code
See Also:
getBosServerHandle(int, java.lang.String)

salvage

protected static void salvage(int cellHandle,
                              int serverHandle,
                              String partitionName,
                              String volName,
                              int numSalvagers,
                              String tempDir,
                              String logFile,
                              boolean inspectAllVolumes,
                              boolean removeBadlyDamaged,
                              boolean writeInodes,
                              boolean writeRootInodes,
                              boolean forceDirectory,
                              boolean forceBlockReads)
                       throws AFSException
Salvages (restores consistency to) a volume, partition, or server

Parameters:
cellHandle - the handle of the cell to which the volume belongs
serverHandle - the bos handle of the server on which the volume resides
partitionName - the name of the partition to salvage, can be null only if volName is null
volName - the name of the volume to salvage, can be null
numSalvagers - the number of salvager processes to run in parallel
tempDir - directory to place temporary files, can be null
logFile - where salvager log will be written, can be null
inspectAllVolumes - whether or not to inspect all volumes, not just those marked as active at crash
removeBadlyDamaged - whether or not to remove a volume if it's badly damaged
writeInodes - whether or not to record a list of inodes modified
writeRootInodes - whether or not to record a list of AFS inodes owned by root
forceDirectory - whether or not to salvage an entire directory structure
forceBlockReads - whether or not to force the salvager to read the partition one block at a time and skip badly damaged blocks. Use if partition has disk errors
AFSException
See Also:
Cell.getCellHandle(), getBosServerHandle(int, java.lang.String)

syncServerWithVLDB

protected static void syncServerWithVLDB(int cellHandle,
                                         int serverHandle,
                                         int partition)
                                  throws AFSException
Synchronizes a particular server with the volume location database.

Parameters:
cellHandle - the handle of the cell to which the server belongs
serverHandle - the vos handle of the server
partition - the id of the partition to sync, can be -1 to ignore
Throws:
AFSException - If an error occurs in the native code
See Also:
Cell.getCellHandle(), getVosServerHandle(int, java.lang.String)

syncVLDBWithServer

protected static void syncVLDBWithServer(int cellHandle,
                                         int serverHandle,
                                         int partition,
                                         boolean forceDeletion)
                                  throws AFSException
Synchronizes the volume location database with a particular server.

Parameters:
cellHandle - the handle of the cell to which the server belongs
serverHandle - the vos handle of the server
partition - the id of the partition to sync, can be -1 to ignore
forceDeletion - whether or not to force the deletion of bad volumes
Throws:
AFSException - If an error occurs in the native code
See Also:
Cell.getCellHandle(), getVosServerHandle(int, java.lang.String)

getLog

protected static String getLog(int serverHandle,
                               String logLocation)
                        throws AFSException
Retrieves a specified bos log from a server. Right now this method will simply return a huge String containing the log, but hopefully we can devise a better way to make this work more efficiently.

Parameters:
serverHandle - the bos handle of the server to which the key belongs
logLocation - the full path and name of the desired bos log
Throws:
AFSException - If an error occurs in the native code
See Also:
getBosServerHandle(int, java.lang.String)

startAllProcesses

protected static void startAllProcesses(int serverHandle)
                                 throws AFSException
Start all server processes.

Parameters:
serverHandle - the bos handle of the server to which the processes belong
Throws:
AFSException - If an error occurs in the native code
See Also:
getBosServerHandle(int, java.lang.String)

restartAllProcesses

protected static void restartAllProcesses(int serverHandle,
                                          boolean restartBosServer)
                                   throws AFSException
Restart all server processes.

Parameters:
serverHandle - the bos handle of the server to which the processes belong
restartBosServer - whether or not to restart the bos server as well
Throws:
AFSException - If an error occurs in the native code
See Also:
getBosServerHandle(int, java.lang.String)

stopAllProcesses

protected static void stopAllProcesses(int serverHandle)
                                throws AFSException
Stop all server processes.

Parameters:
serverHandle - the bos handle of the server to which the processes belong
Throws:
AFSException - If an error occurs in the native code
See Also:
getBosServerHandle(int, java.lang.String)

reclaimServerMemory

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


JAFS API v2