|
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.Partition
An abstract representation of an AFS partition. It holds information about
the partition, such as what its total space is.
Constructing an instance of a Partition
does not mean
an actual AFS partition is created on a server -- on the contrary,
a Partition
object must be a representation of an already
existing AFS partition. There is no way to create a new AFS partition
through this API.
Each Partition
object has its own individual set of
Volume
s. This represents the properties and attributes
of an actual AFS cell.
The following is a simple example of how to obtain and use a
Partition
object. In this example, a list of the
Partition
objects of a server are obtained, and the name
and number of volumes is printed out for each one.
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() + ":"); Partition[] partitions = server.getPartitions(); for (int i = 0; i < partitions.length; i++) { System.out.print("Partition " + partitions[i].getName()); System.out.print("hosts " + partitions[i].getVolumeCount()); System.out.print("volumes.\n"); } } ... }
Field Summary | |
protected boolean |
cachedInfo
|
protected Cell |
cell
|
protected String |
deviceName
|
protected int |
id
|
protected int |
lockFileDescriptor
|
protected String |
name
|
protected Server |
server
|
protected int |
totalFreeSpace
|
protected int |
totalQuota
|
protected int |
totalSpace
|
protected ArrayList |
volumeNames
|
protected ArrayList |
volumes
|
Constructor Summary | |
(package private) |
Partition(Server server)
Creates a blank Server given the cell to which the partition
belongs and the server on which the partition resides. |
|
Partition(String name,
Server server)
Constructs a new Partition object instance given the
name of the AFS partition and the AFS server, represented by
server , to which it belongs. |
|
Partition(String name,
Server server,
boolean preloadAllMembers)
Constructs a new Partition object instance given the name
of the AFS partition and the AFS server, represented by
server , to which it belongs. |
Method Summary | |
int |
compareTo(Object obj)
Comparable interface method. |
int |
compareTo(Partition partition)
Compares two Partition objects respective to their names and does not factor any other attribute. |
boolean |
equals(Partition otherPartition)
Tests whether two Partition objects are equal,
based on their names and hosting server. |
String |
getDeviceName()
Returns the device name of this partition (i.e. |
int |
getID()
Returns the id of this partition (i.e. |
protected String |
getInfo()
Returns a String representation of this
Partition . |
protected String |
getInfoVolumes()
Returns a String containing the String
representations of all the volumes of this Partition . |
int |
getLockFileDescriptor()
Returns the lock file descriptor of this partition |
String |
getName()
Returns the name of this partition. |
protected static void |
getPartitionInfo(int cellHandle,
int serverHandle,
int partition,
Partition thePartition)
Fills in the information fields of the provided Partition . |
Server |
getServer()
Returns this partition's hosting server. |
int |
getTotalFreeSpace()
Returns the total free space on this partition. |
int |
getTotalQuota()
Returns the total combined quota of all volumes on this partition, unless a volume has configured an unlimited quota at which case an AFSException is thrown.
|
int |
getTotalQuota(boolean ignoreUnlimitedQuotas)
Returns the total combined quota of all volumes on this partition, ignoring volumes with unlimited quotas, if
ignoreUnlimitedQuotas is true ; otherwise an
AFSException is thrown if a volume has an unlimited quota.
|
int |
getTotalSpace()
Returns the total space on this partition. |
int |
getUsedSpace()
Returns the total used space on this partition. |
Volume |
getVolume(String name)
Retrieves the Volume object (which is an abstract
representation of an actual AFS volume of this partition) designated
by name (i.e. |
int |
getVolumeCount()
Returns the number of volumes contained in this partition. |
protected static int |
getVolumeCount(int cellHandle,
int serverHandle,
int partition)
Returns the total number of volumes hosted by this partition. |
String[] |
getVolumeNames()
Retrieves an array containing all of the names of volumes associated with this Partition .
|
String[] |
getVolumeNames(int startIndex,
int length)
Returns an array containing a subset of the names of volumes associated with this Partition . |
Volume[] |
getVolumes()
Retrieves an array containing all of the Volume objects
associated with this Partition , each of which is an
abstract representation of an actual AFS volume of the AFS partition.
|
Volume[] |
getVolumes(int startIndex,
int length)
Returns an array containing a subset of the Volume objects
associated with this Partition , each of which is an abstract
representation of an actual AFS volume of the AFS partition. |
protected static int |
getVolumesAdvanceTo(int iterationId,
Volume theVolume,
int advanceCount)
Fills the next volume object of the partition. |
protected static int |
getVolumesBegin(int cellHandle,
int serverHandle,
int partition)
Begin the process of getting the volumes on a partition. |
protected static int |
getVolumesBeginAt(int cellHandle,
int serverHandle,
int partition,
int index)
Begin the process of getting the volumes on a partition. |
protected static void |
getVolumesDone(int iterationId)
Signals that the iteration is complete and will not be accessed anymore. |
protected static int |
getVolumesNext(int iterationId,
Volume theVolume)
Fills the next volume object of the partition. |
protected static String |
getVolumesNextString(int iterationId)
Returns the next volume of the partition. |
boolean |
hasVolumeWithUnlimitedQuota()
Tests whether this partition contains a volume that has an unlimited quota configured. |
protected static void |
reclaimPartitionMemory()
Reclaims all memory being saved by the partition portion of the native library. |
void |
refresh()
Refreshes the properties of this Partition object instance with values from the AFS partition it represents. |
protected void |
refresh(boolean all)
Refreshes the properties of this Partition object instance with values from the AFS partition it represents. |
protected void |
refreshInfo()
Refreshes the information fields of this Partition to
reflect the current state of the AFS partition. |
protected void |
refreshVolumeNames()
Obtains the most current list of volume names of this partition. |
protected void |
refreshVolumes()
Obtains the most current list of Volume objects of this
partition. |
void |
salvage()
Salvages (restores consistency to) this partition. |
void |
syncPartition()
Syncs this partition to the VLDB. |
void |
syncVLDB()
Syncs the VLDB to this partition. |
String |
toString()
Returns the name of this Partition |
protected static String |
translateIDToName(int id)
Translates a partition id into a partition name |
protected static int |
translateNameToID(String name)
Translates a partition name into a partition id |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
protected Cell cell
protected Server server
protected String name
protected int id
protected String deviceName
protected int lockFileDescriptor
protected int totalSpace
protected int totalFreeSpace
protected int totalQuota
protected ArrayList volumes
protected ArrayList volumeNames
protected boolean cachedInfo
Constructor Detail |
public Partition(String name, Server server) throws AFSException
Partition
object instance given the
name of the AFS partition and the AFS server, represented by
server
, to which it belongs. This does not actually
create a new AFS partition, it just represents an existing one.
If name
is not an actual AFS partition, exceptions
will be thrown during subsequent method invocations on this
object.
name
- the name of the partition to representserver
- the server on which the partition resides
AFSException
- If an error occurs in the native codepublic Partition(String name, Server server, boolean preloadAllMembers) throws AFSException
Partition
object instance given the name
of the AFS partition and the AFS server, represented by
server
, to which it belongs. This does not actually
create a new AFS partition, it just represents an existing one.
If name
is not an actual AFS partition, 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 partition to representserver
- the server to which the partition 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()
Partition(Server server) throws AFSException
Server
given the cell to which the partition
belongs and the server on which the partition resides. This blank
object can then be passed into other methods to fill out its properties.
server
- the server on which the partition resides
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 Partition
object instance will be set, or renewed, according to the values of the
AFS partition 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
Partition
to
reflect the current state of the AFS partition. These include total
free space, id, etc.
AFSException
- If an error occurs in the native codeprotected void refreshVolumes() throws AFSException
Volume
objects of this
partition.
AFSException
- If an error occurs in the native codeprotected void refreshVolumeNames() throws AFSException
AFSException
- If an error occurs in the native codepublic void syncPartition() throws AFSException
AFSException
- If an error occurs in the native codepublic void syncVLDB() throws AFSException
AFSException
- If an error occurs in the native codepublic void salvage() throws AFSException
AFSException
- If an error occurs in the native codepublic String getName()
public Server getServer()
public int getVolumeCount() throws AFSException
If the total list of volumes or volume names have already been
collected (see getVolumes()
), 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.
AFSException
- If an error occurs in any
of the associated native methodspublic Volume getVolume(String name) throws AFSException
Volume
object (which is an abstract
representation of an actual AFS volume of this partition) designated
by name
(i.e. "root.afs", etc.). If a volume by
that name does not actually exist in AFS on the partition
represented by this object, an AFSException
will be
thrown.
name
- the name of the volume to retrieve
Volume
designated by name
.
AFSException
- If an error occurs in the native code
NullPointerException
- If name
is
null
.public Volume[] getVolumes() throws AFSException
Volume
objects
associated with this Partition
, each of which is an
abstract representation of an actual AFS volume of the AFS partition.
After this method is called once, it saves the array of
Volume
s and returns that saved array on subsequent calls,
until the refresh()
method is called and a more current list
is obtained.
Volume
array of the Volume
objects of the partition.
AFSException
- If an error occurs in the native coderefresh()
public Volume[] getVolumes(int startIndex, int length) throws AFSException
Volume
objects
associated with this Partition
, each of which is an abstract
representation of an actual AFS volume of the AFS partition. The subset
is a point-in-time list of volumes (Volume
objects
representing AFS volumes) starting at the complete array's index of
startIndex
and containing up to length
elements.
If length
is larger than the number of remaining elements,
respective to startIndex
, then this method will
ignore the remaining positions requested by length
and
return an array that contains the remaining number of elements found in
this partition's complete array of volumes.
This method is especially useful when managing iterations of very
large lists. getVolumeCount()
can be used to determine if
iteration management is practical.
This method does not save the resulting data and therefore queries AFS for each call.
Example: If there are more than 50,000 volumes within this partition then only render them in increments of 10,000.
... Volume[] volumes; if (partition.getVolumeCount() > 50000) { int index = 0; int length = 10000; while (index < partition.getVolumeCount()) { volumes = partition.getVolumes(index, length); for (int i = 0; i < volumes.length; i++) { ... } index += length; ... } } else { volumes = partition.getVolumes(); for (int i = 0; i < volumes.length; i++) { ... } } ...
startIndex
- the base zero index position at which the subset array
should start from, relative to the complete list of
elements present in AFS.length
- the number of elements that the subset should contain
AFSException
- If an error occurs in the native codegetVolumeCount()
,
getVolumeNames(int, int)
,
getVolumes()
public String[] getVolumeNames() throws AFSException
Partition
.
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 volumes of the partition.
AFSException
- If an error occurs in the native coderefresh()
public String[] getVolumeNames(int startIndex, int length) throws AFSException
Partition
. The subset is a
point-in-time list of volume names starting at the complete array's
index of startIndex
and containing up to length
elements.
If length
is larger than the number of remaining elements,
respective to startIndex
, then this method will
ignore the remaining positions requested by length
and
return an array that contains the remaining number of elements found in
this partition's complete array of volume names.
This method is especially useful when managing iterations of very
large lists. getVolumeCount()
can be used to determine if
iteration management is practical.
This method does not save the resulting data and therefore queries AFS for each call.
Example: If there are more than 50,000 volumes within this partition then only render them in increments of 10,000.
... String[] volumes; if (partition.getVolumeCount() > 50000) { int index = 0; int length = 10000; while (index < partition.getVolumeCount()) { volumes = partition.getVolumeNames(index, length); for (int i = 0; i < volumes.length; i++) { ... } index += length; ... } } else { volumes = partition.getVolumeNames(); for (int i = 0; i < volumes.length; i++) { ... } } ...
startIndex
- the base zero index position at which the subset array
should start from, relative to the complete list of
elements present in AFS.length
- the number of elements that the subset should contain
AFSException
- If an error occurs in the native codegetVolumeCount()
,
getVolumes(int, int)
,
getVolumes()
public int getID() throws AFSException
AFSException
- If an error occurs in the native codepublic String getDeviceName() throws AFSException
AFSException
- If an error occurs in the native coderefresh()
public int getLockFileDescriptor() throws AFSException
AFSException
- If an error occurs in the native coderefresh()
public int getTotalSpace() throws AFSException
AFSException
- If an error occurs in the native coderefresh()
public int getTotalFreeSpace() throws AFSException
refresh()
method is called and a more current
value is obtained.
AFSException
- If an error occurs in the native coderefresh()
public int getUsedSpace() throws AFSException
refresh()
method is called and a more current
value is obtained.
AFSException
- If an error occurs in the native coderefresh()
public int getTotalQuota() throws AFSException
AFSException
is thrown.
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 while retrieving and
calculating, or a volume has an
unlimited quota.getTotalQuota(boolean)
,
hasVolumeWithUnlimitedQuota()
,
Volume.getQuota()
public int getTotalQuota(boolean ignoreUnlimitedQuotas) throws AFSException
ignoreUnlimitedQuotas
is true
; otherwise an
AFSException
is thrown if a volume has an unlimited quota.
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 while retrieving and
calculating, or a volume has an
unlimited quota.getTotalQuota()
,
hasVolumeWithUnlimitedQuota()
,
Volume.getQuota()
,
refresh()
public boolean hasVolumeWithUnlimitedQuota() throws AFSException
true
if a contained volume's quota is configured
as unlimited; otherwise false
.
AFSException
- If an error occurs in the native codegetTotalQuota()
,
getTotalQuota(boolean)
,
Volume.isQuotaUnlimited()
,
Volume.getQuota()
,
refresh()
protected String getInfo()
String
representation of this
Partition
. Contains the information fields and a list of
volumes.
String
representation of the Partition
protected String getInfoVolumes() throws AFSException
String
containing the String
representations of all the volumes of this Partition
.
String
representation of the volumes
AFSException
Volume.getInfo()
public int compareTo(Partition partition)
partition
- The Partition object to be compared to
this Partition instance
public int compareTo(Object obj)
compareTo
in interface Comparable
compareTo(Partition)
public boolean equals(Partition otherPartition)
Partition
objects are equal,
based on their names and hosting server.
otherPartition
- the Partition to test
public String toString()
Partition
toString
in class Object
Partition
protected static void getPartitionInfo(int cellHandle, int serverHandle, int partition, Partition thePartition) throws AFSException
Partition
.
cellHandle
- the handle of the cell to which the partition belongsserverHandle
- the vos handle of the server on which the
partition residespartition
- the numeric id of the partition for which to get the
infothePartition
- the Partition
object in which to
fill in the information
AFSException
- If an error occurs in the native codeCell.getCellHandle()
,
Server.getVosServerHandle(int, java.lang.String)
protected static int getVolumeCount(int cellHandle, int serverHandle, int partition) throws AFSException
cellHandle
- the handle of the cell to which the partition belongsserverHandle
- the vos handle of the server to which the partition
belongspartition
- the numeric id of the partition on which the volumes
reside
AFSException
- If an error occurs in the native codeCell.getCellHandle()
,
Server.getVosServerHandle(int, java.lang.String)
protected static int getVolumesBegin(int cellHandle, int serverHandle, int partition) throws AFSException
getVolumesNext
and getVolumesDone
.
cellHandle
- the handle of the cell to which the partition belongsserverHandle
- the vos handle of the server to which the partition
belongspartition
- the numeric id of the partition on which the volumes
reside
AFSException
- If an error occurs in the native codeCell.getCellHandle()
,
Server.getVosServerHandle(int, java.lang.String)
protected static int getVolumesBeginAt(int cellHandle, int serverHandle, int partition, int index) throws AFSException
getVolumesNext
and getVolumesDone
.
cellHandle
- the handle of the cell to which the partition belongsserverHandle
- the vos handle of the server to which the partition
belongspartition
- the numeric id of the partition on which the volumes
reside
AFSException
- If an error occurs in the native codeCell.getCellHandle()
,
Server.getVosServerHandle(int, java.lang.String)
protected static String getVolumesNextString(int iterationId) throws AFSException
null
if there are no more volumes.
iterationId
- the iteration ID of this iteration
AFSException
- If an error occurs in the native codegetVolumesBegin(int, int, int)
protected static int getVolumesNext(int iterationId, Volume theVolume) throws AFSException
iterationId
- the iteration ID of this iterationtheVolume
- the Volume object in which to fill the values
of the next volume
AFSException
- If an error occurs in the native codegetVolumesBegin(int, int, int)
protected static int getVolumesAdvanceTo(int iterationId, Volume theVolume, int advanceCount) throws AFSException
iterationId
- the iteration ID of this iterationtheVolume
- the Volume object in which to fill the values of the
next volume
AFSException
- If an error occurs in the native codegetVolumesBegin(int, int, int)
protected static void getVolumesDone(int iterationId) throws AFSException
iterationId
- the iteration ID of this iteration
AFSException
- If an error occurs in the native codegetVolumesBegin(int, int, int)
protected static int translateNameToID(String name) throws AFSException
name
- the name of the partition in question
AFSException
- If an error occurs in the native codeprotected static String translateIDToName(int id) throws AFSException
id
- the id of the partition in question
AFSException
- If an error occurs in the native codeprotected static void reclaimPartitionMemory()
Partition
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 |