@Override
  public PageStoreDir allocate(String fileId, long fileLength) {
    for (PageStoreDir dir : mDirs) {
      if (dir.hasFile(fileId) || dir.hasTempFile(fileId)) {
        return dir;
      }
    }
    return super.allocate(fileId, fileLength);
  }
@Test
  public void affinityTest() {
    AtomicInteger hashValue = new AtomicInteger(1);
    mAllocator = new AffinityHashAllocator(mDirs, (fileId) -> hashValue.get());
    String fileId = "222";
    //no dir contains the file, it will follow the hash value
    assertEquals("/2", mAllocator.allocate(fileId, 0).getRootPath().toString());
    hashValue.set(2);
    assertEquals("/3", mAllocator.allocate(fileId, 0).getRootPath().toString());
    //put the file to the second dir
    mDirs.get(1).putTempFile(fileId);
    //it will stick to the second dir
    assertEquals("/2", mAllocator.allocate(fileId, 0).getRootPath().toString());
    hashValue.set(0);
    assertEquals("/2", mAllocator.allocate(fileId, 0).getRootPath().toString());
  }