@Override
  public String getDataHome(CoreDescriptor cd) throws IOException {
    if (hdfsDataDir == null) {
      throw new SolrException(
          ErrorCode.SERVER_ERROR,
          "You must set the "
              + this.getClass().getSimpleName()
              + " param "
              + HDFS_HOME
              + " for relative dataDir paths to work");
    }

    // by default, we go off the instance directory
    String path;
    if (cd.getCloudDescriptor() != null) {
      path =
          URLEncoder.encode(cd.getCloudDescriptor().getCollectionName(), "UTF-8")
              + "/"
              + URLEncoder.encode(cd.getCloudDescriptor().getCoreNodeName(), "UTF-8");
    } else {
      path = cd.getName();
    }

    return normalize(
        SolrResourceLoader.normalizeDir(
            ZkController.trimLeadingAndTrailingSlashes(hdfsDataDir)
                + "/"
                + path
                + "/"
                + cd.getDataDir()));
  }