예제 #1
0
  /**
   * Returns an array containing a <code>TreeInfo</code> element for each <code>Tree</code> in the
   * specified volume. If there is no volume with the specified name or if Persistit is not
   * initialized then this method returns an empty array.
   *
   * @param volumeName The name (or unique partial name) of the volume for which information is
   *     being requested.
   * @return The array
   */
  @Override
  public TreeInfo[] getTreeInfoArray(final String volumeName) throws RemoteException {
    if (volumeName == null) {
      return new TreeInfo[0];
    }
    final Volume volume = _persistit.getVolume(volumeName);
    if (volume == null) return new TreeInfo[0];

    try {
      final String[] treeNames = volume.getTreeNames();
      TreeInfo[] results = new TreeInfo[treeNames.length + 1];
      int count = 0;
      results[count++] = new TreeInfo(volume.getDirectoryTree());
      for (int index = 0; index < treeNames.length; index++) {
        final TreeInfo info = volume.getTreeInfo(treeNames[index]);
        if (info != null) {
          results[count++] = info;
        }
      }
      if (count < results.length) {
        final TreeInfo[] temp = new TreeInfo[count];
        System.arraycopy(results, 0, temp, 0, count);
        results = temp;
      }
      return results;
    } catch (final PersistitException pe) {
      throw new WrappedRemoteException(pe);
    }
  }
예제 #2
0
 /**
  * Return a <code>BufferInfo</code> reflecting the state of a page containing the specified key.
  * The <code>volumeName</code> and <code>treeName</code> parameters specify a {@link Tree} in
  * which to seach for the key. The <code>level</code> parameter indicates whether the data page,
  * or one of the pages on the index path to that data page should be returned. Level 0 refers to
  * the data path, level 1 is the lowest index level, and level d-1 where d is the number of levels
  * in the the tree represents the three's root page.
  *
  * <p>Specify <code>treeName</code> as <code>null</code> to access the volume's directory tree.
  *
  * @param volumeName the name of the volume
  * @param treeName the name of the tree within the volume, or <code>null</code> for the directory
  *     tree
  * @param key a <code>KeyState</code> representing a key
  * @param level tree level: 0 for root, 1...d-1 for index pages of a tree having depth d.
  * @return a <code>BufferInfo</code> object reflecting the selected page, or <code>null</code> if
  *     the specified tree does not exist.
  * @throws RemoteException
  */
 @Override
 public BufferInfo getBufferInfo(
     final String volumeName, final String treeName, final KeyState key, final int level)
     throws RemoteException {
   try {
     Exchange exchange;
     final Volume volume = _persistit.getVolume(volumeName);
     if (volume == null) {
       return null;
     }
     if (treeName == null) {
       exchange = volume.getStructure().directoryExchange();
     } else {
       exchange = _persistit.getExchange(volume, treeName, false);
     }
     key.copyTo(exchange.getKey());
     final Buffer buffer = exchange.fetchBufferCopy(level);
     final BufferInfo info = new BufferInfo();
     buffer.populateInfo(info);
     return info;
   } catch (final TreeNotFoundException tnfe) {
     return null;
   } catch (final PersistitException pe) {
     throw new WrappedRemoteException(pe);
   }
 }
예제 #3
0
  @Override
  public LogicalRecord[] getLogicalRecordArray(
      final String volumeName,
      final String treeName,
      final String keyFilterString,
      final KeyState fromKey,
      final Key.Direction direction,
      final int maxCount,
      final int maxValueBytes,
      final boolean decodeStrings)
      throws RemoteException {
    LogicalRecord[] records = new LogicalRecord[maxCount];
    int count = 0;
    final boolean forward = direction == Key.GT || direction == Key.GTEQ;
    Exchange exchange = null;
    try {
      if (treeName.equals(VolumeStructure.DIRECTORY_TREE_NAME)) {
        exchange = _persistit.getVolume(volumeName).getStructure().directoryExchange();
      } else {
        exchange = _persistit.getExchange(volumeName, treeName, false);
      }
      exchange.ignoreMVCCFetch(true);
      KeyFilter filter = null;
      if (keyFilterString != null && keyFilterString.length() > 0) {
        filter = new KeyFilter(keyFilterString);
      }
      fromKey.copyTo(exchange.getKey());
      for (; count < maxCount; count++) {
        if (!exchange.traverse(direction, filter, maxValueBytes)) {
          break;
        } else {
          final LogicalRecord record = new LogicalRecord();
          record._key = new KeyState(exchange.getKey());
          record._value = new ValueState(exchange.getValue(), maxValueBytes);

          if (decodeStrings) {
            record._keyString = _displayFilter.toKeyDisplayString(exchange);
            record._valueString = _displayFilter.toValueDisplayString(exchange);
          }

          if (forward) {
            records[count] = record;
          } else {
            records[maxCount - count - 1] = record;
          }
        }
      }
    } catch (final Exception e) {
      throw new WrappedRemoteException(e);
    } finally {
      exchange.ignoreMVCCFetch(false);
    }
    if (count < maxCount) {
      final LogicalRecord[] trimmed = new LogicalRecord[count];
      System.arraycopy(records, forward ? 0 : maxCount - count, trimmed, 0, count);
      records = trimmed;
    }
    return records;
  }
