Package org.apache.cassandra.dht

Examples of org.apache.cassandra.dht.BigIntegerToken


    {
        // moves after its next neighbor in the ring

        int movingNodeIdx = 1;
        int movingNodeIdxAfterMove = 2;
        BigIntegerToken newToken = new BigIntegerToken("52535295865117307932921825928971026432");
        BigIntegerToken[] tokens = initTokens();
        BigIntegerToken[] tokensAfterMove = initTokensAfterMove(tokens, movingNodeIdx, newToken);
        Pair<Set<Range<Token>>, Set<Range<Token>>> ranges = calculateStreamAndFetchRanges(tokens, tokensAfterMove, movingNodeIdx, newToken);

View Full Code Here


    {
        // moves before its previous neighbor in the ring

        int movingNodeIdx = 1;
        int movingNodeIdxAfterMove = 7;
        BigIntegerToken newToken = new BigIntegerToken("158873535527910577765226390751398592512");
        BigIntegerToken[] tokens = initTokens();
        BigIntegerToken[] tokensAfterMove = initTokensAfterMove(tokens, movingNodeIdx, newToken);
        Pair<Set<Range<Token>>, Set<Range<Token>>> ranges = calculateStreamAndFetchRanges(tokens, tokensAfterMove, movingNodeIdx, newToken);

        Range[] toStream = ranges.left.toArray(new Range[0]);
View Full Code Here

    }

    private BigIntegerToken[] initTokens()
    {
        BigIntegerToken[] tokens = new BigIntegerToken[] {
                new BigIntegerToken("0"), // just to be able to test
                new BigIntegerToken("34028236692093846346337460743176821145"),
                new BigIntegerToken("42535295865117307932921825928971026432"),
                new BigIntegerToken("63802943797675961899382738893456539648"),
                new BigIntegerToken("85070591730234615865843651857942052864"),
                new BigIntegerToken("106338239662793269832304564822427566080"),
                new BigIntegerToken("127605887595351923798765477786913079296"),
                new BigIntegerToken("148873535527910577765226390751398592512")
        };
        return tokens;
    }
View Full Code Here

     * between -1 and Token.MAX_VALUE.
     */
    public static BigIntegerToken tok(int i)
    {
        if (i == -1)
            return new BigIntegerToken(new BigInteger("-1"));
        BigInteger bint = RandomPartitioner.MAXIMUM.divide(TOKEN_SCALE).multiply(new BigInteger(""+i));
        return new BigIntegerToken(bint);
    }
View Full Code Here

    private AbstractReplicationStrategy strategy;

    public void setup(Class stratClass, Map<String, String> strategyOptions) throws Exception
    {
        tmd = new TokenMetadata();
        searchToken = new BigIntegerToken(String.valueOf(15));

        strategy = getStrategyWithNewTokenMetadata(Table.open("Keyspace3").getReplicationStrategy(), tmd);

        tmd.updateNormalToken(new BigIntegerToken(String.valueOf(10)), InetAddress.getByName("127.0.0.1"));
        tmd.updateNormalToken(new BigIntegerToken(String.valueOf(20)), InetAddress.getByName("127.0.0.2"));
        tmd.updateNormalToken(new BigIntegerToken(String.valueOf(30)), InetAddress.getByName("127.0.0.3"));
        tmd.updateNormalToken(new BigIntegerToken(String.valueOf(40)), InetAddress.getByName("127.0.0.4"));
        //tmd.updateNormalToken(new BigIntegerToken(String.valueOf(50)), InetAddress.getByName("127.0.0.5"));
        tmd.updateNormalToken(new BigIntegerToken(String.valueOf(60)), InetAddress.getByName("127.0.0.6"));
        tmd.updateNormalToken(new BigIntegerToken(String.valueOf(70)), InetAddress.getByName("127.0.0.7"));
        tmd.updateNormalToken(new BigIntegerToken(String.valueOf(80)), InetAddress.getByName("127.0.0.8"));
    }
View Full Code Here

        endpoints = strategy.getNaturalEndpoints(searchToken);
        assert endpoints.size() == 5 : StringUtils.join(endpoints, ",");

        // test token addition, in DC2 before existing token
        initial = strategy.getNaturalEndpoints(searchToken);
        tmd.updateNormalToken(new BigIntegerToken(String.valueOf(35)), InetAddress.getByName("127.0.0.5"));
        endpoints = strategy.getNaturalEndpoints(searchToken);
        assert endpoints.size() == 5 : StringUtils.join(endpoints, ",");
        assert !endpoints.equals(initial);

        // test token removal, newly created token
        initial = strategy.getNaturalEndpoints(searchToken);
        tmd.removeEndpoint(InetAddress.getByName("127.0.0.5"));
        endpoints = strategy.getNaturalEndpoints(searchToken);
        assert endpoints.size() == 5 : StringUtils.join(endpoints, ",");
        assert !endpoints.contains(InetAddress.getByName("127.0.0.5"));
        assert !endpoints.equals(initial);

        // test token change
        initial = strategy.getNaturalEndpoints(searchToken);
        //move .8 after search token but before other DC3
        tmd.updateNormalToken(new BigIntegerToken(String.valueOf(25)), InetAddress.getByName("127.0.0.8"));
        endpoints = strategy.getNaturalEndpoints(searchToken);
        assert endpoints.size() == 5 : StringUtils.join(endpoints, ",");
        assert !endpoints.equals(initial);
    }
