• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java CBUtil类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: encode

import org.apache.cassandra.transport.CBUtil; //导入依赖的package包/类
public void encode(QueryOptions options, ByteBuf dest, ProtocolVersion version)
{
    CBUtil.writeConsistencyLevel(options.getConsistency(), dest);

    EnumSet<Flag> flags = gatherFlags(options);
    if (version.isGreaterOrEqualTo(ProtocolVersion.V5))
        dest.writeInt(Flag.serialize(flags));
    else
        dest.writeByte((byte)Flag.serialize(flags));

    if (flags.contains(Flag.VALUES))
        CBUtil.writeValueList(options.getValues(), dest);
    if (flags.contains(Flag.PAGE_SIZE))
        dest.writeInt(options.getPageSize());
    if (flags.contains(Flag.PAGING_STATE))
        CBUtil.writeValue(options.getPagingState().serialize(version), dest);
    if (flags.contains(Flag.SERIAL_CONSISTENCY))
        CBUtil.writeConsistencyLevel(options.getSerialConsistency(), dest);
    if (flags.contains(Flag.TIMESTAMP))
        dest.writeLong(options.getSpecificOptions().timestamp);

    // Note that we don't really have to bother with NAMES_FOR_VALUES server side,
    // and in fact we never really encode QueryOptions, only decode them, so we
    // don't bother.
}
 
开发者ID:Netflix,项目名称:sstable-adaptor,代码行数:26,代码来源:QueryOptions.java


示例2: encodedSize

import org.apache.cassandra.transport.CBUtil; //导入依赖的package包/类
public int encodedSize(QueryOptions options, ProtocolVersion version)
{
    int size = 0;

    size += CBUtil.sizeOfConsistencyLevel(options.getConsistency());

    EnumSet<Flag> flags = gatherFlags(options);
    size += (version.isGreaterOrEqualTo(ProtocolVersion.V5) ? 4 : 1);

    if (flags.contains(Flag.VALUES))
        size += CBUtil.sizeOfValueList(options.getValues());
    if (flags.contains(Flag.PAGE_SIZE))
        size += 4;
    if (flags.contains(Flag.PAGING_STATE))
        size += CBUtil.sizeOfValue(options.getPagingState().serializedSize(version));
    if (flags.contains(Flag.SERIAL_CONSISTENCY))
        size += CBUtil.sizeOfConsistencyLevel(options.getSerialConsistency());
    if (flags.contains(Flag.TIMESTAMP))
        size += 8;

    return size;
}
 
开发者ID:Netflix,项目名称:sstable-adaptor,代码行数:23,代码来源:QueryOptions.java


示例3: encodedSize

