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);

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);

        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

            Gossiper.instance.initializeNodeUnsafe(endpoint, UUID.randomUUID(), 1);
            List<Token> tokens = new ArrayList<Token>();

            for (int j = 0; j < TOKENS_PER_NODE; j++)
            {
                Token token = new BigIntegerToken(String.valueOf(currentToken));
                tokenMap.put(token, endpoint);
                tokens.add(token);
                currentToken += TOKEN_STEP;
            }
View Full Code Here

        Map<Token, List<InetAddress>> expectedEndpoints = new HashMap<Token, List<InetAddress>>();


        for (Token<?> token : tokenMap.keySet())
        {
            BigIntegerToken keyToken = new BigIntegerToken(((BigInteger)token.token).add(new BigInteger("5")));
            List<InetAddress> endpoints = new ArrayList<InetAddress>();
            Iterator<Token> tokenIter = TokenMetadata.ringIterator(tmd.sortedTokens(), keyToken, false);
            while (tokenIter.hasNext())
            {
                InetAddress ep = tmd.getEndpoint(tokenIter.next());
                if (!endpoints.contains(ep))
                    endpoints.add(ep);
            }
            expectedEndpoints.put(keyToken, endpoints);
        }

        // Relocate the first token from the first endpoint, to the second endpoint.
        Token relocateToken = new BigIntegerToken(String.valueOf(TOKEN_STEP));
        ss.onChange(
                InetAddress.getByName("127.0.0.2"),
                ApplicationState.STATUS,
                vvFactory.relocating(Collections.singleton(relocateToken)));
        assertTrue(tmd.isRelocating(relocateToken));

        AbstractReplicationStrategy strategy;
        for (String keyspaceName : Schema.instance.getNonSystemKeyspaces())
        {
            strategy = getStrategy(keyspaceName, tmd);
            for (Token token : tokenMap.keySet())
            {
                BigIntegerToken keyToken = new BigIntegerToken(((BigInteger)token.token).add(new BigInteger("5")));

                HashSet<InetAddress> actual = new HashSet<InetAddress>(tmd.getWriteEndpoints(keyToken, keyspaceName, strategy.calculateNaturalEndpoints(keyToken, tmd.cloneOnlyTokenMap())));
                HashSet<InetAddress> expected = new HashSet<InetAddress>();

                for (int i = 0; i < actual.size(); i++)
View Full Code Here

    {
        createInitialRing(5);

        // Node handling the relocation (dst), and the token being relocated (src).
        InetAddress relocator = InetAddress.getByName("127.0.0.3");
        Token relocatee = new BigIntegerToken(String.valueOf(TOKEN_STEP));

        // Send RELOCATING and ensure token status
        ss.onChange(relocator, ApplicationState.STATUS, vvFactory.relocating(Collections.singleton(relocatee)));
        assertTrue(tmd.isRelocating(relocatee));
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 md5_max = new BigInteger("2").pow(127);
        BigInteger bint = md5_max.divide(TOKEN_SCALE).multiply(new BigInteger(""+i));
        return new BigIntegerToken(bint);
    }
View Full Code Here

        AbstractReplicationStrategy strategy = new RackUnawareStrategy(tmd, partitioner, 3, 7000);

        List<Token> endPointTokens = new ArrayList<Token>();
        List<Token> keyTokens = new ArrayList<Token>();
        for (int i = 0; i < 5; i++) {
            endPointTokens.add(new BigIntegerToken(String.valueOf(10 * i)));
            keyTokens.add(new BigIntegerToken(String.valueOf(10 * i + 5)));
        }
        testGetStorageEndPoints(tmd, strategy, endPointTokens.toArray(new Token[0]), keyTokens.toArray(new Token[0]));
    }
View Full Code Here

        Token[] endPointTokens = new Token[5];
        Token[] keyTokens = new Token[5];
       
        for (int i = 0; i < 5; i++)
        {
            endPointTokens[i] = new BigIntegerToken(String.valueOf(10 * i));
            keyTokens[i] = new BigIntegerToken(String.valueOf(10 * i + 5));
        }
       
        List<EndPoint> hosts = new ArrayList<EndPoint>();
        for (int i = 0; i < endPointTokens.length; i++)
        {
            EndPoint ep = new EndPoint("127.0.0." + String.valueOf(i + 1), 7001);
            tmd.update(endPointTokens[i], ep);
            hosts.add(ep);
        }
       
        //Add bootstrap node id=6
        Token bsToken = new BigIntegerToken(String.valueOf(25));
        EndPoint bootstrapEndPoint = new EndPoint("127.0.0.6", 7001);
        tmd.update(bsToken, bootstrapEndPoint, true);
       
        for (int i = 0; i < keyTokens.length; i++)
        {
View Full Code Here

            */

            for (String token : this.tokens)
            {
                String[] values = token.split(":");
                StorageService.instance().updateTokenMetadata(new BigIntegerToken(new BigInteger(values[0])),new EndPoint(values[1], 7000));
            }
        }
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.