View Full Code Here

                                   List<Token> keyTokens, List<InetAddress> hosts, int howMany)
        throws UnknownHostException
    {
        for (int i=0; i<howMany; i++)
        {
            endpointTokens.add(new BigIntegerToken(String.valueOf(10 * i)));
            keyTokens.add(new BigIntegerToken(String.valueOf(10 * i + 5)));
        }

        for (int i=0; i<endpointTokens.size(); i++)
        {
            InetAddress ep = InetAddress.getByName("127.0.0." + String.valueOf(i + 1));
View Full Code Here

    private AbstractReplicationStrategy strategy;

    public void setup(Class stratClass, Map<String, String> strategyOptions) throws Exception
    {
        tmd = new TokenMetadata();
        searchToken = new BigIntegerToken(String.valueOf(15));

        strategy = getStrategyWithNewTokenMetadata(StorageService.instance.getReplicationStrategy("Keyspace3"), tmd);

        tmd.updateNormalToken(new BigIntegerToken(String.valueOf(10)), InetAddress.getByName("127.0.0.1"));
        tmd.updateNormalToken(new BigIntegerToken(String.valueOf(20)), InetAddress.getByName("127.0.0.2"));
        tmd.updateNormalToken(new BigIntegerToken(String.valueOf(30)), InetAddress.getByName("127.0.0.3"));
        tmd.updateNormalToken(new BigIntegerToken(String.valueOf(40)), InetAddress.getByName("127.0.0.4"));
        //tmd.updateNormalToken(new BigIntegerToken(String.valueOf(50)), InetAddress.getByName("127.0.0.5"));
        tmd.updateNormalToken(new BigIntegerToken(String.valueOf(60)), InetAddress.getByName("127.0.0.6"));
        tmd.updateNormalToken(new BigIntegerToken(String.valueOf(70)), InetAddress.getByName("127.0.0.7"));
        tmd.updateNormalToken(new BigIntegerToken(String.valueOf(80)), InetAddress.getByName("127.0.0.8"));
    }
View Full Code Here

        endpoints = strategy.getNaturalEndpoints(searchToken);
        assert endpoints.size() == 5 : StringUtils.join(endpoints, ",");

        // test token addition, in DC2 before existing token
        initial = strategy.getNaturalEndpoints(searchToken);
        tmd.updateNormalToken(new BigIntegerToken(String.valueOf(35)), InetAddress.getByName("127.0.0.5"));
        endpoints = strategy.getNaturalEndpoints(searchToken);
        assert endpoints.size() == 5 : StringUtils.join(endpoints, ",");
        assert !endpoints.equals(initial);

        // test token removal, newly created token
        initial = strategy.getNaturalEndpoints(searchToken);
        tmd.removeEndpoint(InetAddress.getByName("127.0.0.5"));
        endpoints = strategy.getNaturalEndpoints(searchToken);
        assert endpoints.size() == 5 : StringUtils.join(endpoints, ",");
        assert !endpoints.contains(InetAddress.getByName("127.0.0.5"));
        assert !endpoints.equals(initial);

        // test token change
        initial = strategy.getNaturalEndpoints(searchToken);
        //move .8 after search token but before other DC3
        tmd.updateNormalToken(new BigIntegerToken(String.valueOf(25)), InetAddress.getByName("127.0.0.8"));
        endpoints = strategy.getNaturalEndpoints(searchToken);
        assert endpoints.size() == 5 : StringUtils.join(endpoints, ",");
        assert !endpoints.equals(initial);
    }
View Full Code Here

        return result;
    }

    private void addEndpoint(String endpointTokenID, String keyTokenID, String endpointAddress) throws UnknownHostException
    {
        BigIntegerToken endpointToken = new BigIntegerToken(endpointTokenID);
        endpointTokens.add(endpointToken);

        BigIntegerToken keyToken = new BigIntegerToken(keyTokenID);
        keyTokens.add(keyToken);

        InetAddress ep = InetAddress.getByName(endpointAddress);
        tmd.updateNormalToken(endpointToken, ep);
    }
View Full Code Here

TOP

Related Classes of org.apache.cassandra.dht.BigIntegerToken

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.