{"record":{"id":"beded2c06fb9776b","repo":"apache/cassandra","slug":"iendpointsnitch-has-been-deprecated-and-is-no-long","errorCode":null,"errorMessage":"IEndpointSnitch has been deprecated and is no longer in use","messagePattern":"IEndpointSnitch has been deprecated and is no longer in use","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/locator/AbstractEndpointSnitch.java","lineNumber":36,"sourceCode":"package org.apache.cassandra.locator;\n\nimport com.google.common.collect.Iterables;\n\nimport org.apache.cassandra.config.DatabaseDescriptor;\nimport org.apache.cassandra.tcm.membership.Location;\n\n/**\n * @deprecated\n */\n@Deprecated(since = \"CEP-21\")\npublic abstract class AbstractEndpointSnitch implements IEndpointSnitch\n{\n    public abstract int compareEndpoints(InetAddressAndPort target, Replica r1, Replica r2);\n\n    @Override\n    public String getRack(InetAddressAndPort endpoint)\n    {\n        throw new UnsupportedOperationException(\"IEndpointSnitch has been deprecated and is no longer in use\");\n    }\n\n    @Override\n    public String getDatacenter(InetAddressAndPort endpoint)\n    {\n        throw new UnsupportedOperationException(\"IEndpointSnitch has been deprecated and is no longer in use\");\n    }\n\n    /**\n     * Sorts the <tt>Collection</tt> of node addresses by proximity to the given address\n     * @param address the address to sort by proximity to\n     * @param unsortedAddress the nodes to sort\n     * @return a new sorted <tt>List</tt>\n     */\n    public <C extends ReplicaCollection<? extends C>> C sortedByProximity(final InetAddressAndPort address, C unsortedAddress)\n    {\n        return unsortedAddress.sorted((r1, r2) -> compareEndpoints(address, r1, r2));\n    }","sourceCodeStart":18,"sourceCodeEnd":54,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/locator/AbstractEndpointSnitch.java#L18-L54","documentation":"AbstractEndpointSnitch.getRack unconditionally throws UnsupportedOperationException because the legacy IEndpointSnitch rack/DC API has been removed. Rack and datacenter resolution now goes through the peer metadata / ClusterMetadata layer instead of snitches. Any code (or custom code) still calling getRack on an AbstractEndpointSnitch will always fail.","triggerScenarios":"Calling snitch.getRack(endpoint) on an instance of AbstractEndpointSnitch, or running custom/plugin code written against the pre-4.0 IEndpointSnitch API.","commonSituations":"Third-party plugins or monitoring hooks migrated from Cassandra 3.x that query the snitch for rack info; application code copying old examples that used IEndpointSnitch.getDatacenter/getRack.","solutions":["Replace getRack calls with ClusterMetadata / LocationSubplanes lookups (e.g. ClusterMetadata.current().location(endpoint))","Update custom snitch implementations to extend the current snitch base classes and RackDc interfaces","If rack/DC is needed in tooling, read it from system.peers_v2 / gossip info instead of the snitch","Upgrade dependent code to the 4.0+ locator API"],"exampleFix":"// before\nString rack = snitch.getRack(endpoint);\n// after\nString rack = ClusterMetadata.current().location(endpoint).rack;","handlingStrategy":"type-guard","validationCode":"// Never call the deprecated method; resolve topology via cluster metadata\nString rack = ClusterMetadata.current().location(endpoint).rack;","typeGuard":"function usesLegacySnitchApi(Object snitch) {\n    return snitch instanceof AbstractEndpointSnitch; // getRack/getDatacenter will throw\n}","tryCatchPattern":null,"preventionTips":["Migrate code off IEndpointSnitch rack/DC methods when upgrading to 4.0+","Use ClusterMetadata / Location for topology lookups","Search codebases for '.getRack(' and '.getDatacenter(' calls during upgrades","Update third-party snitch plugins to the current API"],"tags":["deprecated-api","snitch","unsupported-operation"],"backgroundTag":"deprecated-api-usage","analyzedSha":"88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1","analyzedAt":"2026-09-10T07:29:22.284Z","contentChangedAt":"2026-09-10T07:29:22.284Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}