@Override
  @GuardedBy("getLock().writeLock()")
  public void commitFile(String fileId, String newFileId) throws PageNotFoundException {
    Set<PageInfo> pages = mPages.getByField(INDEX_FILE_ID, fileId);
    if (pages.size() == 0) {
      throw new PageNotFoundException(
          String.format("No Pages found for file %s when committing", fileId));
    }
    for (PageInfo oldPageInfo : pages) {
      PageId newPageId = new PageId(newFileId, oldPageInfo.getPageId().getPageIndex());
      PageInfo newPageInfo = new PageInfo(newPageId, oldPageInfo.getPageSize(),
          oldPageInfo.getScope(), oldPageInfo.getLocalCacheDir());
      mPages.remove(oldPageInfo);
      mPages.add(newPageInfo);
    }
  }
@Test
  public void commitFile() throws PageNotFoundException {
    String newTempFile = "newTempFile";
    long pageIndex = 2L;
    PageId newTempPage = new PageId(newTempFile, pageIndex);
    mMetaStore.addPage(mPage, mPageInfo);
    mMetaStore.commitFile(mPage.getFileId(), newTempFile);
    assertEquals(mPageStoreDir, mMetaStore.getPageInfo(newTempPage).getLocalCacheDir());
    assertEquals(newTempFile, mMetaStore.getPageInfo(newTempPage).getPageId().getFileId());
    assertEquals(pageIndex, mMetaStore.getPageInfo(newTempPage).getPageId().getPageIndex());
  }