|
Java AFS API v1.4 | |||||||||
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"); } } ... }
Constructor Summary | |
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. |
int |
getLockFileDescriptor()
Returns the lock file descriptor of this partition |
String |
getName()
Returns the name of this 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. |
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. |
boolean |
hasVolumeWithUnlimitedQuota()
Tests whether this partition contains a volume that has an unlimited quota configured. |
void |
refresh()
Refreshes the properties of this Partition object instance with values from the AFS partition it represents. |
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 |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
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()
Method 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 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()
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
|
Java AFS API (jafs) for OpenAFS | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |