Exemplo n.º 1
0
 /**
  * Returns the number of volumes contained in this partition.
  *
  * <p>If the total list of volumes or volume names have already been collected (see {@link
  * #getVolumes()}), then the returning value will be calculated based upon the current list.
  * Otherwise, AFS will be explicitly queried for the information.
  *
  * <p>The product of this method is not saved, and is recalculated with every call.
  *
  * @return the number of volumes contained in this partition.
  * @exception AFSException If an error occurs in any of the associated native methods
  */
 public int getVolumeCount() throws AFSException {
   if (volumes != null) {
     return volumes.size();
   } else if (volumeNames != null) {
     return volumeNames.size();
   } else {
     return getVolumeCount(cell.getCellHandle(), server.getVosHandle(), getID());
   }
 }
Exemplo n.º 2
0
  /**
   * Obtains the most current list of volume names of this partition.
   *
   * @exception AFSException If an error occurs in the native code
   */
  protected void refreshVolumeNames() throws AFSException {
    String currName;

    long iterationID = getVolumesBegin(cell.getCellHandle(), server.getVosHandle(), getID());

    volumeNames = new ArrayList();

    while ((currName = getVolumesNextString(iterationID)) != null) {
      volumeNames.add(currName);
    }
    getVolumesDone(iterationID);
  }
Exemplo n.º 3
0
  /**
   * Obtains the most current list of <code>Volume</code> objects of this partition.
   *
   * @exception AFSException If an error occurs in the native code
   */
  protected void refreshVolumes() throws AFSException {
    Volume currVolume;

    long iterationID = getVolumesBegin(cell.getCellHandle(), server.getVosHandle(), getID());

    volumes = new ArrayList();

    currVolume = new Volume(this);
    while (getVolumesNext(iterationID, currVolume) != 0) {
      volumes.add(currVolume);
      currVolume = new Volume(this);
    }
    getVolumesDone(iterationID);
  }
Exemplo n.º 4
0
 /**
  * Salvages (restores consistency to) this partition. Uses default values for most salvager
  * options in order to simplify the API.
  *
  * @exception AFSException If an error occurs in the native code
  */
 public void salvage() throws AFSException {
   server.salvage(
       cell.getCellHandle(),
       server.getBosHandle(),
       name,
       null,
       4,
       null,
       null,
       false,
       false,
       false,
       false,
       false,
       false);
 }
Exemplo n.º 5
0
  /**
   * Returns an array containing a subset of the names of volumes associated with this <code>
   * Partition</code>. The subset is a point-in-time list of volume names starting at the complete
   * array's index of <code>startIndex</code> and containing up to <code>length</code> elements.
   *
   * <p>If <code>length</code> is larger than the number of remaining elements, respective to <code>
   * startIndex</code>, then this method will ignore the remaining positions requested by <code>
   * length</code> and return an array that contains the remaining number of elements found in this
   * partition's complete array of volume names.
   *
   * <p>This method is especially useful when managing iterations of very large lists. {@link
   * #getVolumeCount()} can be used to determine if iteration management is practical.
   *
   * <p>This method does not save the resulting data and therefore queries AFS for each call.
   *
   * <p><B>Example:</B> If there are more than 50,000 volumes within this partition then only render
   * them in increments of 10,000.
   *
   * <PRE>
   * ...
   *   String[] volumes;
   *   if (partition.getVolumeCount() > 50000) {
   *     int index = 0;
   *     int length = 10000;
   *     while (index < partition.getVolumeCount()) {
   *       volumes = partition.<B>getVolumeNames</B>(index, length);
   *       for (int i = 0; i < volumes.length; i++) {
   *         ...
   *       }
   *       index += length;
   *       ...
   *     }
   *   } else {
   *     volumes = partition.getVolumeNames();
   *     for (int i = 0; i < volumes.length; i++) {
   *       ...
   *     }
   *   }
   * ...
   * </PRE>
   *
   * @param startIndex the base zero index position at which the subset array should start from,
   *     relative to the complete list of elements present in AFS.
   * @param length the number of elements that the subset should contain
   * @return a subset array of volume names hosted by this partition
   * @exception AFSException If an error occurs in the native code
   * @see #getVolumeCount()
   * @see #getVolumes(int, int)
   * @see #getVolumes()
   */
  public String[] getVolumeNames(int startIndex, int length) throws AFSException {
    String[] volumes = new String[length];
    String currName;
    int i = 0;

    long iterationID =
        getVolumesBeginAt(cell.getCellHandle(), server.getVosHandle(), getID(), startIndex);

    while ((currName = getVolumesNextString(iterationID)) != null && i < length) {
      volumes[i] = currName;
      i++;
    }
    getVolumesDone(iterationID);
    if (i < length) {
      String[] v = new String[i];
      System.arraycopy(volumes, 0, v, 0, i);
      return v;
    } else {
      return volumes;
    }
  }
Exemplo n.º 6
0
  /**
   * Returns an array containing a subset of the <code>Volume</code> objects associated with this
   * <code>Partition</code>, 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 (<code>Volume</code> objects
   * representing AFS volumes) starting at the complete array's index of <code>startIndex</code> and
   * containing up to <code>length</code> elements.
   *
   * <p>If <code>length</code> is larger than the number of remaining elements, respective to <code>
   * startIndex</code>, then this method will ignore the remaining positions requested by <code>
   * length</code> and return an array that contains the remaining number of elements found in this
   * partition's complete array of volumes.
   *
   * <p>This method is especially useful when managing iterations of very large lists. {@link
   * #getVolumeCount()} can be used to determine if iteration management is practical.
   *
   * <p>This method does not save the resulting data and therefore queries AFS for each call.
   *
   * <p><B>Example:</B> If there are more than 50,000 volumes within this partition then only render
   * them in increments of 10,000.
   *
   * <PRE>
   * ...
   *   Volume[] volumes;
   *   if (partition.getVolumeCount() > 50000) {
   *     int index = 0;
   *     int length = 10000;
   *     while (index < partition.getVolumeCount()) {
   *       volumes = partition.<B>getVolumes</B>(index, length);
   *       for (int i = 0; i < volumes.length; i++) {
   *         ...
   *       }
   *       index += length;
   *       ...
   *     }
   *   } else {
   *     volumes = partition.getVolumes();
   *     for (int i = 0; i < volumes.length; i++) {
   *       ...
   *     }
   *   }
   * ...
   * </PRE>
   *
   * @param startIndex the base zero index position at which the subset array should start from,
   *     relative to the complete list of elements present in AFS.
   * @param length the number of elements that the subset should contain
   * @return a subset array of volumes hosted by this partition
   * @exception AFSException If an error occurs in the native code
   * @see #getVolumeCount()
   * @see #getVolumeNames(int, int)
   * @see #getVolumes()
   */
  public Volume[] getVolumes(int startIndex, int length) throws AFSException {
    Volume[] volumes = new Volume[length];
    Volume currVolume = new Volume(this);
    int i = 0;

    long iterationID =
        getVolumesBeginAt(cell.getCellHandle(), server.getVosHandle(), getID(), startIndex);

    while (getVolumesNext(iterationID, currVolume) != 0 && i < length) {
      volumes[i] = currVolume;
      currVolume = new Volume(this);
      i++;
    }
    getVolumesDone(iterationID);
    if (i < length) {
      Volume[] v = new Volume[i];
      System.arraycopy(volumes, 0, v, 0, i);
      return v;
    } else {
      return volumes;
    }
  }
Exemplo n.º 7
0
 /**
  * Syncs the VLDB to this partition.
  *
  * @exception AFSException If an error occurs in the native code
  */
 public void syncVLDB() throws AFSException {
   server.syncVLDBWithServer(cell.getCellHandle(), server.getVosHandle(), getID(), false);
 }
Exemplo n.º 8
0
 /**
  * Syncs this partition to the VLDB.
  *
  * @exception AFSException If an error occurs in the native code
  */
 public void syncPartition() throws AFSException {
   server.syncServerWithVLDB(cell.getCellHandle(), server.getVosHandle(), getID());
 }
Exemplo n.º 9
0
 /**
  * Refreshes the information fields of this <code>Partition</code> to reflect the current state of
  * the AFS partition. These include total free space, id, etc.
  *
  * @exception AFSException If an error occurs in the native code
  */
 protected void refreshInfo() throws AFSException {
   getPartitionInfo(cell.getCellHandle(), server.getVosHandle(), getID(), this);
   cachedInfo = true;
 }