apache/hadoop · error · IllegalArgumentException

Number of thresholds should be {}. Was: {}

Error message

Number of thresholds should be {}. Was: {}

What it means

parseThresholds reads integer percentages from <ns>.decay-scheduler.thresholds (deprecated fallback <ns>.faircallqueue.decay-scheduler.thresholds). For numLevels priority queues exactly numLevels-1 thresholds are needed — each threshold is the cumulative-usage boundary between adjacent queues — so any other count throws IllegalArgumentException with the expected number in the message at scheduler construction.

Source

Thrown at hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ipc/DecayRpcScheduler.java:396

  private static double[] parseThresholds(String ns, Configuration conf,
      int numLevels) {
    int[] percentages = conf.getInts(ns + "." +
        IPC_FCQ_DECAYSCHEDULER_THRESHOLDS_KEY);

    if (percentages.length == 0) {
      percentages = conf.getInts(ns + "." + IPC_DECAYSCHEDULER_THRESHOLDS_KEY);
      if (percentages.length == 0) {
        return getDefaultThresholds(numLevels);
      }
    } else {
      LOG.warn(IPC_FCQ_DECAYSCHEDULER_THRESHOLDS_KEY +
          " is deprecated. Please use " +
          IPC_DECAYSCHEDULER_THRESHOLDS_KEY);
    }

    if (percentages.length != numLevels-1) {
      throw new IllegalArgumentException("Number of thresholds should be " +
        (numLevels-1) + ". Was: " + percentages.length);
    }

    // Convert integer percentages to decimals
    double[] decimals = new double[percentages.length];
    for (int i = 0; i < percentages.length; i++) {
      decimals[i] = percentages[i] / 100.0;
    }

    return decimals;
  }

  private Set<String> parseServiceUserNames(String ns, Configuration conf) {
    Collection<String> collection = conf.getStringCollection(
        ns + "." + IPC_DECAYSCHEDULER_SERVICE_USERS_KEY);
    return new HashSet<>(collection);
  }

View on GitHub (pinned to 2add963021)

Solutions

  1. Count your priority levels N and set exactly N-1 ascending integer percentages, e.g., N=4 -> '10,40,80'.
  2. Or remove decay-scheduler.thresholds entirely to use getDefaultThresholds(numLevels).
  3. After editing, re-check for stray commas/whitespace in the comma-separated list.

Example fix

// before (core-site.xml)
<property><name>ipc.8020.callqueue-priority-levels</name><value>4</value></property>
<property><name>ipc.8020.decay-scheduler.thresholds</name><value>10,40,80,90</value></property>
<!-- expects 3 thresholds, got 4 -> IllegalArgumentException -->

// after
<property><name>ipc.8020.callqueue-priority-levels</name><value>4</value></property>
<property><name>ipc.8020.decay-scheduler.thresholds</name><value>10,40,80</value></property>
Defensive patterns

Strategy: validation

Validate before calling

int levels = conf.getInt("ipc." + port + ".callqueue-priority-levels", 1);
int[] t = conf.getInts("ipc." + port + ".decay-scheduler.thresholds");
if (t.length > 0 && t.length != levels - 1) {
  throw new ConfigException("decay-scheduler.thresholds needs " + (levels - 1)
      + " entries for " + levels + " levels, got " + t.length);
}

Prevention

When it happens

Trigger: Configuring 4 priority levels (ipc.<port>.callqueue-priority-levels=4) but supplying 4 thresholds instead of 3; supplying a single threshold where numLevels-1 > 1; leaving stale thresholds in config after changing the level count; trailing/doubled commas producing an unexpected element count.

Common situations: Changing callqueue-priority-levels during a tuning exercise without updating decay-scheduler.thresholds in lockstep; copying example configs whose level count differs from the local setting.

Understand the failure class

Background: Config validation failed: what "invalid value for {key}" and settings-rejection errors mean across 19 open-source libraries — this error's family across 19 libraries.

Related errors


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