apache/hadoop · error · IllegalArgumentException
Invalid options " + opts.getClass()
Error message
Invalid options " + opts.getClass()
What it means
LevelDBFileRegionAliasMap.getReader requires its own LevelDBOptions subclass (carrying the leveldb path) so it can open the local DB; any other Reader.Options implementation — including options belonging to other alias map implementations — is rejected with IllegalArgumentException before any I/O happens.
Source
Thrown at hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/common/blockaliasmap/impl/LevelDBFileRegionAliasMap.java:79
@Override
public void setConf(Configuration conf) {
opts.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 = this.opts;
}
if (!(opts instanceof LevelDBOptions)) {
throw new IllegalArgumentException("Invalid options " + opts.getClass());
}
LevelDBOptions o = (LevelDBOptions) opts;
return new LevelDBFileRegionAliasMap.LevelDBReader(
createDB(o.levelDBPath, false, blockPoolID));
}
@Override
public Writer<FileRegion> getWriter(Writer.Options opts, String blockPoolID)
throws IOException {
if (null == opts) {
opts = this.opts;
}
if (!(opts instanceof LevelDBOptions)) {
throw new IllegalArgumentException("Invalid options " + opts.getClass());
}
LevelDBOptions o = (LevelDBOptions) opts;
return new LevelDBFileRegionAliasMap.LevelDBWriter(
createDB(o.levelDBPath, true, blockPoolID));View on GitHub (pinned to 2add963021)
Solutions
- Pass null to use the map's defaults built from configuration (dfs.provided.aliasmap.leveldb.path)
- Or construct the right type: new LevelDBFileRegionAliasMap.LevelDBOptions() and set its levelDBPath
- Keep Options objects paired with their implementation — don't share them across alias map classes
Example fix
// before BlockAliasMap.Reader.Options o = new TextFileRegionAliasMap.ReaderOptions(); Reader<FileRegion> r = leveldbAliasMap.getReader(o, bpid); // after Reader<FileRegion> r = leveldbAliasMap.getReader(null, bpid); // uses conf defaults
Defensive patterns
Strategy: type-guard
Type guard
static boolean validReaderOpts(LevelDBFileRegionAliasMap map,
BlockAliasMap.Reader.Options o) {
return o == null || o instanceof LevelDBFileRegionAliasMap.LevelDBOptions;
} Prevention
- Prefer passing null and letting configuration drive defaults
- Never share Options instances across different BlockAliasMap implementations
When it happens
Trigger: Passing a TextFileRegionAliasMap.ReaderOptions, InMemoryLevelDB options, or a hand-rolled Options class to getReader of LevelDBFileRegionAliasMap.
Common situations: Generic factory code that abstracts over BlockAliasMap implementations but shares one Options object; refactoring from the text alias map to the leveldb alias map without updating call sites.
Related errors
- Invalid options " + opts.getClass()
- InMemoryAliasMap location is null
- Unable to create aliasmap snapshot directory {newLevelDBDir}
- A valid path needs to be specified for " + LevelDBFileRegion
- Unable to create " + dbFile
AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22).
Data as JSON: /api/errors/d53130c519f1502b.
Report an issue: GitHub.