apache/hadoop · error · UnsupportedOperationException

{} doesn't support setStoragePolicy

Error message

{} doesn't support setStoragePolicy

What it means

AbstractFileSystem.setStoragePolicy(Path, String) is a default stub throwing UnsupportedOperationException with the implementing class name. Block storage policies (HOT/WARM/COLD, EC policies' storage types) are an HDFS concept; the FileContext path hits the stub whenever the resolved implementation does not override it.

Source

Thrown at hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/AbstractFileSystem.java:1536

   * @throws IOException raised on errors performing I/O.
   */
  public void satisfyStoragePolicy(final Path path) throws IOException {
    throw new UnsupportedOperationException(
        getClass().getSimpleName() + " doesn't support satisfyStoragePolicy");
  }

  /**
   * Set the storage policy for a given file or directory.
   *
   * @param path file or directory path.
   * @param policyName the name of the target storage policy. The list
   *                   of supported Storage policies can be retrieved
   *                   via {@link #getAllStoragePolicies}.
   * @throws IOException raised on errors performing I/O.
   */
  public void setStoragePolicy(final Path path, final String policyName)
      throws IOException {
    throw new UnsupportedOperationException(getClass().getSimpleName()
        + " doesn't support setStoragePolicy");
  }


  /**
   * Unset the storage policy set for a given file or directory.
   * @param src file or directory path.
   * @throws IOException raised on errors performing I/O.
   */
  public void unsetStoragePolicy(final Path src) throws IOException {
    throw new UnsupportedOperationException(getClass().getSimpleName()
        + " doesn't support unsetStoragePolicy");
  }

  /**
   * Retrieve the storage policy for a given file or directory.
   *
   * @param src file or directory path.

View on GitHub (pinned to 2add963021)

Solutions

  1. Apply storage policies only on hdfs:// paths; validate the scheme before calling.
  2. Use DistributedFileSystem.setStoragePolicy or `hdfs dfsadmin -setStoragePolicy` for the supported flow.
  3. Check the policy name against getAllStoragePolicies() where supported instead of assuming.
  4. Catch UnsupportedOperationException and skip policy assignment on stores without support.

Example fix

// before
fc.setStoragePolicy(path, "COLD"); // throws: LocalFs doesn't support setStoragePolicy

// after
if ("hdfs".equals(path.toUri().getScheme())) {
  fc.setStoragePolicy(path, "COLD");
}
Defensive patterns

Strategy: validation

Validate before calling

static boolean policyOpsSupported(Path p) {
  return "hdfs".equals(p.toUri().getScheme());
}

Try / catch

try {
  fc.setStoragePolicy(path, "COLD");
} catch (UnsupportedOperationException e) {
  // no policy engine on this filesystem: skip assignment
}

Prevention

When it happens

Trigger: FileContext.setStoragePolicy(path, "COLD") on file://, s3a://, gs://, or ftp:// URIs; policy-assignment code run in local unit tests; a viewfs path whose target store is not HDFS.

Common situations: Tiering/ILM code written against HDFS gets exercised against local FS in tests or against object stores after migration; the policy name is valid but the store simply has no policy engine.

Related errors


AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22). Data as JSON: /api/errors/08490c21e51a0f64. Report an issue: GitHub.