src/java/org/apache/cassandra/db/SystemTable.java
/**
     * Return a map of stored tokens to IP addresses
     *
     */
Return a map of stored tokens to IP addresses
Return a map of stored tokens to IP addresses
public static HashMap<Token, InetAddress> loadTokens()
    {
        HashMap<Token, InetAddress> tokenMap = new HashMap<Token, InetAddress>();
        IPartitioner p = StorageService.getPartitioner();
        Table table = Table.open(Table.SYSTEM_TABLE);
        QueryFilter filter = QueryFilter.getIdentityFilter(decorate(RING_KEY), new QueryPath(STATUS_CF));
        ColumnFamily cf = ColumnFamilyStore.removeDeleted(table.getColumnFamilyStore(STATUS_CF).getColumnFamily(filter), Integer.MAX_VALUE);
        if (cf != null)
        {
            for (IColumn column : cf.getSortedColumns())
            {
                try
                {
                    ByteBuffer v = column.value();
                    byte[] addr = new byte[v.remaining()];
                    ByteBufferUtil.arrayCopy(v, v.position(), addr, 0, v.remaining());
                    tokenMap.put(p.getTokenFactory().fromByteArray(column.name()), InetAddress.getByAddress(addr));
                }
                catch (UnknownHostException e)
                {
                    throw new IOError(e);
                }
            }
        }
        return tokenMap;
    }
public static HashMap < Token , InetAddress > loadTokens ( ) { HashMap < Token , InetAddress > tokenMap = new HashMap < Token , InetAddress > ( ) ; IPartitioner p = StorageService . getPartitioner ( ) ; Table table = Table . open ( Table . SYSTEM_TABLE ) ; QueryFilter filter = QueryFilter . getIdentityFilter ( decorate ( RING_KEY ) , new QueryPath ( STATUS_CF ) ) ; ColumnFamily cf = ColumnFamilyStore . removeDeleted ( table . getColumnFamilyStore ( STATUS_CF ) . getColumnFamily ( filter ) , Integer . MAX_VALUE ) ; if ( cf != null ) { for ( IColumn column : cf . getSortedColumns ( ) ) { try { ByteBuffer v = column . value ( ) ; byte [ ] addr = new byte [ v . remaining ( ) ] ; ByteBufferUtil . arrayCopy ( v , v . position ( ) , addr , 0 , v . remaining ( ) ) ; tokenMap . put ( p . getTokenFactory ( ) . fromByteArray ( column . name ( ) ) , InetAddress . getByAddress ( addr ) ) ; } catch ( UnknownHostException e ) { throw new IOError ( e ) ; } } } return tokenMap ; }
Return a map of stored tokens to IP addresses
Return a map of stored tokens to IP addresses