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


Java ByteBufferUtil.writeWithLength方法代码示例

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


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

示例1: serialize

import org.apache.cassandra.utils.ByteBufferUtil; //导入方法依赖的package包/类
public void serialize(Version version, CompactionMetadata component, DataOutputPlus out) throws IOException
{
    if (version.hasCompactionAncestors())
    {   // write empty ancestor marker
        out.writeInt(0);
    }
    ByteBufferUtil.writeWithLength(component.cardinalityEstimator.getBytes(), out);
}
 
开发者ID:Netflix,项目名称:sstable-adaptor,代码行数:9,代码来源:CompactionMetadata.java

示例2: saveSummary

import org.apache.cassandra.utils.ByteBufferUtil; //导入方法依赖的package包/类
/**
 * Save index summary to Summary.db file.
 */
public static void saveSummary(Descriptor descriptor, DecoratedKey first, DecoratedKey last, IndexSummary summary)
{

    String filePath = descriptor.filenameFor(Component.SUMMARY);

    //TODO: add a retry here on deletion
    HadoopFileUtils.deleteIfExists(filePath, descriptor.getConfiguration());


    //TODO: will make the retry nicer
    int attempt = 0;
    int maxAttempt = 5;
    boolean isSuccess = false;
    while (!isSuccess) {
        if (attempt > 0)
            FBUtilities.sleepQuietly((int) Math.round(Math.pow(2, attempt)) * 1000);

        try (HadoopFileUtils.HadoopFileChannel hos = HadoopFileUtils.newFilesystemChannel(filePath,
                                                                                  descriptor.getConfiguration());
             DataOutputStreamPlus oStream = new BufferedDataOutputStreamPlus(hos)) {
            IndexSummary.serializer.serialize(summary, oStream, descriptor.version.hasSamplingLevel());
            if (first != null && last != null) {
                ByteBufferUtil.writeWithLength(first.getKey(), oStream);
                ByteBufferUtil.writeWithLength(last.getKey(), oStream);
            }
            isSuccess = true;
        } catch (Throwable e) {
            logger.trace("Cannot save SSTable Summary: ", e);

            // corrupted hence delete it and let it load it now.
            HadoopFileUtils.deleteIfExists(filePath, descriptor.getConfiguration());
            attempt++;
            if (attempt == maxAttempt) //TODO: do we need to record all retried excpetions here or assume they'r same
                throw new RuntimeException("Have retried for " + maxAttempt + " times but still failed!", e);
        }
    }
}
 
开发者ID:Netflix,项目名称:sstable-adaptor,代码行数:41,代码来源:SSTableReader.java

示例3: serialize

import org.apache.cassandra.utils.ByteBufferUtil; //导入方法依赖的package包/类
public void serialize(Token token, DataOutputPlus out, int version) throws IOException
{
    IPartitioner p = token.getPartitioner();
    ByteBuffer b = p.getTokenFactory().toByteArray(token);
    ByteBufferUtil.writeWithLength(b, out);
}
 
开发者ID:Netflix,项目名称:sstable-adaptor,代码行数:7,代码来源:Token.java


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