apache/hadoop · error · HadoopIllegalArgumentException

Redundant -setlevel command

Error message

Redundant -setlevel command

What it means

parseSetLevelArgs throws HadoopIllegalArgumentException('Redundant -setlevel command') when -setlevel appears a second time, because the operation enum is already SETLEVEL. The tool accepts exactly one operation per run, so repeated or mixed operation flags fail fast during parsing, before any HTTP request is made.

Source

Thrown at hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/log/LogLevel.java:194

        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(
            "Redundant -setlevel command");
      }
      // check number of arguments is sufficient
      if (index+3 >= args.length) {
        throw new HadoopIllegalArgumentException(
            "-setlevel needs three parameters");
      }
      operation = Operations.SETLEVEL;
      hostName = args[index+1];
      className = args[index+2];
      level = args[index+3];
      return index+4;
    }

    private int parseProtocolArgs(String[] args, int index) throws
        HadoopIllegalArgumentException {
      // make sure only -protocol is specified
      if (protocol != null) {

View on GitHub (pinned to 2add963021)

Solutions

  1. Keep exactly one operation flag per invocation.
  2. Execute multiple level changes as separate commands.
  3. Audit aliases/wrappers that may already inject -setlevel before your extra flag is appended.

Example fix

# before
hadoop loglevel -setlevel nn:9870 A DEBUG -setlevel nn:9870 B INFO

# after
hadoop loglevel -setlevel nn:9870 A DEBUG && hadoop loglevel -setlevel nn:9870 B INFO
Defensive patterns

Strategy: validation

Validate before calling

long n = Arrays.stream(args).filter(a -> a.equals("-setlevel")).count();
if (n > 1) {
  throw new HadoopIllegalArgumentException("-setlevel may appear only once");
}

Prevention

When it happens

Trigger: 'hadoop loglevel -setlevel h:9870 cls DEBUG -setlevel ...'; command built by concatenating fragments that each already contain the flag; mixed '-getlevel ... -setlevel ...' also lands here (the second operation flag trips the redundancy check).

Common situations: Script loops or conditionals appending the operation flag twice; copy-paste of two full commands into one line; shell aliases that pre-append -setlevel.

Related errors


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