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


Java RandomAccessReader.deallocate方法代码示例

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


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

示例1: put

import org.apache.cassandra.io.util.RandomAccessReader; //导入方法依赖的package包/类
public void put(CacheKey cacheKey, RandomAccessReader instance)
{
    int memoryUsed = memoryUsage.get();
    if (logger.isDebugEnabled())
        logger.debug("Estimated memory usage is {} compared to actual usage {}", memoryUsed, sizeInBytes());

    CacheBucket bucket = cache.getIfPresent(cacheKey);
    if (memoryUsed >= MEMORY_USAGE_THRESHOLD || bucket == null)
    {
        instance.deallocate();
    }
    else
    {
        memoryUsage.addAndGet(instance.getTotalBufferSize());
        bucket.queue.add(instance);
        if (bucket.discarded)
        {
            RandomAccessReader reader = bucket.queue.poll();
            if (reader != null)
            {
                memoryUsage.addAndGet(-1 * reader.getTotalBufferSize());
                reader.deallocate();
            }
        }
    }
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:27,代码来源:FileCacheService.java

示例2: put

import org.apache.cassandra.io.util.RandomAccessReader; //导入方法依赖的package包/类
public void put(RandomAccessReader instance)
{
    int memoryUsed = memoryUsage.get();
    if (logger.isDebugEnabled())
        logger.debug("Estimated memory usage is {} compared to actual usage {}", memoryUsed, sizeInBytes());

    if (memoryUsed >= MEMORY_USAGE_THRESHOLD)
    {
        instance.deallocate();
    }
    else
    {
        memoryUsage.addAndGet(instance.getTotalBufferSize());
        getCacheFor(instance.getPath()).add(instance);
    }
}
 
开发者ID:mafernandez-stratio,项目名称:cassandra-cqlMod,代码行数:17,代码来源:FileCacheService.java

示例3: put

import org.apache.cassandra.io.util.RandomAccessReader; //导入方法依赖的package包/类
public void put(RandomAccessReader instance)
{
    // This wouldn't be precise sometimes when CRAR is used because
    // there is a way for users to dynamically change the size of the buffer,
    // but we don't expect that to happen frequently in production.
    // Doing accounting this way also allows us to avoid atomic CAS operation on read path.
    long memoryUsage = (cache.size() + 1) * instance.getBufferSize();

    if (memoryUsage >= MEMORY_USAGE_THRESHOLD)
        instance.deallocate();
    else
        getCacheFor(instance.getPath()).add(instance);
}
 
开发者ID:pgaref,项目名称:ACaZoo,代码行数:14,代码来源:FileCacheService.java

示例4: FileCacheService

import org.apache.cassandra.io.util.RandomAccessReader; //导入方法依赖的package包/类
protected FileCacheService()
{
    RemovalListener<String, Queue<RandomAccessReader>> onRemove = new RemovalListener<String, Queue<RandomAccessReader>>()
    {
        @Override
        public void onRemoval(RemovalNotification<String, Queue<RandomAccessReader>> notification)
        {
            Queue<RandomAccessReader> cachedInstances = notification.getValue();
            if (cachedInstances == null)
                return;

            if (cachedInstances.size() > 0)
                logger.debug("Evicting cold readers for {}", cachedInstances.peek().getPath());

            for (RandomAccessReader reader : cachedInstances)
            {
                memoryUsage.addAndGet(-1 * reader.getTotalBufferSize());
                reader.deallocate();
            }
        }
    };

    cache = CacheBuilder.<String, Queue<RandomAccessReader>>newBuilder()
            .expireAfterAccess(AFTER_ACCESS_EXPIRATION, TimeUnit.MILLISECONDS)
            .concurrencyLevel(DatabaseDescriptor.getConcurrentReaders())
            .removalListener(onRemove)
            .build();
}
 
开发者ID:mafernandez-stratio,项目名称:cassandra-cqlMod,代码行数:29,代码来源:FileCacheService.java


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