当前位置: 首页>>代码示例>>Java>>正文


Java IPartitioner.getToken方法代码示例

本文整理汇总了Java中org.apache.cassandra.dht.IPartitioner.getToken方法的典型用法代码示例。如果您正苦于以下问题:Java IPartitioner.getToken方法的具体用法?Java IPartitioner.getToken怎么用?Java IPartitioner.getToken使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.cassandra.dht.IPartitioner的用法示例。


在下文中一共展示了IPartitioner.getToken方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: validateKeyRange

import org.apache.cassandra.dht.IPartitioner; //导入方法依赖的package包/类
public static void validateKeyRange(CFMetaData metadata, ByteBuffer superColumn, KeyRange range) throws org.apache.cassandra.exceptions.InvalidRequestException
{
    if ((range.start_key == null) == (range.start_token == null)
        || (range.end_key == null) == (range.end_token == null))
    {
        throw new org.apache.cassandra.exceptions.InvalidRequestException("exactly one each of {start key, start token} and {end key, end token} must be specified");
    }

    // (key, token) is supported (for wide-row CFRR) but not (token, key)
    if (range.start_token != null && range.end_key != null)
        throw new org.apache.cassandra.exceptions.InvalidRequestException("start token + end key is not a supported key range");

    IPartitioner p = StorageService.getPartitioner();

    if (range.start_key != null && range.end_key != null)
    {
        Token startToken = p.getToken(range.start_key);
        Token endToken = p.getToken(range.end_key);
        if (startToken.compareTo(endToken) > 0 && !endToken.isMinimum(p))
        {
            if (p.preservesOrder())
                throw new org.apache.cassandra.exceptions.InvalidRequestException("start key must sort before (or equal to) finish key in your partitioner!");
            else
                throw new org.apache.cassandra.exceptions.InvalidRequestException("start key's token sorts after end key's token.  this is not allowed; you probably should not specify end key at all except with an ordered partitioner");
        }
    }
    else if (range.start_key != null && range.end_token != null)
    {
        // start_token/end_token can wrap, but key/token should not
        RowPosition stop = p.getTokenFactory().fromString(range.end_token).maxKeyBound(p);
        if (RowPosition.forKey(range.start_key, p).compareTo(stop) > 0 && !stop.isMinimum())
            throw new org.apache.cassandra.exceptions.InvalidRequestException("Start key's token sorts after end token");
    }

    validateFilterClauses(metadata, range.row_filter);

    if (!isEmpty(range.row_filter) && superColumn != null)
    {
        throw new org.apache.cassandra.exceptions.InvalidRequestException("super columns are not supported for indexing");
    }

    if (range.count <= 0)
    {
        throw new org.apache.cassandra.exceptions.InvalidRequestException("maxRows must be positive");
    }
}
 
开发者ID:pgaref,项目名称:ACaZoo,代码行数:47,代码来源:ThriftValidation.java

示例2: testConviction