import org.apache.cassandra.transport.CBUtil; //导入依赖的package包/类
public int encodedSize(QueryOptions options, int version)
{
    int size = 0;

    size += CBUtil.sizeOfConsistencyLevel(options.getConsistency());

    EnumSet<Flag> flags = gatherFlags(options);
    size += 1;

    if (flags.contains(Flag.VALUES))
        size += CBUtil.sizeOfValueList(options.getValues());
    if (flags.contains(Flag.PAGE_SIZE))
        size += 4;
    if (flags.contains(Flag.PAGING_STATE))
        size += CBUtil.sizeOfValue(options.getPagingState().serialize());
    if (flags.contains(Flag.SERIAL_CONSISTENCY))
        size += CBUtil.sizeOfConsistencyLevel(options.getSerialConsistency());
    if (flags.contains(Flag.TIMESTAMP))
        size += 8;

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


示例4: encodedSize

import org.apache.cassandra.transport.CBUtil; //导入依赖的package包/类
public int encodedSize(QueryOptions options, int version)
{
    int size = 0;

    size += CBUtil.sizeOfConsistencyLevel(options.getConsistency());

    EnumSet<Flag> flags = gatherFlags(options);
    size += 1;

    if (flags.contains(Flag.VALUES))
        size += CBUtil.sizeOfValueList(options.getValues());
    if (flags.contains(Flag.PAGE_SIZE))
        size += 4;
    if (flags.contains(Flag.PAGING_STATE))
        size += CBUtil.sizeOfValue(options.getPagingState().serialize());
    if (flags.contains(Flag.SERIAL_CONSISTENCY))
        size += CBUtil.sizeOfConsistencyLevel(options.getSerialConsistency());

    return size;
}
 
开发者ID:pgaref,项目名称:ACaZoo,代码行数:21,代码来源:QueryOptions.java


示例5: encode

import org.apache.cassandra.transport.CBUtil; //导入依赖的package包/类
public void encode(QueryOptions options, ByteBuf dest, int version)
{
    CBUtil.writeConsistencyLevel(options.getConsistency(), dest);

    EnumSet<Flag> flags = gatherFlags(options);
    dest.writeByte((byte)Flag.serialize(flags));

    if (flags.contains(Flag.VALUES))
        CBUtil.writeValueList(options.getValues(), dest);
    if (flags.contains(Flag.PAGE_SIZE))
        dest.writeInt(options.getPageSize());
    if (flags.contains(Flag.PAGING_STATE))
        CBUtil.writeValue(options.getPagingState().serialize(version), dest);
    if (flags.contains(Flag.SERIAL_CONSISTENCY))
        CBUtil.writeConsistencyLevel(options.getSerialConsistency(), dest);
    if (flags.contains(Flag.TIMESTAMP))
        dest.writeLong(options.getSpecificOptions().timestamp);

    // Note that we don't really have to bother with NAMES_FOR_VALUES server side,
    // and in fact we never really encode QueryOptions, only decode them, so we
    // don't bother.
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:23,代码来源:QueryOptions.java


示例6: encodedSize

import org.apache.cassandra.transport.CBUtil; //导入依赖的package包/类
public int encodedSize(QueryOptions options, int version)
{
    int size = 0;

    size += CBUtil.sizeOfConsistencyLevel(options.getConsistency());

    EnumSet<Flag> flags = gatherFlags(options);
    size += 1;

    if (flags.contains(Flag.VALUES))
        size += CBUtil.sizeOfValueList(options.getValues());
    if (flags.contains(Flag.PAGE_SIZE))
        size += 4;
    if (flags.contains(Flag.PAGING_STATE))
        size += CBUtil.sizeOfValue(options.getPagingState().serializedSize(version));
    if (flags.contains(Flag.SERIAL_CONSISTENCY))
        size += CBUtil.sizeOfConsistencyLevel(options.getSerialConsistency());
    if (flags.contains(Flag.TIMESTAMP))
        size += 8;

    return size;
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:23,代码来源:QueryOptions.java


示例7: decode

import org.apache.cassandra.transport.CBUtil; //导入依赖的package包/类
public AuthChallenge decode(ByteBuf body, int version)
{
    ByteBuffer b = CBUtil.readValue(body);
    byte[] token = new byte[b.remaining()];
    b.get(token);
    return new AuthChallenge(token);
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:8,代码来源:AuthChallenge.java


示例8: encode

import org.apache.cassandra.transport.CBUtil; //导入依赖的package包/类
public void encode(ErrorMessage msg, ByteBuf dest, int version)
{
    dest.writeInt(msg.error.code().value);
    CBUtil.writeString(msg.error.getMessage(), dest);

    switch (msg.error.code())
    {
        case UNAVAILABLE:
            UnavailableException ue = (UnavailableException)msg.error;
            CBUtil.writeConsistencyLevel(ue.consistency, dest);
            dest.writeInt(ue.required);
            dest.writeInt(ue.alive);
            break;
        case WRITE_TIMEOUT:
        case READ_TIMEOUT:
            RequestTimeoutException rte = (RequestTimeoutException)msg.error;
            boolean isWrite = msg.error.code() == ExceptionCode.WRITE_TIMEOUT;

            CBUtil.writeConsistencyLevel(rte.consistency, dest);
            dest.writeInt(rte.received);
            dest.writeInt(rte.blockFor);
            if (isWrite)
                CBUtil.writeString(((WriteTimeoutException)rte).writeType.toString(), dest);
            else
                dest.writeByte((byte)(((ReadTimeoutException)rte).dataPresent ? 1 : 0));
            break;
        case UNPREPARED:
            PreparedQueryNotFoundException pqnfe = (PreparedQueryNotFoundException)msg.error;
            CBUtil.writeBytes(pqnfe.id.bytes, dest);
            break;
        case ALREADY_EXISTS:
            AlreadyExistsException aee = (AlreadyExistsException)msg.error;
            CBUtil.writeString(aee.ksName, dest);
            CBUtil.writeString(aee.cfName, dest);
            break;
    }
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:38,代码来源:ErrorMessage.java


示例9: encodedSize

import org.apache.cassandra.transport.CBUtil; //导入依赖的package包/类
public int encodedSize(ErrorMessage msg, int version)
{
    int size = 4 + CBUtil.sizeOfString(msg.error.getMessage());
    switch (msg.error.code())
    {
        case UNAVAILABLE:
            UnavailableException ue = (UnavailableException)msg.error;
            size += CBUtil.sizeOfConsistencyLevel(ue.consistency) + 8;
            break;
        case WRITE_TIMEOUT:
        case READ_TIMEOUT:
            RequestTimeoutException rte = (RequestTimeoutException)msg.error;
            boolean isWrite = msg.error.code() == ExceptionCode.WRITE_TIMEOUT;
            size += CBUtil.sizeOfConsistencyLevel(rte.consistency) + 8;
            size += isWrite ? CBUtil.sizeOfString(((WriteTimeoutException)rte).writeType.toString()) : 1;
            break;
        case UNPREPARED:
            PreparedQueryNotFoundException pqnfe = (PreparedQueryNotFoundException)msg.error;
            size += CBUtil.sizeOfBytes(pqnfe.id.bytes);
            break;
        case ALREADY_EXISTS:
            AlreadyExistsException aee = (AlreadyExistsException)msg.error;
            size += CBUtil.sizeOfString(aee.ksName);
            size += CBUtil.sizeOfString(aee.cfName);
            break;
    }
    return size;
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:29,代码来源:ErrorMessage.java


示例10: decode

import org.apache.cassandra.transport.CBUtil; //导入依赖的package包/类
public AuthResponse decode(ByteBuf body, int version)
{
    if (version == 1)
        throw new ProtocolException("SASL Authentication is not supported in version 1 of the protocol");

    ByteBuffer b = CBUtil.readValue(body);
    byte[] token = new byte[b.remaining()];
    b.get(token);
    return new AuthResponse(token);
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:11,代码来源:AuthResponse.java


示例11: decode

import org.apache.cassandra.transport.CBUtil; //导入依赖的package包/类
public AuthSuccess decode(ByteBuf body, int version)
{
    ByteBuffer b = CBUtil.readValue(body);
    byte[] token = new byte[b.remaining()];
    b.get(token);
    return new AuthSuccess(token);
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:8,代码来源:AuthSuccess.java


示例12: decode

import org.apache.cassandra.transport.CBUtil; //导入依赖的package包/类
public CredentialsMessage decode(ByteBuf body, int version)
{
    if (version > 1)
        throw new ProtocolException("Legacy credentials authentication is not supported in " +
                "protocol versions > 1. Please use SASL authentication via a SaslResponse message");

    Map<String, String> credentials = CBUtil.readStringMap(body);
    return new CredentialsMessage(credentials);
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:10,代码来源:CredentialsMessage.java


示例13: decode

import org.apache.cassandra.transport.CBUtil; //导入依赖的package包/类
public AuthChallenge decode(ChannelBuffer body, int version)
{
    ByteBuffer b = CBUtil.readValue(body);
    byte[] token = new byte[b.remaining()];
    b.get(token);
    return new AuthChallenge(token);
}
 
开发者ID:pgaref,项目名称:ACaZoo,代码行数:8,代码来源:AuthChallenge.java


示例14: encode

import org.apache.cassandra.transport.CBUtil; //导入依赖的package包/类
public void encode(ErrorMessage msg, ChannelBuffer dest, int version)
{
    dest.writeInt(msg.error.code().value);
    CBUtil.writeString(msg.error.getMessage(), dest);

    switch (msg.error.code())
    {
        case UNAVAILABLE:
            UnavailableException ue = (UnavailableException)msg.error;
            CBUtil.writeConsistencyLevel(ue.consistency, dest);
            dest.writeInt(ue.required);
            dest.writeInt(ue.alive);
            break;
        case WRITE_TIMEOUT:
        case READ_TIMEOUT:
            RequestTimeoutException rte = (RequestTimeoutException)msg.error;
            boolean isWrite = msg.error.code() == ExceptionCode.WRITE_TIMEOUT;

            CBUtil.writeConsistencyLevel(rte.consistency, dest);
            dest.writeInt(rte.received);
            dest.writeInt(rte.blockFor);
            if (isWrite)
                CBUtil.writeString(((WriteTimeoutException)rte).writeType.toString(), dest);
            else
                dest.writeByte((byte)(((ReadTimeoutException)rte).dataPresent ? 1 : 0));
            break;
        case UNPREPARED:
            PreparedQueryNotFoundException pqnfe = (PreparedQueryNotFoundException)msg.error;
            CBUtil.writeBytes(pqnfe.id.bytes, dest);
            break;
        case ALREADY_EXISTS:
            AlreadyExistsException aee = (AlreadyExistsException)msg.error;
            CBUtil.writeString(aee.ksName, dest);
            CBUtil.writeString(aee.cfName, dest);
            break;
    }
}
 
开发者ID:pgaref,项目名称:ACaZoo,代码行数:38,代码来源:ErrorMessage.java


示例15: decode

import org.apache.cassandra.transport.CBUtil; //导入依赖的package包/类
public AuthResponse decode(ChannelBuffer body, int version)
{
    if (version == 1)
        throw new ProtocolException("SASL Authentication is not supported in version 1 of the protocol");

    ByteBuffer b = CBUtil.readValue(body);
    byte[] token = new byte[b.remaining()];
    b.get(token);
    return new AuthResponse(token);
}
 
开发者ID:pgaref,项目名称:ACaZoo,代码行数:11,代码来源:AuthResponse.java


示例16: decode

import org.apache.cassandra.transport.CBUtil; //导入依赖的package包/类
public AuthSuccess decode(ChannelBuffer body, int version)
{
    ByteBuffer b = CBUtil.readValue(body);
    byte[] token = new byte[b.remaining()];
    b.get(token);
    return new AuthSuccess(token);
}
 
开发者ID:pgaref,项目名称:ACaZoo,代码行数:8,代码来源:AuthSuccess.java


示例17: decode

import org.apache.cassandra.transport.CBUtil; //导入依赖的package包/类
public CredentialsMessage decode(ChannelBuffer body, int version)
{
    if (version > 1)
        throw new ProtocolException("Legacy credentials authentication is not supported in " +
                "protocol versions > 1. Please use SASL authentication via a SaslResponse message");

    Map<String, String> credentials = CBUtil.readStringMap(body);
    return new CredentialsMessage(credentials);
}
 
开发者ID:pgaref,项目名称:ACaZoo,代码行数:10,代码来源:CredentialsMessage.java


示例18: encode

import org.apache.cassandra.transport.CBUtil; //导入依赖的package包/类
public void encode(QueryMessage msg, ByteBuf dest, int version)
{
    CBUtil.writeLongString(msg.query, dest);
    if (version == 1)
        CBUtil.writeConsistencyLevel(msg.options.getConsistency(), dest);
    else
        QueryOptions.codec.encode(msg.options, dest, version);
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:9,代码来源:QueryMessage.java


示例19: encodedSize

import org.apache.cassandra.transport.CBUtil; //导入依赖的package包/类
public int encodedSize(QueryMessage msg, int version)
{
    int size = CBUtil.sizeOfLongString(msg.query);

    if (version == 1)
    {
        size += CBUtil.sizeOfConsistencyLevel(msg.options.getConsistency());
    }
    else
    {
        size += QueryOptions.codec.encodedSize(msg.options, version);
    }
    return size;
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:15,代码来源:QueryMessage.java


示例20: decode

import org.apache.cassandra.transport.CBUtil; //导入依赖的package包/类
public AuthSuccess decode(ByteBuf body, int version)
{
    ByteBuffer b = CBUtil.readValue(body);
    byte[] token = null;
    if (b != null)
    {
        token = new byte[b.remaining()];
        b.get(token);
    }
    return new AuthSuccess(token);
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:12,代码来源:AuthSuccess.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java TaskAttemptEvent类代码示例发布时间:2022-05-22
下一篇:
Java Wrapper类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap