src/java/org/apache/cassandra/service/StorageService.java
/**
     * The TokenRange for a given keyspace.
     *
     * @param keyspace The keyspace to fetch information about
     *
     * @return a List of TokenRange(s) for the given keyspace
     *
     * @throws InvalidRequestException if there is no ring information available about keyspace
     */
The TokenRange for a given keyspace.
@param keyspace The keyspace to fetch information about

@return a List of TokenRange(s) for the given keyspace

@throws InvalidRequestException if there is no ring information available about keyspace
The TokenRange for a given keyspace . @param keyspace The keyspace to fetch information about @return a List of TokenRange ( s ) for the given keyspace @throws InvalidRequestException if there is no ring information available about keyspace
public List<TokenRange> describeRing(String keyspace) throws InvalidRequestException
    {
        if (keyspace == null || !Schema.instance.getNonSystemTables().contains(keyspace))
            throw new InvalidRequestException("There is no ring for the keyspace: " + keyspace);
        List<TokenRange> ranges = new ArrayList<TokenRange>();
        Token.TokenFactory tf = getPartitioner().getTokenFactory();
        for (Map.Entry<Range<Token>, List<InetAddress>> entry : getRangeToAddressMap(keyspace).entrySet())
        {
            Range range = entry.getKey();
            List<String> endpoints = new ArrayList<String>();
            List<String> rpc_endpoints = new ArrayList<String>();
            List<EndpointDetails> epDetails = new ArrayList<EndpointDetails>();
            for (InetAddress endpoint : entry.getValue())
            {
                EndpointDetails details = new EndpointDetails();
                details.host = endpoint.getHostAddress();
                details.datacenter = DatabaseDescriptor.getEndpointSnitch().getDatacenter(endpoint);
                details.rack = DatabaseDescriptor.getEndpointSnitch().getRack(endpoint);
                endpoints.add(details.host);
                rpc_endpoints.add(getRpcaddress(endpoint));
                epDetails.add(details);
            }
            TokenRange tr = new TokenRange(tf.toString(range.left.getToken()), tf.toString(range.right.getToken()), endpoints)
                                    .setEndpoint_details(epDetails)
                                    .setRpc_endpoints(rpc_endpoints);
            ranges.add(tr);
        }
        return ranges;
    }
public List < TokenRange > describeRing ( String keyspace ) throws InvalidRequestException { if ( keyspace == null || ! Schema . instance . getNonSystemTables ( ) . contains ( keyspace ) ) throw new InvalidRequestException ( "There is no ring for the keyspace: " + keyspace ) ; List < TokenRange > ranges = new ArrayList < TokenRange > ( ) ; Token . TokenFactory tf = getPartitioner ( ) . getTokenFactory ( ) ; for ( Map . Entry < Range < Token > , List < InetAddress > > entry : getRangeToAddressMap ( keyspace ) . entrySet ( ) ) { Range range = entry . getKey ( ) ; List < String > endpoints = new ArrayList < String > ( ) ; List < String > rpc_endpoints = new ArrayList < String > ( ) ; List < EndpointDetails > epDetails = new ArrayList < EndpointDetails > ( ) ; for ( InetAddress endpoint : entry . getValue ( ) ) { EndpointDetails details = new EndpointDetails ( ) ; details . host = endpoint . getHostAddress ( ) ; details . datacenter = DatabaseDescriptor . getEndpointSnitch ( ) . getDatacenter ( endpoint ) ; details . rack = DatabaseDescriptor . getEndpointSnitch ( ) . getRack ( endpoint ) ; endpoints . add ( details . host ) ; rpc_endpoints . add ( getRpcaddress ( endpoint ) ) ; epDetails . add ( details ) ; } TokenRange tr = new TokenRange ( tf . toString ( range . left . getToken ( ) ) , tf . toString ( range . right . getToken ( ) ) , endpoints ) . setEndpoint_details ( epDetails ) . setRpc_endpoints ( rpc_endpoints ) ; ranges . add ( tr ) ; } return ranges ; }
The TokenRange for a given keyspace.
The TokenRange for a given keyspace .