apache/cassandra · error · ConfigurationException
Token allocation does not support replication strategy
Error message
Token allocation does not support replication strategy
What it means
TokenAllocation only supports NetworkTopologyStrategy and SimpleStrategy replication strategies. When createStrategy encounters any other strategy (e.g. LocalStrategy or a custom IReplicationStrategy subclass) it throws ConfigurationException because no StrategyAdapter can be produced for computing allocation weights.
Solutions
- Use a supported strategy (SimpleStrategy or NetworkTopologyStrategy) on the keyspace being allocated for
- If you need allocation for a custom strategy, implement a corresponding StrategyAdapter in TokenAllocation
- Target a different keyspace when invoking token allocation
- Check the keyspace's strategy via cqlsh: DESCRIBE KEYSPACE
Example fix
// before
cqlsh> ALTER KEYSPACE myks WITH replication = {'class':'MyCustomStrategy','replication_factor':3};
// token allocation fails
// after
cqlsh> ALTER KEYSPACE myks WITH replication = {'class':'NetworkTopologyStrategy','dc1':3}; Defensive patterns
Strategy: validation
Validate before calling
// before allocation, check the strategy
String cls = Keyspace.open(ks).getReplicationStrategy().getClass().getSimpleName();
if (!cls.equals("NetworkTopologyStrategy") && !cls.equals("SimpleStrategy"))
throw new IllegalArgumentException("Unsupported strategy for token allocation: " + cls); Try / catch
try {
TokenAllocation.allocate(metadata, ks, dc);
} catch (ConfigurationException e) {
if (e.getMessage().contains("does not support replication strategy")) {
// switch keyspace to NetworkTopologyStrategy or pick another keyspace
}
} Prevention
- Use NetworkTopologyStrategy or SimpleStrategy for keyspaces you allocate tokens for
- Never target system keyspaces (LocalStrategy) with token allocation
- Review DESCRIBE KEYSPACE before running allocation tooling
When it happens
Trigger: Calling TokenAllocation.allocate (via createStrategy/getOrCreateStrategy) for a keyspace whose replication strategy is neither NetworkTopologyStrategy nor SimpleStrategy.
Common situations: Trying to allocate tokens for a keyspace using LocalStrategy (system keyspaces) or a third-party custom replication strategy.
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
- A repair_session_space of
- accord.journal_directory must not be the same as the…
- Accord journal is configured in periodic mode, while…
- accord.working_set_size option was set incorrectly to
- Allocated token already assigned to node . Is another node…
AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10).
Data as JSON: /api/errors/feafa8cde0f73785.
Report an issue: GitHub.
Appendix: source
Thrown at src/java/org/apache/cassandra/dht/tokenallocator/TokenAllocation.java:260
private StrategyAdapter getOrCreateStrategy(InetAddressAndPort endpoint)
{
Location location = metadata.locator.location(endpoint);
return getOrCreateStrategy(location.datacenter, location.rack);
}
private StrategyAdapter getOrCreateStrategy(String dc, String rack)
{
return strategyByRackDc.computeIfAbsent(dc, k -> new HashMap<>()).computeIfAbsent(rack, k -> createStrategy(dc, rack));
}
private StrategyAdapter createStrategy(String dc, String rack)
{
if (replicationStrategy instanceof NetworkTopologyStrategy)
return createStrategy(metadata, (NetworkTopologyStrategy) replicationStrategy, dc, rack);
if (replicationStrategy instanceof SimpleStrategy)
return createStrategy(metadata, (SimpleStrategy) replicationStrategy);
throw new ConfigurationException("Token allocation does not support replication strategy " + replicationStrategy.getClass().getSimpleName());
}
private StrategyAdapter createStrategy(ClusterMetadata metadata, final SimpleStrategy rs)
{
return createStrategy(() -> metadata.locator, null, null, rs.getReplicationFactor().allReplicas, false);
}
private StrategyAdapter createStrategy(ClusterMetadata metadata, NetworkTopologyStrategy strategy, String dc, String rack)
{
int replicas = strategy.getReplicationFactor(dc).allReplicas;
// if topology hasn't been setup yet for this dc+rack then treat it as a separate unit
Multimap<String, InetAddressAndPort> datacenterRacks = metadata.directory.datacenterRacks(dc);
Supplier<Locator> locator = () -> metadata.locator;
int racks = datacenterRacks != null && datacenterRacks.containsKey(rack)
? datacenterRacks.asMap().size()
: 1;
View on GitHub (pinned to 88fd0f6a0e)