本文整理汇总了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();
}
}
}
}
示例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);
}
}
示例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);
}
示例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();
}