本文整理汇总了Java中org.apache.hadoop.hbase.io.hfile.BlockCacheKey.toString方法的典型用法代码示例。如果您正苦于以下问题:Java BlockCacheKey.toString方法的具体用法?Java BlockCacheKey.toString怎么用?Java BlockCacheKey.toString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.hadoop.hbase.io.hfile.BlockCacheKey
的用法示例。
在下文中一共展示了BlockCacheKey.toString方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: cacheBlock
import org.apache.hadoop.hbase.io.hfile.BlockCacheKey; //导入方法依赖的package包/类
/**
* Add block to cache.
* @param cacheKey The block's cache key.
* @param buf The block contents wrapped in a ByteBuffer.
* @param inMemory Whether block should be treated as in-memory
*/
public void cacheBlock(BlockCacheKey cacheKey, Cacheable buf, boolean inMemory){
boolean contains = false;
try {
String blockName = cacheKey.toString();
contains = offHeapCache.contains(blockName);
if ( contains) {
// TODO - what does it mean? Can we ignore this?
throw new RuntimeException("Cached an already cached block: "+blockName);
}
// Always cache block to off-heap cache first
offHeapCache.put(blockName, buf);
if(buf.getBlockType() != BlockType.DATA && onHeapEnabled()){
// Cache on-heap only non-data blocks
onHeapCache.cacheBlock(cacheKey, buf, inMemory);
}
if( isExternalStorageEnabled()){
// FIXME This code disables storage in non-test mode???
byte[] hashed = Utils.hash128(blockName);
// TODO : do we really need to check this?
if( extStorageCache.contains(hashed) == false){
// Store external if we found object in a block cache and not in external cache
// ONLY IN TEST MODE
storeExternalWithCodec(blockName, buf, false);
}
}
} catch (Exception e) {
LOG.error(e);
throw new RuntimeException(e);
}
}
示例2: cacheBlock
import org.apache.hadoop.hbase.io.hfile.BlockCacheKey; //导入方法依赖的package包/类
/**
* Add block to cache.
* @param cacheKey The block's cache key.
* @param buf The block contents wrapped in a ByteBuffer.
* @param inMemory Whether block should be treated as in-memory
*/
public void cacheBlock(BlockCacheKey cacheKey, Cacheable buf, boolean inMemory){
boolean contains = false;
try {
String blockName = cacheKey.toString();
// TODO remove these checks?
if (inMemory) {
contains = permGenCache.contains(blockName);
} else {
contains = tenGenCache.contains(blockName);
if ( !contains) {
contains = youngGenCache.contains(blockName);
}
}
if ( contains) {
// TODO - what does it mean? Can we ignore this?
throw new RuntimeException("Cached an already cached block: "+blockName);
}
if (inMemory) {
permGenCache.put(blockName, buf);
storeExternalWithCodec(blockName, buf, true);
} else{
youngGenCache.put(blockName, buf);
}
} catch (Exception e) {
LOG.error(e);
throw new RuntimeException(e);
}
}