예제 #4
0
 /**
  * Returns an array containing a <code>RecordInfo</code> element for each record in the page
  * specified by <code>volumeName</code> and <code>pageAddress</code>. If Persistit is not
  * initialized, or if there is no unique <code>Volume</code> for the specified <code>volumeName
  * </code>, or if there is no page associated with the specified <code>pageAddress</code> or if
  * there is any transient condition that causes the attempt to retrieve records to fail, then this
  * method returns an empty array.
  *
  * @param volumeName
  * @param pageAddress
  * @return the array
  */
 @Override
 public RecordInfo[] getRecordInfoArray(final String volumeName, final long pageAddress)
     throws RemoteException {
   final Volume volume = _persistit.getVolume(volumeName);
   if (volume == null) return new RecordInfo[0];
   try {
     final Buffer buffer = volume.getPool().getBufferCopy(volume, pageAddress);
     return buffer.getRecords();
   } catch (final PersistitException pe) {
     throw new WrappedRemoteException(pe);
   }
 }
예제 #5
0
 /**
  * Returns a <code>BufferInfo</code> reflecting the status of the buffer containing the page
  * specified by the supplied <code>volumeName</code> and <code>pageAddress</code>. If Persisit is
  * not initialized or of the attempt the find the specified page fails, this method returns <code>
  * null</code>
  *
  * @param volumeName the name of the volume
  * @param pageAddress the page address
  * @return the BufferInfo for the buffer containing the designated page, of <code>null</code> if
  *     there is none.
  */
 @Override
 public BufferInfo getBufferInfo(final String volumeName, final long pageAddress)
     throws RemoteException {
   final Volume volume = _persistit.getVolume(volumeName);
   if (volume == null) return null;
   try {
     final Buffer buffer = volume.getPool().getBufferCopy(volume, pageAddress);
     final BufferInfo info = new BufferInfo();
     buffer.populateInfo(info);
     return info;
   } catch (final PersistitException pe) {
     throw new WrappedRemoteException(pe);
   }
 }
예제 #6
0
 /**
  * Returns a <code>TreeInfo</code> for a specified <code>Volume</code> and </code>Tree</code>. If
  * Persisit is not initialized, or if no no volume or tree with corresponding names is found, or
  * if there is a transient error in acquiring the information, this method returns <code>null
  * </code>.
  *
  * @param volumeName The name (or partial name) of the volume
  * @param treeName The name of the tree
  * @return the <code>TreeInfo</code>
  */
 @Override
 public TreeInfo getTreeInfo(final String volumeName, final String treeName)
     throws RemoteException {
   final Volume volume = _persistit.getVolume(volumeName);
   if (volume == null) return null;
   try {
     Tree tree = null;
     if (VolumeStructure.DIRECTORY_TREE_NAME.equals(treeName)) {
       tree = volume.getDirectoryTree();
     } else {
       tree = volume.getTree(treeName, false);
     }
     if (tree != null) return new TreeInfo(tree);
   } catch (final PersistitException pe) {
     throw new WrappedRemoteException(pe);
   }
   return null;
 }
예제 #7
0
 /**
  * Returns the <code>VolumeInfo</code> for the volume specified by the supplied <code>volumeName
  * </code>. If Persisit is not initialized or there is no unique volume corresponding with the
  * supplied name, then this method returns <code>null</code>.
  *
  * @param volumeName
  * @return the <code>VolumeInfo</code>
  */
 @Override
 public VolumeInfo getVolumeInfo(final String volumeName) {
   final Volume volume = _persistit.getVolume(volumeName);
   if (volume == null) return null;
   else return new VolumeInfo(volume);
 }