Package org.apache.cassandra.dht

Examples of org.apache.cassandra.dht.Token


            {
                int hashLen = dis.readInt();
                byte[] hash = hashLen >= 0 ? new byte[hashLen] : null;
                if (hash != null)
                    dis.readFully(hash);
                Token token = Token.serializer().deserialize(dis);
                Hashable lchild = Hashable.serializer.deserialize(dis, version);
                Hashable rchild = Hashable.serializer.deserialize(dis, version);
                return new Inner(token, lchild, rchild);
            }
View Full Code Here


     */
    public void unsafeAssassinateEndpoint(String address) throws UnknownHostException
    {
        InetAddress endpoint = InetAddress.getByName(address);
        EndpointState epState = endpointStateMap.get(endpoint);
        Token token = null;
        logger.warn("Assassinating {} via gossip", endpoint);
        if (epState == null)
        {
            epState = new EndpointState(new HeartBeatState((int)((System.currentTimeMillis() + 60000) / 1000), 9999));
        }
View Full Code Here

        try
        {
            boolean shouldSortTokens = false;
            for (Pair<Token, InetAddress> tokenEndpointPair : tokenPairs)
            {
                Token token = tokenEndpointPair.left;
                InetAddress endpoint = tokenEndpointPair.right;

                assert token != null;
                assert endpoint != null;
View Full Code Here

        }

        if (range.start_key != null)
        {
            IPartitioner p = StorageService.getPartitioner();
            Token startToken = p.getToken(range.start_key);
            Token endToken = p.getToken(range.end_key);
            if (startToken.compareTo(endToken) > 0 && !endToken.isMinimum(p))
            {
                if (p instanceof RandomPartitioner)
                    throw new InvalidRequestException("start key's md5 sorts after end key's md5.  this is not allowed; you probably should not specify end key at all, under RandomPartitioner");
                else
                    throw new InvalidRequestException("start key must sort before (or equal to) finish key in your partitioner!");
View Full Code Here

    }

    public static void validateKeyRange(String start_key, String end_key, int row_count) throws InvalidRequestException
    {
        IPartitioner p = StorageService.getPartitioner();
        Token startToken = p.decorateKey(start_key).token;
        Token endToken = p.decorateKey(end_key).token;
        if (startToken.compareTo(endToken) > 0 && !endToken.equals(p.getMinimumToken()))
        {
            if (p instanceof RandomPartitioner)
                throw new InvalidRequestException("start key's md5 sorts after end key's md5.  this is not allowed; you probably should not specify end key at all, under RandomPartitioner");
            else
                throw new InvalidRequestException("start key must sort before (or equal to) finish key in your partitioner!");
View Full Code Here

        ByteBuffer finishKey = (select.getKeyFinish() != null)
                                ? select.getKeyFinish().getByteBuffer(keyType)
                                : (new Term()).getByteBuffer();

        Token startToken = p.getToken(startKey), finishToken = p.getToken(finishKey);
        if (startToken.compareTo(finishToken) > 0 && !finishToken.equals(p.getMinimumToken()))
        {
            if (p instanceof RandomPartitioner)
                throw new InvalidRequestException("Start key's md5 sorts after end key's md5. This is not allowed; you probably should not specify end key at all, under RandomPartitioner");
            else
                throw new InvalidRequestException("Start key must sort before (or equal to) finish key in your partitioner!");
View Full Code Here

     */
    public void unsafeAssassinateEndpoint(String address) throws UnknownHostException
    {
        InetAddress endpoint = InetAddress.getByName(address);
        EndpointState epState = endpointStateMap.get(endpoint);
        Token token = null;
        logger.warn("Assassinating {} via gossip", endpoint);
        if (epState == null)
        {
            epState = new EndpointState(new HeartBeatState((int)((System.currentTimeMillis() + 60000) / 1000), 9999));
        }
View Full Code Here

        // divide the queryRange into pieces delimited by the ring and minimum tokens
        Iterator<Token> ringIter = TokenMetadata.ringIterator(tokenMetadata.sortedTokens(), queryRange.left, true);
        AbstractBounds remainder = queryRange;
        while (ringIter.hasNext())
        {
            Token token = ringIter.next();
            if (remainder == null || !(remainder.left.equals(token) || remainder.contains(token)))
                // no more splits
                break;
            Pair<AbstractBounds,AbstractBounds> splits = remainder.split(token);
            if (splits.left != null)
View Full Code Here

    public static List<Row> scan(final String keyspace, String column_family, IndexClause index_clause, SlicePredicate column_predicate, ConsistencyLevel consistency_level)
    throws IOException, TimeoutException, UnavailableException
    {
        IPartitioner p = StorageService.getPartitioner();

        Token leftToken = index_clause.start_key == null ? p.getMinimumToken() : p.getToken(index_clause.start_key);
        List<AbstractBounds> ranges = getRestrictedRanges(new Bounds(leftToken, p.getMinimumToken()));
        logger.debug("scan ranges are {}", StringUtils.join(ranges, ","));

        // now scan until we have enough results
        List<Row> rows = new ArrayList<Row>(index_clause.count);
View Full Code Here

        // divide the queryRange into pieces delimited by the ring and minimum tokens
        Iterator<Token> ringIter = TokenMetadata.ringIterator(tokenMetadata.sortedTokens(), queryRange.left, true);
        AbstractBounds remainder = queryRange;
        while (ringIter.hasNext())
        {
            Token token = ringIter.next();
            if (remainder == null || !(remainder.left.equals(token) || remainder.contains(token)))
                // no more splits
                break;
            Pair<AbstractBounds,AbstractBounds> splits = remainder.split(token);
            if (splits.left != null)
View Full Code Here

TOP

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

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.