public static void ensureCleanDirectory(File dir) {
    try {
      if (dir.exists()) {
        // need to clean data directory to ensure that there is no interference from old runs
        // Cleaning is happening here to allow debugging in case of tests fail
        // we don;t have to clean logs since it is an append mode
        log.info("Cleaning the druid directory [{}]", dir.getAbsolutePath());
        FileUtils.deleteDirectory(dir);
      } else {
        log.info("Creating the druid directory [{}]", dir.getAbsolutePath());
        dir.mkdirs();
      }
    } catch (IOException e) {
      log.error("Failed to clean druid directory");
      Throwables.propagate(e);
    }
  }
Checks to see if a specific port is available.

@param port the port to check for availability
itests/qtest-druid/src/main/java/org/apache/hive/druid/MiniDruidCluster.java