2 * @(#)Partition.java 1.0 6/29/2001
4 * Copyright (c) 2001 International Business Machines Corp.
7 * This software has been released under the terms of the IBM Public
8 * License. For details, see the LICENSE file in the top-level source
9 * directory or online at http://www.openafs.org/dl/license10.html
11 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
12 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
13 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
14 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR
15 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
16 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
17 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
18 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
19 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
20 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
21 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 package org
.openafs
.jafs
;
26 import java
.io
.Serializable
;
27 import java
.util
.ArrayList
;
30 * An abstract representation of an AFS partition. It holds information about
31 * the partition, such as what its total space is.
34 * Constructing an instance of a <code>Partition</code> does not mean
35 * an actual AFS partition is created on a server -- on the contrary,
36 * a <code>Partition</code> object must be a representation of an already
37 * existing AFS partition. There is no way to create a new AFS partition
38 * through this API.<BR><BR>
40 * Each <code>Partition</code> object has its own individual set of
41 * <code>Volume</code>s. This represents the properties and attributes
42 * of an actual AFS cell.<BR><BR>
44 * <!--Example of how to use class-->
45 * The following is a simple example of how to obtain and use a
46 * <code>Partition</code> object. In this example, a list of the
47 * <code>Partition</code> objects of a server are obtained, and the name
48 * and number of volumes is printed out for each one.<BR><BR>
51 * import org.openafs.jafs.Cell;
52 * import org.openafs.jafs.AFSException;
53 * import org.openafs.jafs.Partition;
54 * import org.openafs.jafs.Server;
60 * private Server server;
62 * public static void main(String[] args) throws Exception
64 * String username = arg[0];
65 * String password = arg[1];
66 * String cellName = arg[2];
67 * String serverName = arg[3];
69 * token = new Token(username, password, cellName);
70 * cell = new Cell(token);
71 * server = new Server(serverName, cell);
73 * System.out.println("Partitions in Server " + server.getName() + ":");
74 * Partition[] partitions = server.getPartitions();
75 * for (int i = 0; i < partitions.length; i++) {
76 * System.out.print("Partition " + partitions[i].getName());
77 * System.out.print("hosts " + partitions[i].getVolumeCount());
78 * System.out.print("volumes.\n");
86 public class Partition
implements Serializable
, Comparable
89 protected Server server
;
91 /* Populated by native method */
92 protected String name
;
94 /* Populated by native method */
97 /* Populated by native method */
98 protected String deviceName
;
100 /* Populated by native method */
101 protected int lockFileDescriptor
;
103 /* Populated by native method */
104 protected int totalSpace
;
106 /* Populated by native method */
107 protected int totalFreeSpace
;
109 protected int totalQuota
;
111 protected ArrayList volumes
;
112 protected ArrayList volumeNames
;
114 protected boolean cachedInfo
;
117 * Constructs a new <code>Partition</code> object instance given the
118 * name of the AFS partition and the AFS server, represented by
119 * <CODE>server</CODE>, to which it belongs. This does not actually
120 * create a new AFS partition, it just represents an existing one.
121 * If <code>name</code> is not an actual AFS partition, exceptions
122 * will be thrown during subsequent method invocations on this
125 * @param name the name of the partition to represent
126 * @param server the server on which the partition resides
127 * @exception AFSException If an error occurs in the native code
129 public Partition( String name
, Server server
) throws AFSException
132 this.server
= server
;
133 this.cell
= server
.getCell();
144 * Constructs a new <CODE>Partition</CODE> object instance given the name
145 * of the AFS partition and the AFS server, represented by
146 * <CODE>server</CODE>, to which it belongs. This does not actually
147 * create a new AFS partition, it just represents an existing one.
148 * If <code>name</code> is not an actual AFS partition, exceptions
149 * will be thrown during subsequent method invocations on this
152 * <P> This constructor is ideal for point-in-time representation and
153 * transient applications. It ensures all data member values are set and
154 * available without calling back to the filesystem at the first request
155 * for them. Use the {@link #refresh()} method to address any coherency
158 * @param name the name of the partition to represent
159 * @param server the server to which the partition belongs.
160 * @param preloadAllMembers true will ensure all object members are
161 * set upon construction;
162 * otherwise members will be set upon access,
163 * which is the default behavior.
164 * @exception AFSException If an error occurs in the native code
167 public Partition( String name
, Server server
, boolean preloadAllMembers
)
171 if (preloadAllMembers
) refresh(true);
175 * Creates a blank <code>Server</code> given the cell to which the partition
176 * belongs and the server on which the partition resides. This blank
177 * object can then be passed into other methods to fill out its properties.
179 * @exception AFSException If an error occurs in the native code
180 * @param cell the cell to which the partition belongs.
181 * @param server the server on which the partition resides
183 Partition( Server server
) throws AFSException
185 this( null, server
);
188 /*-------------------------------------------------------------------------*/
191 * Refreshes the properties of this Partition object instance with values
192 * from the AFS partition
193 * it represents. All properties that have been initialized and/or
194 * accessed will be renewed according to the values of the AFS partition
195 * this Partition object instance represents.
197 * <P>Since in most environments administrative changes can be administered
198 * from an AFS command-line program or an alternate GUI application, this
199 * method provides a means to refresh the Java object representation and
200 * thereby ascertain any possible modifications that may have been made
201 * from such alternate administrative programs. Using this method before
202 * an associated instance accessor will ensure the highest level of
203 * representative accuracy, accommodating changes made external to the
204 * Java application space. If administrative changes to the underlying AFS
205 * system are only allowed via this API, then the use of this method is
208 * @exception AFSException If an error occurs in the native code
210 public void refresh() throws AFSException
216 * Refreshes the properties of this Partition object instance with values
217 * from the AFS partition it represents. If <CODE>all</CODE> is
218 * <CODE>true</CODE> then <U>all</U> of the properties of this Partition
219 * object instance will be set, or renewed, according to the values of the
220 * AFS partition it represents, disregarding any previously set properties.
222 * <P> Thus, if <CODE>all</CODE> is <CODE>false</CODE> then properties
223 * that are currently set will be refreshed and properties that are not
224 * set will remain uninitialized. See {@link #refresh()} for more
227 * @param all if true set or renew all object properties; otherwise
228 * renew all set properties
229 * @exception AFSException If an error occurs in the native code
232 protected void refresh(boolean all
) throws AFSException
234 if (all
|| volumes
!= null) {
237 if (all
|| volumeNames
!= null) {
238 refreshVolumeNames();
240 if (all
|| cachedInfo
) {
246 * Refreshes the information fields of this <code>Partition</code> to
247 * reflect the current state of the AFS partition. These include total
248 * free space, id, etc.
250 * @exception AFSException If an error occurs in the native code
252 protected void refreshInfo() throws AFSException
254 getPartitionInfo( cell
.getCellHandle(), server
.getVosHandle(), getID(),
260 * Obtains the most current list of <code>Volume</code> objects of this
263 * @exception AFSException If an error occurs in the native code
265 protected void refreshVolumes() throws AFSException
269 long iterationID
= getVolumesBegin( cell
.getCellHandle(),
270 server
.getVosHandle(), getID() );
272 volumes
= new ArrayList();
274 currVolume
= new Volume( this );
275 while( getVolumesNext( iterationID
, currVolume
) != 0 ) {
276 volumes
.add( currVolume
);
277 currVolume
= new Volume( this );
279 getVolumesDone( iterationID
);
283 * Obtains the most current list of volume names of this partition.
285 * @exception AFSException If an error occurs in the native code
287 protected void refreshVolumeNames() throws AFSException
291 long iterationID
= getVolumesBegin( cell
.getCellHandle(),
292 server
.getVosHandle(), getID() );
294 volumeNames
= new ArrayList();
296 while( ( currName
= getVolumesNextString( iterationID
) ) != null ) {
297 volumeNames
.add( currName
);
299 getVolumesDone( iterationID
);
303 * Syncs this partition to the VLDB.
305 * @exception AFSException If an error occurs in the native code
307 public void syncPartition() throws AFSException
309 server
.syncServerWithVLDB( cell
.getCellHandle(), server
.getVosHandle(),
314 * Syncs the VLDB to this partition.
316 * @exception AFSException If an error occurs in the native code
318 public void syncVLDB() throws AFSException
320 server
.syncVLDBWithServer( cell
.getCellHandle(), server
.getVosHandle(),
325 * Salvages (restores consistency to) this partition. Uses default values for
326 * most salvager options in order to simplify the API.
328 * @exception AFSException If an error occurs in the native code
330 public void salvage() throws AFSException
332 server
.salvage( cell
.getCellHandle(), server
.getBosHandle(), name
, null,
333 4, null, null, false, false, false, false, false, false );
336 //////////////// accessors: ////////////////////////
339 * Returns the name of this partition.
341 * @return the name of this partition
343 public String
getName()
349 * Returns this partition's hosting server.
351 * @return this partition's server
353 public Server
getServer()
359 * Returns the number of volumes contained in this partition.
361 * <P>If the total list of volumes or volume names have already been
362 * collected (see {@link #getVolumes()}), then the returning value will
363 * be calculated based upon the current list. Otherwise, AFS will be
364 * explicitly queried for the information.
366 * <P> The product of this method is not saved, and is recalculated
369 * @return the number of volumes contained in this partition.
370 * @exception AFSException If an error occurs in any
371 * of the associated native methods
373 public int getVolumeCount() throws AFSException
375 if (volumes
!= null) {
376 return volumes
.size();
377 } else if (volumeNames
!= null) {
378 return volumeNames
.size();
380 return getVolumeCount( cell
.getCellHandle(),
381 server
.getVosHandle(), getID() );
386 * Retrieves the <CODE>Volume</CODE> object (which is an abstract
387 * representation of an actual AFS volume of this partition) designated
388 * by <code>name</code> (i.e. "root.afs", etc.). If a volume by
389 * that name does not actually exist in AFS on the partition
390 * represented by this object, an {@link AFSException} will be
393 * @exception AFSException If an error occurs in the native code
394 * @exception NullPointerException If <CODE>name</CODE> is
396 * @param name the name of the volume to retrieve
397 * @return <CODE>Volume</CODE> designated by <code>name</code>.
399 public Volume
getVolume(String name
) throws AFSException
401 if (name
== null) throw new NullPointerException();
402 Volume volume
= new Volume(name
, this);
407 * Retrieves an array containing all of the <code>Volume</code> objects
408 * associated with this <code>Partition</code>, each of which is an
409 * abstract representation of an actual AFS volume of the AFS partition.
410 * After this method is called once, it saves the array of
411 * <code>Volume</code>s and returns that saved array on subsequent calls,
412 * until the {@link #refresh()} method is called and a more current list
415 * @exception AFSException If an error occurs in the native code
416 * @return a <code>Volume</code> array of the <code>Volume</code>
417 * objects of the partition.
420 public Volume
[] getVolumes() throws AFSException
422 if (volumes
== null) refreshVolumes();
423 return (Volume
[]) volumes
.toArray( new Volume
[volumes
.size()] );
427 * Returns an array containing a subset of the <code>Volume</code> objects
428 * associated with this <code>Partition</code>, each of which is an abstract
429 * representation of an actual AFS volume of the AFS partition. The subset
430 * is a point-in-time list of volumes (<code>Volume</code> objects
431 * representing AFS volumes) starting at the complete array's index of
432 * <code>startIndex</code> and containing up to <code>length</code>
435 * If <code>length</code> is larger than the number of remaining elements,
436 * respective to <code>startIndex</code>, then this method will
437 * ignore the remaining positions requested by <code>length</code> and
438 * return an array that contains the remaining number of elements found in
439 * this partition's complete array of volumes.
441 * <P>This method is especially useful when managing iterations of very
442 * large lists. {@link #getVolumeCount()} can be used to determine if
443 * iteration management is practical.
445 * <P>This method does not save the resulting data and therefore
446 * queries AFS for each call.
448 * <P><B>Example:</B> If there are more than 50,000 volumes within this partition
449 * then only render them in increments of 10,000.
453 * if (partition.getVolumeCount() > 50000) {
455 * int length = 10000;
456 * while (index < partition.getVolumeCount()) {
457 * volumes = partition.<B>getVolumes</B>(index, length);
458 * for (int i = 0; i < volumes.length; i++) {
465 * volumes = partition.getVolumes();
466 * for (int i = 0; i < volumes.length; i++) {
473 * @param startIndex the base zero index position at which the subset array
474 * should start from, relative to the complete list of
475 * elements present in AFS.
476 * @param length the number of elements that the subset should contain
477 * @return a subset array of volumes hosted by this partition
478 * @exception AFSException If an error occurs in the native code
479 * @see #getVolumeCount()
480 * @see #getVolumeNames(int, int)
483 public Volume
[] getVolumes(int startIndex
, int length
) throws AFSException
485 Volume
[] volumes
= new Volume
[length
];
486 Volume currVolume
= new Volume( this );
489 long iterationID
= getVolumesBeginAt( cell
.getCellHandle(),
490 server
.getVosHandle(), getID(), startIndex
);
492 while( getVolumesNext( iterationID
, currVolume
) != 0 && i
< length
) {
493 volumes
[i
] = currVolume
;
494 currVolume
= new Volume( this );
497 getVolumesDone( iterationID
);
499 Volume
[] v
= new Volume
[i
];
500 System
.arraycopy(volumes
, 0, v
, 0, i
);
508 * Retrieves an array containing all of the names of volumes
509 * associated with this <code>Partition</code>.
510 * After this method is called once, it saves the array of
511 * <code>String</code>s and returns that saved array on subsequent calls,
512 * until the {@link #refresh()} method is called and a more current
515 * @return a <code>String</code> array of the volumes of the partition.
516 * @exception AFSException If an error occurs in the native code
519 public String
[] getVolumeNames() throws AFSException
521 if (volumeNames
== null) refreshVolumeNames();
522 return (String
[]) volumeNames
.toArray( new String
[volumeNames
.size() ] );
526 * Returns an array containing a subset of the names of volumes
527 * associated with this <code>Partition</code>. The subset is a
528 * point-in-time list of volume names starting at the complete array's
529 * index of <code>startIndex</code> and containing up to <code>length</code>
532 * If <code>length</code> is larger than the number of remaining elements,
533 * respective to <code>startIndex</code>, then this method will
534 * ignore the remaining positions requested by <code>length</code> and
535 * return an array that contains the remaining number of elements found in
536 * this partition's complete array of volume names.
538 * <P>This method is especially useful when managing iterations of very
539 * large lists. {@link #getVolumeCount()} can be used to determine if
540 * iteration management is practical.
542 * <P>This method does not save the resulting data and therefore
543 * queries AFS for each call.
545 * <P><B>Example:</B> If there are more than 50,000 volumes within this partition
546 * then only render them in increments of 10,000.
550 * if (partition.getVolumeCount() > 50000) {
552 * int length = 10000;
553 * while (index < partition.getVolumeCount()) {
554 * volumes = partition.<B>getVolumeNames</B>(index, length);
555 * for (int i = 0; i < volumes.length; i++) {
562 * volumes = partition.getVolumeNames();
563 * for (int i = 0; i < volumes.length; i++) {
570 * @param startIndex the base zero index position at which the subset array
571 * should start from, relative to the complete list of
572 * elements present in AFS.
573 * @param length the number of elements that the subset should contain
574 * @return a subset array of volume names hosted by this partition
575 * @exception AFSException If an error occurs in the native code
576 * @see #getVolumeCount()
577 * @see #getVolumes(int, int)
580 public String
[] getVolumeNames(int startIndex
, int length
) throws AFSException
582 String
[] volumes
= new String
[length
];
586 long iterationID
= getVolumesBeginAt( cell
.getCellHandle(),
587 server
.getVosHandle(), getID(), startIndex
);
589 while( ( currName
= getVolumesNextString( iterationID
) ) != null && i
< length
) {
590 volumes
[i
] = currName
;
593 getVolumesDone( iterationID
);
595 String
[] v
= new String
[i
];
596 System
.arraycopy(volumes
, 0, v
, 0, i
);
604 * Returns the id of this partition (i.e. "vicepa" = 0, etc.)
606 * @exception AFSException If an error occurs in the native code
607 * @return the id of this partition
609 public int getID() throws AFSException
611 if (id
== -1) id
= translateNameToID( name
);
616 * Returns the device name of this partition (i.e. "hda5", etc.)
618 * @exception AFSException If an error occurs in the native code
619 * @return the device name of this partition
622 public String
getDeviceName() throws AFSException
624 if (!cachedInfo
) refreshInfo();
629 * Returns the lock file descriptor of this partition
631 * @exception AFSException If an error occurs in the native code
632 * @return the lock file descriptor of this partition
635 public int getLockFileDescriptor() throws AFSException
637 if (!cachedInfo
) refreshInfo();
638 return lockFileDescriptor
;
642 * Returns the total space on this partition.
644 * @exception AFSException If an error occurs in the native code
645 * @return the total space on this partition
648 public int getTotalSpace() throws AFSException
650 if (!cachedInfo
) refreshInfo();
655 * Returns the total free space on this partition.
656 * After this method is called once, it saves the total free space
657 * and returns that value on subsequent calls,
658 * until the {@link #refresh()} method is called and a more current
661 * @exception AFSException If an error occurs in the native code
662 * @return the total free space on this partition
665 public int getTotalFreeSpace() throws AFSException
667 if (!cachedInfo
) refreshInfo();
668 return totalFreeSpace
;
672 * Returns the total used space on this partition.
673 * After this method is called once, it saves the total used space
674 * and returns that value on subsequent calls,
675 * until the {@link #refresh()} method is called and a more current
678 * @exception AFSException If an error occurs in the native code
679 * @return the total used space on this partition
682 public int getUsedSpace() throws AFSException
684 if (!cachedInfo
) refreshInfo();
685 return (totalSpace
- totalFreeSpace
);
689 * Returns the total combined quota of all volumes on this partition,
690 * unless a volume has configured an unlimited quota at which case an
691 * {@link AFSException} is thrown.
693 * <P>After this method is called once, it saves the value and returns
694 * that value on subsequent calls, until the {@link #refresh()}
695 * method is called and a more current value is obtained.
697 * @exception AFSException If an error occurs while retrieving and
698 * calculating, or a volume has an
700 * @return the total combined quota of all volumes on this partition
701 * @see #getTotalQuota(boolean)
702 * @see #hasVolumeWithUnlimitedQuota()
703 * @see Volume#getQuota()
705 public int getTotalQuota() throws AFSException
707 return getTotalQuota(false);
711 * Returns the total combined quota of all volumes on this partition,
712 * ignoring volumes with unlimited quotas, if <CODE>
713 * ignoreUnlimitedQuotas</CODE> is <CODE>true</CODE>; otherwise an
714 * {@link AFSException} is thrown if a volume has an unlimited quota.
716 * <P>After this method is called once, it saves the value and returns
717 * that value on subsequent calls, until the {@link #refresh()}
718 * method is called and a more current value is obtained.
720 * @exception AFSException If an error occurs while retrieving and
721 * calculating, or a volume has an
723 * @return the total combined quota of all volumes on this partition
724 * @see #getTotalQuota()
725 * @see #hasVolumeWithUnlimitedQuota()
726 * @see Volume#getQuota()
729 public int getTotalQuota(boolean ignoreUnlimitedQuotas
)
732 if (volumes
== null) refreshVolumes();
733 if (totalQuota
== 0 || !ignoreUnlimitedQuotas
) {
734 Volume
[] volumes
= getVolumes();
735 for (int i
= 0; i
< volumes
.length
; i
++) {
737 totalQuota
+= volumes
[i
].getQuota();
738 } catch (AFSException e
) {
739 if (!ignoreUnlimitedQuotas
) {
750 * Tests whether this partition contains a volume that has an unlimited
753 * @exception AFSException If an error occurs in the native code
754 * @return <CODE>true</CODE> if a contained volume's quota is configured
755 * as unlimited; otherwise <CODE>false</CODE>.
756 * @see #getTotalQuota()
757 * @see #getTotalQuota(boolean)
758 * @see Volume#isQuotaUnlimited()
759 * @see Volume#getQuota()
762 public boolean hasVolumeWithUnlimitedQuota() throws AFSException
764 if (volumes
== null) refreshVolumes();
765 Volume
[] volumes
= getVolumes();
766 for (int i
= 0; i
< volumes
.length
; i
++) {
767 if (volumes
[i
].isQuotaUnlimited()) return true;
772 /////////////// custom information methods ////////////////////
775 * Returns a <code>String</code> representation of this
776 * <code>Partition</code>. Contains the information fields and a list of
779 * @return a <code>String</code> representation of the <code>Partition</code>
781 public String
getInfo()
787 r
= "Partition: " + name
+ "\tid: " + getID() + "\n";
789 r
+= "\tDevice name: " + getDeviceName() + "\n";
790 r
+= "\tLock file descriptor: " + getLockFileDescriptor() + "\n";
791 r
+= "\tTotal free space: " + getTotalFreeSpace() + " K\n";
792 r
+= "\tTotal space: " + getTotalSpace() + " K\n";
796 String vols
[] = getVolumeNames();
798 for( int i
= 0; i
< vols
.length
; i
++ ) {
799 r
+= "\t\t" + vols
[i
] + "\n";
802 } catch( Exception e
) {
809 * Returns a <code>String</code> containing the <code>String</code>
810 * representations of all the volumes of this <code>Partition</code>.
812 * @return a <code>String</code> representation of the volumes
813 * @see Volume#getInfo
815 public String
getInfoVolumes() throws AFSException
819 r
= "Partition: " + name
+ "\n\n";
820 r
+= "--Volumes--\n";
822 Volume vols
[] = getVolumes();
823 for( int i
= 0; i
< vols
.length
; i
++ ) {
824 r
+= vols
[i
].getInfo() + "\n";
829 /////////////// custom override methods ////////////////////
832 * Compares two Partition objects respective to their names and does not
833 * factor any other attribute. Alphabetic case is significant in
836 * @param partition The Partition object to be compared to
837 * this Partition instance
839 * @return Zero if the argument is equal to this Partition's name, a
840 * value less than zero if this Partition's name is
841 * lexicographically less than the argument, or a value greater
842 * than zero if this Partition's name is lexicographically
843 * greater than the argument
845 public int compareTo(Partition partition
)
847 return this.getName().compareTo(partition
.getName());
851 * Comparable interface method.
853 * @see #compareTo(Partition)
855 public int compareTo(Object obj
)
857 return compareTo((Partition
)obj
);
861 * Tests whether two <code>Partition</code> objects are equal,
862 * based on their names and hosting server.
864 * @param otherPartition the Partition to test
865 * @return whether the specifed Partition is the same as this Partition
867 public boolean equals( Partition otherPartition
)
869 return ( name
.equals(otherPartition
.getName()) ) &&
870 ( getServer().equals(otherPartition
.getServer()) );
874 * Returns the name of this <CODE>Partition</CODE>
876 * @return the name of this <CODE>Partition</CODE>
878 public String
toString()
883 /////////////// native methods ////////////////////
886 * Fills in the information fields of the provided <code>Partition</code>.
888 * @param cellHandle the handle of the cell to which the partition belongs
889 * @see Cell#getCellHandle
890 * @param serverHandle the vos handle of the server on which the
892 * @see Server#getVosServerHandle
893 * @param partition the numeric id of the partition for which to get the
895 * @param thePartition the {@link Partition Partition} object in which to
896 * fill in the information
897 * @exception AFSException If an error occurs in the native code
899 protected static native void getPartitionInfo( long cellHandle
,
902 Partition thePartition
)
906 * Returns the total number of volumes hosted by this partition.
908 * @param cellHandle the handle of the cell to which the partition belongs
909 * @param serverHandle the vos handle of the server to which the partition
911 * @param partition the numeric id of the partition on which the volumes
913 * @return total number of volumes hosted by this partition
914 * @exception AFSException If an error occurs in the native code
915 * @see Cell#getCellHandle
916 * @see Server#getVosServerHandle
918 protected static native int getVolumeCount( long cellHandle
,
924 * Begin the process of getting the volumes on a partition. Returns
925 * an iteration ID to be used by subsequent calls to
926 * <code>getVolumesNext</code> and <code>getVolumesDone</code>.
928 * @param cellHandle the handle of the cell to which the partition belongs
929 * @see Cell#getCellHandle
930 * @param serverHandle the vos handle of the server to which the partition
932 * @see Server#getVosServerHandle
933 * @param partition the numeric id of the partition on which the volumes
935 * @return an iteration ID
936 * @exception AFSException If an error occurs in the native code
938 protected static native long getVolumesBegin( long cellHandle
,
944 * Begin the process of getting the volumes on a partition. Returns
945 * an iteration ID to be used by subsequent calls to
946 * <code>getVolumesNext</code> and <code>getVolumesDone</code>.
948 * @param cellHandle the handle of the cell to which the partition belongs
949 * @see Cell#getCellHandle
950 * @param serverHandle the vos handle of the server to which the partition
952 * @see Server#getVosServerHandle
953 * @param partition the numeric id of the partition on which the volumes
955 * @return an iteration ID
956 * @exception AFSException If an error occurs in the native code
958 protected static native long getVolumesBeginAt( long cellHandle
,
960 int partition
, int index
)
964 * Returns the next volume of the partition. Returns <code>null</code>
965 * if there are no more volumes.
967 * @param iterationId the iteration ID of this iteration
968 * @see #getVolumesBegin
969 * @return the name of the next volume of the server
970 * @exception AFSException If an error occurs in the native code
972 protected static native String
getVolumesNextString( long iterationId
)
976 * Fills the next volume object of the partition. Returns 0 if there
977 * are no more volumes, != 0 otherwise.
979 * @param iterationId the iteration ID of this iteration
980 * @param theVolume the Volume object in which to fill the values
982 * @see #getVolumesBegin
983 * @return 0 if there are no more volumes, != 0 otherwise
984 * @exception AFSException If an error occurs in the native code
986 protected static native int getVolumesNext( long iterationId
,
991 * Fills the next volume object of the partition. Returns 0 if there
992 * are no more volumes, != 0 otherwise.
994 * @param iterationId the iteration ID of this iteration
995 * @param theVolume the Volume object in which to fill the values of the
997 * @see #getVolumesBegin
998 * @return 0 if there are no more volumes, != 0 otherwise
999 * @exception AFSException If an error occurs in the native code
1001 protected static native int getVolumesAdvanceTo( long iterationId
,
1004 throws AFSException
;
1007 * Signals that the iteration is complete and will not be accessed anymore.
1009 * @param iterationId the iteration ID of this iteration
1010 * @see #getVolumesBegin
1011 * @exception AFSException If an error occurs in the native code
1013 protected static native void getVolumesDone( long iterationId
)
1014 throws AFSException
;
1017 * Translates a partition name into a partition id
1019 * @param name the name of the partition in question
1020 * @return the id of the partition in question
1021 * @exception AFSException If an error occurs in the native code
1023 protected static native int translateNameToID( String name
)
1024 throws AFSException
;
1027 * Translates a partition id into a partition name
1029 * @param id the id of the partition in question
1030 * @return the name of the partition in question
1031 * @exception AFSException If an error occurs in the native code
1033 protected static native String
translateIDToName( int id
)
1034 throws AFSException
;
1037 * Reclaims all memory being saved by the partition portion of the native
1038 * library. This method should be called when no more <code>Partition</code>
1039 * objects are expected to be
1042 protected static native void reclaimPartitionMemory();