@VisibleForTesting
  boolean shouldConsiderSameMountVolume(FsVolumeSpi fsVolume,
      StorageType targetStorageType, String targetStorageID) {
    if (targetStorageID != null && !targetStorageID.isEmpty()) {
      return false;
    }
    if (!(fsVolume instanceof FsVolumeImpl)
        || ((FsVolumeImpl) fsVolume).getMount().isEmpty()) {
      return false;
    }
    StorageType sourceStorageType = fsVolume.getStorageType();
    // Source/dest storage types are different
    if (sourceStorageType == targetStorageType) {
      return false;
    }
    // Source/dest storage types are either DISK or ARCHIVE.
    return StorageType.allowSameDiskTiering(sourceStorageType)
        && StorageType.allowSameDiskTiering(targetStorageType);
  }
@Test(timeout = 10000)
  public void testShouldConsiderSameMountVolume() throws IOException {
    FsVolumeImpl volume = new FsVolumeImplBuilder()
        .setConf(conf)
        .setDataset(dataset)
        .setStorageID("storage-id")
        .setStorageDirectory(
            new StorageDirectory(StorageLocation.parse(BASE_DIR)))
        .build();
    assertFalse(dataset.shouldConsiderSameMountVolume(volume,
        StorageType.ARCHIVE, null));

    conf.setBoolean(DFSConfigKeys
            .DFS_DATANODE_ALLOW_SAME_DISK_TIERING, true);
    conf.setDouble(DFSConfigKeys
            .DFS_DATANODE_RESERVE_FOR_ARCHIVE_DEFAULT_PERCENTAGE,
        0.5);
    volume = new FsVolumeImplBuilder()
        .setConf(conf)
        .setDataset(dataset)
        .setStorageID("storage-id")
        .setStorageDirectory(
            new StorageDirectory(StorageLocation.parse(BASE_DIR)))
        .build();
    assertTrue(dataset.shouldConsiderSameMountVolume(volume,
        StorageType.ARCHIVE, null));
    assertTrue(dataset.shouldConsiderSameMountVolume(volume,
        StorageType.ARCHIVE, ""));
    assertFalse(dataset.shouldConsiderSameMountVolume(volume,
        StorageType.DISK, null));
    assertFalse(dataset.shouldConsiderSameMountVolume(volume,
        StorageType.ARCHIVE, "target"));
  }