@Override
  public void delete(SegmentDirectoryLoaderContext segmentLoaderContext)
      throws Exception {
    String segmentName = segmentLoaderContext.getSegmentName();
    String[] lastTierPath = getSegmentTierPersistedLocally(segmentName, segmentLoaderContext);
    File lastDataDir = lastTierPath[1] != null ? new File(lastTierPath[1]) : getDefaultDataDir(segmentLoaderContext);
    if (lastDataDir.exists()) {
      FileUtils.deleteQuietly(lastDataDir);
      LOGGER.info("Deleted segment directory {} on last known tier: {}", lastDataDir,
          TierConfigUtils.normalizeTierName(lastTierPath[0]));
    }
    deleteSegmentTierPersistedLocally(segmentName, segmentLoaderContext);
  }
@Test
  public void testDeleteSegmentOnDefaultTier()
      throws Exception {
    TierBasedSegmentDirectoryLoader loader = new TierBasedSegmentDirectoryLoader();
    SegmentDirectoryLoaderContext loaderCtx = new SegmentDirectoryLoaderContext.Builder().setSegmentName("seg01")
        .setTableDataDir(TEMP_DIR.getAbsolutePath() + "/" + TABLE_NAME_WITH_TYPE).build();
    // When segDir is on the default tier.
    File tableDataDir = new File(TEMP_DIR.getAbsolutePath(), TABLE_NAME_WITH_TYPE);
    File segDataDir = new File(tableDataDir, "seg01");
    FileUtils.touch(segDataDir);
    loader.delete(loaderCtx);
    assertFalse(segDataDir.exists());
  }