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


Java LocalStrategy类代码示例

本文整理汇总了Java中org.apache.cassandra.locator.LocalStrategy的典型用法代码示例。如果您正苦于以下问题:Java LocalStrategy类的具体用法?Java LocalStrategy怎么用?Java LocalStrategy使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: validate

import org.apache.cassandra.locator.LocalStrategy; //导入依赖的package包/类
public void validate(ClientState state) throws RequestValidationException
{
    KeyspaceMetadata ksm = Schema.instance.getKSMetaData(name);
    if (ksm == null)
        throw new InvalidRequestException("Unknown keyspace " + name);
    if (Schema.isSystemKeyspace(ksm.name))
        throw new InvalidRequestException("Cannot alter system keyspace");

    attrs.validate();

    if (attrs.getReplicationStrategyClass() == null && !attrs.getReplicationOptions().isEmpty())
        throw new ConfigurationException("Missing replication strategy class");

    if (attrs.getReplicationStrategyClass() != null)
    {
        // The strategy is validated through KSMetaData.validate() in announceKeyspaceUpdate below.
        // However, for backward compatibility with thrift, this doesn't validate unexpected options yet,
        // so doing proper validation here.
        KeyspaceParams params = attrs.asAlteredKeyspaceParams(ksm.params);
        params.validate(name);
        if (params.replication.klass.equals(LocalStrategy.class))
            throw new ConfigurationException("Unable to use given strategy class: LocalStrategy is reserved for internal use.");
    }
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:25,代码来源:AlterKeyspaceStatement.java

示例2: validate

import org.apache.cassandra.locator.LocalStrategy; //导入依赖的package包/类
/**
 * The <code>CqlParser</code> only goes as far as extracting the keyword arguments
 * from these statements, so this method is responsible for processing and
 * validating.
 *
 * @throws InvalidRequestException if arguments are missing or unacceptable
 */
public void validate(ClientState state) throws RequestValidationException
{
    ThriftValidation.validateKeyspaceNotSystem(name);

    // keyspace name
    if (!name.matches("\\w+"))
        throw new InvalidRequestException(String.format("\"%s\" is not a valid keyspace name", name));
    if (name.length() > Schema.NAME_LENGTH)
        throw new InvalidRequestException(String.format("Keyspace names shouldn't be more than %s characters long (got \"%s\")", Schema.NAME_LENGTH, name));

    attrs.validate();

    if (attrs.getReplicationStrategyClass() == null)
        throw new ConfigurationException("Missing mandatory replication strategy class");

    // The strategy is validated through KSMetaData.validate() in announceNewKeyspace below.
    // However, for backward compatibility with thrift, this doesn't validate unexpected options yet,
    // so doing proper validation here.
    KeyspaceParams params = attrs.asNewKeyspaceParams();
    params.validate(name);
    if (params.replication.klass.equals(LocalStrategy.class))
        throw new ConfigurationException("Unable to use given strategy class: LocalStrategy is reserved for internal use.");
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:31,代码来源:CreateKeyspaceStatement.java

示例3: fromThrift

import org.apache.cassandra.locator.LocalStrategy; //导入依赖的package包/类
public static KeyspaceMetadata fromThrift(KsDef ksd, CFMetaData... cfDefs) throws ConfigurationException
{
    Class<? extends AbstractReplicationStrategy> cls = AbstractReplicationStrategy.getClass(ksd.strategy_class);
    if (cls.equals(LocalStrategy.class))
        throw new ConfigurationException("Unable to use given strategy class: LocalStrategy is reserved for internal use.");

    Map<String, String> replicationMap = new HashMap<>();
    if (ksd.strategy_options != null)
        replicationMap.putAll(ksd.strategy_options);
    replicationMap.put(ReplicationParams.CLASS, cls.getName());

    return KeyspaceMetadata.create(ksd.name, KeyspaceParams.create(ksd.durable_writes, replicationMap), Tables.of(cfDefs));
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:14,代码来源:ThriftConversion.java

示例4: getNonLocalStrategyKeyspaces

import org.apache.cassandra.locator.LocalStrategy; //导入依赖的package包/类
/**
 * @return a collection of keyspaces that do not use LocalStrategy for replication
 */
public List<String> getNonLocalStrategyKeyspaces()
{
    return keyspaces.values().stream()
            .filter(keyspace -> keyspace.params.replication.klass != LocalStrategy.class)
            .map(keyspace -> keyspace.name)
            .collect(Collectors.toList());
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:11,代码来源:Schema.java

示例5: describeRing

import org.apache.cassandra.locator.LocalStrategy; //导入依赖的package包/类
private List<TokenRange> describeRing(String keyspace, boolean includeOnlyLocalDC) throws InvalidRequestException
{
    if (!Schema.instance.getKeyspaces().contains(keyspace))
        throw new InvalidRequestException("No such keyspace: " + keyspace);

    if (keyspace == null || Keyspace.open(keyspace).getReplicationStrategy() instanceof LocalStrategy)
        throw new InvalidRequestException("There is no ring for the keyspace: " + keyspace);

    List<TokenRange> ranges = new ArrayList<>();
    Token.TokenFactory tf = getPartitioner().getTokenFactory();

    Map<Range<Token>, List<InetAddress>> rangeToAddressMap =
            includeOnlyLocalDC
                    ? getRangeToAddressMapInLocalDC(keyspace)
                    : getRangeToAddressMap(keyspace);

    for (Map.Entry<Range<Token>, List<InetAddress>> entry : rangeToAddressMap.entrySet())
    {
        Range range = entry.getKey();
        List<InetAddress> addresses = entry.getValue();
        List<String> endpoints = new ArrayList<>(addresses.size());
        List<String> rpc_endpoints = new ArrayList<>(addresses.size());
        List<EndpointDetails> epDetails = new ArrayList<>(addresses.size());

        for (InetAddress endpoint : addresses)
        {
            EndpointDetails details = new EndpointDetails();
            details.host = endpoint.getHostAddress();
            details.datacenter = DatabaseDescriptor.getEndpointSnitch().getDatacenter(endpoint);
            details.rack = DatabaseDescriptor.getEndpointSnitch().getRack(endpoint);

            endpoints.add(details.host);
            rpc_endpoints.add(getRpcaddress(endpoint));

            epDetails.add(details);
        }

        TokenRange tr = new TokenRange(tf.toString(range.left.getToken()), tf.toString(range.right.getToken()), endpoints)
                                .setEndpoint_details(epDetails)
                                .setRpc_endpoints(rpc_endpoints);

        ranges.add(tr);
    }

    return ranges;
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:47,代码来源:StorageService.java


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