apache/hadoop · info · UnsupportedOperationException

Use Token.renew instead

Error message

Use Token.renew instead

What it means

YARNRunner.cancelDelegationToken is intentionally not implemented and always throws UnsupportedOperationException telling the caller to use the Hadoop security Token API instead. Under YARN, delegation-token lifecycle is managed through org.apache.hadoop.security.token.Token (obtained from the RM/HS via the client protocol), so the legacy ClientProtocol cancel/renew entry points are stubs. Note the message says 'renew' but the method is cancel — both legacy variants delegate to the Token API.

Source

Thrown at hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-jobclient/src/main/java/org/apache/hadoop/mapred/YARNRunner.java:197

      this.defaultFileContext = FileContext.getFileContext(this.conf);
    } catch (UnsupportedFileSystemException ufe) {
      throw new RuntimeException("Error in instantiating YarnClient", ufe);
    }
  }
  
  @Private
  /**
   * Used for testing mostly.
   * @param resMgrDelegate the resource manager delegate to set to.
   */
  public void setResourceMgrDelegate(ResourceMgrDelegate resMgrDelegate) {
    this.resMgrDelegate = resMgrDelegate;
  }
  
  @Override
  public void cancelDelegationToken(Token<DelegationTokenIdentifier> arg0)
      throws IOException, InterruptedException {
    throw new UnsupportedOperationException("Use Token.renew instead");
  }

  @Override
  public TaskTrackerInfo[] getActiveTrackers() throws IOException,
      InterruptedException {
    return resMgrDelegate.getActiveTrackers();
  }

  @Override
  public JobStatus[] getAllJobs() throws IOException, InterruptedException {
    return resMgrDelegate.getAllJobs();
  }

  @Override
  public TaskTrackerInfo[] getBlacklistedTrackers() throws IOException,
      InterruptedException {
    return resMgrDelegate.getBlacklistedTrackers();
  }

View on GitHub (pinned to 2add963021)

Solutions

  1. Replace the call with token.cancel() on the org.apache.hadoop.security.token.Token instance obtained from the ResourceManager/JobHistoryServer (getDelegationToken)
  2. Remove the legacy cancel/renew code path entirely for mapreduce.framework.name=yarn
  3. For HS tokens, fetch the token via the history server client and cancel against the issuing service

Example fix

// before
runner.cancelDelegationToken(token); // UnsupportedOperationException

// after
org.apache.hadoop.security.token.Token<
    org.apache.hadoop.mapreduce.security.token.delegation.DelegationTokenIdentifier> t =
  (Token<DelegationTokenIdentifier>) token;
t.cancel(new org.apache.hadoop.conf.Configuration()); // via Token API
Defensive patterns

Strategy: validation

Validate before calling

if (runner instanceof org.apache.hadoop.mapred.YARNRunner) {
  // ClientProtocol token cancel is a stub on YARN - skip and use Token API
  token.cancel(conf);
} else {
  runner.cancelDelegationToken(token);
}

Type guard

boolean isLegacyTokenApiSupported(ClientProtocol p) {
  return !(p instanceof org.apache.hadoop.mapred.YARNRunner);
}

Prevention

When it happens

Trigger: Calling cancelDelegationToken on a JobClient/YARNRunner-backed Cluster instance, e.g. legacy code written against the old JobClient token APIs or tools that walk ClientProtocol and invoke every method.

Common situations: Porting pre-YARN (MR1) code that cancelled delegation tokens via the job client; Generic client frameworks that reflectively invoke all ClientProtocol methods; Custom token-management tooling unaware that YARN moved renew/cancel to Token

Related errors


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