import org.apache.cassandra.dht.IPartitioner; //导入方法依赖的package包/类
@Test
public void testConviction() throws Exception
{
    InetAddress remote = InetAddress.getByName("127.0.0.2");
    Gossiper.instance.initializeNodeUnsafe(remote, UUID.randomUUID(), 1);

    // Set up RepairSession
    UUID parentSessionId = UUIDGen.getTimeUUID();
    UUID sessionId = UUID.randomUUID();
    IPartitioner p = Murmur3Partitioner.instance;
    Range<Token> repairRange = new Range<>(p.getToken(ByteBufferUtil.bytes(0)), p.getToken(ByteBufferUtil.bytes(100)));
    Set<InetAddress> endpoints = Sets.newHashSet(remote);
    RepairSession session = new RepairSession(parentSessionId, sessionId, Arrays.asList(repairRange), "Keyspace1", RepairParallelism.SEQUENTIAL, endpoints, ActiveRepairService.UNREPAIRED_SSTABLE, "Standard1");

    // perform convict
    session.convict(remote, Double.MAX_VALUE);

    // RepairSession should throw ExecutorException with the cause of IOException when getting its value
    try
    {
        session.get();
        fail();
    }
    catch (ExecutionException ex)
    {
        assertEquals(IOException.class, ex.getCause().getClass());
    }
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:29,代码来源:RepairSessionTest.java

示例3: validateKeyRange

import org.apache.cassandra.dht.IPartitioner; //导入方法依赖的package包/类
public static void validateKeyRange(CFMetaData metadata, ByteBuffer superColumn, KeyRange range) throws org.apache.cassandra.exceptions.InvalidRequestException
{
    if ((range.start_key == null) == (range.start_token == null)
        || (range.end_key == null) == (range.end_token == null))
    {
        throw new org.apache.cassandra.exceptions.InvalidRequestException("exactly one each of {start key, start token} and {end key, end token} must be specified");
    }

    // (key, token) is supported (for wide-row CFRR) but not (token, key)
    if (range.start_token != null && range.end_key != null)
        throw new org.apache.cassandra.exceptions.InvalidRequestException("start token + end key is not a supported key range");

    IPartitioner p = StorageService.getPartitioner();

    if (range.start_key != null && range.end_key != null)
    {
        Token startToken = p.getToken(range.start_key);
        Token endToken = p.getToken(range.end_key);
        if (startToken.compareTo(endToken) > 0 && !endToken.isMinimum(p))
        {
            if (p.preservesOrder())
                throw new org.apache.cassandra.exceptions.InvalidRequestException("start key must sort before (or equal to) finish key in your partitioner!");
            else
                throw new org.apache.cassandra.exceptions.InvalidRequestException("start key's token sorts after end key's token.  this is not allowed; you probably should not specify end key at all except with an ordered partitioner");
        }
    }
    else if (range.start_key != null && range.end_token != null)
    {
        // start_token/end_token can wrap, but key/token should not
        RowPosition stop = p.getTokenFactory().fromString(range.end_token).maxKeyBound(p);
        if (RowPosition.ForKey.get(range.start_key, p).compareTo(stop) > 0 && !stop.isMinimum())
            throw new org.apache.cassandra.exceptions.InvalidRequestException("Start key's token sorts after end token");
    }

    validateFilterClauses(metadata, range.row_filter);

    if (!isEmpty(range.row_filter) && superColumn != null)
    {
        throw new org.apache.cassandra.exceptions.InvalidRequestException("super columns are not supported for indexing");
    }

    if (range.count <= 0)
    {
        throw new org.apache.cassandra.exceptions.InvalidRequestException("maxRows must be positive");
    }
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:47,代码来源:ThriftValidation.java

示例4: validateKeyRange

import org.apache.cassandra.dht.IPartitioner; //导入方法依赖的package包/类
public static void validateKeyRange(CFMetaData metadata, ByteBuffer superColumn, KeyRange range) throws org.apache.cassandra.exceptions.InvalidRequestException
{
    if ((range.start_key == null) == (range.start_token == null)
        || (range.end_key == null) == (range.end_token == null))
    {
        throw new org.apache.cassandra.exceptions.InvalidRequestException("exactly one each of {start key, start token} and {end key, end token} must be specified");
    }

    // (key, token) is supported (for wide-row CFRR) but not (token, key)
    if (range.start_token != null && range.end_key != null)
        throw new org.apache.cassandra.exceptions.InvalidRequestException("start token + end key is not a supported key range");

    IPartitioner p = metadata.partitioner;

    if (range.start_key != null && range.end_key != null)
    {
        Token startToken = p.getToken(range.start_key);
        Token endToken = p.getToken(range.end_key);
        if (startToken.compareTo(endToken) > 0 && !endToken.isMinimum())
        {
            if (p.preservesOrder())
                throw new org.apache.cassandra.exceptions.InvalidRequestException("start key must sort before (or equal to) finish key in your partitioner!");
            else
                throw new org.apache.cassandra.exceptions.InvalidRequestException("start key's token sorts after end key's token.  this is not allowed; you probably should not specify end key at all except with an ordered partitioner");
        }
    }
    else if (range.start_key != null && range.end_token != null)
    {
        // start_token/end_token can wrap, but key/token should not
        PartitionPosition stop = p.getTokenFactory().fromString(range.end_token).maxKeyBound();
        if (PartitionPosition.ForKey.get(range.start_key, p).compareTo(stop) > 0 && !stop.isMinimum())
            throw new org.apache.cassandra.exceptions.InvalidRequestException("Start key's token sorts after end token");
    }

    validateFilterClauses(metadata, range.row_filter);

    if (!isEmpty(range.row_filter) && superColumn != null)
    {
        throw new org.apache.cassandra.exceptions.InvalidRequestException("super columns are not supported for indexing");
    }

    if (range.count <= 0)
    {
        throw new org.apache.cassandra.exceptions.InvalidRequestException("maxRows must be positive");
    }
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:47,代码来源:ThriftValidation.java


注:本文中的org.apache.cassandra.dht.IPartitioner.getToken方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。