private static void checkAvailable(DistributedFileSystem dfs, String policy)
    throws HBaseIOException {
    Collection<ErasureCodingPolicyInfo> policies;
    try {
      policies = dfs.getAllErasureCodingPolicies();
    } catch (IOException e) {
      throw new HBaseIOException("Failed to check for Erasure Coding policy: " + policy, e);
    }
    for (ErasureCodingPolicyInfo policyInfo : policies) {
      if (policyInfo.getPolicy().getName().equals(policy)) {
        if (!policyInfo.isEnabled()) {
          throw new DoNotRetryIOException("Cannot set Erasure Coding policy: " + policy
            + ". The policy must be enabled, but has state " + policyInfo.getState());
        }
        return;
      }
    }
    throw new DoNotRetryIOException(
      "Cannot set Erasure Coding policy: " + policy + ". Policy not found. Available policies are: "
        + policies.stream().map(p -> p.getPolicy().getName()).collect(Collectors.joining(", ")));
  }
Runs checks against the FileSystem, verifying that HDFS is supported and the policy is
available, enabled, and works with a simple write.
hbase-server/src/main/java/org/apache/hadoop/hbase/fs/ErasureCodingUtils.java