apache/hadoop · error · IllegalArgumentException

Invalid options " + opts.getClass()

Error message

Invalid options " + opts.getClass()

What it means

TextFileRegionAliasMap.getReader requires its own ReaderOptions (file path, delimiter, codec, conf) to locate and parse the alias text file; any other Reader.Options implementation is rejected with IllegalArgumentException before the file is opened.

Source

Thrown at hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/common/blockaliasmap/impl/TextFileRegionAliasMap.java:93

  public void setConf(Configuration conf) {
    readerOpts.setConf(conf);
    writerOpts.setConf(conf);
    this.conf = conf;
  }

  @Override
  public Configuration getConf() {
    return conf;
  }

  @Override
  public Reader<FileRegion> getReader(Reader.Options opts, String blockPoolID)
      throws IOException {
    if (null == opts) {
      opts = readerOpts;
    }
    if (!(opts instanceof ReaderOptions)) {
      throw new IllegalArgumentException("Invalid options " + opts.getClass());
    }
    ReaderOptions o = (ReaderOptions) opts;
    Configuration readerConf = (null == o.getConf())
        ? new Configuration()
            : o.getConf();
    return createReader(o.file, o.delim, readerConf, blockPoolID);
  }

  @VisibleForTesting
  TextReader createReader(Path file, String delim, Configuration cfg,
      String blockPoolID) throws IOException {
    FileSystem fs = file.getFileSystem(cfg);
    if (fs instanceof LocalFileSystem) {
      fs = ((LocalFileSystem)fs).getRaw();
    }
    CompressionCodecFactory factory = new CompressionCodecFactory(cfg);
    CompressionCodec codec = factory.getCodec(file);
    String filename = fileNameFromBlockPoolID(blockPoolID);

View on GitHub (pinned to 2add963021)

Solutions

  1. Pass null so the map builds ReaderOptions from configuration (dfs.provided.aliasmap.text.path etc.)
  2. Or construct TextFileRegionAliasMap.ReaderOptions and set file/delimiter/codec explicitly
  3. Pair each Options object with its owning implementation

Example fix

// before
BlockAliasMap.Reader.Options o = new LevelDBFileRegionAliasMap.LevelDBOptions();
Reader<FileRegion> r = textAliasMap.getReader(o, bpid);

// after
Reader<FileRegion> r = textAliasMap.getReader(null, bpid);
Defensive patterns

Strategy: type-guard

Type guard

static boolean validReaderOpts(TextFileRegionAliasMap map,
    BlockAliasMap.Reader.Options o) {
  return o == null || o instanceof TextFileRegionAliasMap.ReaderOptions;
}

Prevention

When it happens

Trigger: Passing options from another alias map implementation (LevelDBOptions, InMemory client options) or a custom Options class to getReader of TextFileRegionAliasMap.

Common situations: Generic factory code over BlockAliasMap implementations sharing one Options instance; swapping dfs.provided.aliasmap.class between leveldb and text without updating option construction.

Related errors


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