apache/hadoop · error · HadoopIllegalArgumentException
Redundant -getlevel command
Error message
Redundant -getlevel command
What it means
parseGetLevelArgs throws HadoopIllegalArgumentException('Redundant -getlevel command') when a second -getlevel flag is encountered, because the operation enum is already set to GETLEVEL. The log-level tool accepts exactly one operation per invocation; combining or repeating operations is rejected at parse time.
Source
Thrown at hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/log/LogLevel.java:176
}
// if operation is never specified in the arguments
if (operation == Operations.UNKNOWN) {
throw new HadoopIllegalArgumentException(
"Must specify either -getlevel or -setlevel");
}
// if protocol is unspecified, set it as http.
if (protocol == null) {
protocol = PROTOCOL_HTTP;
}
}
private int parseGetLevelArgs(String[] args, int index) throws
HadoopIllegalArgumentException {
// fail if multiple operations are specified in the arguments
if (operation != Operations.UNKNOWN) {
throw new HadoopIllegalArgumentException(
"Redundant -getlevel command");
}
// check number of arguments is sufficient
if (index+2 >= args.length) {
throw new HadoopIllegalArgumentException(
"-getlevel needs two parameters");
}
operation = Operations.GETLEVEL;
hostName = args[index+1];
className = args[index+2];
return index+3;
}
private int parseSetLevelArgs(String[] args, int index) throws
HadoopIllegalArgumentException {
// fail if multiple operations are specified in the arguments
if (operation != Operations.UNKNOWN) {
throw new HadoopIllegalArgumentException(View on GitHub (pinned to 2add963021)
Solutions
- Remove the duplicate — issue exactly one -getlevel (or one -setlevel) per invocation.
- Run separate invocations for separate queries instead of chaining flags.
- Fix the script that builds the command so it appends the operation exactly once.
Example fix
# before hadoop loglevel -getlevel nn:9870 A -getlevel nn:9870 B # after hadoop loglevel -getlevel nn:9870 A && hadoop loglevel -getlevel nn:9870 B
Defensive patterns
Strategy: validation
Validate before calling
long n = Arrays.stream(args).filter(a -> a.equals("-getlevel")).count();
if (n > 1) {
throw new HadoopIllegalArgumentException("-getlevel may appear only once");
} Prevention
- Issue one operation per invocation; chain with && for multiple queries.
- Never concatenate two full loglevel commands into one line.
- Check command templates for loops that can append the flag twice.
When it happens
Trigger: 'hadoop loglevel -getlevel h:9870 cls -getlevel h:9870 cls2'; a duplicated flag from a shell loop or a for-loop bug appending the flag twice; copy-paste concatenation of two commands.
Common situations: Bash history editing duplicating a flag; wrapper scripts appending '-getlevel ...' to a variable that already contained it; documentation examples pasted back to back.
Related errors
- Redundant -setlevel command
- Redundant -protocol command
- Expect either -getlevel or -setlevel
- No arguments specified
- "Unexpected argument " + args[nextArgIndex]
AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22).
Data as JSON: /api/errors/6428aef384bbb119.
Report an issue: GitHub.