apache/cassandra · error · UnsupportedOperationException

Token type does not support token allocation.

Error message

Token type %s does not support token allocation.

What it means

ByteOrderedPartitioner's token factory implements TokenFactory.size() as an unsupported operation because byte-ordered tokens have no uniform numeric ring size usable by the token-allocation code. Token allocation (e.g. allocate_tokens_for_local_replication_factor) is simply not supported for this partitioner. Any code path that asks a ByteOrderedPartitioner token for its ring 'size' gets UnsupportedOperationException.

Solutions

  1. Switch the cluster partitioner to Murmur3Partitioner (default) if token allocation is desired — requires a full cluster migration otherwise.
  2. Disable token allocation (remove allocate_tokens_for_local_replication_factor) and assign ByteOrderedPartitioner tokens manually.
  3. Guard code paths that call Factory.size with a partitioner check before invoking token allocation.

Example fix

// before
double w = FBUtilities.newPartitioner().getTokenFactory().size(next);
// after
IPartitioner p = FBUtilities.newPartitioner();
if (p instanceof ByteOrderedPartitioner) throw new IllegalStateException("Token allocation unsupported for " + p.getClass().getSimpleName());
double w = p.getTokenFactory().size(next);
Defensive patterns

Strategy: type-guard

Validate before calling

if (FBUtilities.newPartitioner() instanceof ByteOrderedPartitioner && allocateTokensEnabled)
    throw new IllegalStateException("Token allocation is unsupported with ByteOrderedPartitioner");

Type guard

boolean supportsTokenAllocation(IPartitioner p) { return p instanceof Murmur3Partitioner; }

Try / catch

try {
    double s = factory.size(next);
} catch (UnsupportedOperationException e) {
    // partitioner does not support allocation; use manual tokens
}

Prevention

When it happens

Trigger: Calling Token.Factory.size(token) (directly or via TokenAllocation.allocateTokens) on a token whose partitioner is ByteOrderedPartitioner — e.g. bootstrap with allocate_tokens_for_local_replication_factor set while partitioner is ByteOrderedPartitioner.

Common situations: Clusters migrated to or running ByteOrderedPartitioner (deprecated, discouraged) with token-allocation options enabled; code written against RandomPartitioner/Murmur3Partitioner reused on a BOP cluster.

Understand the failure class

Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.

Related errors


AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10). Data as JSON: /api/errors/7d6cdf2d526a1b59. Report an issue: GitHub.

Appendix: source

Thrown at src/java/org/apache/cassandra/dht/ByteOrderedPartitioner.java:154

            return token;
        }

        @Override
        public int tokenHash()
        {
            return hashCode();
        }

        @Override
        public TokenFactory tokenFactory()
        {
            return tokenFactory;
        }

        @Override
        public double size(Token next)
        {
            throw new UnsupportedOperationException(String.format("Token type %s does not support token allocation.",
                                                                  getClass().getSimpleName()));
        }

        @Override
        public Token nextValidToken()
        {
            throw new UnsupportedOperationException(String.format("Token type %s does not support token allocation.",
                                                                  getClass().getSimpleName()));
        }

        public Token increaseSlightly()
        {
            // find first byte we can increment
            int i = token.length - 1;
            while (i >= 0)
            {
                if (token[i] != -1)
                    break;

View on GitHub (pinned to 88fd0f6a0e)