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


Java ClientState.setCQLVersion方法代码示例

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


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

示例1: execute

import org.apache.cassandra.service.ClientState; //导入方法依赖的package包/类
public Message.Response execute(QueryState state)
{
    ClientState cState = state.getClientState();
    String cqlVersion = options.get(CQL_VERSION);
    if (cqlVersion == null)
        throw new ProtocolException("Missing value CQL_VERSION in STARTUP message");

    try 
    {
        cState.setCQLVersion(cqlVersion);
    }
    catch (InvalidRequestException e)
    {
        throw new ProtocolException(e.getMessage());
    }

    if (cState.getCQLVersion().compareTo(new SemanticVersion("2.99.0")) < 0)
        throw new ProtocolException(String.format("CQL version %s is not supported by the binary protocol (supported version are >= 3.0.0)", cqlVersion));

    if (options.containsKey(COMPRESSION))
    {
        String compression = options.get(COMPRESSION).toLowerCase();
        if (compression.equals("snappy"))
        {
            if (FrameCompressor.SnappyCompressor.instance == null)
                throw new ProtocolException("This instance does not support Snappy compression");
            connection.setCompressor(FrameCompressor.SnappyCompressor.instance);
        }
        else if (compression.equals("lz4"))
        {
            connection.setCompressor(FrameCompressor.LZ4Compressor.instance);
        }
        else
        {
            throw new ProtocolException(String.format("Unknown compression algorithm: %s", compression));
        }
    }

    if (DatabaseDescriptor.getAuthenticator().requireAuthentication())
        return new AuthenticateMessage(DatabaseDescriptor.getAuthenticator().getClass().getName());
    else
        return new ReadyMessage();
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:44,代码来源:StartupMessage.java


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