/** Reproduce the journal and check if the state is correct. */
  private void reproduceAndCheckState(int successFiles) throws Exception {
    FileSystemMaster fsMaster = createFsMasterFromJournal();

    int actualFiles = fsMaster.getFileInfoList(new TachyonURI(TEST_FILE_DIR)).size();
    Assert.assertTrue((successFiles == actualFiles) || (successFiles + 1 == actualFiles));
    for (int f = 0; f < successFiles; f++) {
      Assert.assertTrue(
          fsMaster.getFileId(new TachyonURI(TEST_FILE_DIR + f)) != IdUtils.INVALID_FILE_ID);
    }
    fsMaster.stop();
  }
예제 #2
0
  /**
   * Creates a new key-value store.
   *
   * @param path URI of the key-value store
   * @throws FileAlreadyExistsException if a key-value store URI exists
   */
  public synchronized void createStore(TachyonURI path)
      throws FileAlreadyExistsException, InvalidPathException {
    try {
      // Create this dir
      mFileSystemMaster.mkdir(
          path,
          new CreateDirectoryOptions.Builder(MasterContext.getConf()).setRecursive(true).build());
    } catch (IOException e) {
      // TODO(binfan): Investigate why mFileSystemMaster.mkdir throws IOException
      throw new InvalidPathException(
          String.format("Failed to createStore: can not create path %s", path), e);
    }
    final long fileId = mFileSystemMaster.getFileId(path);
    Preconditions.checkState(fileId != IdUtils.INVALID_FILE_ID);

    createStoreInternal(fileId);
    writeJournalEntry(newCreateStoreEntry(fileId));
    flushJournal();
  }
예제 #3
0
 /**
  * Marks a key-value store complete.
  *
  * @param path URI of the key-value store
  * @throws FileDoesNotExistException if the key-value store URI does not exists
  */
 public synchronized void completeStore(TachyonURI path) throws FileDoesNotExistException {
   final long fileId = mFileSystemMaster.getFileId(path);
   if (fileId == IdUtils.INVALID_FILE_ID) {
     throw new FileDoesNotExistException(
         String.format("Failed to completeStore: path %s does not exist", path));
   }
   completeStoreInternal(fileId);
   writeJournalEntry(newCompleteStoreEntry(fileId));
   flushJournal();
 }
예제 #4
0
  /**
   * Gets a list of partitions of a given key-value store.
   *
   * @param path URI of the key-value store
   * @return a list of partition information
   * @throws FileDoesNotExistException if the key-value store URI does not exists
   */
  public synchronized List<PartitionInfo> getPartitionInfo(TachyonURI path)
      throws FileDoesNotExistException {
    final long fileId = mFileSystemMaster.getFileId(path);
    if (fileId == IdUtils.INVALID_FILE_ID) {
      throw new FileDoesNotExistException(
          String.format("Failed to getPartitionInfo: path %s does not exist", path));
    }

    List<PartitionInfo> partitions = mCompleteStoreToPartitions.get(fileId);
    if (partitions == null) {
      return Lists.newArrayList();
    }
    return partitions;
  }